* [PATCH] i40e: fix memcpy with swapped arguments
@ 2017-03-20 14:46 Colin King
2017-03-20 23:33 ` [Intel-wired-lan] " Keller, Jacob E
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2017-03-20 14:46 UTC (permalink / raw)
To: Jeff Kirsher, intel-wired-lan, netdev; +Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
The current code copies an uninitialized params into
cdev->lan_info.params and then passes the uninitialized params
to the call cdev->client->ops->l2_param_change. I believe the
order of the source and destination in the memcpy is the wrong
way around and should be swapped.
Detected with static analysis by cppcheck
Fixes: 0ef2d5afb12d ("i40e: KISS the client interface")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/net/ethernet/intel/i40e/i40e_client.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_client.c b/drivers/net/ethernet/intel/i40e/i40e_client.c
index a9f0d22a7cf4..191580ed946d 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_client.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_client.c
@@ -147,7 +147,7 @@ void i40e_notify_client_of_l2_param_changes(struct i40e_vsi *vsi)
dev_dbg(&vsi->back->pdev->dev, "Client is not open, abort l2 param change\n");
return;
}
- memcpy(&cdev->lan_info.params, ¶ms, sizeof(struct i40e_params));
+ memcpy(¶ms, &cdev->lan_info.params, sizeof(struct i40e_params));
cdev->client->ops->l2_param_change(&cdev->lan_info, cdev->client,
¶ms);
}
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [Intel-wired-lan] [PATCH] i40e: fix memcpy with swapped arguments
2017-03-20 14:46 [PATCH] i40e: fix memcpy with swapped arguments Colin King
@ 2017-03-20 23:33 ` Keller, Jacob E
0 siblings, 0 replies; 2+ messages in thread
From: Keller, Jacob E @ 2017-03-20 23:33 UTC (permalink / raw)
To: Colin King, Kirsher, Jeffrey T, intel-wired-lan@lists.osuosl.org,
netdev@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces@lists.osuosl.org] On
> Behalf Of Colin King
> Sent: Monday, March 20, 2017 7:46 AM
> To: Kirsher, Jeffrey T <jeffrey.t.kirsher@intel.com>; intel-wired-
> lan@lists.osuosl.org; netdev@vger.kernel.org
> Cc: kernel-janitors@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: [Intel-wired-lan] [PATCH] i40e: fix memcpy with swapped arguments
>
> From: Colin Ian King <colin.king@canonical.com>
Hi there,
>
> The current code copies an uninitialized params into
> cdev->lan_info.params and then passes the uninitialized params
> to the call cdev->client->ops->l2_param_change. I believe the
> order of the source and destination in the memcpy is the wrong
> way around and should be swapped.
>
So you are correct that params is uninitialized. However, the fix here is not correct. Somehow we dropped the code for initializing the parameters.
See commit d7ce6422d6e6 ("i40e: don't check params until after checking for client instance", 2017-02-09) It looks like the commit itself was malformed when applied upstream, and a later commit which should have preserved the changes 3140aa9a78c9 ("i40e: KISS the client interface", 2017-03-14) accidentally dropped them.
I'll provide a patch to get this back into the correct state.
Thanks for catching this.
Regards,
Jake
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-20 23:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-20 14:46 [PATCH] i40e: fix memcpy with swapped arguments Colin King
2017-03-20 23:33 ` [Intel-wired-lan] " Keller, Jacob E
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).