V4L/DVB (11231): hdpvr: locking fixes

unlock io_mutex in hdpvr_stop_streaming hdpvr_disconnect to allow the
streaming worker to stop before we flush the workqueue.
do not return to user space with mutex held in vidioc_encoder_cmd with
an unknown encoder command.

Signed-off-by: Janne Grunau <j@jannau.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
diff --git a/drivers/media/video/hdpvr/hdpvr-video.c b/drivers/media/video/hdpvr/hdpvr-video.c
index e9078cd..2fe5730 100644
--- a/drivers/media/video/hdpvr/hdpvr-video.c
+++ b/drivers/media/video/hdpvr/hdpvr-video.c
@@ -300,12 +300,14 @@
 
 	dev->status = STATUS_SHUTTING_DOWN;
 	hdpvr_config_call(dev, CTRL_STOP_STREAMING_VALUE, 0x00);
+	mutex_unlock(&dev->io_mutex);
 
 	wake_up_interruptible(&dev->wait_buffer);
 	msleep(50);
 
 	flush_workqueue(dev->workqueue);
 
+	mutex_lock(&dev->io_mutex);
 	/* kill the still outstanding urbs */
 	hdpvr_cancel_queue(dev);
 
@@ -1130,7 +1132,7 @@
 	default:
 		v4l2_dbg(MSG_INFO, hdpvr_debug, dev->video_dev,
 			 "Unsupported encoder cmd %d\n", a->cmd);
-		return -EINVAL;
+		res = -EINVAL;
 	}
 	mutex_unlock(&dev->io_mutex);
 	return res;