linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <gregkh@suse.de>
To: mina86@mina86.com, gregkh@suse.de, Linux-kernel@vger.kernel.org,
	stern@rowland.harvard.edu
Subject: patch usb-core-config.c-usb_get_configuration-simplified.patch added to gregkh-2.6 tree
Date: Thu, 29 Apr 2010 16:21:08 -0700	[thread overview]
Message-ID: <1272583268118@kroah.org> (raw)
In-Reply-To: <87sk6uaz9h.fsf@erwin.mina86.com>


This is a note to let you know that I've just added the patch titled

    Subject: USB: core: config.c: usb_get_configuration() simplified

to my gregkh-2.6 tree.  Its filename is

    usb-core-config.c-usb_get_configuration-simplified.patch

This tree can be found at 
    http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/


>From mina86@mina86.com  Thu Apr 29 16:05:40 2010
From: Michal Nazarewicz <mina86@mina86.com>
Date: Sat, 17 Apr 2010 17:12:58 +0200
Subject: USB: core: config.c: usb_get_configuration() simplified
To: Alan Stern <stern@rowland.harvard.edu>
Cc: linux-usb@vger.kernel.org, <Linux-kernel@vger.kernel.org>, Greg Kroah-Hartman <gregkh@suse.de>
Message-ID: <87sk6uaz9h.fsf@erwin.mina86.com>


usb_gat_configuratio() used two pointers to point to the same
memory.  Code simplified, by removing one of them.

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 drivers/usb/core/config.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -735,7 +735,6 @@ int usb_get_configuration(struct usb_dev
 	int ncfg = dev->descriptor.bNumConfigurations;
 	int result = 0;
 	unsigned int cfgno, length;
-	unsigned char *buffer;
 	unsigned char *bigbuffer;
 	struct usb_config_descriptor *desc;
 
@@ -764,17 +763,16 @@ int usb_get_configuration(struct usb_dev
 	if (!dev->rawdescriptors)
 		goto err2;
 
-	buffer = kmalloc(USB_DT_CONFIG_SIZE, GFP_KERNEL);
-	if (!buffer)
+	desc = kmalloc(USB_DT_CONFIG_SIZE, GFP_KERNEL);
+	if (!desc)
 		goto err2;
-	desc = (struct usb_config_descriptor *)buffer;
 
 	result = 0;
 	for (; cfgno < ncfg; cfgno++) {
 		/* We grab just the first descriptor so we know how long
 		 * the whole configuration is */
 		result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno,
-		    buffer, USB_DT_CONFIG_SIZE);
+		    desc, USB_DT_CONFIG_SIZE);
 		if (result < 0) {
 			dev_err(ddev, "unable to read config index %d "
 			    "descriptor/%s: %d\n", cfgno, "start", result);
@@ -823,7 +821,7 @@ int usb_get_configuration(struct usb_dev
 	result = 0;
 
 err:
-	kfree(buffer);
+	kfree(desc);
 out_not_authorized:
 	dev->descriptor.bNumConfigurations = cfgno;
 err2:


      parent reply	other threads:[~2010-04-30 16:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-17 12:38 [PATCH] usb: core: config.c: use buffer on stack rather then on heap Michal Nazarewicz
2010-04-17 14:42 ` Alan Stern
2010-04-17 15:12   ` [PATCH] usb: core: config.c: usb_get_configuration() simplified Michal Nazarewicz
2010-04-17 16:13     ` Alan Stern
2010-04-29 23:21     ` gregkh [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1272583268118@kroah.org \
    --to=gregkh@suse.de \
    --cc=Linux-kernel@vger.kernel.org \
    --cc=mina86@mina86.com \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).