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

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
...
}

Thanks,
Yang
>
> Thomas.
>

  reply	other threads:[~2022-11-22 11:43 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 [this message]
2022-11-22 12:07       ` Thomas Bogendoerfer
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=bd044af5-77ca-6e4f-1023-16f0b92302a8@huawei.com \
    --to=yangyingliang@huawei.com \
    --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=tsbogend@alpha.franken.de \
    /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).