All of lore.kernel.org
 help / color / mirror / Atom feed
From: Navid Emamdoost <navid.emamdoost@gmail.com>
To: gregkh@linuxfoundation.org
Cc: devel@driverdev.osuosl.org, b.zolnierkie@samsung.com,
	kjlu@umn.edu, linux-kernel@vger.kernel.org,
	John Whitmore <johnfwhitmore@gmail.com>,
	emamd001@umn.edu, Nishka Dasgupta <nishkadg.linux@gmail.com>,
	smccaman@umn.edu, Colin Ian King <colin.king@canonical.com>,
	Navid Emamdoost <navid.emamdoost@gmail.com>
Subject: [PATCH v3] staging: rtl8192u: null check the kzalloc
Date: Tue, 30 Jul 2019 17:01:39 -0500	[thread overview]
Message-ID: <20190730220141.6608-1-navid.emamdoost__1503.48482873$1564524124$gmane$org@gmail.com> (raw)
In-Reply-To: <20190730164304.GA10640@kroah.com>

In rtl8192_init_priv_variable allocation for priv->pFirmware may fail,
so a null check is necessary.priv->pFirmware is accessed later in
rtl8192_adapter_start. I added the check and made appropriate changes
to propagate the errno to the caller.

---
Update v2: fixed style errors
Update V3: fixed prefix

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index fe1f279ca368..569d02240bf5 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -2096,7 +2096,7 @@ static void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode)
 }
 
 /* init priv variables here. only non_zero value should be initialized here. */
-static void rtl8192_init_priv_variable(struct net_device *dev)
+static int rtl8192_init_priv_variable(struct net_device *dev)
 {
 	struct r8192_priv *priv = ieee80211_priv(dev);
 	u8 i;
@@ -2223,6 +2223,8 @@ static void rtl8192_init_priv_variable(struct net_device *dev)
 
 	priv->AcmControl = 0;
 	priv->pFirmware = kzalloc(sizeof(rt_firmware), GFP_KERNEL);
+	if (!priv->pFirmware)
+		return -ENOMEM;
 
 	/* rx related queue */
 	skb_queue_head_init(&priv->rx_queue);
@@ -2236,6 +2238,8 @@ static void rtl8192_init_priv_variable(struct net_device *dev)
 	for (i = 0; i < MAX_QUEUE_SIZE; i++)
 		skb_queue_head_init(&priv->ieee80211->skb_drv_aggQ[i]);
 	priv->rf_set_chan = rtl8192_phy_SwChnl;
+
+	return 0;
 }
 
 /* init lock here */
@@ -2605,7 +2609,10 @@ static short rtl8192_init(struct net_device *dev)
 		memcpy(priv->txqueue_to_outpipemap, queuetopipe, 9);
 	}
 #endif
-	rtl8192_init_priv_variable(dev);
+	err = rtl8192_init_priv_variable(dev);
+	if (err)
+		return err;
+
 	rtl8192_init_priv_lock(priv);
 	rtl8192_init_priv_task(dev);
 	rtl8192_get_eeprom_size(dev);
-- 
2.17.1

  reply	other threads:[~2019-07-30 22:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-20 20:25 [PATCH] rtl8192_init_priv_variable: null check is missing for kzalloc Navid Emamdoost
2019-07-20 20:25 ` Navid Emamdoost
2019-07-25 12:45 ` Greg Kroah-Hartman
2019-07-25 12:45 ` Greg Kroah-Hartman
2019-07-30 14:30   ` [PATCH v2] " Navid Emamdoost
2019-07-30 16:43     ` Greg KH
2019-07-30 22:01       ` Navid Emamdoost [this message]
2019-07-30 22:01       ` [PATCH v3] staging: rtl8192u: null check the kzalloc Navid Emamdoost
2019-07-31 11:36         ` Greg KH
2019-07-31 14:19           ` [PATCH v4] " Navid Emamdoost
2019-07-31 14:19           ` Navid Emamdoost
2019-07-30 14:30   ` [PATCH v2] rtl8192_init_priv_variable: null check is missing for kzalloc Navid Emamdoost

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='20190730220141.6608-1-navid.emamdoost__1503.48482873$1564524124$gmane$org@gmail.com' \
    --to=navid.emamdoost@gmail.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=colin.king@canonical.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=emamd001@umn.edu \
    --cc=gregkh@linuxfoundation.org \
    --cc=johnfwhitmore@gmail.com \
    --cc=kjlu@umn.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nishkadg.linux@gmail.com \
    --cc=smccaman@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.