Skip to content

Commit

Permalink
cxl: Unlock on error in probe
Browse files Browse the repository at this point in the history
We should unlock if get_cxl_adapter() fails.

Fixes: 594ff7d ("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>
  • Loading branch information
Dan Carpenter authored and Michael Ellerman committed Jun 6, 2017
1 parent 4386c09 commit 58d876f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/misc/cxl/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -446,6 +448,8 @@ static int device_open(struct inode *inode, struct file *file)
free_page((unsigned long) le);
err:
put_device(&adapter->dev);
err_unlock:
up(&sem);

return rc;
}
Expand Down

0 comments on commit 58d876f

Please sign in to comment.