]> Pileus Git - ~andy/linux/blobdiff - drivers/media/pci/ttpci/av7110_ca.c
Merge tag 'stable/for-linus-3.9-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel...
[~andy/linux] / drivers / media / pci / ttpci / av7110_ca.c
index 9fc1dd0ba4c35fc1d6030fb17dc90fbe75d5d849..a6079b90252a9f4e65e2514e86f54b84dd5ba226 100644 (file)
@@ -253,12 +253,17 @@ static int dvb_ca_ioctl(struct file *file, unsigned int cmd, void *parg)
        struct dvb_device *dvbdev = file->private_data;
        struct av7110 *av7110 = dvbdev->priv;
        unsigned long arg = (unsigned long) parg;
+       int ret = 0;
 
        dprintk(8, "av7110:%p\n",av7110);
 
+       if (mutex_lock_interruptible(&av7110->ioctl_mutex))
+               return -ERESTARTSYS;
+
        switch (cmd) {
        case CA_RESET:
-               return ci_ll_reset(&av7110->ci_wbuffer, file, arg, &av7110->ci_slot[0]);
+               ret = ci_ll_reset(&av7110->ci_wbuffer, file, arg,
+                                 &av7110->ci_slot[0]);
                break;
        case CA_GET_CAP:
        {
@@ -277,8 +282,10 @@ static int dvb_ca_ioctl(struct file *file, unsigned int cmd, void *parg)
        {
                ca_slot_info_t *info=(ca_slot_info_t *)parg;
 
-               if (info->num < 0 || info->num > 1)
+               if (info->num < 0 || info->num > 1) {
+                       mutex_unlock(&av7110->ioctl_mutex);
                        return -EINVAL;
+               }
                av7110->ci_slot[info->num].num = info->num;
                av7110->ci_slot[info->num].type = FW_CI_LL_SUPPORT(av7110->arm_app) ?
                                                        CA_CI_LINK : CA_CI;
@@ -306,10 +313,10 @@ static int dvb_ca_ioctl(struct file *file, unsigned int cmd, void *parg)
        {
                ca_descr_t *descr = (ca_descr_t*) parg;
 
-               if (descr->index >= 16)
-                       return -EINVAL;
-               if (descr->parity > 1)
+               if (descr->index >= 16 || descr->parity > 1) {
+                       mutex_unlock(&av7110->ioctl_mutex);
                        return -EINVAL;
+               }
                av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetDescr, 5,
                              (descr->index<<8)|descr->parity,
                              (descr->cw[0]<<8)|descr->cw[1],
@@ -320,9 +327,12 @@ static int dvb_ca_ioctl(struct file *file, unsigned int cmd, void *parg)
        }
 
        default:
-               return -EINVAL;
+               ret = -EINVAL;
+               break;
        }
-       return 0;
+
+       mutex_unlock(&av7110->ioctl_mutex);
+       return ret;
 }
 
 static ssize_t dvb_ca_write(struct file *file, const char __user *buf,