From: Vojtech Pavlik <vojtech@ucw.cz>
To: Greg KH <greg@kroah.com>
Cc: Torrey Hoffman <thoffman@arnor.net>,
vojtech@ucw.cz, Linux Kernel <linux-kernel@vger.kernel.org>,
linux-usb-devel@lists.sourceforge.net
Subject: Re: depmod problem for 2.5.2-dj4
Date: Wed, 23 Jan 2002 23:47:14 +0100 [thread overview]
Message-ID: <20020123234714.A7536@suse.cz> (raw)
In-Reply-To: <1011744752.2440.0.camel@shire.arnor.net> <20020123045405.GA12060@kroah.com> <20020123094414.D5170@suse.cz> <20020123212435.GB15259@kroah.com> <20020123222251.GE15259@kroah.com>
In-Reply-To: <20020123222251.GE15259@kroah.com>; from greg@kroah.com on Wed, Jan 23, 2002 at 02:22:51PM -0800
On Wed, Jan 23, 2002 at 02:22:51PM -0800, Greg KH wrote:
> On Wed, Jan 23, 2002 at 01:24:36PM -0800, Greg KH wrote:
> > On Wed, Jan 23, 2002 at 09:44:14AM +0100, Vojtech Pavlik wrote:
> > > On Tue, Jan 22, 2002 at 08:54:05PM -0800, Greg KH wrote:
> > > > Vojtech, is this a USB function that you want added to usb.c?
> > >
> > > Yes, please. This will change later when Pat Mochels devicefs kicks in,
> > > but for the time being, it'd be very useful.
> >
> > Here's a patch against 2.5.3-pre3, does it look ok to you (I fixed the
> > potential memory leak in the second kmalloc call from what was in
> > 2.5.2-dj4)?
Yes, this is perfect. *shiver* I can't believe I made the code so leaky.
Sorry for that, it's a copy-paste problem.
Thanks for fixing it.
> Oops, more memory leak fixes:
>
> > diff -Nru a/drivers/usb/usb.c b/drivers/usb/usb.c
> > --- a/drivers/usb/usb.c Wed Jan 23 13:20:28 2002
> > +++ b/drivers/usb/usb.c Wed Jan 23 13:20:28 2002
> > @@ -2513,6 +2513,49 @@
> > return err;
> > }
> >
> > +/**
> > + * usb_make_path - returns device path in the hub tree
> > + * @dev: the device whose path is being constructed
> > + * @buf: where to put the string
> > + * @size: how big is "buf"?
> > + *
> > + * Returns length of the string (>= 0) or out of memory status (< 0).
> > + */
> > +int usb_make_path(struct usb_device *dev, char *buf, size_t size)
> > +{
> > + struct usb_device *pdev = dev->parent;
> > + char *tmp;
> > + char *port;
> > + int i;
> > +
> > + if (!(port = kmalloc(size, GFP_KERNEL)))
> > + return -ENOMEM;
> > + if (!(tmp = kmalloc(size, GFP_KERNEL))) {
> > + kfree(port);
> > + return -ENOMEM;
> > + }
> > +
> > + *port = 0;
> > +
> > + while (pdev) {
> > + for (i = 0; i < pdev->maxchild; i++)
> > + if (pdev->children[i] == dev)
> > + break;
> > +
> > + if (pdev->children[i] != dev)
> > + return -1;
>
> Should be:
> if (pdev->children[i] != dev) {
> kfree(port);
> kfree(tmp);
> return -ENODEV;
> }
>
> > +
> > + strcpy(tmp, port);
> > + snprintf(port, size, strlen(port) ? "%d.%s" : "%d", i + 1, tmp);
> > +
> > + dev = pdev;
> > + pdev = dev->parent;
> > + }
> > +
> > + snprintf(buf, size, "usb%d:%s", dev->bus->busnum, port);
>
> And add:
> kfree(port);
> kfree(tmp);
>
> > + return strlen(buf);
> > +}
>
>
> Does that look better?
>
> thanks,
>
> greg k-h
--
Vojtech Pavlik
SuSE Labs
next prev parent reply other threads:[~2002-01-23 22:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-01-23 0:12 depmod problem for 2.5.2-dj4 Torrey Hoffman
2002-01-23 4:54 ` Greg KH
2002-01-23 8:44 ` Vojtech Pavlik
2002-01-23 21:24 ` Greg KH
2002-01-23 22:22 ` Greg KH
2002-01-23 22:47 ` Vojtech Pavlik [this message]
2002-01-23 23:00 ` Greg KH
2002-01-24 0:46 ` [linux-usb-devel] " David Brownell
2002-01-24 9:01 ` Vojtech Pavlik
2002-01-24 9:20 ` Dave Jones
2002-01-24 15:27 ` [linux-usb-devel] Re: usb+driverfs [was depmod problem for 2.5.2-dj4] David Brownell
2002-01-24 15:32 ` Vojtech Pavlik
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=20020123234714.A7536@suse.cz \
--to=vojtech@ucw.cz \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb-devel@lists.sourceforge.net \
--cc=thoffman@arnor.net \
/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