diff mbox

brcmfmac: fix uninitialized warning in brcmf_usb_probe_phase2()

Message ID 1497602195-29895-1-git-send-email-arend.vanspriel@broadcom.com (mailing list archive)
State Accepted
Commit 35abcd4f9f303ac4f10f99b3f7e993e5f2e6fa37
Delegated to: Kalle Valo
Headers show

Commit Message

Arend van Spriel June 16, 2017, 8:36 a.m. UTC
This fixes the following warning:

  drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c: In function
  'brcmf_usb_probe_phase2':
  drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c:1198:2:
  warning: 'devinfo' may be used uninitialized in this function
  [-Wmaybe-uninitialized]
    mutex_unlock(&devinfo->dev_init_lock);

Fixes: 6d0507a777fb ("brcmfmac: add parameter to pass error code in firmware callback")
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Reported-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
---
Hi Kalle,

Here it is. Was indeed a valid warning.

Thanks,
Arend
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Kalle Valo June 16, 2017, 8:44 a.m. UTC | #1
Arend van Spriel <arend.vanspriel@broadcom.com> writes:

> This fixes the following warning:
>
>   drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c: In function
>   'brcmf_usb_probe_phase2':
>   drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c:1198:2:
>   warning: 'devinfo' may be used uninitialized in this function
>   [-Wmaybe-uninitialized]
>     mutex_unlock(&devinfo->dev_init_lock);
>
> Fixes: 6d0507a777fb ("brcmfmac: add parameter to pass error code in firmware callback")
> Cc: Stephen Rothwell <sfr@canb.auug.org.au>
> Reported-by: Kalle Valo <kvalo@codeaurora.org>
> Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
> ---
> Hi Kalle,
>
> Here it is. Was indeed a valid warning.

Thanks for the quick fix.

> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
> @@ -1164,14 +1164,13 @@ static void brcmf_usb_probe_phase2(struct device *dev, int ret,
>  				   void *nvram, u32 nvlen)
>  {
>  	struct brcmf_bus *bus = dev_get_drvdata(dev);
> -	struct brcmf_usbdev_info *devinfo;
> +	struct brcmf_usbdev_info *devinfo = bus->bus_priv.usb->devinfo;;

But an extra semicolon :) I'll try to edit it out during commit.
Kalle Valo June 16, 2017, 8:53 a.m. UTC | #2
Arend Van Spriel <arend.vanspriel@broadcom.com> wrote:

> This fixes the following warning:
> 
>   drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c: In function
>   'brcmf_usb_probe_phase2':
>   drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c:1198:2:
>   warning: 'devinfo' may be used uninitialized in this function
>   [-Wmaybe-uninitialized]
>     mutex_unlock(&devinfo->dev_init_lock);
> 
> Fixes: 6d0507a777fb ("brcmfmac: add parameter to pass error code in firmware callback")
> Cc: Stephen Rothwell <sfr@canb.auug.org.au>
> Reported-by: Kalle Valo <kvalo@codeaurora.org>
> Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>

Patch applied to wireless-drivers.git, thanks.

35abcd4f9f30 brcmfmac: fix uninitialized warning in brcmf_usb_probe_phase2()
Arend van Spriel June 16, 2017, 10:12 a.m. UTC | #3
On 6/16/2017 10:44 AM, Kalle Valo wrote:
> Arend van Spriel <arend.vanspriel@broadcom.com> writes:
> 
>> This fixes the following warning:
>>
>>    drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c: In function
>>    'brcmf_usb_probe_phase2':
>>    drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c:1198:2:
>>    warning: 'devinfo' may be used uninitialized in this function
>>    [-Wmaybe-uninitialized]
>>      mutex_unlock(&devinfo->dev_init_lock);
>>
>> Fixes: 6d0507a777fb ("brcmfmac: add parameter to pass error code in firmware callback")
>> Cc: Stephen Rothwell <sfr@canb.auug.org.au>
>> Reported-by: Kalle Valo <kvalo@codeaurora.org>
>> Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
>> ---
>> Hi Kalle,
>>
>> Here it is. Was indeed a valid warning.
> 
> Thanks for the quick fix.

Well, wanted to send it sooner, but ...

>> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
>> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
>> @@ -1164,14 +1164,13 @@ static void brcmf_usb_probe_phase2(struct device *dev, int ret,
>>   				   void *nvram, u32 nvlen)
>>   {
>>   	struct brcmf_bus *bus = dev_get_drvdata(dev);
>> -	struct brcmf_usbdev_info *devinfo;
>> +	struct brcmf_usbdev_info *devinfo = bus->bus_priv.usb->devinfo;;
> 
> But an extra semicolon :) I'll try to edit it out during commit.

needed time for the extra semicolon :-p Thanks for being thorough.

Gr. AvS
Julian Calaby June 18, 2017, 4:26 a.m. UTC | #4
Hi Arend,

On Fri, Jun 16, 2017 at 6:36 PM, Arend van Spriel
<arend.vanspriel@broadcom.com> wrote:
> This fixes the following warning:
>
>   drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c: In function
>   'brcmf_usb_probe_phase2':
>   drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c:1198:2:
>   warning: 'devinfo' may be used uninitialized in this function
>   [-Wmaybe-uninitialized]
>     mutex_unlock(&devinfo->dev_init_lock);
>
> Fixes: 6d0507a777fb ("brcmfmac: add parameter to pass error code in firmware callback")
> Cc: Stephen Rothwell <sfr@canb.auug.org.au>
> Reported-by: Kalle Valo <kvalo@codeaurora.org>
> Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
> ---
>  drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
> index 9ce3b55..8b16387 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
> @@ -1164,14 +1164,13 @@ static void brcmf_usb_probe_phase2(struct device *dev, int ret,
>                                    void *nvram, u32 nvlen)
>  {
>         struct brcmf_bus *bus = dev_get_drvdata(dev);
> -       struct brcmf_usbdev_info *devinfo;
> +       struct brcmf_usbdev_info *devinfo = bus->bus_priv.usb->devinfo;;
>
>         if (ret)
>                 goto error;

Completely unrelated to this specific patch, I just want to point out
that this construct looks _really_ weird.

Thanks,
Arend van Spriel June 18, 2017, 1:01 p.m. UTC | #5
On 18-06-17 06:26, Julian Calaby wrote:
> Hi Arend,
> 
> On Fri, Jun 16, 2017 at 6:36 PM, Arend van Spriel
> <arend.vanspriel@broadcom.com> wrote:
>> This fixes the following warning:
>>
>>   drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c: In function
>>   'brcmf_usb_probe_phase2':
>>   drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c:1198:2:
>>   warning: 'devinfo' may be used uninitialized in this function
>>   [-Wmaybe-uninitialized]
>>     mutex_unlock(&devinfo->dev_init_lock);
>>
>> Fixes: 6d0507a777fb ("brcmfmac: add parameter to pass error code in firmware callback")
>> Cc: Stephen Rothwell <sfr@canb.auug.org.au>
>> Reported-by: Kalle Valo <kvalo@codeaurora.org>
>> Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
>> ---
>>  drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
>> index 9ce3b55..8b16387 100644
>> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
>> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
>> @@ -1164,14 +1164,13 @@ static void brcmf_usb_probe_phase2(struct device *dev, int ret,
>>                                    void *nvram, u32 nvlen)
>>  {
>>         struct brcmf_bus *bus = dev_get_drvdata(dev);
>> -       struct brcmf_usbdev_info *devinfo;
>> +       struct brcmf_usbdev_info *devinfo = bus->bus_priv.usb->devinfo;;
>>
>>         if (ret)
>>                 goto error;
> 
> Completely unrelated to this specific patch, I just want to point out
> that this construct looks _really_ weird.

Guess it might. This is a callback function in which the caller passes
the result. Could have chosen a better name than 'ret'. Other option
would have been a separate callback for the error handling, but I
decided that to be overkill.

Regards,
Arend
diff mbox

Patch

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
index 9ce3b55..8b16387 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
@@ -1164,14 +1164,13 @@  static void brcmf_usb_probe_phase2(struct device *dev, int ret,
 				   void *nvram, u32 nvlen)
 {
 	struct brcmf_bus *bus = dev_get_drvdata(dev);
-	struct brcmf_usbdev_info *devinfo;
+	struct brcmf_usbdev_info *devinfo = bus->bus_priv.usb->devinfo;;
 
 	if (ret)
 		goto error;
 
 	brcmf_dbg(USB, "Start fw downloading\n");
 
-	devinfo = bus->bus_priv.usb->devinfo;
 	ret = check_file(fw->data);
 	if (ret < 0) {
 		brcmf_err("invalid firmware\n");