Skip to content

Commit

Permalink
can: gs_usb: check for kzalloc allocation failure
Browse files Browse the repository at this point in the history
smatch detected the following issue:
drivers/net/can/usb/gs_usb.c:904 gs_usb_probe() error:
   potential null dereference 'dev'.  (kzalloc returns null)

Add a check for null return from kzalloc and return -ENOMEM

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  • Loading branch information
Colin Ian King authored and marckleinebudde committed Mar 22, 2015
1 parent 7e184c2 commit 37920a7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/net/can/usb/gs_usb.c
Expand Up @@ -901,6 +901,8 @@ static int gs_usb_probe(struct usb_interface *intf, const struct usb_device_id *
}

dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev)
return -ENOMEM;
init_usb_anchor(&dev->rx_submitted);

atomic_set(&dev->active_channels, 0);
Expand Down

0 comments on commit 37920a7

Please sign in to comment.