]> git.baikalelectronics.ru Git - kernel.git/commit
iio: dummy: iio_simple_dummy: check the return value of kstrdup()
authorXiaoke Wang <xkernel.wang@foxmail.com>
Sat, 5 Mar 2022 03:14:05 +0000 (11:14 +0800)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 4 Apr 2022 08:11:24 +0000 (09:11 +0100)
commitc710f01e6e66b580bf47596a138cc97d454a8383
tree063eededf1192c5571b1e9cd557295c8bf591bee
parentf430955ef0b1e9268833d33cb225d8fdcb169e7e
iio: dummy: iio_simple_dummy: check the return value of kstrdup()

kstrdup() is also a memory allocation-related function, it returns NULL
when some memory errors happen. So it is better to check the return
value of it so to catch the memory error in time. Besides, there should
have a kfree() to clear up the allocation if we get a failure later in
this function to prevent memory leak.

Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
Link: https://lore.kernel.org/r/tencent_C920CFCC33B9CC1C63141FE1334A39FF8508@qq.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/dummy/iio_simple_dummy.c