net: bnx2x: fix variable dereferenced before check
PATCH 1/1 net: bnx2x: fix variable dereferenced before check
Smatch says:
bnx2x_init_ops.h:640 bnx2x_ilt_client_mem_op() warn: variable dereferenced before check 'ilt' (see line 638)
Move ilt_cli variable initialization _after_ ilt validation, because it's unsafe to deref the pointer before validation check.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h +3 -1
@@ -635,11 +635,13 @@ static int bnx2x_ilt_client_mem_op(struct bnx2x *bp, int cli_num, {int i, rc;struct bnx2x_ilt *ilt =BP_ILT (bp); -struct ilt_client_info *ilt_cli = &ilt->clients[cli_num]; +struct ilt_client_info *ilt_cli;if (!ilt || !ilt->lines)return -1 ; + ilt_cli = &ilt->clients[cli_num]; +if (ilt_cli->flags & (ILT_CLIENT_SKIP_INIT |ILT_CLIENT_SKIP_MEM ))return 0 ;
Signature · 1 line
2.33.1
Quoted 4 lines · Pavel Skripkin
Smatch says:
bnx2x_init_ops.h:640 bnx2x_ilt_client_mem_op() warn: variable dereferenced before check 'ilt' (see line 638)
Quoted 9 lines
Move
ilt_clivariable initialization _after_ ilt validation, because it's unsafe to deref the pointer before validation check.Fixes 523224a3b3cd ("bnx2x, cnic, bnx2i: use new FW/HSI")Signed-off-by Pavel Skripkin <[email protected]>--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Btw, looks like [email protected] doesn't exist anymore. It's listed in 2 MAINTAINERS entries. Should it be removed from MAINTAINERS file?
Quoting private email from [email protected]:
Quoted 4 lines
Delivery has failed to these recipients or groups:
[email protected]<mailto:[email protected]>
The email address you entered couldn't be found. Please check the recipient's email address and try to resend the message. If the problem continues, please contact your helpdesk.
With regards,
Pavel Skripkin
This patch was applied to netdev/net.git (master) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:
Quoted 8 lines · On Sun, 14 Nov 2021 01:36:36 +0300 you wrote:
Smatch says:
bnx2x_init_ops.h:640 bnx2x_ilt_client_mem_op() warn: variable dereferenced before check 'ilt' (see line 638)Move
ilt_clivariable initialization _after_ ilt validation, because it's unsafe to deref the pointer before validation check.[...]
Here is the summary with links:
- net: bnx2x: fix variable dereferenced before check
https://git.kernel.org/netdev/net/c/f8885ac89ce3
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Jakub Kicinski
maintainerQuoted 3 lines · On Sun, 14 Nov 2021 01:41:59 +0300 Pavel Skripkin wrote:
Btw, looks like [email protected] doesn't exist anymore. It's listed in 2
MAINTAINERSentries. Should it be removed fromMAINTAINERSfile?
Yes, if it bounces it should be removed. Can you send a patch?
PATCH 1/1 MAINTAINERS: remove [email protected]
I've sent a patch to [email protected] few days ago and got a reply from [email protected]:
Delivery has failed to these recipients or groups:
[email protected]<mailto:[email protected]> The email address you entered couldn't be found. Please check the recipient's email address and try to resend the message. If the problem continues, please contact your helpdesk.
Since this email bounces, let's remove it from MAINTAINERS file.
---
CCed others related maintainers from marvell, maybe they know what happened with this email
--- MAINTAINERS | 2 -- 1 file changed, 2 deletions(-)
MAINTAINERS +0 -2
@@ -3733,7 +3733,6 @@ F: drivers/scsi/bnx2i/ BROADCOM BNX2X 10 GIGABIT ETHERNET DRIVER M: Ariel Elior <[email protected]> M: Sudarsana Kalluru <[email protected]> -M: [email protected] L: [email protected] S: Supported F: drivers/net/ethernet/broadcom/bnx2x/
@@ -15593,7 +15592,6 @@ F: drivers/scsi/qedi/ QLOGIC QL4xxx ETHERNET DRIVER M: Ariel Elior <[email protected]> -M: [email protected] L: [email protected] S: Supported F: drivers/net/ethernet/qlogic/qed/
Signature · 1 line
2.33.1
Re: [PATCH] MAINTAINERS: remove [email protected]
Quoted 10 lines
I've sent a patch to [email protected] few days ago and got a reply from [email protected]:
Delivery has failed to these recipients or groups:
[email protected]<mailto:[email protected]> The email address you entered couldn't be found. Please check the recipient's email address and try to resend the message. If the problem continues, please contact your helpdesk.
Quoted 8 lines
Since this email bounces, let's remove it from
MAINTAINERSfile.Signed-off-by Pavel Skripkin <[email protected]>---
CCed others related maintainers from marvell, maybe they know what happened with this email
Pavel,
Yes [email protected] has been disabled, But please add Manish Chopra <[email protected]> to the maintainer list.
Thanks,
Alok
Quoted 1 line
---
Re: [PATCH] MAINTAINERS: remove [email protected]
Quoted 4 lines
Pavel,
Yes [email protected] has been disabled, But please add Manish Chopra <[email protected]> to the maintainer list.
Sorry , Correction it should Manish Chopra <[email protected]>
Quoted 3 lines
Thanks,
Alok
PATCH v2 1/1 MAINTAINERS: remove [email protected]
I've sent a patch to [email protected] few days ago and got a reply from [email protected]:
Delivery has failed to these recipients or groups:
[email protected]<mailto:[email protected]> The email address you entered couldn't be found. Please check the recipient's email address and try to resend the message. If the problem continues, please contact your helpdesk.
As requested by Alok Prasad, replacing [email protected] with Manish Chopra's email address. [0]
---
Changes in v2:
Replaced [email protected] with Manish Chopra's email, as requested by Alok.
--- MAINTAINERS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
MAINTAINERS +2 -2
@@ -3733,7 +3733,7 @@ F: drivers/scsi/bnx2i/ BROADCOM BNX2X 10 GIGABIT ETHERNET DRIVER M: Ariel Elior <[email protected]> M: Sudarsana Kalluru <[email protected]> -M: [email protected] +M: Manish Chopra <[email protected]> L: [email protected] S: Supported F: drivers/net/ethernet/broadcom/bnx2x/
@@ -15593,7 +15593,7 @@ F: drivers/scsi/qedi/ QLOGIC QL4xxx ETHERNET DRIVER M: Ariel Elior <[email protected]> -M: [email protected] +M: Manish Chopra <[email protected]> L: [email protected] S: Supported F: drivers/net/ethernet/qlogic/qed/
Signature · 1 line
2.33.1
Re: [PATCH v2] MAINTAINERS: remove [email protected]
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Tue, 16 Nov 2021 17:13:03 +0300 you wrote:
I've sent a patch to [email protected] few days ago and got a reply from [email protected]:
Delivery has failed to these recipients or groups:
[email protected]<mailto:[email protected]> The email address you entered couldn't be found. Please check the recipient's email address and try to resend the message. If the problem continues, please contact your helpdesk.
[...]
Here is the summary with links:
- [v2] MAINTAINERS: remove [email protected]
https://git.kernel.org/netdev/net/c/0a83f96f8709
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
[ Adding Dan. ]
Quoted 6 lines · Pavel Skripkin
Smatch says:
bnx2x_init_ops.h:640 bnx2x_ilt_client_mem_op() warn: variable dereferenced before check 'ilt' (see line 638)Move
ilt_clivariable initialization _after_ ilt validation, because it's unsafe to deref the pointer before validation check.
It seems smatch is confused here. There is no dereference happening until after the check, we're just determining the address when initialising ilt_cli.
I know this has been applied, and the change itself is fine, but the patch description is wrong and the Fixes tag is unwarranted.
Quoted 14 lines
Fixes 523224a3b3cd ("bnx2x, cnic, bnx2i: use new FW/HSI")Signed-off-by Pavel Skripkin <[email protected]>--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h +0
-0@@ -635,11 +635,13 @@ static int bnx2x_ilt_client_mem_op(struct bnx2x *bp, int cli_num, {int i, rc;struct bnx2x_ilt *ilt =BP_ILT (bp);
drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h static int bnx2x_ilt_client_mem_op(struct bnx2x *bp, int cli_num, · line 646
Quoted 10 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h +3
-1-struct ilt_client_info *ilt_cli = &ilt->clients[cli_num]; +struct ilt_client_info *ilt_cli;if (!ilt || !ilt->lines)return -1 ; + ilt_cli = &ilt->clients[cli_num]; +if (ilt_cli->flags & (ILT_CLIENT_SKIP_INIT |ILT_CLIENT_SKIP_MEM ))return 0 ;
Johan
Quoted 10 lines · Johan Hovold
[ Adding Dan. ]
Quoted 6 lines · Pavel Skripkin
Smatch says:
bnx2x_init_ops.h:640 bnx2x_ilt_client_mem_op() warn: variable dereferenced before check 'ilt' (see line 638)Move
ilt_clivariable initialization _after_ ilt validation, because it's unsafe to deref the pointer before validation check.
Quoted 7 lines
It seems smatch is confused here. There is no dereference happening until after the check, we're just determining the address when initialising
ilt_cli.I know this has been applied, and the change itself is fine, but the patch description is wrong and the Fixes tag is unwarranted.
I agree. I came up with same thing after the patch has been applied. I thought about a revert, but seems it's not necessary, since there is no function change.
I should check smatch warnings more carefully next time, can't say why I didn't notice it before sending :(
thanks
With regards,
Pavel Skripkin
Quoted 7 lines · Johan Hovold
[ Adding Dan. ]
Quoted 4 lines · Pavel Skripkin
Smatch says:
bnx2x_init_ops.h:640 bnx2x_ilt_client_mem_op() warn: variable dereferenced before check 'ilt' (see line 638)
Quoted 6 lines
Quoted 2 lines
Move
ilt_clivariable initialization _after_ ilt validation, because it's unsafe to deref the pointer before validation check.It seems smatch is confused here. There is no dereference happening until after the check, we're just determining the address when initialising
ilt_cli.
Yep. You're right. I will fix this. I've written a fix and I'll test it tonight.
regards,
dan carpenter