diff mbox series

[-next,5/5] USB: usbip: Remove an unnecessary NULL value

Message ID 20230804093253.91647-6-ruanjinjie@huawei.com (mailing list archive)
State Accepted
Commit b35935d66a3a25848519b9bffc1fca0b6b1004c5
Headers show
Series usb: Remove many unnecessary NULL values | expand

Commit Message

Jinjie Ruan Aug. 4, 2023, 9:32 a.m. UTC
The NULL initialization of the pointers assigned by kzalloc() first is
not necessary, because if the kzalloc() failed, the pointers will be
assigned NULL, otherwise it works as usual. so remove it.

Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
---
 drivers/usb/usbip/vudc_dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Shuah Aug. 4, 2023, 8:09 p.m. UTC | #1
On 8/4/23 03:32, Ruan Jinjie wrote:
> The NULL initialization of the pointers assigned by kzalloc() first is
> not necessary, because if the kzalloc() failed, the pointers will be
> assigned NULL, otherwise it works as usual. so remove it.
> 
> Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
> ---
>   drivers/usb/usbip/vudc_dev.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/usbip/vudc_dev.c b/drivers/usb/usbip/vudc_dev.c
> index 2bc428f2e261..8e42839e6060 100644
> --- a/drivers/usb/usbip/vudc_dev.c
> +++ b/drivers/usb/usbip/vudc_dev.c
> @@ -489,7 +489,7 @@ static void vudc_device_unusable(struct usbip_device *ud)
>   
>   struct vudc_device *alloc_vudc_device(int devid)
>   {
> -	struct vudc_device *udc_dev = NULL;
> +	struct vudc_device *udc_dev;
>   
>   	udc_dev = kzalloc(sizeof(*udc_dev), GFP_KERNEL);
>   	if (!udc_dev)

In addition to this, make a change to return NULL instead
of going to out.

if (!udc_dev)
                 goto out;

thanks,
-- Shuah
Jinjie Ruan Aug. 5, 2023, 2:46 a.m. UTC | #2
On 2023/8/5 4:09, shuah wrote:
> On 8/4/23 03:32, Ruan Jinjie wrote:
>> The NULL initialization of the pointers assigned by kzalloc() first is
>> not necessary, because if the kzalloc() failed, the pointers will be
>> assigned NULL, otherwise it works as usual. so remove it.
>>
>> Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
>> ---
>>   drivers/usb/usbip/vudc_dev.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/usbip/vudc_dev.c b/drivers/usb/usbip/vudc_dev.c
>> index 2bc428f2e261..8e42839e6060 100644
>> --- a/drivers/usb/usbip/vudc_dev.c
>> +++ b/drivers/usb/usbip/vudc_dev.c
>> @@ -489,7 +489,7 @@ static void vudc_device_unusable(struct
>> usbip_device *ud)
>>     struct vudc_device *alloc_vudc_device(int devid)
>>   {
>> -    struct vudc_device *udc_dev = NULL;
>> +    struct vudc_device *udc_dev;
>>         udc_dev = kzalloc(sizeof(*udc_dev), GFP_KERNEL);
>>       if (!udc_dev)
> 
> In addition to this, make a change to return NULL instead
> of going to out.
> 
> if (!udc_dev)
>                 goto out;

Thank you! I'll research it and fix sooner.

> 
> thanks,
> -- Shuah
>
diff mbox series

Patch

diff --git a/drivers/usb/usbip/vudc_dev.c b/drivers/usb/usbip/vudc_dev.c
index 2bc428f2e261..8e42839e6060 100644
--- a/drivers/usb/usbip/vudc_dev.c
+++ b/drivers/usb/usbip/vudc_dev.c
@@ -489,7 +489,7 @@  static void vudc_device_unusable(struct usbip_device *ud)
 
 struct vudc_device *alloc_vudc_device(int devid)
 {
-	struct vudc_device *udc_dev = NULL;
+	struct vudc_device *udc_dev;
 
 	udc_dev = kzalloc(sizeof(*udc_dev), GFP_KERNEL);
 	if (!udc_dev)