[PATCH] media: m920x: Remove useless kfree

Haowen Bai posted 1 patch 4 years ago
drivers/media/usb/dvb-usb/m920x.c | 1 -
1 file changed, 1 deletion(-)
[PATCH] media: m920x: Remove useless kfree
Posted by Haowen Bai 4 years ago
After alloc fail, we do not need to kfree.

Signed-off-by: Haowen Bai <baihaowen@meizu.com>
---
 drivers/media/usb/dvb-usb/m920x.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/media/usb/dvb-usb/m920x.c b/drivers/media/usb/dvb-usb/m920x.c
index 548199cd86f6..9df0ccfb654b 100644
--- a/drivers/media/usb/dvb-usb/m920x.c
+++ b/drivers/media/usb/dvb-usb/m920x.c
@@ -277,7 +277,6 @@ static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int nu
 			char *read = kmalloc(1, GFP_KERNEL);
 			if (!read) {
 				ret = -ENOMEM;
-				kfree(read);
 				goto unlock;
 			}
 
-- 
2.7.4
Re: [PATCH] media: m920x: Remove useless kfree
Posted by Kieran Bingham 4 years ago
Quoting Haowen Bai (2022-04-22 07:06:47)
> After alloc fail, we do not need to kfree.
> 

Agreed, this shouldn't hurt as kfree will be a noop here but it is
always null so redundant.

May still warrant a fixes tag though, but it's not a critical fix.


Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

> Signed-off-by: Haowen Bai <baihaowen@meizu.com>
> ---
>  drivers/media/usb/dvb-usb/m920x.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/media/usb/dvb-usb/m920x.c b/drivers/media/usb/dvb-usb/m920x.c
> index 548199cd86f6..9df0ccfb654b 100644
> --- a/drivers/media/usb/dvb-usb/m920x.c
> +++ b/drivers/media/usb/dvb-usb/m920x.c
> @@ -277,7 +277,6 @@ static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int nu
>                         char *read = kmalloc(1, GFP_KERNEL);
>                         if (!read) {
>                                 ret = -ENOMEM;
> -                               kfree(read);
>                                 goto unlock;
>                         }
>  
> -- 
> 2.7.4
>