Message ID | YJupQPb+Y4vw3rDk@mwanda (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net] net: hso: check for allocation failure in hso_create_bulk_serial_device() | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | fail | 1 blamed authors not CCed: alan@redhat.com; 2 maintainers not CCed: geert@linux-m68k.org alan@redhat.com |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 5 this patch: 5 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 13 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 5 this patch: 5 |
netdev/header_inline | success | Link |
On Wed, May 12, 2021 at 01:09:04PM +0300, Dan Carpenter wrote: > Add a couple checks for if these allocations fail. > > Fixes: 542f54823614 ("tty: Modem functions for the HSO driver") > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> > --- > drivers/net/usb/hso.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c > index 3ef4b2841402..3b2a868d7a72 100644 > --- a/drivers/net/usb/hso.c > +++ b/drivers/net/usb/hso.c > @@ -2618,9 +2618,13 @@ static struct hso_device *hso_create_bulk_serial_device( > num_urbs = 2; > serial->tiocmget = kzalloc(sizeof(struct hso_tiocmget), > GFP_KERNEL); > + if (!serial->tiocmget) > + goto exit; Nice catch; the next assignment would go boom if this ever failed. This appears to have been introduced by af0de1303c4e ("usb: hso: obey DMA rules in tiocmget") > serial->tiocmget->serial_state_notification > = kzalloc(sizeof(struct hso_serial_state_notification), > GFP_KERNEL); > + if (!serial->tiocmget->serial_state_notification) > + goto exit; > /* it isn't going to break our heart if serial->tiocmget > * allocation fails don't bother checking this. > */ You should remove this comment and drop the conditional on the following line as well now, though. Johan
On Wed, May 12, 2021 at 12:19:03PM +0200, Johan Hovold wrote: > On Wed, May 12, 2021 at 01:09:04PM +0300, Dan Carpenter wrote: > > Add a couple checks for if these allocations fail. > > > > Fixes: 542f54823614 ("tty: Modem functions for the HSO driver") > > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> > > --- > > drivers/net/usb/hso.c | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c > > index 3ef4b2841402..3b2a868d7a72 100644 > > --- a/drivers/net/usb/hso.c > > +++ b/drivers/net/usb/hso.c > > @@ -2618,9 +2618,13 @@ static struct hso_device *hso_create_bulk_serial_device( > > num_urbs = 2; > > serial->tiocmget = kzalloc(sizeof(struct hso_tiocmget), > > GFP_KERNEL); > > + if (!serial->tiocmget) > > + goto exit; > > Nice catch; the next assignment would go boom if this ever failed. > > This appears to have been introduced by > > af0de1303c4e ("usb: hso: obey DMA rules in tiocmget") > > > serial->tiocmget->serial_state_notification > > = kzalloc(sizeof(struct hso_serial_state_notification), > > GFP_KERNEL); > > + if (!serial->tiocmget->serial_state_notification) > > + goto exit; > > /* it isn't going to break our heart if serial->tiocmget > > * allocation fails don't bother checking this. > > */ > > You should remove this comment and drop the conditional on the following > line as well now, though. Ah, good catch. I'll resend. Thanks! regards, dan carpenter
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index 3ef4b2841402..3b2a868d7a72 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c @@ -2618,9 +2618,13 @@ static struct hso_device *hso_create_bulk_serial_device( num_urbs = 2; serial->tiocmget = kzalloc(sizeof(struct hso_tiocmget), GFP_KERNEL); + if (!serial->tiocmget) + goto exit; serial->tiocmget->serial_state_notification = kzalloc(sizeof(struct hso_serial_state_notification), GFP_KERNEL); + if (!serial->tiocmget->serial_state_notification) + goto exit; /* it isn't going to break our heart if serial->tiocmget * allocation fails don't bother checking this. */
Add a couple checks for if these allocations fail. Fixes: 542f54823614 ("tty: Modem functions for the HSO driver") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> --- drivers/net/usb/hso.c | 4 ++++ 1 file changed, 4 insertions(+)