Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 5b53a7a

Browse files
Zhu Jungregkh
authored andcommitted
tools/iio: Add memory allocation failure check for trigger_name
[ Upstream commit 3c6b818 ] Added a check to handle memory allocation failure for `trigger_name` and return `-ENOMEM`. Signed-off-by: Zhu Jun <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent b01793c commit 5b53a7a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tools/iio/iio_generic_buffer.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,10 @@ int main(int argc, char **argv)
498498
return -ENOMEM;
499499
}
500500
trigger_name = malloc(IIO_MAX_NAME_LENGTH);
501+
if (!trigger_name) {
502+
ret = -ENOMEM;
503+
goto error;
504+
}
501505
ret = read_sysfs_string("name", trig_dev_name, trigger_name);
502506
free(trig_dev_name);
503507
if (ret < 0) {

0 commit comments

Comments
 (0)