]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
hwmon: (cgbc-hwmon) Add missing NULL check after devm_kzalloc()
authorLi Qiang <liqiang01@kylinos.cn>
Fri, 17 Oct 2025 06:34:14 +0000 (14:34 +0800)
committerGuenter Roeck <linux@roeck-us.net>
Mon, 20 Oct 2025 01:56:14 +0000 (18:56 -0700)
commita09a5aa8bf258ddc99a22c30f17fe304b96b5350
tree0604dcda98a9fcf3bb7c3f549dac50864d6f9b4c
parent57f6f47920ef2f598c46d0a04bd9c8984c98e6df
hwmon: (cgbc-hwmon) Add missing NULL check after devm_kzalloc()

The driver allocates memory for sensor data using devm_kzalloc(), but
did not check if the allocation succeeded. In case of memory allocation
failure, dereferencing the NULL pointer would lead to a kernel crash.

Add a NULL pointer check and return -ENOMEM to handle allocation failure
properly.

Signed-off-by: Li Qiang <liqiang01@kylinos.cn>
Fixes: 08ebc9def79fc ("hwmon: Add Congatec Board Controller monitoring driver")
Reviewed-by: Thomas Richard <thomas.richard@bootlin.com>
Link: https://lore.kernel.org/r/20251017063414.1557447-1-liqiang01@kylinos.cn
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/cgbc-hwmon.c