mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Ivan Bornyakov <brnkv.i1@gmail.com>
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	benchan@chromium.org, jnjoseph@google.com, rspringer@google.com
Subject: Re: [PATCH] staging: gasket: sysfs: fix potential null dereference
Date: Wed, 1 Aug 2018 20:08:07 +0200	[thread overview]
Message-ID: <20180801180807.GA31510@kroah.com> (raw)
In-Reply-To: <20180731152320.11575-1-brnkv.i1@gmail.com>

On Tue, Jul 31, 2018 at 06:23:20PM +0300, Ivan Bornyakov wrote:
> Add handling of possible allocation failure.
> 
> Reported by smatch:
> 
>   drivers/staging/gasket/gasket_sysfs.c:105 put_mapping() error: potential null dereference 'files_to_remove'. (kcalloc returns null)
> 
> Signed-off-by: Ivan Bornyakov <brnkv.i1@gmail.com>
> ---
>  drivers/staging/gasket/gasket_sysfs.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c
> index ef4eca02afa6..682e5c21f203 100644
> --- a/drivers/staging/gasket/gasket_sysfs.c
> +++ b/drivers/staging/gasket/gasket_sysfs.c
> @@ -101,6 +101,12 @@ static void put_mapping(struct gasket_sysfs_mapping *mapping)
>  		files_to_remove = kcalloc(num_files_to_remove,
>  					  sizeof(*files_to_remove),
>  					  GFP_KERNEL);
> +		if (!files_to_remove) {
> +			pr_err("%s: can't allocate memory\n", __func__);

kcalloc failing will print something, no need to do it again here.

thanks,

greg k-h

  reply	other threads:[~2018-08-01 18:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-31 15:23 Ivan Bornyakov
2018-08-01 18:08 ` Greg KH [this message]
2018-08-01 18:37   ` [PATCH v2] " Ivan Bornyakov

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=20180801180807.GA31510@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=benchan@chromium.org \
    --cc=brnkv.i1@gmail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=jnjoseph@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rspringer@google.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®