mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RESEND] tools/iio: Add memory allocation failure check for trigger_name
@ 2024-09-12  3:28 Zhu Jun
  2024-09-14 14:29 ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: Zhu Jun @ 2024-09-12  3:28 UTC (permalink / raw)
  To: jic23; +Cc: lars, linux-iio, linux-kernel, zhujun2

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

Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
 tools/iio/iio_generic_buffer.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c
index 0d0a7a19d6f9..9ef5ee087eda 100644
--- a/tools/iio/iio_generic_buffer.c
+++ b/tools/iio/iio_generic_buffer.c
@@ -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) {
-- 
2.17.1




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RESEND] tools/iio: Add memory allocation failure check for trigger_name
  2024-09-12  3:28 [RESEND] tools/iio: Add memory allocation failure check for trigger_name Zhu Jun
@ 2024-09-14 14:29 ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2024-09-14 14:29 UTC (permalink / raw)
  To: Zhu Jun; +Cc: lars, linux-iio, linux-kernel

On Wed, 11 Sep 2024 20:28:46 -0700
Zhu Jun <zhujun2@cmss.chinamobile.com> wrote:

> Added a check to handle memory allocation failure for `trigger_name`
> and return `-ENOMEM`.
> 
> Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
I queued this up already but seems I forgot to say so!

Sorry about that. It is on my testing branch until I can rebase on rc1
when that becomes available.

Thanks,

Jonathan

> ---
>  tools/iio/iio_generic_buffer.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c
> index 0d0a7a19d6f9..9ef5ee087eda 100644
> --- a/tools/iio/iio_generic_buffer.c
> +++ b/tools/iio/iio_generic_buffer.c
> @@ -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) {


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [RESEND] tools/iio: Add memory allocation failure check for trigger_name
@ 2024-09-12  3:28 Zhu Jun
  0 siblings, 0 replies; 4+ messages in thread
From: Zhu Jun @ 2024-09-12  3:28 UTC (permalink / raw)
  To: jic23; +Cc: lars, linux-iio, linux-kernel, zhujun2

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

Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
 tools/iio/iio_generic_buffer.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c
index 0d0a7a19d6f9..9ef5ee087eda 100644
--- a/tools/iio/iio_generic_buffer.c
+++ b/tools/iio/iio_generic_buffer.c
@@ -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) {
-- 
2.17.1




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [RESEND] tools/iio: Add memory allocation failure check for trigger_name
@ 2024-09-12  3:28 Zhu Jun
  0 siblings, 0 replies; 4+ messages in thread
From: Zhu Jun @ 2024-09-12  3:28 UTC (permalink / raw)
  To: jic23; +Cc: lars, linux-iio, linux-kernel, zhujun2

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

Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
 tools/iio/iio_generic_buffer.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c
index 0d0a7a19d6f9..9ef5ee087eda 100644
--- a/tools/iio/iio_generic_buffer.c
+++ b/tools/iio/iio_generic_buffer.c
@@ -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) {
-- 
2.17.1




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-09-14 14:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-12  3:28 [RESEND] tools/iio: Add memory allocation failure check for trigger_name Zhu Jun
2024-09-14 14:29 ` Jonathan Cameron
2024-09-12  3:28 Zhu Jun
2024-09-12  3:28 Zhu Jun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®