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 |
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
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 --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)
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(-)