netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] irda-usb: add error handling and fix leak
@ 2010-03-07 12:35 Dan Carpenter
  2010-03-07 23:26 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2010-03-07 12:35 UTC (permalink / raw)
  To: Samuel Ortiz
  Cc: David S. Miller, Stephen Hemminger, Patrick McHardy, Tadashi Abe,
	Julia Lawall, netdev, kernel-janitors

If the call to kcalloc() fails then we should return -ENOMEM.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c
index e8e33bb..2c9b3af 100644
--- a/drivers/net/irda/irda-usb.c
+++ b/drivers/net/irda/irda-usb.c
@@ -1651,6 +1651,8 @@ static int irda_usb_probe(struct usb_interface *intf,
 
 	self->rx_urb = kcalloc(self->max_rx_urb, sizeof(struct urb *),
 				GFP_KERNEL);
+	if (!self->rx_urb)
+		goto err_free_net;
 
 	for (i = 0; i < self->max_rx_urb; i++) {
 		self->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL);
@@ -1783,6 +1785,8 @@ err_out_2:
 err_out_1:
 	for (i = 0; i < self->max_rx_urb; i++)
 		usb_free_urb(self->rx_urb[i]);
+	kfree(self->rx_urb);
+err_free_net:
 	free_netdev(net);
 err_out:
 	return ret;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-03-07 23:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-07 12:35 [patch] irda-usb: add error handling and fix leak Dan Carpenter
2010-03-07 23:26 ` David Miller

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