linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Aditya Pakki <pakki001@umn.edu>
Cc: kjlu@umn.edu, Amitkumar Karwar <amitkarwar@gmail.com>,
	Siva Rebbagondla <siva8118@gmail.com>,
	Kalle Valo <kvalo@codeaurora.org>,
	"David S. Miller" <davem@davemloft.net>,
	linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rsi: Fix NULL pointer dereference in kmalloc
Date: Sun, 03 Mar 2019 15:14:43 +0100	[thread overview]
Message-ID: <2cfc6bc5170f9e4191fa0ad6fd13d7e88418b2c3.camel@sipsolutions.net> (raw)
In-Reply-To: <20190302203123.9182-1-pakki001@umn.edu> (sfid-20190302_213904_982056_54C36803)

On Sat, 2019-03-02 at 14:31 -0600, Aditya Pakki wrote:
> kmalloc can fail in rsi_register_rates_channels but memcpy still attempts
> to write to channels. The patch checks and avoids such a situation.
> 
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
>  drivers/net/wireless/rsi/rsi_91x_mac80211.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/net/wireless/rsi/rsi_91x_mac80211.c b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
> index e56fc83faf0e..59eb1f533d0e 100644
> --- a/drivers/net/wireless/rsi/rsi_91x_mac80211.c
> +++ b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
> @@ -197,6 +197,11 @@ static void rsi_register_rates_channels(struct rsi_hw *adapter, int band)
>  
>  	if (band == NL80211_BAND_2GHZ) {
>  		channels = kmalloc(sizeof(rsi_2ghz_channels), GFP_KERNEL);
> +		if (!channels) {
> +			rsi_dbg(ERR_ZONE, "Failed to allocate memory\n");
> +			return;
> +		}
> +
>  		memcpy(channels,
>  		       rsi_2ghz_channels,
>  		       sizeof(rsi_2ghz_channels));

Should probably be kmemdup() anyway though.

johannes


      parent reply	other threads:[~2019-03-03 14:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-02 20:31 [PATCH] rsi: Fix NULL pointer dereference in kmalloc Aditya Pakki
2019-03-03  3:02 ` Joe Perches
2019-03-03 14:14 ` Johannes Berg [this message]

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=2cfc6bc5170f9e4191fa0ad6fd13d7e88418b2c3.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=amitkarwar@gmail.com \
    --cc=davem@davemloft.net \
    --cc=kjlu@umn.edu \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pakki001@umn.edu \
    --cc=siva8118@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;
as well as URLs for NNTP newsgroup(s).