mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Zhu Jun <zhujun2@cmss.chinamobile.com>
Cc: lars@metafoo.de, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RESEND] tools/iio: Add memory allocation failure check for trigger_name
Date: Sat, 14 Sep 2024 15:29:48 +0100	[thread overview]
Message-ID: <20240914152948.1f9927c2@jic23-huawei> (raw)
In-Reply-To: <20240912032846.2914-1-zhujun2@cmss.chinamobile.com>

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) {


  reply	other threads:[~2024-09-14 14:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-12  3:28 Zhu Jun
2024-09-14 14:29 ` Jonathan Cameron [this message]
2024-09-12  3:28 Zhu Jun
2024-09-12  3:28 Zhu Jun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240914152948.1f9927c2@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zhujun2@cmss.chinamobile.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®