* [PATCH] can: gs_usb: check for kzalloc allocation failure
@ 2015-03-16 22:42 Colin King
2015-03-17 8:04 ` Marc Kleine-Budde
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2015-03-16 22:42 UTC (permalink / raw)
To: Wolfgang Grandegger, Marc Kleine-Budde, linux-can, netdev; +Cc: linux-kernel
From: Colin Ian King <colin.king@canonical.com>
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>
---
drivers/net/can/usb/gs_usb.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c
index 009acc8..8b4d3e6 100644
--- a/drivers/net/can/usb/gs_usb.c
+++ b/drivers/net/can/usb/gs_usb.c
@@ -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);
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] can: gs_usb: check for kzalloc allocation failure
2015-03-16 22:42 [PATCH] can: gs_usb: check for kzalloc allocation failure Colin King
@ 2015-03-17 8:04 ` Marc Kleine-Budde
0 siblings, 0 replies; 2+ messages in thread
From: Marc Kleine-Budde @ 2015-03-17 8:04 UTC (permalink / raw)
To: Colin King, Wolfgang Grandegger, linux-can, netdev; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 703 bytes --]
On 03/16/2015 11:42 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> 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>
Thanks, applied to can.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-03-17 8:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-16 22:42 [PATCH] can: gs_usb: check for kzalloc allocation failure Colin King
2015-03-17 8:04 ` Marc Kleine-Budde
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).