From: Jonathan Cameron <jic23@kernel.org>
To: jianchunfu <jianchunfu@cmss.chinamobile.com>
Cc: lars@metafoo.de, linux-iio@vger.kernel.org
Subject: Re: [PATCH] tools:iio: Fix the potential stack overflow risk
Date: Sun, 27 Mar 2022 15:45:13 +0100 [thread overview]
Message-ID: <20220327154513.0eaa8dfc@jic23-huawei> (raw)
In-Reply-To: <20220324110157.13143-1-jianchunfu@cmss.chinamobile.com>
On Thu, 24 Mar 2022 19:01:57 +0800
jianchunfu <jianchunfu@cmss.chinamobile.com> wrote:
> Add judgment to fix the potential stack overflow risk.
>
> Signed-off-by: jianchunfu <jianchunfu@cmss.chinamobile.com>
Yikes.
Whilst it doesn't promise to be good code (it's meant to show
the principles, not for anyone to use it) the error handling
in this function is a mess :(
Whilst your change here looks good I think this function needs
a closer look so we fix them all together.
Just glancing at it, the decision on whether to go to the unified
error handling or return without doing anything seems entirely random.
If you want to take on a more general rework of the error handling
in that function it would be great. If not I 'might' get to it at
somepoint....
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 2491c54a5..733fc21c2 100644
> --- a/tools/iio/iio_generic_buffer.c
> +++ b/tools/iio/iio_generic_buffer.c
> @@ -487,6 +487,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) {
next prev parent reply other threads:[~2022-03-27 14:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-24 11:01 [PATCH] tools:iio: Fix the potential stack overflow risk jianchunfu
2022-03-27 14:45 ` Jonathan Cameron [this message]
2022-03-27 22:12 ` Andy Shevchenko
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=20220327154513.0eaa8dfc@jic23-huawei \
--to=jic23@kernel.org \
--cc=jianchunfu@cmss.chinamobile.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
/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