diff mbox series

[net-next] net: fman: memac: Uninitialized variable on error path

Message ID Ywd2X6gdKmTfYBxD@kili (mailing list archive)
State Accepted
Commit 931d0a8b201a46aedb7767087438ea9e4467b6cd
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: fman: memac: Uninitialized variable on error path | 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: 85 this patch: 85
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
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: 85 this patch: 85
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 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 Aug. 25, 2022, 1:17 p.m. UTC
The "fixed_link" is only allocated sometimes but it's freed
unconditionally in the error handling.  Set it to NULL so we don't free
uninitialized data.

Fixes: 9ea4742a55ca ("net: fman: Configure fixed link in memac_initialization")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/net/ethernet/freescale/fman/mac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sean Anderson Aug. 25, 2022, 2:32 p.m. UTC | #1
On 8/25/22 9:17 AM, Dan Carpenter wrote:
> The "fixed_link" is only allocated sometimes but it's freed
> unconditionally in the error handling.  Set it to NULL so we don't free
> uninitialized data.
> 
> Fixes: 9ea4742a55ca ("net: fman: Configure fixed link in memac_initialization")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/net/ethernet/freescale/fman/mac.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/freescale/fman/mac.c b/drivers/net/ethernet/freescale/fman/mac.c
> index c376b9bf657d..f9a3f85760fb 100644
> --- a/drivers/net/ethernet/freescale/fman/mac.c
> +++ b/drivers/net/ethernet/freescale/fman/mac.c
> @@ -389,7 +389,7 @@ static int memac_initialization(struct mac_device *mac_dev,
>  {
>  	int			 err;
>  	struct fman_mac_params	 params;
> -	struct fixed_phy_status *fixed_link;
> +	struct fixed_phy_status *fixed_link = NULL;
>  
>  	mac_dev->set_promisc		= memac_set_promiscuous;
>  	mac_dev->change_addr		= memac_modify_mac_address;
> 

This is also fixed by [1]

--Sean

[1] https://lore.kernel.org/netdev/20220818161649.2058728-10-sean.anderson@seco.com/
Sean Anderson Aug. 25, 2022, 2:36 p.m. UTC | #2
On 8/25/22 10:32 AM, Sean Anderson wrote:
> 
> 
> On 8/25/22 9:17 AM, Dan Carpenter wrote:
>> The "fixed_link" is only allocated sometimes but it's freed
>> unconditionally in the error handling.  Set it to NULL so we don't free
>> uninitialized data.
>> 
>> Fixes: 9ea4742a55ca ("net: fman: Configure fixed link in memac_initialization")
>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>> ---
>>  drivers/net/ethernet/freescale/fman/mac.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/drivers/net/ethernet/freescale/fman/mac.c b/drivers/net/ethernet/freescale/fman/mac.c
>> index c376b9bf657d..f9a3f85760fb 100644
>> --- a/drivers/net/ethernet/freescale/fman/mac.c
>> +++ b/drivers/net/ethernet/freescale/fman/mac.c
>> @@ -389,7 +389,7 @@ static int memac_initialization(struct mac_device *mac_dev,
>>  {
>>  	int			 err;
>>  	struct fman_mac_params	 params;
>> -	struct fixed_phy_status *fixed_link;
>> +	struct fixed_phy_status *fixed_link = NULL;
>>  
>>  	mac_dev->set_promisc		= memac_set_promiscuous;
>>  	mac_dev->change_addr		= memac_modify_mac_address;
>> 
> 
> This is also fixed by [1]
> 
> --Sean
> 
> [1] https://lore.kernel.org/netdev/20220818161649.2058728-10-sean.anderson@seco.com/
> 

Whoops, I didn't read this correctly.

Reviewed-by: Sean Anderson <sean.anderson@seco.com>
patchwork-bot+netdevbpf@kernel.org Aug. 27, 2022, 2:50 a.m. UTC | #3
Hello:

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

On Thu, 25 Aug 2022 16:17:19 +0300 you wrote:
> The "fixed_link" is only allocated sometimes but it's freed
> unconditionally in the error handling.  Set it to NULL so we don't free
> uninitialized data.
> 
> Fixes: 9ea4742a55ca ("net: fman: Configure fixed link in memac_initialization")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> [...]

Here is the summary with links:
  - [net-next] net: fman: memac: Uninitialized variable on error path
    https://git.kernel.org/netdev/net-next/c/931d0a8b201a

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/freescale/fman/mac.c b/drivers/net/ethernet/freescale/fman/mac.c
index c376b9bf657d..f9a3f85760fb 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -389,7 +389,7 @@  static int memac_initialization(struct mac_device *mac_dev,
 {
 	int			 err;
 	struct fman_mac_params	 params;
-	struct fixed_phy_status *fixed_link;
+	struct fixed_phy_status *fixed_link = NULL;
 
 	mac_dev->set_promisc		= memac_set_promiscuous;
 	mac_dev->change_addr		= memac_modify_mac_address;