netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] qlcnic: Initialize mailbox cmd structure to zero.
@ 2014-05-25 14:55 Rajesh Borundia
  2014-05-30 22:27 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Rajesh Borundia @ 2014-05-25 14:55 UTC (permalink / raw)
  To: davem; +Cc: netdev, Dept-HSGLinuxNICDev

o Uninitialized fields in mailbox command structure
  caused commands to time out randomly due to garbage
  values, so initialize it to zero.

Signed-off-by: Rajesh Borundia <rajesh.borundia@qlogic.com>
---
 .../ethernet/qlogic/qlcnic/qlcnic_sriov_common.c   |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
index 6afe9c1..15f4c9e 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
@@ -702,6 +702,7 @@ static int qlcnic_sriov_alloc_bc_mbx_args(struct qlcnic_cmd_args *mbx, u32 type)
 	const struct qlcnic_mailbox_metadata *mbx_tbl;
 	int i, size;
 
+	memset(mbx, 0, sizeof(*mbx));
 	mbx_tbl = qlcnic_sriov_bc_mbx_tbl;
 	size = ARRAY_SIZE(qlcnic_sriov_bc_mbx_tbl);
 
-- 
1.6.3.3

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

* Re: [PATCH net] qlcnic: Initialize mailbox cmd structure to zero.
  2014-05-25 14:55 [PATCH net] qlcnic: Initialize mailbox cmd structure to zero Rajesh Borundia
@ 2014-05-30 22:27 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2014-05-30 22:27 UTC (permalink / raw)
  To: rajesh.borundia; +Cc: netdev, Dept-HSGLinuxNICDev

From: Rajesh Borundia <rajesh.borundia@qlogic.com>
Date: Sun, 25 May 2014 10:55:02 -0400

> o Uninitialized fields in mailbox command structure
>   caused commands to time out randomly due to garbage
>   values, so initialize it to zero.
> 
> Signed-off-by: Rajesh Borundia <rajesh.borundia@qlogic.com>

The reason you ran into this problem is that some callers clear out
the command structure, and some do not.

And after your change it's even more confusing, because it is not
clear at all who is responsible for this initialization.

In my opinion it is better to have the place that allocates the
memory perform the initialization.  This means for interfaces that
take on-stack references from their caller, the caller does it.

This also avoids situations (which currently isn't happening here)
where error codes cause early function exits and as a result the
passed in variable isn't cleared out.

It also makes it so that the compiler can %100 see that the entire
object is initialized before being used, in all code paths.

Therefore, please change this bug fix to instead add the appropriate
memset()'s to qlcnic_sriov_get_vf_acl(), qlcnic_sriov_channel_cfg_cmd(),
and qlcnic_sriov_cfg_vf_guest_vlan().

Thanks.

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

end of thread, other threads:[~2014-05-30 22:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-25 14:55 [PATCH net] qlcnic: Initialize mailbox cmd structure to zero Rajesh Borundia
2014-05-30 22:27 ` David Miller

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