public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers/usb/class/cdc-acm.c: clear dangling pointer
@ 2011-12-23 13:02 Julia Lawall
  2011-12-27 21:56 ` Oliver Neukum
  0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2011-12-23 13:02 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: kernel-janitors, Greg Kroah-Hartman, linux-usb, linux-kernel

From: Julia Lawall <julia@diku.dk>

On some failures, the country_code field of an acm structure is freed
without freeing the acm structure itself.  Elsewhere, operations including
memcpy and kfree are performed on the country_code field.  The patch sets
the country_code field to NULL when it is freed, and likewise sets the
country_code_size field to 0.

Signed-off-by: Julia Lawall <julia@diku.dk>

---
Only compile tested.  The second goto skip_countries serves no purpose, but
is perhaps useful from a readability point of view.

 drivers/usb/class/cdc-acm.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index f30fbff..9543b19 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1230,6 +1230,8 @@ made_compressed_probe:
 		i = device_create_file(&intf->dev, &dev_attr_wCountryCodes);
 		if (i < 0) {
 			kfree(acm->country_codes);
+			acm->country_codes = NULL;
+			acm->country_code_size = 0;
 			goto skip_countries;
 		}
 
@@ -1238,6 +1240,8 @@ made_compressed_probe:
 		if (i < 0) {
 			device_remove_file(&intf->dev, &dev_attr_wCountryCodes);
 			kfree(acm->country_codes);
+			acm->country_codes = NULL;
+			acm->country_code_size = 0;
 			goto skip_countries;
 		}
 	}


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

* Re: [PATCH] drivers/usb/class/cdc-acm.c: clear dangling pointer
  2011-12-23 13:02 [PATCH] drivers/usb/class/cdc-acm.c: clear dangling pointer Julia Lawall
@ 2011-12-27 21:56 ` Oliver Neukum
  0 siblings, 0 replies; 2+ messages in thread
From: Oliver Neukum @ 2011-12-27 21:56 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Oliver Neukum, kernel-janitors, Greg Kroah-Hartman, linux-usb,
	linux-kernel

Am Freitag, 23. Dezember 2011, 14:02:55 schrieb Julia Lawall:
> From: Julia Lawall <julia@diku.dk>
> 
> On some failures, the country_code field of an acm structure is freed
> without freeing the acm structure itself.  Elsewhere, operations including
> memcpy and kfree are performed on the country_code field.  The patch sets
> the country_code field to NULL when it is freed, and likewise sets the
> country_code_size field to 0.
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: Oliver NEukum <oneukum@suse.de>

This is in principle oopsable and should go into stable.

	Regards
		Oliver

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

end of thread, other threads:[~2011-12-27 21:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-23 13:02 [PATCH] drivers/usb/class/cdc-acm.c: clear dangling pointer Julia Lawall
2011-12-27 21:56 ` Oliver Neukum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox