linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
To: Yang Yingliang <yangyingliang@huawei.com>
Cc: linux-mips@vger.kernel.org, dengcheng.zhu@imgtec.com,
	Steven.Hill@imgtec.com, Qais.Yousef@imgtec.com,
	blogic@openwrt.org
Subject: Re: [PATCH v2 1/2] MIPS: vpe-mt: fix possible memory leak while module exiting
Date: Tue, 22 Nov 2022 13:07:02 +0100	[thread overview]
Message-ID: <20221122120702.GA10816@alpha.franken.de> (raw)
In-Reply-To: <bd044af5-77ca-6e4f-1023-16f0b92302a8@huawei.com>

On Tue, Nov 22, 2022 at 07:41:26PM +0800, Yang Yingliang wrote:
> Hi,
> 
> On 2022/11/22 19:21, Thomas Bogendoerfer wrote:
> > On Fri, Nov 04, 2022 at 11:39:44AM +0800, Yang Yingliang wrote:
> > > Afer commit 1fa5ae857bb1 ("driver core: get rid of struct device's
> > > bus_id string array"), the name of device is allocated dynamically,
> > > it need be freed when module exiting, call put_device() to give up
> > > reference, so that it can be freed in kobject_cleanup() when the
> > > refcount hit to 0. The vpe_device is static, so remove kfree() from
> > > vpe_device_release().
> > > 
> > > Fixes: 1fa5ae857bb1 ("driver core: get rid of struct device's bus_id string array")
> > > Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> > > ---
> > >   arch/mips/kernel/vpe-mt.c | 4 ++--
> > >   1 file changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/arch/mips/kernel/vpe-mt.c b/arch/mips/kernel/vpe-mt.c
> > > index bad6b0891b2b..84a82b551ec3 100644
> > > --- a/arch/mips/kernel/vpe-mt.c
> > > +++ b/arch/mips/kernel/vpe-mt.c
> > > @@ -313,7 +313,6 @@ ATTRIBUTE_GROUPS(vpe);
> > >   static void vpe_device_release(struct device *cd)
> > >   {
> > > -	kfree(cd);
> > >   }
> > as this is empty now, we can IMHO remove the function completly. Same
> > for the other patch in this series.
> It can not be removed, or it will cause WARNING in device_release() when
> calling
> put_device()/device_unregister().
> 
> static void device_release(struct kobject *kobj)
> {
> ...
> 
>         if (dev->release)
>                 dev->release(dev);
>         else if (dev->type && dev->type->release)
>                 dev->type->release(dev);
>         else if (dev->class && dev->class->dev_release)
>                 dev->class->dev_release(dev);
>         else
>                 WARN(1, KERN_ERR "Device '%s' does not have a release()
> function, it is broken and must be fixed. See
> Documentation/core-api/kobject.rst.\n",
>                         dev_name(dev));  // WANING here

you are right, thank you for looking into that,

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

  reply	other threads:[~2022-11-22 12:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-04  3:39 [PATCH v2 0/2] MIPS: fix possible memory leak while module exiting Yang Yingliang
2022-11-04  3:39 ` [PATCH v2 1/2] MIPS: vpe-mt: " Yang Yingliang
2022-11-22 11:21   ` Thomas Bogendoerfer
2022-11-22 11:41     ` Yang Yingliang
2022-11-22 12:07       ` Thomas Bogendoerfer [this message]
2022-11-04  3:39 ` [PATCH v2 2/2] MIPS: vpe-cmp: " Yang Yingliang
2022-11-22 12:29 ` [PATCH v2 0/2] MIPS: " Thomas Bogendoerfer

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=20221122120702.GA10816@alpha.franken.de \
    --to=tsbogend@alpha.franken.de \
    --cc=Qais.Yousef@imgtec.com \
    --cc=Steven.Hill@imgtec.com \
    --cc=blogic@openwrt.org \
    --cc=dengcheng.zhu@imgtec.com \
    --cc=linux-mips@vger.kernel.org \
    --cc=yangyingliang@huawei.com \
    /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).