mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-28 21:33:52 +00:00
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>
This commit is contained in:
parent
43a4b60d04
commit
0dfa0bed96
1 changed files with 5 additions and 0 deletions
|
@ -4096,12 +4096,16 @@ static int cnic_cm_alloc_mem(struct cnic_dev *dev)
|
||||||
{
|
{
|
||||||
struct cnic_local *cp = dev->cnic_priv;
|
struct cnic_local *cp = dev->cnic_priv;
|
||||||
u32 port_id;
|
u32 port_id;
|
||||||
|
int i;
|
||||||
|
|
||||||
cp->csk_tbl = kvcalloc(MAX_CM_SK_TBL_SZ, sizeof(struct cnic_sock),
|
cp->csk_tbl = kvcalloc(MAX_CM_SK_TBL_SZ, sizeof(struct cnic_sock),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!cp->csk_tbl)
|
if (!cp->csk_tbl)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
for (i = 0; i < MAX_CM_SK_TBL_SZ; i++)
|
||||||
|
atomic_set(&cp->csk_tbl[i].ref_count, 0);
|
||||||
|
|
||||||
port_id = prandom_u32();
|
port_id = prandom_u32();
|
||||||
port_id %= CNIC_LOCAL_PORT_RANGE;
|
port_id %= CNIC_LOCAL_PORT_RANGE;
|
||||||
if (cnic_init_id_tbl(&cp->csk_port_tbl, CNIC_LOCAL_PORT_RANGE,
|
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,
|
||||||
cdev->unregister_device = cnic_unregister_device;
|
cdev->unregister_device = cnic_unregister_device;
|
||||||
cdev->iscsi_nl_msg_recv = cnic_iscsi_nl_msg_recv;
|
cdev->iscsi_nl_msg_recv = cnic_iscsi_nl_msg_recv;
|
||||||
cdev->get_fc_npiv_tbl = cnic_get_fc_npiv_tbl;
|
cdev->get_fc_npiv_tbl = cnic_get_fc_npiv_tbl;
|
||||||
|
atomic_set(&cdev->ref_count, 0);
|
||||||
|
|
||||||
cp = cdev->cnic_priv;
|
cp = cdev->cnic_priv;
|
||||||
cp->dev = cdev;
|
cp->dev = cdev;
|
||||||
|
|
Loading…
Reference in a new issue