Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tools/iio: Add memory allocation failure check for trigger_name

Added a check to handle memory allocation failure for `trigger_name`
and return `-ENOMEM`.

Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
Link: https://patch.msgid.link/20240828093129.3040-1-zhujun2@cmss.chinamobile.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Zhu Jun and committed by
Jonathan Cameron
3c6b818b da83fd15

+4
+4
tools/iio/iio_generic_buffer.c
··· 498 498 return -ENOMEM; 499 499 } 500 500 trigger_name = malloc(IIO_MAX_NAME_LENGTH); 501 + if (!trigger_name) { 502 + ret = -ENOMEM; 503 + goto error; 504 + } 501 505 ret = read_sysfs_string("name", trig_dev_name, trigger_name); 502 506 free(trig_dev_name); 503 507 if (ret < 0) {