]> git.baikalelectronics.ru Git - kernel.git/commit
power: supply: fix null pointer dereferencing in power_supply_get_battery_info
authorruanjinjie <ruanjinjie@huawei.com>
Mon, 5 Dec 2022 07:51:53 +0000 (15:51 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:41:28 +0000 (11:41 +0100)
commit0acb12d18073ae92de1639b5dd873535c113754f
tree4337f44dc2e140b873fdfba7502f0cc355cc641f
parent468b230393988b94c5ade8b3af014d27c6fd6ce4
power: supply: fix null pointer dereferencing in power_supply_get_battery_info

[ Upstream commit 104bb8a663451404a26331263ce5b96c34504049 ]

when kmalloc() fail to allocate memory in kasprintf(), propname
will be NULL, strcmp() called by of_get_property() will cause
null pointer dereference.

So return ENOMEM if kasprintf() return NULL pointer.

Fixes: fd7ec456301d ("power: supply: core: Add some helpers to use the battery OCV capacity table")
Signed-off-by: ruanjinjie <ruanjinjie@huawei.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/power/supply/power_supply_core.c