linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][net-next] qtnfmac: fix uninitialized return code in ret
@ 2017-06-21 13:25 Colin King
  2017-06-21 13:54 ` Sergey Matyukevich
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Colin King @ 2017-06-21 13:25 UTC (permalink / raw)
  To: Igor Mitsyanko, Avinash Patil, Sergey Matyukevich, Kalle Valo,
	David S . Miller, Bindu Therthala, Kamlesh Rath,
	Sergei Maksimenko, Johannes Berg, linux-wireless, netdev
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The return value ret is unitialized and garbage is being returned
for the three different error conditions when setting up the PCIe
BARs. Fix this by initializing ret to  -ENOMEM to indicate that
the BARs failed to be setup correctly.

Detected by CoverityScan, CID#1437563 ("Unitialized scalar variable")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c b/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c
index f93b27f3a236..7fc4f0d6a9ad 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c
@@ -247,7 +247,7 @@ static void qtnf_pcie_free_shm_ipc(struct qtnf_pcie_bus_priv *priv)
 
 static int qtnf_pcie_init_memory(struct qtnf_pcie_bus_priv *priv)
 {
-	int ret;
+	int ret = -ENOMEM;
 
 	priv->sysctl_bar = qtnf_map_bar(priv, QTN_SYSCTL_BAR);
 	if (IS_ERR_OR_NULL(priv->sysctl_bar)) {
-- 
2.11.0

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

* Re: [PATCH][net-next] qtnfmac: fix uninitialized return code in ret
  2017-06-21 13:25 [PATCH][net-next] qtnfmac: fix uninitialized return code in ret Colin King
@ 2017-06-21 13:54 ` Sergey Matyukevich
  2017-06-21 13:55   ` Colin Ian King
  2017-06-22  5:10 ` Dan Carpenter
  2017-06-28 17:50 ` [net-next] " Kalle Valo
  2 siblings, 1 reply; 6+ messages in thread
From: Sergey Matyukevich @ 2017-06-21 13:54 UTC (permalink / raw)
  To: Colin King
  Cc: Igor Mitsyanko, Avinash Patil, Sergey Matyukevich, Kalle Valo,
	David S . Miller, Bindu Therthala, Kamlesh Rath,
	Sergei Maksimenko, Johannes Berg, linux-wireless, netdev,
	kernel-janitors, linux-kernel

> The return value ret is unitialized and garbage is being returned
> for the three different error conditions when setting up the PCIe
> BARs. Fix this by initializing ret to  -ENOMEM to indicate that
> the BARs failed to be setup correctly.
> 
> Detected by CoverityScan, CID#1437563 ("Unitialized scalar variable")
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c b/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c
> index f93b27f3a236..7fc4f0d6a9ad 100644
> --- a/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c
> +++ b/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c
> @@ -247,7 +247,7 @@ static void qtnf_pcie_free_shm_ipc(struct qtnf_pcie_bus_priv *priv)
> 
>  static int qtnf_pcie_init_memory(struct qtnf_pcie_bus_priv *priv)
>  {
> -       int ret;
> +       int ret = -ENOMEM;
> 
>         priv->sysctl_bar = qtnf_map_bar(priv, QTN_SYSCTL_BAR);
>         if (IS_ERR_OR_NULL(priv->sysctl_bar)) {
> --

Thanks !

Reviewed-by: Sergey Matyukevich <sergey.matyukevich.os@quantenna.com>

By the way, could you please use the recepient list suggested by
get_maintainer.pl script from the kernel scripts directory.

Regards,
Sergey

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

* Re: [PATCH][net-next] qtnfmac: fix uninitialized return code in ret
  2017-06-21 13:54 ` Sergey Matyukevich
@ 2017-06-21 13:55   ` Colin Ian King
  0 siblings, 0 replies; 6+ messages in thread
From: Colin Ian King @ 2017-06-21 13:55 UTC (permalink / raw)
  To: Igor Mitsyanko, Avinash Patil, Sergey Matyukevich, Kalle Valo,
	David S . Miller, Bindu Therthala, Kamlesh Rath,
	Sergei Maksimenko, Johannes Berg, linux-wireless, netdev,
	kernel-janitors, linux-kernel

On 21/06/17 14:54, Sergey Matyukevich wrote:
>> The return value ret is unitialized and garbage is being returned
>> for the three different error conditions when setting up the PCIe
>> BARs. Fix this by initializing ret to  -ENOMEM to indicate that
>> the BARs failed to be setup correctly.
>>
>> Detected by CoverityScan, CID#1437563 ("Unitialized scalar variable")
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>  drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c b/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c
>> index f93b27f3a236..7fc4f0d6a9ad 100644
>> --- a/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c
>> +++ b/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c
>> @@ -247,7 +247,7 @@ static void qtnf_pcie_free_shm_ipc(struct qtnf_pcie_bus_priv *priv)
>>
>>  static int qtnf_pcie_init_memory(struct qtnf_pcie_bus_priv *priv)
>>  {
>> -       int ret;
>> +       int ret = -ENOMEM;
>>
>>         priv->sysctl_bar = qtnf_map_bar(priv, QTN_SYSCTL_BAR);
>>         if (IS_ERR_OR_NULL(priv->sysctl_bar)) {
>> --
> 
> Thanks !
> 
> Reviewed-by: Sergey Matyukevich <sergey.matyukevich.os@quantenna.com>
> 
> By the way, could you please use the recepient list suggested by
> get_maintainer.pl script from the kernel scripts directory.

Yep, I did.

> 
> Regards,
> Sergey
> 

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

* Re: [PATCH][net-next] qtnfmac: fix uninitialized return code in ret
  2017-06-21 13:25 [PATCH][net-next] qtnfmac: fix uninitialized return code in ret Colin King
  2017-06-21 13:54 ` Sergey Matyukevich
@ 2017-06-22  5:10 ` Dan Carpenter
  2017-06-22  8:24   ` Sergey Matyukevich
  2017-06-28 17:50 ` [net-next] " Kalle Valo
  2 siblings, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2017-06-22  5:10 UTC (permalink / raw)
  To: Colin King
  Cc: Igor Mitsyanko, Avinash Patil, Sergey Matyukevich, Kalle Valo,
	David S . Miller, Bindu Therthala, Kamlesh Rath,
	Sergei Maksimenko, Johannes Berg, linux-wireless, netdev,
	kernel-janitors, linux-kernel

On Wed, Jun 21, 2017 at 02:25:30PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The return value ret is unitialized and garbage is being returned
> for the three different error conditions when setting up the PCIe
> BARs. Fix this by initializing ret to  -ENOMEM to indicate that
> the BARs failed to be setup correctly.
> 
> Detected by CoverityScan, CID#1437563 ("Unitialized scalar variable")
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c b/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c
> index f93b27f3a236..7fc4f0d6a9ad 100644
> --- a/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c
> +++ b/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c
> @@ -247,7 +247,7 @@ static void qtnf_pcie_free_shm_ipc(struct qtnf_pcie_bus_priv *priv)
>  
>  static int qtnf_pcie_init_memory(struct qtnf_pcie_bus_priv *priv)
>  {
> -	int ret;
> +	int ret = -ENOMEM;
>  
>  	priv->sysctl_bar = qtnf_map_bar(priv, QTN_SYSCTL_BAR);
>  	if (IS_ERR_OR_NULL(priv->sysctl_bar)) {

Not related to your patch but qtnf_map_bar() should be changed not to
return NULL.  When functions return both NULL and error pointers the
NULL is supposed to be a special type of success return.  Here it is
just a fail return where we forgot to set the error code to
ERR_PTR(-ENOMEM).

regards,
dan carpenter

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

* Re: [PATCH][net-next] qtnfmac: fix uninitialized return code in ret
  2017-06-22  5:10 ` Dan Carpenter
@ 2017-06-22  8:24   ` Sergey Matyukevich
  0 siblings, 0 replies; 6+ messages in thread
From: Sergey Matyukevich @ 2017-06-22  8:24 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Colin King, Igor Mitsyanko, Avinash Patil, Sergey Matyukevich,
	Kalle Valo, David S . Miller, Bindu Therthala, Kamlesh Rath,
	Sergei Maksimenko, Johannes Berg, linux-wireless, netdev,
	kernel-janitors, linux-kernel

> Not related to your patch but qtnf_map_bar() should be changed not to
> return NULL.  When functions return both NULL and error pointers the
> NULL is supposed to be a special type of success return.  Here it is
> just a fail return where we forgot to set the error code to
> ERR_PTR(-ENOMEM).

Thanks for reporting! FWIW it is not a bug, all the checks of pci maps
are in place. Though having both ERR_PTR and NULL in return indeed
looks confusing. We will add a fix in the upcoming cleanup series.

Regards,
Sergey

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

* Re: [net-next] qtnfmac: fix uninitialized return code in ret
  2017-06-21 13:25 [PATCH][net-next] qtnfmac: fix uninitialized return code in ret Colin King
  2017-06-21 13:54 ` Sergey Matyukevich
  2017-06-22  5:10 ` Dan Carpenter
@ 2017-06-28 17:50 ` Kalle Valo
  2 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2017-06-28 17:50 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Igor Mitsyanko, Avinash Patil, Sergey Matyukevich,
	David S . Miller, Bindu Therthala, Kamlesh Rath,
	Sergei Maksimenko, Johannes Berg, linux-wireless, netdev,
	kernel-janitors, linux-kernel

Colin Ian King <colin.king@canonical.com> wrote:

> From: Colin Ian King <colin.king@canonical.com>
> 
> The return value ret is unitialized and garbage is being returned
> for the three different error conditions when setting up the PCIe
> BARs. Fix this by initializing ret to  -ENOMEM to indicate that
> the BARs failed to be setup correctly.
> 
> Detected by CoverityScan, CID#1437563 ("Unitialized scalar variable")
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> Reviewed-by: Sergey Matyukevich <sergey.matyukevich.os@quantenna.com>

Patch applied to wireless-drivers-next.git, thanks.

3e3d8aa61107 qtnfmac: fix uninitialized return code in ret

-- 
https://patchwork.kernel.org/patch/9801833/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

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

end of thread, other threads:[~2017-06-28 17:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-21 13:25 [PATCH][net-next] qtnfmac: fix uninitialized return code in ret Colin King
2017-06-21 13:54 ` Sergey Matyukevich
2017-06-21 13:55   ` Colin Ian King
2017-06-22  5:10 ` Dan Carpenter
2017-06-22  8:24   ` Sergey Matyukevich
2017-06-28 17:50 ` [net-next] " Kalle Valo

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).