diff mbox series

[next] xen/gntdev: remove redundant non-zero check on ret

Message ID 20191111122009.67789-1-colin.king@canonical.com (mailing list archive)
State New, archived
Headers show
Series [next] xen/gntdev: remove redundant non-zero check on ret | expand

Commit Message

Colin King Nov. 11, 2019, 12:20 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

The non-zero check on ret is always going to be false because
ret was initialized as zero and the only place it is set to
non-zero contains a return path before the non-zero check. Hence
the check is redundant and can be removed.

Addresses-Coverity: ("Logically dead code")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/xen/gntdev.c | 5 -----
 1 file changed, 5 deletions(-)

Comments

Jürgen Groß Nov. 11, 2019, 12:25 p.m. UTC | #1
On 11.11.19 13:20, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The non-zero check on ret is always going to be false because
> ret was initialized as zero and the only place it is set to
> non-zero contains a return path before the non-zero check. Hence
> the check is redundant and can be removed.

Which version did you patch against? In current master the above
statement is not true.


Juergen

> 
> Addresses-Coverity: ("Logically dead code")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   drivers/xen/gntdev.c | 5 -----
>   1 file changed, 5 deletions(-)
> 
> diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
> index 10cc5e9e612a..07d80b176118 100644
> --- a/drivers/xen/gntdev.c
> +++ b/drivers/xen/gntdev.c
> @@ -524,11 +524,6 @@ static int gntdev_open(struct inode *inode, struct file *flip)
>   	}
>   #endif
>   
> -	if (ret) {
> -		kfree(priv);
> -		return ret;
> -	}
> -
>   	flip->private_data = priv;
>   #ifdef CONFIG_XEN_GRANT_DMA_ALLOC
>   	priv->dma_dev = gntdev_miscdev.this_device;
>
Colin King Nov. 11, 2019, 12:31 p.m. UTC | #2
On 11/11/2019 12:25, Jürgen Groß wrote:
> On 11.11.19 13:20, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> The non-zero check on ret is always going to be false because
>> ret was initialized as zero and the only place it is set to
>> non-zero contains a return path before the non-zero check. Hence
>> the check is redundant and can be removed.
> 
> Which version did you patch against? In current master the above
> statement is not true.

against today's linux-next

Colin
> 
> 
> Juergen
> 
>>
>> Addresses-Coverity: ("Logically dead code")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>   drivers/xen/gntdev.c | 5 -----
>>   1 file changed, 5 deletions(-)
>>
>> diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
>> index 10cc5e9e612a..07d80b176118 100644
>> --- a/drivers/xen/gntdev.c
>> +++ b/drivers/xen/gntdev.c
>> @@ -524,11 +524,6 @@ static int gntdev_open(struct inode *inode,
>> struct file *flip)
>>       }
>>   #endif
>>   -    if (ret) {
>> -        kfree(priv);
>> -        return ret;
>> -    }
>> -
>>       flip->private_data = priv;
>>   #ifdef CONFIG_XEN_GRANT_DMA_ALLOC
>>       priv->dma_dev = gntdev_miscdev.this_device;
>>
>
Jürgen Groß Nov. 11, 2019, 1:17 p.m. UTC | #3
On 11.11.19 13:31, Colin Ian King wrote:
> On 11/11/2019 12:25, Jürgen Groß wrote:
>> On 11.11.19 13:20, Colin King wrote:
>>> From: Colin Ian King <colin.king@canonical.com>
>>>
>>> The non-zero check on ret is always going to be false because
>>> ret was initialized as zero and the only place it is set to
>>> non-zero contains a return path before the non-zero check. Hence
>>> the check is redundant and can be removed.
>>
>> Which version did you patch against? In current master the above
>> statement is not true.
> 
> against today's linux-next

Ah, okay, this is likely the result of the recent mm-notifier patch
series. I'll put this patch on hold until the recent patches have
hit master.


Juergen
Colin King Nov. 11, 2019, 1:23 p.m. UTC | #4
On 11/11/2019 13:17, Jürgen Groß wrote:
> On 11.11.19 13:31, Colin Ian King wrote:
>> On 11/11/2019 12:25, Jürgen Groß wrote:
>>> On 11.11.19 13:20, Colin King wrote:
>>>> From: Colin Ian King <colin.king@canonical.com>
>>>>
>>>> The non-zero check on ret is always going to be false because
>>>> ret was initialized as zero and the only place it is set to
>>>> non-zero contains a return path before the non-zero check. Hence
>>>> the check is redundant and can be removed.
>>>
>>> Which version did you patch against? In current master the above
>>> statement is not true.
>>
>> against today's linux-next
> 
> Ah, okay, this is likely the result of the recent mm-notifier patch
> series. I'll put this patch on hold until the recent patches have
> hit master.

Cool, thanks!
> 
> 
> Juergen
diff mbox series

Patch

diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index 10cc5e9e612a..07d80b176118 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -524,11 +524,6 @@  static int gntdev_open(struct inode *inode, struct file *flip)
 	}
 #endif
 
-	if (ret) {
-		kfree(priv);
-		return ret;
-	}
-
 	flip->private_data = priv;
 #ifdef CONFIG_XEN_GRANT_DMA_ALLOC
 	priv->dma_dev = gntdev_miscdev.this_device;