]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
cxl: Unlock on error in probe
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 5 May 2017 05:34:58 +0000 (08:34 +0300)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 6 Jun 2017 09:23:52 +0000 (19:23 +1000)
We should unlock if get_cxl_adapter() fails.

Fixes: 594ff7d067ca ("cxl: Support to flash a new image on the adapter from a guest")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
drivers/misc/cxl/flash.c

index 7c61c70ba3f65c67d26fbdde32de8067a8334bd3..3aa216bf0939ff015c0b6ae121f6f1e7f69bd33d 100644 (file)
@@ -401,8 +401,10 @@ static int device_open(struct inode *inode, struct file *file)
        if (down_interruptible(&sem) != 0)
                return -EPERM;
 
-       if (!(adapter = get_cxl_adapter(adapter_num)))
-               return -ENODEV;
+       if (!(adapter = get_cxl_adapter(adapter_num))) {
+               rc = -ENODEV;
+               goto err_unlock;
+       }
 
        file->private_data = adapter;
        continue_token = 0;
@@ -446,6 +448,8 @@ err1:
                free_page((unsigned long) le);
 err:
        put_device(&adapter->dev);
+err_unlock:
+       up(&sem);
 
        return rc;
 }