All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rtl8192_init_priv_variable: null check is missing for kzalloc
@ 2019-07-20 20:25 ` Navid Emamdoost
  0 siblings, 0 replies; 12+ messages in thread
From: Navid Emamdoost @ 2019-07-20 20:25 UTC (permalink / raw)
  Cc: kjlu, smccaman, secalert, emamd001, Navid Emamdoost,
	Greg Kroah-Hartman, John Whitmore, Nishka Dasgupta,
	Colin Ian King, devel, linux-kernel

Allocation for priv->pFirmware may fail, so a null check is necessary.
priv->pFirmware is accessed at line 2743. I added the check and made
appropriate changes to propagate the errno to the caller.

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

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index fe1f279ca368..5fb24b13ce5b 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,10 @@ 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 +2240,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 +2611,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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH] rtl8192_init_priv_variable: null check is missing for kzalloc
@ 2019-07-20 20:25 ` Navid Emamdoost
  0 siblings, 0 replies; 12+ messages in thread
From: Navid Emamdoost @ 2019-07-20 20:25 UTC (permalink / raw)


Allocation for priv->pFirmware may fail, so a null check is necessary.
priv->pFirmware is accessed at line 2743. I added the check and made
appropriate changes to propagate the errno to the caller.

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

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index fe1f279ca368..5fb24b13ce5b 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,10 @@ 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 +2240,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 +2611,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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] rtl8192_init_priv_variable: null check is missing for kzalloc
  2019-07-20 20:25 ` Navid Emamdoost
  (?)
  (?)
@ 2019-07-25 12:45 ` Greg Kroah-Hartman
  2019-07-30 14:30   ` [PATCH v2] " Navid Emamdoost
  2019-07-30 14:30   ` [PATCH v2] rtl8192_init_priv_variable: null check is missing for kzalloc Navid Emamdoost
  -1 siblings, 2 replies; 12+ messages in thread
From: Greg Kroah-Hartman @ 2019-07-25 12:45 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: devel, secalert, kjlu, linux-kernel, John Whitmore, emamd001,
	Nishka Dasgupta, smccaman, Colin Ian King

On Sat, Jul 20, 2019 at 03:25:44PM -0500, Navid Emamdoost wrote:
> Allocation for priv->pFirmware may fail, so a null check is necessary.
> priv->pFirmware is accessed at line 2743. I added the check and made
> appropriate changes to propagate the errno to the caller.
> 
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
>  drivers/staging/rtl8192u/r8192U_core.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
> index fe1f279ca368..5fb24b13ce5b 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,10 @@ 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 +2240,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 +2611,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;
> +	}

Always run checkpatch.pl on your patch before sending it so you do not
get grumpy emails telling you to run checkpatch.pl before sending your
patch :)


thanks,

greg k-h

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] rtl8192_init_priv_variable: null check is missing for kzalloc
  2019-07-20 20:25 ` Navid Emamdoost
  (?)
@ 2019-07-25 12:45 ` Greg Kroah-Hartman
  -1 siblings, 0 replies; 12+ messages in thread
From: Greg Kroah-Hartman @ 2019-07-25 12:45 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: devel, secalert, kjlu, linux-kernel, John Whitmore, emamd001,
	Nishka Dasgupta, smccaman, Colin Ian King

On Sat, Jul 20, 2019 at 03:25:44PM -0500, Navid Emamdoost wrote:
> Allocation for priv->pFirmware may fail, so a null check is necessary.
> priv->pFirmware is accessed at line 2743. I added the check and made
> appropriate changes to propagate the errno to the caller.
> 
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
>  drivers/staging/rtl8192u/r8192U_core.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
> index fe1f279ca368..5fb24b13ce5b 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,10 @@ 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 +2240,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 +2611,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;
> +	}

Always run checkpatch.pl on your patch before sending it so you do not
get grumpy emails telling you to run checkpatch.pl before sending your
patch :)


thanks,

greg k-h

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2] rtl8192_init_priv_variable: null check is missing for kzalloc
  2019-07-25 12:45 ` Greg Kroah-Hartman
@ 2019-07-30 14:30   ` Navid Emamdoost
  2019-07-30 16:43     ` Greg KH
  2019-07-30 14:30   ` [PATCH v2] rtl8192_init_priv_variable: null check is missing for kzalloc Navid Emamdoost
  1 sibling, 1 reply; 12+ messages in thread
From: Navid Emamdoost @ 2019-07-30 14:30 UTC (permalink / raw)
  To: gregkh
  Cc: kjlu, smccaman, emamd001, Navid Emamdoost, John Whitmore,
	Nishka Dasgupta, Colin Ian King, devel, linux-kernel

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: fixed style errors

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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2] rtl8192_init_priv_variable: null check is missing for kzalloc
  2019-07-25 12:45 ` Greg Kroah-Hartman
  2019-07-30 14:30   ` [PATCH v2] " Navid Emamdoost
@ 2019-07-30 14:30   ` Navid Emamdoost
  1 sibling, 0 replies; 12+ messages in thread
From: Navid Emamdoost @ 2019-07-30 14:30 UTC (permalink / raw)
  To: gregkh
  Cc: devel, kjlu, linux-kernel, John Whitmore, emamd001,
	Nishka Dasgupta, smccaman, Colin Ian King, Navid Emamdoost

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: fixed style errors

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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] rtl8192_init_priv_variable: null check is missing for kzalloc
  2019-07-30 14:30   ` [PATCH v2] " Navid Emamdoost
@ 2019-07-30 16:43     ` Greg KH
  2019-07-30 22:01       ` [PATCH v3] staging: rtl8192u: null check the kzalloc Navid Emamdoost
  2019-07-30 22:01       ` Navid Emamdoost
  0 siblings, 2 replies; 12+ messages in thread
From: Greg KH @ 2019-07-30 16:43 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: devel, kjlu, linux-kernel, John Whitmore, emamd001,
	Nishka Dasgupta, smccaman, Colin Ian King

On Tue, Jul 30, 2019 at 09:30:58AM -0500, Navid Emamdoost wrote:
> 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: fixed style errors

The "changelog" goes below the --- line, as is described in the kernel
documentation.

Also, please look at other patches for this driver, use the same prefix
for the subject line as those did.

v3 please?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3] staging: rtl8192u: null check the kzalloc
  2019-07-30 16:43     ` Greg KH
  2019-07-30 22:01       ` [PATCH v3] staging: rtl8192u: null check the kzalloc Navid Emamdoost
@ 2019-07-30 22:01       ` Navid Emamdoost
  2019-07-31 11:36         ` Greg KH
  1 sibling, 1 reply; 12+ messages in thread
From: Navid Emamdoost @ 2019-07-30 22:01 UTC (permalink / raw)
  To: gregkh
  Cc: emamd001, kjlu, b.zolnierkie, smccaman, Navid Emamdoost,
	John Whitmore, Nishka Dasgupta, Colin Ian King, devel,
	linux-kernel

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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v3] staging: rtl8192u: null check the kzalloc
  2019-07-30 16:43     ` Greg KH
@ 2019-07-30 22:01       ` Navid Emamdoost
  2019-07-30 22:01       ` Navid Emamdoost
  1 sibling, 0 replies; 12+ messages in thread
From: Navid Emamdoost @ 2019-07-30 22:01 UTC (permalink / raw)
  To: gregkh
  Cc: devel, b.zolnierkie, kjlu, linux-kernel, John Whitmore, emamd001,
	Nishka Dasgupta, smccaman, Colin Ian King, Navid Emamdoost

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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] staging: rtl8192u: null check the kzalloc
  2019-07-30 22:01       ` 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
  0 siblings, 2 replies; 12+ messages in thread
From: Greg KH @ 2019-07-31 11:36 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: devel, b.zolnierkie, kjlu, linux-kernel, John Whitmore, emamd001,
	Nishka Dasgupta, smccaman, Colin Ian King

On Tue, Jul 30, 2019 at 05:01:39PM -0500, Navid Emamdoost wrote:
> 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>

So close, the signed-off-by goes above the --- line.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v4] staging: rtl8192u: null check the kzalloc
  2019-07-31 11:36         ` Greg KH
@ 2019-07-31 14:19           ` Navid Emamdoost
  2019-07-31 14:19           ` Navid Emamdoost
  1 sibling, 0 replies; 12+ messages in thread
From: Navid Emamdoost @ 2019-07-31 14:19 UTC (permalink / raw)
  To: gregkh
  Cc: emamd001, kjlu, b.zolnierkie, smccaman, Navid Emamdoost,
	John Whitmore, Nishka Dasgupta, Colin Ian King, devel,
	linux-kernel

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.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>

---
Update v2: fixed style errors
Update V3: fixed prefix
Update V4: fixed style
---
 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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v4] staging: rtl8192u: null check the kzalloc
  2019-07-31 11:36         ` Greg KH
  2019-07-31 14:19           ` [PATCH v4] " Navid Emamdoost
@ 2019-07-31 14:19           ` Navid Emamdoost
  1 sibling, 0 replies; 12+ messages in thread
From: Navid Emamdoost @ 2019-07-31 14:19 UTC (permalink / raw)
  To: gregkh
  Cc: devel, b.zolnierkie, kjlu, linux-kernel, John Whitmore, emamd001,
	Nishka Dasgupta, smccaman, Colin Ian King, Navid Emamdoost

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.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>

---
Update v2: fixed style errors
Update V3: fixed prefix
Update V4: fixed style
---
 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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-07-31 14:19 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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       ` [PATCH v3] staging: rtl8192u: null check the kzalloc Navid Emamdoost
2019-07-30 22:01       ` 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

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.