All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vme: remove unneeded kfree
@ 2018-09-06  8:51 Ding Xiang
  2018-09-07  5:04 ` Linus Torvalds
  0 siblings, 1 reply; 4+ messages in thread
From: Ding Xiang @ 2018-09-06  8:51 UTC (permalink / raw)
  To: martyn, manohar.vanga, gregkh, devel, linux-kernel

put_device will call vme_dev_release to free vdev, kfree is
unnecessary here.

Signed-off-by: Ding Xiang <dingxiang@cmss.chinamobile.com>
---
 drivers/vme/vme.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c
index 92500f6..520a5f9 100644
--- a/drivers/vme/vme.c
+++ b/drivers/vme/vme.c
@@ -1890,7 +1890,6 @@ static int __vme_register_driver_bus(struct vme_driver *drv,
 
 err_reg:
 	put_device(&vdev->dev);
-	kfree(vdev);
 err_devalloc:
 	list_for_each_entry_safe(vdev, tmp, &drv->devices, drv_list) {
 		list_del(&vdev->drv_list);
-- 
1.9.1




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

* Re: [PATCH] vme: remove unneeded kfree
  2018-09-06  8:51 [PATCH] vme: remove unneeded kfree Ding Xiang
@ 2018-09-07  5:04 ` Linus Torvalds
  2018-09-07  7:20   ` Greg Kroah-Hartman
  2018-09-07  8:33   ` Martyn Welch
  0 siblings, 2 replies; 4+ messages in thread
From: Linus Torvalds @ 2018-09-07  5:04 UTC (permalink / raw)
  To: dingxiang
  Cc: martyn, manohar.vanga, Greg Kroah-Hartman,
	Staging subsystem List, Linux Kernel Mailing List

On Thu, Sep 6, 2018 at 1:51 AM Ding Xiang
<dingxiang@cmss.chinamobile.com> wrote:
>
> put_device will call vme_dev_release to free vdev, kfree is
> unnecessary here.

That does seem to be the case.  I think "unnecessary" is overly kind,
it does seem to be a double free.

Looks like the issue was introduced back in 2013 by commit
def1820d25fa ("vme: add missing put_device() after device_register()
fails").

It seems you should *either* kfree() the vdev, _or_ do put_device(),
but doing both seems wrong.

I presume the device_register() has never failed, and this being
vme-only I'm guessing there isn't a vibrant testing community.

Greg?

              Linus

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

* Re: [PATCH] vme: remove unneeded kfree
  2018-09-07  5:04 ` Linus Torvalds
@ 2018-09-07  7:20   ` Greg Kroah-Hartman
  2018-09-07  8:33   ` Martyn Welch
  1 sibling, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2018-09-07  7:20 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: dingxiang, Staging subsystem List, martyn, manohar.vanga,
	Linux Kernel Mailing List

On Thu, Sep 06, 2018 at 10:04:49PM -0700, Linus Torvalds wrote:
> On Thu, Sep 6, 2018 at 1:51 AM Ding Xiang
> <dingxiang@cmss.chinamobile.com> wrote:
> >
> > put_device will call vme_dev_release to free vdev, kfree is
> > unnecessary here.
> 
> That does seem to be the case.  I think "unnecessary" is overly kind,
> it does seem to be a double free.
> 
> Looks like the issue was introduced back in 2013 by commit
> def1820d25fa ("vme: add missing put_device() after device_register()
> fails").
> 
> It seems you should *either* kfree() the vdev, _or_ do put_device(),
> but doing both seems wrong.

You should only ever call put_device() after you have created the
structure, the documentation should say that somewhere...

> I presume the device_register() has never failed, and this being
> vme-only I'm guessing there isn't a vibrant testing community.
> 
> Greg?

It's the correct fix, I'll queue it up soon, thanks.

greg k-h

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

* Re: [PATCH] vme: remove unneeded kfree
  2018-09-07  5:04 ` Linus Torvalds
  2018-09-07  7:20   ` Greg Kroah-Hartman
@ 2018-09-07  8:33   ` Martyn Welch
  1 sibling, 0 replies; 4+ messages in thread
From: Martyn Welch @ 2018-09-07  8:33 UTC (permalink / raw)
  To: Linus Torvalds, dingxiang
  Cc: manohar.vanga, Greg Kroah-Hartman, Staging subsystem List,
	Linux Kernel Mailing List

On Thu, 2018-09-06 at 22:04 -0700, Linus Torvalds wrote:
> On Thu, Sep 6, 2018 at 1:51 AM Ding Xiang
> <dingxiang@cmss.chinamobile.com> wrote:
> > 
> > put_device will call vme_dev_release to free vdev, kfree is
> > unnecessary here.
> 
> That does seem to be the case.  I think "unnecessary" is overly kind,
> it does seem to be a double free.
> 
> Looks like the issue was introduced back in 2013 by commit
> def1820d25fa ("vme: add missing put_device() after device_register()
> fails").
> 
> It seems you should *either* kfree() the vdev, _or_ do put_device(),
> but doing both seems wrong.
> 
> I presume the device_register() has never failed, and this being
> vme-only I'm guessing there isn't a vibrant testing community.
> 

I think that is also overly kind :-)

I currently lack access to suitable hardware to test fully myself and I
need to find some time to (re)implement some automated testing, after I
lost access to the bits I had when I left a previous employer. That and
see if I can get access to some hardware again...

Manohar, do you still have access/interest in the VME stuff? You've
been very quiet for a long time now.

Martyn

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

end of thread, other threads:[~2018-09-07  8:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-06  8:51 [PATCH] vme: remove unneeded kfree Ding Xiang
2018-09-07  5:04 ` Linus Torvalds
2018-09-07  7:20   ` Greg Kroah-Hartman
2018-09-07  8:33   ` Martyn Welch

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.