From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: brgl@bgdev.pl
Cc: Linus Walleij <linus.walleij@linaro.org>,
Kent Gibson <warthog618@gmail.com>,
Alexey Dobriyan <adobriyan@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
akpm@linux-foundation.org, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [PATCH v4] gpio: sim: fix an invalid __free() usage
Date: Tue, 19 Sep 2023 13:49:26 +0300 [thread overview]
Message-ID: <ZQl8tkWnQcjtFBbQ@smile.fi.intel.com> (raw)
In-Reply-To: <CAMRc=MfkzdFgwEuNGJYgxyCA_b__Ds-jA4S+jVT1ULJ9DTRhOw@mail.gmail.com>
On Tue, Sep 19, 2023 at 12:31:36AM -0700, brgl@bgdev.pl wrote:
> On Mon, 18 Sep 2023 17:31:36 +0200, Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> said:
> > On Mon, Sep 18, 2023 at 04:55:33PM +0200, Bartosz Golaszewski wrote:
...
> > Of course this can be replace with...
> >
> >> + line_names = kcalloc(line_names_size, sizeof(*line_names),
> >> + GFP_KERNEL);
> >
> >> + if (!line_names)
> >
> > ZERO_OR_NULL_PTR() check here, but I assume we discourage use of it.
>
> Why? There are less than 40 instances of using it in the kernel. kmalloc()
> returns NULL on failure.
Nope, k*alloc*() returns ZERO or NULL on failure. That's what most developers
are missing :-)
> >> + return ERR_PTR(-ENOMEM);
Hence either one needs to check for 0 the size given to the kmalloc(),
_or_ to check for all possible return values from it.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2023-09-19 10:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-18 14:55 [PATCH v4] gpio: sim: fix an invalid __free() usage Bartosz Golaszewski
2023-09-18 15:31 ` Andy Shevchenko
2023-09-19 7:31 ` brgl
2023-09-19 7:37 ` Kent Gibson
2023-09-19 7:46 ` brgl
2023-09-19 10:49 ` Andy Shevchenko [this message]
2023-09-23 18:19 ` Linus Torvalds
2023-09-25 6:58 ` 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=ZQl8tkWnQcjtFBbQ@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=bartosz.golaszewski@linaro.org \
--cc=brgl@bgdev.pl \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=torvalds@linux-foundation.org \
--cc=warthog618@gmail.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