diff mbox series

[net] wifi: airo: avoid uninitialized warning in airo_get_rate()

Message ID 20230709133154.26206-1-rdunlap@infradead.org (mailing list archive)
State Accepted
Commit 9373771aaed17f5c2c38485f785568abe3a9f8c1
Delegated to: Netdev Maintainers
Headers show
Series [net] wifi: airo: avoid uninitialized warning in airo_get_rate() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1402 this patch: 1402
netdev/cc_maintainers warning 3 maintainers not CCed: gustavoars@kernel.org Jason@zx2c4.com keescook@chromium.org
netdev/build_clang success Errors and warnings before: 1364 this patch: 1364
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1425 this patch: 1425
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 12 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Randy Dunlap July 9, 2023, 1:31 p.m. UTC
Quieten a gcc (11.3.0) build error or warning by checking the function
call status and returning -EBUSY if the function call failed.
This is similar to what several other wireless drivers do for the
SIOCGIWRATE ioctl call when there is a locking problem.

drivers/net/wireless/cisco/airo.c: error: 'status_rid.currentXmitRate' is used uninitialized [-Werror=uninitialized]

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Link: lore.kernel.org/r/39abf2c7-24a-f167-91da-ed4c5435d1c4@linux-m68k.org
Cc: Kalle Valo <kvalo@kernel.org>
Cc: linux-wireless@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org
---
 drivers/net/wireless/cisco/airo.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Simon Horman July 11, 2023, 5:25 p.m. UTC | #1
On Sun, Jul 09, 2023 at 06:31:54AM -0700, Randy Dunlap wrote:
> Quieten a gcc (11.3.0) build error or warning by checking the function
> call status and returning -EBUSY if the function call failed.
> This is similar to what several other wireless drivers do for the
> SIOCGIWRATE ioctl call when there is a locking problem.
> 
> drivers/net/wireless/cisco/airo.c: error: 'status_rid.currentXmitRate' is used uninitialized [-Werror=uninitialized]

Hi Randy,

There seem to be other calls to readStatusRid() in the same file
with similar properties. Perhaps it would be best to fix them too?

> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Link: lore.kernel.org/r/39abf2c7-24a-f167-91da-ed4c5435d1c4@linux-m68k.org
> Cc: Kalle Valo <kvalo@kernel.org>
> Cc: linux-wireless@vger.kernel.org
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: netdev@vger.kernel.org
> ---
>  drivers/net/wireless/cisco/airo.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff -- a/drivers/net/wireless/cisco/airo.c b/drivers/net/wireless/cisco/airo.c
> --- a/drivers/net/wireless/cisco/airo.c
> +++ b/drivers/net/wireless/cisco/airo.c
> @@ -6157,8 +6157,11 @@ static int airo_get_rate(struct net_devi
>  	struct iw_param *vwrq = &wrqu->bitrate;
>  	struct airo_info *local = dev->ml_priv;
>  	StatusRid status_rid;		/* Card status info */
> +	int ret;
>  
> -	readStatusRid(local, &status_rid, 1);
> +	ret = readStatusRid(local, &status_rid, 1);
> +	if (ret)
> +		return -EBUSY;
>  
>  	vwrq->value = le16_to_cpu(status_rid.currentXmitRate) * 500000;
>  	/* If more than one rate, set auto */
>
Randy Dunlap July 11, 2023, 9:07 p.m. UTC | #2
Hi Simon,

On 7/11/23 10:25, Simon Horman wrote:
> On Sun, Jul 09, 2023 at 06:31:54AM -0700, Randy Dunlap wrote:
>> Quieten a gcc (11.3.0) build error or warning by checking the function
>> call status and returning -EBUSY if the function call failed.
>> This is similar to what several other wireless drivers do for the
>> SIOCGIWRATE ioctl call when there is a locking problem.
>>
>> drivers/net/wireless/cisco/airo.c: error: 'status_rid.currentXmitRate' is used uninitialized [-Werror=uninitialized]
> 
> Hi Randy,
> 
> There seem to be other calls to readStatusRid() in the same file
> with similar properties. Perhaps it would be best to fix them too?
> 

Yes, there are 40+ calls that could have problems.
Please see this thread:
  https://lore.kernel.org/all/2f6ffd1c-a756-b7b8-bba4-77c2308f26b9@infradead.org/

This is an attempt to shut up the build error/warning, which only occurs after
this one function call.

For such an old driver/hardware, I don't plan to do massive surgery
to it.

>> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
>> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
>> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
>> Link: lore.kernel.org/r/39abf2c7-24a-f167-91da-ed4c5435d1c4@linux-m68k.org
>> Cc: Kalle Valo <kvalo@kernel.org>
>> Cc: linux-wireless@vger.kernel.org
>> Cc: "David S. Miller" <davem@davemloft.net>
>> Cc: Eric Dumazet <edumazet@google.com>
>> Cc: Jakub Kicinski <kuba@kernel.org>
>> Cc: Paolo Abeni <pabeni@redhat.com>
>> Cc: netdev@vger.kernel.org
>> ---
>>  drivers/net/wireless/cisco/airo.c |    5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff -- a/drivers/net/wireless/cisco/airo.c b/drivers/net/wireless/cisco/airo.c
>> --- a/drivers/net/wireless/cisco/airo.c
>> +++ b/drivers/net/wireless/cisco/airo.c
>> @@ -6157,8 +6157,11 @@ static int airo_get_rate(struct net_devi
>>  	struct iw_param *vwrq = &wrqu->bitrate;
>>  	struct airo_info *local = dev->ml_priv;
>>  	StatusRid status_rid;		/* Card status info */
>> +	int ret;
>>  
>> -	readStatusRid(local, &status_rid, 1);
>> +	ret = readStatusRid(local, &status_rid, 1);
>> +	if (ret)
>> +		return -EBUSY;
>>  
>>  	vwrq->value = le16_to_cpu(status_rid.currentXmitRate) * 500000;
>>  	/* If more than one rate, set auto */
>>
patchwork-bot+netdevbpf@kernel.org July 12, 2023, 2:30 a.m. UTC | #3
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Sun,  9 Jul 2023 06:31:54 -0700 you wrote:
> Quieten a gcc (11.3.0) build error or warning by checking the function
> call status and returning -EBUSY if the function call failed.
> This is similar to what several other wireless drivers do for the
> SIOCGIWRATE ioctl call when there is a locking problem.
> 
> drivers/net/wireless/cisco/airo.c: error: 'status_rid.currentXmitRate' is used uninitialized [-Werror=uninitialized]
> 
> [...]

Here is the summary with links:
  - [net] wifi: airo: avoid uninitialized warning in airo_get_rate()
    https://git.kernel.org/netdev/net/c/9373771aaed1

You are awesome, thank you!
Simon Horman July 13, 2023, 8:38 a.m. UTC | #4
On Tue, Jul 11, 2023 at 02:07:57PM -0700, Randy Dunlap wrote:
> Hi Simon,
> 
> On 7/11/23 10:25, Simon Horman wrote:
> > On Sun, Jul 09, 2023 at 06:31:54AM -0700, Randy Dunlap wrote:
> >> Quieten a gcc (11.3.0) build error or warning by checking the function
> >> call status and returning -EBUSY if the function call failed.
> >> This is similar to what several other wireless drivers do for the
> >> SIOCGIWRATE ioctl call when there is a locking problem.
> >>
> >> drivers/net/wireless/cisco/airo.c: error: 'status_rid.currentXmitRate' is used uninitialized [-Werror=uninitialized]
> > 
> > Hi Randy,
> > 
> > There seem to be other calls to readStatusRid() in the same file
> > with similar properties. Perhaps it would be best to fix them too?
> > 
> 
> Yes, there are 40+ calls that could have problems.
> Please see this thread:
>   https://lore.kernel.org/all/2f6ffd1c-a756-b7b8-bba4-77c2308f26b9@infradead.org/
> 
> This is an attempt to shut up the build error/warning, which only occurs after
> this one function call.
> 
> For such an old driver/hardware, I don't plan to do massive surgery
> to it.

Thanks Randy,

given the circumstances I agree this is a reasonable approach.

Reviewed-by: Simon Horman <simon.horman@corigine.com>
diff mbox series

Patch

diff -- a/drivers/net/wireless/cisco/airo.c b/drivers/net/wireless/cisco/airo.c
--- a/drivers/net/wireless/cisco/airo.c
+++ b/drivers/net/wireless/cisco/airo.c
@@ -6157,8 +6157,11 @@  static int airo_get_rate(struct net_devi
 	struct iw_param *vwrq = &wrqu->bitrate;
 	struct airo_info *local = dev->ml_priv;
 	StatusRid status_rid;		/* Card status info */
+	int ret;
 
-	readStatusRid(local, &status_rid, 1);
+	ret = readStatusRid(local, &status_rid, 1);
+	if (ret)
+		return -EBUSY;
 
 	vwrq->value = le16_to_cpu(status_rid.currentXmitRate) * 500000;
 	/* If more than one rate, set auto */