public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Aditya Pakki <pakki001@umn.edu>
Cc: devel@driverdev.osuosl.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Nathan Chancellor <natechancellor@gmail.com>,
	kjlu@umn.edu, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: rtlwifi: Fix potential NULL pointer dereference
Date: Wed, 20 Mar 2019 13:38:13 +0300	[thread overview]
Message-ID: <20190320103812.GG2202@kadam> (raw)
In-Reply-To: <20190313161336.20182-1-pakki001@umn.edu>

On Wed, Mar 13, 2019 at 11:13:34AM -0500, Aditya Pakki wrote:
> phydm.internal is allocated using kzalloc which is used multiple
> times without a check for NULL pointer. This patch avoids such a
> scenario.
> 
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
>  drivers/staging/rtlwifi/phydm/rtl_phydm.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/staging/rtlwifi/phydm/rtl_phydm.c b/drivers/staging/rtlwifi/phydm/rtl_phydm.c
> index 9930ed954abb..37c7fcb72b65 100644
> --- a/drivers/staging/rtlwifi/phydm/rtl_phydm.c
> +++ b/drivers/staging/rtlwifi/phydm/rtl_phydm.c
> @@ -181,6 +181,9 @@ static int rtl_phydm_init_priv(struct rtl_priv *rtlpriv,
>  	rtlpriv->phydm.internal =
>  		kzalloc(sizeof(struct phy_dm_struct), GFP_KERNEL);
>  
> +	if (!rtlpriv->phydm.internal)

Don't put a blank line between the allocation and the check.  They're

part of the same code and it's weird to double space the code.

regards,
dan carpenter


  reply	other threads:[~2019-03-20 10:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-13 16:13 [PATCH] staging: rtlwifi: Fix potential NULL pointer dereference Aditya Pakki
2019-03-20 10:38 ` Dan Carpenter [this message]
2019-03-20 13:12 ` Mukesh Ojha
2019-03-20 15:06 ` Mukesh Ojha
  -- strict thread matches above, loose matches on Subject: below --
2019-03-13 16:29 Aditya Pakki
2019-03-17 11:13 ` Greg Kroah-Hartman

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=20190320103812.GG2202@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kjlu@umn.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=natechancellor@gmail.com \
    --cc=pakki001@umn.edu \
    /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