2019-04-08 04:02:33

by zhong jiang

[permalink] [raw]
Subject: [PATCH] mm/memory_hotplug: Do not unlock when fails to take the device_hotplug_lock

When adding the memory by probing memory block in sysfs interface, there is an
obvious issue that we will unlock the device_hotplug_lock when fails to takes it.

That issue was introduced in Commit 8df1d0e4a265
("mm/memory_hotplug: make add_memory() take the device_hotplug_lock")

We should drop out in time when fails to take the device_hotplug_lock.

Fixes: 8df1d0e4a265 ("mm/memory_hotplug: make add_memory() take the device_hotplug_lock")
Reported-by: Yang yingliang <[email protected]>
Signed-off-by: zhong jiang <[email protected]>
---
drivers/base/memory.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index d9ebb89..8b0cec7 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -507,7 +507,7 @@ static ssize_t probe_store(struct device *dev, struct device_attribute *attr,

ret = lock_device_hotplug_sysfs();
if (ret)
- goto out;
+ goto ret;

nid = memory_add_physaddr_to_nid(phys_addr);
ret = __add_memory(nid, phys_addr,
--
1.7.12.4


2019-04-08 04:11:42

by zhong jiang

[permalink] [raw]
Subject: Re: [PATCH] mm/memory_hotplug: Do not unlock when fails to take the device_hotplug_lock

I am sorry, It is incorrect. please ignore the patch. I will resent it.

Thanks,
zhong jiang
On 2019/4/8 12:00, zhong jiang wrote:
> When adding the memory by probing memory block in sysfs interface, there is an
> obvious issue that we will unlock the device_hotplug_lock when fails to takes it.
>
> That issue was introduced in Commit 8df1d0e4a265
> ("mm/memory_hotplug: make add_memory() take the device_hotplug_lock")
>
> We should drop out in time when fails to take the device_hotplug_lock.
>
> Fixes: 8df1d0e4a265 ("mm/memory_hotplug: make add_memory() take the device_hotplug_lock")
> Reported-by: Yang yingliang <[email protected]>
> Signed-off-by: zhong jiang <[email protected]>
> ---
> drivers/base/memory.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/base/memory.c b/drivers/base/memory.c
> index d9ebb89..8b0cec7 100644
> --- a/drivers/base/memory.c
> +++ b/drivers/base/memory.c
> @@ -507,7 +507,7 @@ static ssize_t probe_store(struct device *dev, struct device_attribute *attr,
>
> ret = lock_device_hotplug_sysfs();
> if (ret)
> - goto out;
> + goto ret;
>
> nid = memory_add_physaddr_to_nid(phys_addr);
> ret = __add_memory(nid, phys_addr,


2019-04-08 07:27:41

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] mm/memory_hotplug: Do not unlock when fails to take the device_hotplug_lock

Hi zhong,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on driver-core/driver-core-testing]
[also build test ERROR on v5.1-rc4 next-20190405]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/zhong-jiang/mm-memory_hotplug-Do-not-unlock-when-fails-to-take-the-device_hotplug_lock/20190408-142325
config: x86_64-randconfig-x007-201914 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64

All errors (new ones prefixed by >>):

drivers/base/memory.c: In function 'probe_store':
>> drivers/base/memory.c:509:3: error: label 'ret' used but not defined
goto ret;
^~~~

vim +/ret +509 drivers/base/memory.c

485
486 /*
487 * Some architectures will have custom drivers to do this, and
488 * will not need to do it from userspace. The fake hot-add code
489 * as well as ppc64 will do all of their discovery in userspace
490 * and will require this interface.
491 */
492 #ifdef CONFIG_ARCH_MEMORY_PROBE
493 static ssize_t probe_store(struct device *dev, struct device_attribute *attr,
494 const char *buf, size_t count)
495 {
496 u64 phys_addr;
497 int nid, ret;
498 unsigned long pages_per_block = PAGES_PER_SECTION * sections_per_block;
499
500 ret = kstrtoull(buf, 0, &phys_addr);
501 if (ret)
502 return ret;
503
504 if (phys_addr & ((pages_per_block << PAGE_SHIFT) - 1))
505 return -EINVAL;
506
507 ret = lock_device_hotplug_sysfs();
508 if (ret)
> 509 goto ret;
510
511 nid = memory_add_physaddr_to_nid(phys_addr);
512 ret = __add_memory(nid, phys_addr,
513 MIN_MEMORY_BLOCK_SIZE * sections_per_block);
514
515 if (ret)
516 goto out;
517
518 ret = count;
519 out:
520 unlock_device_hotplug();
521 return ret;
522 }
523

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (2.20 kB)
.config.gz (30.78 kB)
Download all attachments