memory tier: release the new_memtier in find_create_memory_tier()

commit 93419139fa upstream.

In find_create_memory_tier(), if failed to register device, then we should
release new_memtier from the tier list and put device instead of memtier.

Link: https://lkml.kernel.org/r/20230129040651.1329208-1-tongtiangen@huawei.com
Fixes: 9832fb8783 ("mm/demotion: expose memory tier details via sysfs")
Signed-off-by: Tong Tiangen <tongtiangen@huawei.com>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Cc: Hanjun Guo <guohanjun@huawei.com>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Guohanjun <guohanjun@huawei.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Tong Tiangen 2023-01-29 04:06:51 +00:00 committed by Greg Kroah-Hartman
parent e10a97f684
commit 313b18c774
1 changed files with 2 additions and 2 deletions

View File

@ -211,8 +211,8 @@ static struct memory_tier *find_create_memory_tier(struct memory_dev_type *memty
ret = device_register(&new_memtier->dev); ret = device_register(&new_memtier->dev);
if (ret) { if (ret) {
list_del(&memtier->list); list_del(&new_memtier->list);
put_device(&memtier->dev); put_device(&new_memtier->dev);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
memtier = new_memtier; memtier = new_memtier;