netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] i40e: fix return of uninitialized aq_ret in i40e_set_vsi_promisc
@ 2020-08-13 11:26 Stefan Assmann
  2020-08-13 20:46 ` Jakub Kicinski
  2020-09-04 18:17 ` [Intel-wired-lan] " Brown, Aaron F
  0 siblings, 2 replies; 3+ messages in thread
From: Stefan Assmann @ 2020-08-13 11:26 UTC (permalink / raw)
  To: intel-wired-lan
  Cc: netdev, davem, jeffrey.t.kirsher, lihong.yang, sassmann, kuba

drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c: In function ‘i40e_set_vsi_promisc’:
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c:1176:14: error: ‘aq_ret’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  i40e_status aq_ret;

In case the code inside the if statement and the for loop does not get
executed aq_ret will be uninitialized when the variable gets returned at
the end of the function.

Avoid this by changing num_vlans from int to u16, so aq_ret always gets
set. Making this change in additional places as num_vlans should never
be negative.

Fixes: 37d318d7805f ("i40e: Remove scheduling while atomic possibility")
Signed-off-by: Stefan Assmann <sassmann@kpanic.de>
---
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index 8e133d6545bd..90ef810cba97 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -1115,7 +1115,7 @@ static int i40e_quiesce_vf_pci(struct i40e_vf *vf)
 static int i40e_getnum_vf_vsi_vlan_filters(struct i40e_vsi *vsi)
 {
 	struct i40e_mac_filter *f;
-	int num_vlans = 0, bkt;
+	u16 num_vlans = 0, bkt;
 
 	hash_for_each(vsi->mac_filter_hash, bkt, f, hlist) {
 		if (f->vlan >= 0 && f->vlan <= I40E_MAX_VLANID)
@@ -1134,7 +1134,7 @@ static int i40e_getnum_vf_vsi_vlan_filters(struct i40e_vsi *vsi)
  *
  * Called to get number of VLANs and VLAN list present in mac_filter_hash.
  **/
-static void i40e_get_vlan_list_sync(struct i40e_vsi *vsi, int *num_vlans,
+static void i40e_get_vlan_list_sync(struct i40e_vsi *vsi, u16 *num_vlans,
 					   s16 **vlan_list)
 {
 	struct i40e_mac_filter *f;
@@ -1169,7 +1169,7 @@ static void i40e_get_vlan_list_sync(struct i40e_vsi *vsi, int *num_vlans,
  **/
 static i40e_status
 i40e_set_vsi_promisc(struct i40e_vf *vf, u16 seid, bool multi_enable,
-		     bool unicast_enable, s16 *vl, int num_vlans)
+		     bool unicast_enable, s16 *vl, u16 num_vlans)
 {
 	struct i40e_pf *pf = vf->pf;
 	struct i40e_hw *hw = &pf->hw;
@@ -1258,7 +1258,7 @@ static i40e_status i40e_config_vf_promiscuous_mode(struct i40e_vf *vf,
 	i40e_status aq_ret = I40E_SUCCESS;
 	struct i40e_pf *pf = vf->pf;
 	struct i40e_vsi *vsi;
-	int num_vlans;
+	u16 num_vlans;
 	s16 *vl;
 
 	vsi = i40e_find_vsi_from_id(pf, vsi_id);
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] i40e: fix return of uninitialized aq_ret in i40e_set_vsi_promisc
  2020-08-13 11:26 [PATCH v2] i40e: fix return of uninitialized aq_ret in i40e_set_vsi_promisc Stefan Assmann
@ 2020-08-13 20:46 ` Jakub Kicinski
  2020-09-04 18:17 ` [Intel-wired-lan] " Brown, Aaron F
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2020-08-13 20:46 UTC (permalink / raw)
  To: Stefan Assmann
  Cc: intel-wired-lan, netdev, davem, jeffrey.t.kirsher, lihong.yang

On Thu, 13 Aug 2020 13:26:38 +0200 Stefan Assmann wrote:
> drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c: In function ‘i40e_set_vsi_promisc’:
> drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c:1176:14: error: ‘aq_ret’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>   i40e_status aq_ret;
> 
> In case the code inside the if statement and the for loop does not get
> executed aq_ret will be uninitialized when the variable gets returned at
> the end of the function.
> 
> Avoid this by changing num_vlans from int to u16, so aq_ret always gets
> set. Making this change in additional places as num_vlans should never
> be negative.
> 
> Fixes: 37d318d7805f ("i40e: Remove scheduling while atomic possibility")
> Signed-off-by: Stefan Assmann <sassmann@kpanic.de>

Acked-by: Jakub Kicinski <kuba@kernel.org>

Good enough - in general unless you're trying to save space using types
other than unsigned int is not really worth it, and can slow the code
down - since 2B arithmetic is actually slowest on modern CPUs. But it's
not a fast path, so doesn't matter much.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [Intel-wired-lan] [PATCH v2] i40e: fix return of uninitialized aq_ret in i40e_set_vsi_promisc
  2020-08-13 11:26 [PATCH v2] i40e: fix return of uninitialized aq_ret in i40e_set_vsi_promisc Stefan Assmann
  2020-08-13 20:46 ` Jakub Kicinski
@ 2020-09-04 18:17 ` Brown, Aaron F
  1 sibling, 0 replies; 3+ messages in thread
From: Brown, Aaron F @ 2020-09-04 18:17 UTC (permalink / raw)
  To: Stefan Assmann, intel-wired-lan; +Cc: netdev, kuba, davem

> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
> Stefan Assmann
> Sent: Thursday, August 13, 2020 4:27 AM
> To: intel-wired-lan@lists.osuosl.org
> Cc: netdev@vger.kernel.org; sassmann@kpanic.de; kuba@kernel.org;
> davem@davemloft.net
> Subject: [Intel-wired-lan] [PATCH v2] i40e: fix return of uninitialized aq_ret in
> i40e_set_vsi_promisc
> 
> drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c: In function
> ‘i40e_set_vsi_promisc’:
> drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c:1176:14: error: ‘aq_ret’
> may be used uninitialized in this function [-Werror=maybe-uninitialized]
>   i40e_status aq_ret;
> 
> In case the code inside the if statement and the for loop does not get
> executed aq_ret will be uninitialized when the variable gets returned at
> the end of the function.
> 
> Avoid this by changing num_vlans from int to u16, so aq_ret always gets
> set. Making this change in additional places as num_vlans should never
> be negative.
> 
> Fixes: 37d318d7805f ("i40e: Remove scheduling while atomic possibility")
> Signed-off-by: Stefan Assmann <sassmann@kpanic.de>
> ---
>  drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

Tested-by: Aaron Brown <aaron.f.brown@intel.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-04 18:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-13 11:26 [PATCH v2] i40e: fix return of uninitialized aq_ret in i40e_set_vsi_promisc Stefan Assmann
2020-08-13 20:46 ` Jakub Kicinski
2020-09-04 18:17 ` [Intel-wired-lan] " Brown, Aaron F

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).