提交 d98ef50f 编写于 作者: S Suresh Reddy 提交者: David S. Miller

be2net: Fixed memory leak

Signed-off-by: NSuresh Reddy <suresh.reddy@emulex.com>
Signed-off-by: NSarveshwar Bandi <sarveshwar.bandi@emulex.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 2c1bbbff
...@@ -2493,6 +2493,9 @@ int be_cmd_get_cntl_attributes(struct be_adapter *adapter) ...@@ -2493,6 +2493,9 @@ int be_cmd_get_cntl_attributes(struct be_adapter *adapter)
struct mgmt_controller_attrib *attribs; struct mgmt_controller_attrib *attribs;
struct be_dma_mem attribs_cmd; struct be_dma_mem attribs_cmd;
if (mutex_lock_interruptible(&adapter->mbox_lock))
return -1;
memset(&attribs_cmd, 0, sizeof(struct be_dma_mem)); memset(&attribs_cmd, 0, sizeof(struct be_dma_mem));
attribs_cmd.size = sizeof(struct be_cmd_resp_cntl_attribs); attribs_cmd.size = sizeof(struct be_cmd_resp_cntl_attribs);
attribs_cmd.va = pci_alloc_consistent(adapter->pdev, attribs_cmd.size, attribs_cmd.va = pci_alloc_consistent(adapter->pdev, attribs_cmd.size,
...@@ -2500,12 +2503,10 @@ int be_cmd_get_cntl_attributes(struct be_adapter *adapter) ...@@ -2500,12 +2503,10 @@ int be_cmd_get_cntl_attributes(struct be_adapter *adapter)
if (!attribs_cmd.va) { if (!attribs_cmd.va) {
dev_err(&adapter->pdev->dev, dev_err(&adapter->pdev->dev,
"Memory allocation failure\n"); "Memory allocation failure\n");
return -ENOMEM; status = -ENOMEM;
goto err;
} }
if (mutex_lock_interruptible(&adapter->mbox_lock))
return -1;
wrb = wrb_from_mbox(adapter); wrb = wrb_from_mbox(adapter);
if (!wrb) { if (!wrb) {
status = -EBUSY; status = -EBUSY;
...@@ -2525,8 +2526,9 @@ int be_cmd_get_cntl_attributes(struct be_adapter *adapter) ...@@ -2525,8 +2526,9 @@ int be_cmd_get_cntl_attributes(struct be_adapter *adapter)
err: err:
mutex_unlock(&adapter->mbox_lock); mutex_unlock(&adapter->mbox_lock);
pci_free_consistent(adapter->pdev, attribs_cmd.size, attribs_cmd.va, if (attribs_cmd.va)
attribs_cmd.dma); pci_free_consistent(adapter->pdev, attribs_cmd.size,
attribs_cmd.va, attribs_cmd.dma);
return status; return status;
} }
...@@ -2826,6 +2828,9 @@ int be_cmd_get_acpi_wol_cap(struct be_adapter *adapter) ...@@ -2826,6 +2828,9 @@ int be_cmd_get_acpi_wol_cap(struct be_adapter *adapter)
CMD_SUBSYSTEM_ETH)) CMD_SUBSYSTEM_ETH))
return -EPERM; return -EPERM;
if (mutex_lock_interruptible(&adapter->mbox_lock))
return -1;
memset(&cmd, 0, sizeof(struct be_dma_mem)); memset(&cmd, 0, sizeof(struct be_dma_mem));
cmd.size = sizeof(struct be_cmd_resp_acpi_wol_magic_config_v1); cmd.size = sizeof(struct be_cmd_resp_acpi_wol_magic_config_v1);
cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size, cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size,
...@@ -2833,12 +2838,10 @@ int be_cmd_get_acpi_wol_cap(struct be_adapter *adapter) ...@@ -2833,12 +2838,10 @@ int be_cmd_get_acpi_wol_cap(struct be_adapter *adapter)
if (!cmd.va) { if (!cmd.va) {
dev_err(&adapter->pdev->dev, dev_err(&adapter->pdev->dev,
"Memory allocation failure\n"); "Memory allocation failure\n");
return -ENOMEM; status = -ENOMEM;
goto err;
} }
if (mutex_lock_interruptible(&adapter->mbox_lock))
return -1;
wrb = wrb_from_mbox(adapter); wrb = wrb_from_mbox(adapter);
if (!wrb) { if (!wrb) {
status = -EBUSY; status = -EBUSY;
...@@ -2869,6 +2872,7 @@ int be_cmd_get_acpi_wol_cap(struct be_adapter *adapter) ...@@ -2869,6 +2872,7 @@ int be_cmd_get_acpi_wol_cap(struct be_adapter *adapter)
} }
err: err:
mutex_unlock(&adapter->mbox_lock); mutex_unlock(&adapter->mbox_lock);
if (cmd.va)
pci_free_consistent(adapter->pdev, cmd.size, cmd.va, cmd.dma); pci_free_consistent(adapter->pdev, cmd.size, cmd.va, cmd.dma);
return status; return status;
...@@ -3001,16 +3005,18 @@ int be_cmd_get_func_config(struct be_adapter *adapter) ...@@ -3001,16 +3005,18 @@ int be_cmd_get_func_config(struct be_adapter *adapter)
int status; int status;
struct be_dma_mem cmd; struct be_dma_mem cmd;
if (mutex_lock_interruptible(&adapter->mbox_lock))
return -1;
memset(&cmd, 0, sizeof(struct be_dma_mem)); memset(&cmd, 0, sizeof(struct be_dma_mem));
cmd.size = sizeof(struct be_cmd_resp_get_func_config); cmd.size = sizeof(struct be_cmd_resp_get_func_config);
cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size, cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size,
&cmd.dma); &cmd.dma);
if (!cmd.va) { if (!cmd.va) {
dev_err(&adapter->pdev->dev, "Memory alloc failure\n"); dev_err(&adapter->pdev->dev, "Memory alloc failure\n");
return -ENOMEM; status = -ENOMEM;
goto err;
} }
if (mutex_lock_interruptible(&adapter->mbox_lock))
return -1;
wrb = wrb_from_mbox(adapter); wrb = wrb_from_mbox(adapter);
if (!wrb) { if (!wrb) {
...@@ -3050,8 +3056,8 @@ int be_cmd_get_func_config(struct be_adapter *adapter) ...@@ -3050,8 +3056,8 @@ int be_cmd_get_func_config(struct be_adapter *adapter)
} }
err: err:
mutex_unlock(&adapter->mbox_lock); mutex_unlock(&adapter->mbox_lock);
pci_free_consistent(adapter->pdev, cmd.size, if (cmd.va)
cmd.va, cmd.dma); pci_free_consistent(adapter->pdev, cmd.size, cmd.va, cmd.dma);
return status; return status;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册