[PATCH] cxl: Unlock on error in probe

walter harms wharms at bfs.de
Fri May 5 17:23:02 AEST 2017



Am 05.05.2017 09:14, schrieb Andrew Donnellan:
> On 05/05/17 15:34, Dan Carpenter wrote:
>> 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 at oracle.com>
>>
>> diff --git a/drivers/misc/cxl/flash.c b/drivers/misc/cxl/flash.c
>> index 7c61c70ba3f6..37475abea3e6 100644
>> --- a/drivers/misc/cxl/flash.c
>> +++ b/drivers/misc/cxl/flash.c
>> @@ -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 @@ 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;
>>  }
> 
> sem is a global and it looks like it's intended to be held after
> device_open() returns and only released in device_close(), so this looks
> wrong.
> 

the patch relates to the error path, do you expect a close() after the open() failed ?

re,
 wh


More information about the Linuxppc-dev mailing list