diff mbox series

[net-next] net: microchip: sparx5: Fix uninitialized variable in vcap_path_exist()

Message ID Y8qbYAb+YSXo1DgR@kili (mailing list archive)
State Accepted
Commit 3bee9b573af515a8f15db70e7875ac96f87d57b5
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: microchip: sparx5: Fix uninitialized variable in vcap_path_exist() | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 2 this patch: 2
netdev/cc_maintainers warning 1 maintainers not CCed: linux-arm-kernel@lists.infradead.org
netdev/build_clang success Errors and warnings before: 1 this patch: 1
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
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: 2 this patch: 2
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Dan Carpenter Jan. 20, 2023, 1:47 p.m. UTC
The "eport" variable needs to be initialized to NULL for this code to
work.

Fixes: 814e7693207f ("net: microchip: vcap api: Add a storage state to a VCAP rule")
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
Probably you had CONFIG_INIT_STACK_ALL=y in your .config for this to
pass testing.

 drivers/net/ethernet/microchip/vcap/vcap_api.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Steen Hegelund Jan. 20, 2023, 2:25 p.m. UTC | #1
Hi Dan,

Thanks for the fix.

I have not seen any CONFIG_INIT_STACK_ALL=y in any of my .configs, though, so I
will be updating my test suite to catch this.

Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>

On Fri, 2023-01-20 at 16:47 +0300, Dan Carpenter wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the
> content is safe
> 
> The "eport" variable needs to be initialized to NULL for this code to
> work.
> 
> Fixes: 814e7693207f ("net: microchip: vcap api: Add a storage state to a VCAP
> rule")
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
> Probably you had CONFIG_INIT_STACK_ALL=y in your .config for this to
> pass testing.
> 
>  drivers/net/ethernet/microchip/vcap/vcap_api.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api.c
> b/drivers/net/ethernet/microchip/vcap/vcap_api.c
> index 71f787a78295..69c026778b42 100644
> --- a/drivers/net/ethernet/microchip/vcap/vcap_api.c
> +++ b/drivers/net/ethernet/microchip/vcap/vcap_api.c
> @@ -2012,7 +2012,8 @@ static int vcap_get_next_chain(struct vcap_control
> *vctrl,
>  static bool vcap_path_exist(struct vcap_control *vctrl, struct net_device
> *ndev,
>                             int dst_cid)
>  {
> -       struct vcap_enabled_port *eport, *elem;
> +       struct vcap_enabled_port *eport = NULL;
> +       struct vcap_enabled_port *elem;
>         struct vcap_admin *admin;
>         int tmp;
> 
> --
> 2.35.1
> 

BR
Steen
Dan Carpenter Jan. 20, 2023, 3:10 p.m. UTC | #2
On Fri, Jan 20, 2023 at 03:25:36PM +0100, Steen Hegelund wrote:
> Hi Dan,
> 
> Thanks for the fix.
> 
> I have not seen any CONFIG_INIT_STACK_ALL=y in any of my .configs, though, so I
> will be updating my test suite to catch this.

No, what I'm saying is that for a lot of people all stack variables are
initialized to zero by default so sometimes people are like, "I've
tested this a thousand times.  How has it even been working?"

In your case I guess it was working because the eport was never not
found.

regards,
dan carpenter
patchwork-bot+netdevbpf@kernel.org Jan. 24, 2023, 5:40 a.m. UTC | #3
Hello:

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

On Fri, 20 Jan 2023 16:47:12 +0300 you wrote:
> The "eport" variable needs to be initialized to NULL for this code to
> work.
> 
> Fixes: 814e7693207f ("net: microchip: vcap api: Add a storage state to a VCAP rule")
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
> Probably you had CONFIG_INIT_STACK_ALL=y in your .config for this to
> pass testing.
> 
> [...]

Here is the summary with links:
  - [net-next] net: microchip: sparx5: Fix uninitialized variable in vcap_path_exist()
    https://git.kernel.org/netdev/net-next/c/3bee9b573af5

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api.c b/drivers/net/ethernet/microchip/vcap/vcap_api.c
index 71f787a78295..69c026778b42 100644
--- a/drivers/net/ethernet/microchip/vcap/vcap_api.c
+++ b/drivers/net/ethernet/microchip/vcap/vcap_api.c
@@ -2012,7 +2012,8 @@  static int vcap_get_next_chain(struct vcap_control *vctrl,
 static bool vcap_path_exist(struct vcap_control *vctrl, struct net_device *ndev,
 			    int dst_cid)
 {
-	struct vcap_enabled_port *eport, *elem;
+	struct vcap_enabled_port *eport = NULL;
+	struct vcap_enabled_port *elem;
 	struct vcap_admin *admin;
 	int tmp;