Skip to contentSkip to conversation

ipheth: potential null dereferences on error path

PATCH Applied Dan Carpenter 3 participants 5 messages Apr 27, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipheth: potential null dereferences on error path

The calls to usb_free_buffer() dereference rx_urb and tx_urb in the parameter list but those could be NULL.

drivers/net/usb/ipheth.c +8 -7
index fd10331..418825d 100644
@@ -122,25 +122,25 @@ static int ipheth_alloc_urbs(struct ipheth_device *iphone)
 
 	tx_urb = usb_alloc_urb(0, GFP_KERNEL);
 	if (tx_urb = NULL)
-		goto error;
+		goto error_nomem;
 
 	rx_urb = usb_alloc_urb(0, GFP_KERNEL);
 	if (rx_urb = NULL)
-		goto error;
+		goto free_tx_urb;
 
 	tx_buf = usb_buffer_alloc(iphone->udev,
 				  IPHETH_BUF_SIZE,
 				  GFP_KERNEL,
 				  &tx_urb->transfer_dma);
 	if (tx_buf = NULL)
-		goto error;
+		goto free_rx_urb;
 
 	rx_buf = usb_buffer_alloc(iphone->udev,
 				  IPHETH_BUF_SIZE,
 				  GFP_KERNEL,
 				  &rx_urb->transfer_dma);
 	if (rx_buf = NULL)
-		goto error;
+		goto free_tx_buf;
 
 
 	iphone->tx_urb = tx_urb;
@@ -149,13 +149,14 @@ static int ipheth_alloc_urbs(struct ipheth_device *iphone)
 	iphone->rx_buf = rx_buf;
 	return 0;
 
-error:
-	usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, rx_buf,
-			rx_urb->transfer_dma);
+free_tx_buf:
 	usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, tx_buf,
 			tx_urb->transfer_dma);
+free_rx_urb:
 	usb_free_urb(rx_urb);
+free_tx_urb:
 	usb_free_urb(tx_urb);
+error_nomem:
 	return -ENOMEM;
 }
 
#1 lore raw
Quoted 4 lines · Dan Carpenter

The calls to usb_free_buffer() dereference rx_urb and tx_urb in the parameter list but those could be NULL.

Seems good to me (should I ack it or any other kind of singoff?).

Signature · 7 lines
L. Alberto Giménez
JabberID [email protected]
GnuPG key ID 0x3BAABDE1
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#2 lore raw

From: L. Alberto Giménez <[email protected]>
Date: Tue, 27 Apr 2010 23:00:03 +0200

Quoted 7 lines · Dan Carpenter
Quoted 4 lines

The calls to usb_free_buffer() dereference rx_urb and tx_urb in the parameter list but those could be NULL.

Seems good to me (should I ack it or any other kind of singoff?).

If you give it an "Acked-by: ..." that would be nice.

Acked-by on v1 1/1
#3 lore raw
In reply to Dan Carpenter
Quoted 4 lines · Dan Carpenter

The calls to usb_free_buffer() dereference rx_urb and tx_urb in the parameter list but those could be NULL.

Signature · 7 lines
L. Alberto Giménez
JabberID [email protected]
GnuPG key ID 0x3BAABDE1
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html