Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1518992
| From | Sudip Mukherjee <sudipm.mukherjee@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2] ppdev: fix double-free of pp->pdev->name |
| Date | 2016-11-10 15:00 +0100 |
| Message-ID | <sBY3v-6TP-19@gated-at.bofh.it> (permalink) |
| References | <sy6M1-2cQ-3@gated-at.bofh.it> <sBXqN-6H1-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Thu, Nov 10, 2016 at 02:18:12PM +0100, Arnd Bergmann wrote:
> On Sunday, October 30, 2016 11:19:24 PM CET Jann Horn wrote:
> > diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
> > index d23368874710..6af1ce04b3da 100644
> > --- a/drivers/char/ppdev.c
> > +++ b/drivers/char/ppdev.c
> > @@ -748,10 +748,7 @@ static int pp_release(struct inode *inode, struct file *file)
> > }
> >
> > if (pp->pdev) {
> > - const char *name = pp->pdev->name;
> > -
> > parport_unregister_device(pp->pdev);
> > - kfree(name);
> > pp->pdev = NULL;
> > pr_debug(CHRDEV "%x: unregistered pardevice\n", minor);
> > }
> >
>
> I took a closer look at this and found that we also leak the name
> that is passed in register_device() in the same file:
>
> name = kasprintf(GFP_KERNEL, CHRDEV "%x", minor);
> ...
> pdev = parport_register_dev_model(port, name, &ppdev_cb, minor);
>
> parport_register_dev_model() copies the name using kstrdup() and
> we should really free it after parport_register_dev_model().
yes. I missed that while converting the driver to use device model.
Thanks. I will send a patch to fix this tonight.
>
> It's not a huge problem, just leaking a few bytes of memory, but
> the extra kfree() probably came from this confusion.
No, it was the old code which was not in the device-model. The old code
uses parport_register_device() which just uses the same string that is
passed to it and so it was freed while releasing the device.
Regards
Sudip
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH v2] ppdev: fix double-free of pp->pdev->name Jann Horn <jann@thejh.net> - 2016-10-30 23:30 +0100
Re: [PATCH v2] ppdev: fix double-free of pp->pdev->name Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-11-10 12:40 +0100
Re: [PATCH v2] ppdev: fix double-free of pp->pdev->name Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2016-11-10 13:50 +0100
Re: [PATCH v2] ppdev: fix double-free of pp->pdev->name Arnd Bergmann <arnd@arndb.de> - 2016-11-10 14:20 +0100
Re: [PATCH v2] ppdev: fix double-free of pp->pdev->name Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2016-11-10 15:00 +0100
csiph-web