All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
To: Xishi Qiu <qiuxishi@huawei.com>
Cc: gregkh@linuxfoundation.org, akpm@linux-foundation.org,
	stable@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org
Subject: Re: [PATCH] driver/base/node: remove unnecessary kfree of node struct from unregister_one_node
Date: Thu, 9 Oct 2014 14:03:54 +0900	[thread overview]
Message-ID: <5436173A.1050002@jp.fujitsu.com> (raw)
In-Reply-To: <54360ABF.9030302@huawei.com>

(2014/10/09 13:10), Xishi Qiu wrote:
> On 2014/10/3 18:06, Yasuaki Ishimatsu wrote:
> 
>> Commit 92d585ef067d ("numa: fix NULL pointer access and memory
>> leak in unregister_one_node()") added kfree() of node struct in
>> unregister_one_node(). But node struct is freed by node_device_release()
>> which is called in  unregister_node(). So by adding the kfree(),
> 
> Hi,
> 
> Is this path?
> unregister_node()
>    device_unregister()
>      device_del()
>        bus_remove_device()
>          device_release_driver()
>            __device_release_driver()
>              devres_release_all()
>                release_nodes()
>                  dr->node.release(dev, dr->data);
>                    then which function is be called?

node_device_release is called as follows:

unregister_one_node()
-> unregister_node()
  -> device_unregister()
    -> put_device()
      -> kobject_put()
        -> kref_put()
          -> kref_sub()
            -> kobject_release()
              -> kobject_cleanup()
                -> device_release()
                  -> node_device_release()

Thanks,
Yasuaki Ishimatsu

> 
> Thanks,
> Xishi Qiu
> 
>> node struct is freed two times.
>>
>> While hot removing memory, the commit leads the following BUG_ON():
>>
>>    kernel BUG at mm/slub.c:3346!
>>    invalid opcode: 0000 [#1] SMP
>>    [...]
>>    Call Trace:
>>     [...] unregister_one_node
>>     [...] try_offline_node
>>     [...] remove_memory
>>     [...] acpi_memory_device_remove
>>     [...] acpi_bus_trim
>>     [...] acpi_bus_trim
>>     [...] acpi_device_hotplug
>>     [...] acpi_hotplug_work_fn
>>     [...] process_one_work
>>     [...] worker_thread
>>     [...] ? rescuer_thread
>>     [...] kthread
>>     [...] ? kthread_create_on_node
>>     [...] ret_from_fork
>>     [...] ? kthread_create_on_node
>>
>> This patch removes unnecessary kfree() from unregister_one_node().
>>
>> Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
>> Cc: Xishi Qiu <qiuxishi@huawei.com>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: Andrew Morton <akpm@linux-foundation.org>
>> Cc: stable@vger.kernel.org # v3.16+
>> Fixes: 92d585ef067d "numa: fix NULL pointer access and memory leak in unregister_one_node()"
>> ---
>>   drivers/base/node.c | 1 -
>>   1 file changed, 1 deletion(-)
>>
>> diff --git a/drivers/base/node.c b/drivers/base/node.c
>> index c6d3ae0..d51c49c 100644
>> --- a/drivers/base/node.c
>> +++ b/drivers/base/node.c
>> @@ -603,7 +603,6 @@ void unregister_one_node(int nid)
>>   		return;
>>
>>   	unregister_node(node_devices[nid]);
>> -	kfree(node_devices[nid]);
>>   	node_devices[nid] = NULL;
>>   }
>>
> 
> 
> 


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

WARNING: multiple messages have this Message-ID (diff)
From: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
To: Xishi Qiu <qiuxishi@huawei.com>
Cc: <gregkh@linuxfoundation.org>, <akpm@linux-foundation.org>,
	<stable@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-mm@kvack.org>
Subject: Re: [PATCH] driver/base/node: remove unnecessary kfree of node struct from unregister_one_node
Date: Thu, 9 Oct 2014 14:03:54 +0900	[thread overview]
Message-ID: <5436173A.1050002@jp.fujitsu.com> (raw)
In-Reply-To: <54360ABF.9030302@huawei.com>

(2014/10/09 13:10), Xishi Qiu wrote:
> On 2014/10/3 18:06, Yasuaki Ishimatsu wrote:
> 
>> Commit 92d585ef067d ("numa: fix NULL pointer access and memory
>> leak in unregister_one_node()") added kfree() of node struct in
>> unregister_one_node(). But node struct is freed by node_device_release()
>> which is called in  unregister_node(). So by adding the kfree(),
> 
> Hi,
> 
> Is this path?
> unregister_node()
>    device_unregister()
>      device_del()
>        bus_remove_device()
>          device_release_driver()
>            __device_release_driver()
>              devres_release_all()
>                release_nodes()
>                  dr->node.release(dev, dr->data);
>                    then which function is be called?

node_device_release is called as follows:

unregister_one_node()
-> unregister_node()
  -> device_unregister()
    -> put_device()
      -> kobject_put()
        -> kref_put()
          -> kref_sub()
            -> kobject_release()
              -> kobject_cleanup()
                -> device_release()
                  -> node_device_release()

Thanks,
Yasuaki Ishimatsu

> 
> Thanks,
> Xishi Qiu
> 
>> node struct is freed two times.
>>
>> While hot removing memory, the commit leads the following BUG_ON():
>>
>>    kernel BUG at mm/slub.c:3346!
>>    invalid opcode: 0000 [#1] SMP
>>    [...]
>>    Call Trace:
>>     [...] unregister_one_node
>>     [...] try_offline_node
>>     [...] remove_memory
>>     [...] acpi_memory_device_remove
>>     [...] acpi_bus_trim
>>     [...] acpi_bus_trim
>>     [...] acpi_device_hotplug
>>     [...] acpi_hotplug_work_fn
>>     [...] process_one_work
>>     [...] worker_thread
>>     [...] ? rescuer_thread
>>     [...] kthread
>>     [...] ? kthread_create_on_node
>>     [...] ret_from_fork
>>     [...] ? kthread_create_on_node
>>
>> This patch removes unnecessary kfree() from unregister_one_node().
>>
>> Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
>> Cc: Xishi Qiu <qiuxishi@huawei.com>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: Andrew Morton <akpm@linux-foundation.org>
>> Cc: stable@vger.kernel.org # v3.16+
>> Fixes: 92d585ef067d "numa: fix NULL pointer access and memory leak in unregister_one_node()"
>> ---
>>   drivers/base/node.c | 1 -
>>   1 file changed, 1 deletion(-)
>>
>> diff --git a/drivers/base/node.c b/drivers/base/node.c
>> index c6d3ae0..d51c49c 100644
>> --- a/drivers/base/node.c
>> +++ b/drivers/base/node.c
>> @@ -603,7 +603,6 @@ void unregister_one_node(int nid)
>>   		return;
>>
>>   	unregister_node(node_devices[nid]);
>> -	kfree(node_devices[nid]);
>>   	node_devices[nid] = NULL;
>>   }
>>
> 
> 
> 



  reply	other threads:[~2014-10-09  5:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-03 10:06 [PATCH] driver/base/node: remove unnecessary kfree of node struct from unregister_one_node Yasuaki Ishimatsu
2014-10-03 10:06 ` Yasuaki Ishimatsu
2014-10-09  4:10 ` Xishi Qiu
2014-10-09  4:10   ` Xishi Qiu
2014-10-09  5:03   ` Yasuaki Ishimatsu [this message]
2014-10-09  5:03     ` Yasuaki Ishimatsu

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=5436173A.1050002@jp.fujitsu.com \
    --to=isimatu.yasuaki@jp.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=qiuxishi@huawei.com \
    --cc=stable@vger.kernel.org \
    /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 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.