Message ID | 20190319173407.7279-1-kjlu@umn.edu (mailing list archive) |
---|---|
State | Mainlined |
Commit | 3de3dbe7c13210171ba8411e36b409a2c29c7415 |
Headers | show |
Series | usb: u132-hcd: fix potential NULL pointer dereference | expand |
On Tue, Mar 19, 2019 at 12:34:06PM -0500, Kangjie Lu wrote: > In case create_singlethread_workqueue fails, the fix notifies > callers the error to avoid potential NULL pointer dereferences. > > Signed-off-by: Kangjie Lu <kjlu@umn.edu> > --- > removed "unlikely" > --- > drivers/usb/host/u132-hcd.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c > index 934584f0a20a..6d5b532b03f8 100644 > --- a/drivers/usb/host/u132-hcd.c > +++ b/drivers/usb/host/u132-hcd.c > @@ -3203,6 +3203,8 @@ static int __init u132_hcd_init(void) > return -ENODEV; > printk(KERN_INFO "driver %s\n", hcd_name); > workqueue = create_singlethread_workqueue("u132"); > + if (!workqueue) > + return -ENOMEM; > retval = platform_driver_register(&u132_platform_driver); > return retval; if platform_driver_register() fails, shouldn't you clean up the workqueue? That can be a separate patch, that's not your fault here :) thanks, greg k-h
Please change the patch version in subject while sending patch. On 3/26/2019 10:11 AM, Greg Kroah-Hartman wrote: > On Tue, Mar 19, 2019 at 12:34:06PM -0500, Kangjie Lu wrote: >> In case create_singlethread_workqueue fails, the fix notifies >> callers the error to avoid potential NULL pointer dereferences. >> >> Signed-off-by: Kangjie Lu <kjlu@umn.edu> Reviewed-by: Mukesh Ojha <mojha@codeaurora.org> -Mukesh >> --- >> removed "unlikely" >> --- >> drivers/usb/host/u132-hcd.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c >> index 934584f0a20a..6d5b532b03f8 100644 >> --- a/drivers/usb/host/u132-hcd.c >> +++ b/drivers/usb/host/u132-hcd.c >> @@ -3203,6 +3203,8 @@ static int __init u132_hcd_init(void) >> return -ENODEV; >> printk(KERN_INFO "driver %s\n", hcd_name); >> workqueue = create_singlethread_workqueue("u132"); >> + if (!workqueue) >> + return -ENOMEM; >> retval = platform_driver_register(&u132_platform_driver); >> return retval; > if platform_driver_register() fails, shouldn't you clean up the > workqueue? That can be a separate patch, that's not your fault here :) I have taken care of it. https://lore.kernel.org/patchwork/patch/1054800/ > > thanks, > > greg k-h
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c index 934584f0a20a..6d5b532b03f8 100644 --- a/drivers/usb/host/u132-hcd.c +++ b/drivers/usb/host/u132-hcd.c @@ -3203,6 +3203,8 @@ static int __init u132_hcd_init(void) return -ENODEV; printk(KERN_INFO "driver %s\n", hcd_name); workqueue = create_singlethread_workqueue("u132"); + if (!workqueue) + return -ENOMEM; retval = platform_driver_register(&u132_platform_driver); return retval; }
In case create_singlethread_workqueue fails, the fix notifies callers the error to avoid potential NULL pointer dereferences. Signed-off-by: Kangjie Lu <kjlu@umn.edu> --- removed "unlikely" --- drivers/usb/host/u132-hcd.c | 2 ++ 1 file changed, 2 insertions(+)