Skip to content

Commit

Permalink
enic: free all rq buffs when allocation fails
Browse files Browse the repository at this point in the history
When allocation of all RQs fail, we do not free previously allocated buffers,
before returning error. This causes memory leak.

This patch fixes this by calling vnic_rq_clean(), which frees all the rq
buffers.

Signed-off-by: Govindarajulu Varadarajan <_govind@gmx.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Govindarajulu Varadarajan authored and David S. Miller committed Jan 2, 2015
1 parent 531ad42 commit 9dac623
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/net/ethernet/cisco/enic/enic_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1616,7 +1616,7 @@ static int enic_open(struct net_device *netdev)
if (vnic_rq_desc_used(&enic->rq[i]) == 0) {
netdev_err(netdev, "Unable to alloc receive buffers\n");
err = -ENOMEM;
goto err_out_notify_unset;
goto err_out_free_rq;
}
}

Expand Down Expand Up @@ -1649,7 +1649,9 @@ static int enic_open(struct net_device *netdev)

return 0;

err_out_notify_unset:
err_out_free_rq:
for (i = 0; i < enic->rq_count; i++)
vnic_rq_clean(&enic->rq[i], enic_free_rq_buf);
enic_dev_notify_unset(enic);
err_out_free_intr:
enic_free_intr(enic);
Expand Down

0 comments on commit 9dac623

Please sign in to comment.