netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [2.6 patch] hso_create_bulk_serial_device(): fix a double free
@ 2008-08-27 22:02 Adrian Bunk
  2008-09-13 19:56 ` Jeff Garzik
  0 siblings, 1 reply; 2+ messages in thread
From: Adrian Bunk @ 2008-08-27 22:02 UTC (permalink / raw)
  To: gregkh-l3A5Bk7waGM, jgarzik-e+AXbWqSrlAAvxtiuMwx3w
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA

hso_serial_common_free() mustn't be called if
hso_serial_common_create() fails.

Reported-by: Adrian Bunk <bunk-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Signed-off-by: Adrian Bunk <bunk-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

---

 drivers/net/usb/hso.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

d7557f8eda806e6888232bae1b86dfdd8b6cf330 
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 1b7cac7..8c11295 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -2206,39 +2206,40 @@ static struct hso_device *hso_create_bulk_serial_device(
 	if (hso_serial_common_create(serial, num_urbs, BULK_URB_RX_SIZE,
 				     BULK_URB_TX_SIZE))
 		goto exit;
 
 	serial->in_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_BULK,
 				     USB_DIR_IN);
 	if (!serial->in_endp) {
 		dev_err(&interface->dev, "Failed to find BULK IN ep\n");
-		goto exit;
+		goto exit2;
 	}
 
 	if (!
 	    (serial->out_endp =
 	     hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, USB_DIR_OUT))) {
 		dev_err(&interface->dev, "Failed to find BULK IN ep\n");
-		goto exit;
+		goto exit2;
 	}
 
 	serial->write_data = hso_std_serial_write_data;
 
 	/* and record this serial */
 	set_serial_by_index(serial->minor, serial);
 
 	/* setup the proc dirs and files if needed */
 	hso_log_port(hso_dev);
 
 	/* done, return it */
 	return hso_dev;
+
+exit2:
+	hso_serial_common_free(serial);
 exit:
-	if (hso_dev && serial)
-		hso_serial_common_free(serial);
 	kfree(serial);
 	hso_free_device(hso_dev);
 	return NULL;
 }
 
 /* Creates a multiplexed AT channel */
 static
 struct hso_device *hso_create_mux_serial_device(struct usb_interface *interface,
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [2.6 patch] hso_create_bulk_serial_device(): fix a double free
  2008-08-27 22:02 [2.6 patch] hso_create_bulk_serial_device(): fix a double free Adrian Bunk
@ 2008-09-13 19:56 ` Jeff Garzik
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Garzik @ 2008-09-13 19:56 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: gregkh, linux-usb, netdev

Adrian Bunk wrote:
> hso_serial_common_free() mustn't be called if
> hso_serial_common_create() fails.
> 
> Reported-by: Adrian Bunk <bunk@kernel.org>
> Signed-off-by: Adrian Bunk <bunk@kernel.org>
> 
> ---
> 
>  drivers/net/usb/hso.c |    9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> d7557f8eda806e6888232bae1b86dfdd8b6cf330 
> diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
> index 1b7cac7..8c11295 100644
> --- a/drivers/net/usb/hso.c
> +++ b/drivers/net/usb/hso.c
> @@ -2206,39 +2206,40 @@ static struct hso_device *hso_create_bulk_serial_device(
>  	if (hso_serial_common_create(serial, num_urbs, BULK_URB_RX_SIZE,
>  				     BULK_URB_TX_SIZE))
>  		goto exit;
>  
>  	serial->in_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_BULK,
>  				     USB_DIR_IN);
>  	if (!serial->in_endp) {
>  		dev_err(&interface->dev, "Failed to find BULK IN ep\n");
> -		goto exit;
> +		goto exit2;
>  	}
>  
>  	if (!
>  	    (serial->out_endp =
>  	     hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, USB_DIR_OUT))) {
>  		dev_err(&interface->dev, "Failed to find BULK IN ep\n");
> -		goto exit;
> +		goto exit2;
>  	}
>  
>  	serial->write_data = hso_std_serial_write_data;
>  
>  	/* and record this serial */
>  	set_serial_by_index(serial->minor, serial);
>  
>  	/* setup the proc dirs and files if needed */
>  	hso_log_port(hso_dev);
>  
>  	/* done, return it */
>  	return hso_dev;
> +
> +exit2:
> +	hso_serial_common_free(serial);
>  exit:
> -	if (hso_dev && serial)
> -		hso_serial_common_free(serial);
>  	kfree(serial);
>  	hso_free_device(hso_dev);
>  	return NULL;
>  }
>  
>  /* Creates a multiplexed AT channel */
>  static

applied



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

end of thread, other threads:[~2008-09-13 19:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-27 22:02 [2.6 patch] hso_create_bulk_serial_device(): fix a double free Adrian Bunk
2008-09-13 19:56 ` Jeff Garzik

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