Skip to content

Commit

Permalink
tools/iio: Add memory allocation failure check for trigger_name
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Zhu Jun authored and jic23 committed Sep 3, 2024
1 parent da83fd1 commit 3c6b818
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tools/iio/iio_generic_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,10 @@ int main(int argc, char **argv)
return -ENOMEM;
}
trigger_name = malloc(IIO_MAX_NAME_LENGTH);
if (!trigger_name) {
ret = -ENOMEM;
goto error;
}
ret = read_sysfs_string("name", trig_dev_name, trigger_name);
free(trig_dev_name);
if (ret < 0) {
Expand Down

0 comments on commit 3c6b818

Please sign in to comment.