Skip to content

Commit 0dfa0be

Browse files
Michael Chandavem330
authored andcommitted
cnic: Explicitly initialize all reference counts to 0.
The driver is relying on zero'ed allocated memory and does not explicitly call atomic_set() to initialize the ref counts to 0. Add these atomic_set() calls so that it will be more straight forward to convert atomic ref counts to refcount_t. Reported-by: Chuhong Yuan <hslester96@gmail.com> Cc: Rasesh Mody <rmody@marvell.com> Cc: <GR-Linux-NIC-Dev@marvell.com> Signed-off-by: Michael Chan <michael.chan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 43a4b60 commit 0dfa0be

File tree

1 file changed

+5
-0
lines changed
  • drivers/net/ethernet/broadcom

1 file changed

+5
-0
lines changed

drivers/net/ethernet/broadcom/cnic.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4096,12 +4096,16 @@ static int cnic_cm_alloc_mem(struct cnic_dev *dev)
40964096
{
40974097
struct cnic_local *cp = dev->cnic_priv;
40984098
u32 port_id;
4099+
int i;
40994100

41004101
cp->csk_tbl = kvcalloc(MAX_CM_SK_TBL_SZ, sizeof(struct cnic_sock),
41014102
GFP_KERNEL);
41024103
if (!cp->csk_tbl)
41034104
return -ENOMEM;
41044105

4106+
for (i = 0; i < MAX_CM_SK_TBL_SZ; i++)
4107+
atomic_set(&cp->csk_tbl[i].ref_count, 0);
4108+
41054109
port_id = prandom_u32();
41064110
port_id %= CNIC_LOCAL_PORT_RANGE;
41074111
if (cnic_init_id_tbl(&cp->csk_port_tbl, CNIC_LOCAL_PORT_RANGE,
@@ -5480,6 +5484,7 @@ static struct cnic_dev *cnic_alloc_dev(struct net_device *dev,
54805484
cdev->unregister_device = cnic_unregister_device;
54815485
cdev->iscsi_nl_msg_recv = cnic_iscsi_nl_msg_recv;
54825486
cdev->get_fc_npiv_tbl = cnic_get_fc_npiv_tbl;
5487+
atomic_set(&cdev->ref_count, 0);
54835488

54845489
cp = cdev->cnic_priv;
54855490
cp->dev = cdev;

0 commit comments

Comments
 (0)