Commit 50fa9259 authored by Anton Vasilyev's avatar Anton Vasilyev Committed by Jiri Kosina

HID: intel_ish-hid: tx_buf memory leak on probe/remove

ish_dev_init() allocates 512*176 bytes memory for tx_buf and stores it at
&dev->wr_free_list_head.link list on ish_probe().
But there is no deallocation of this memory in ish_remove() and in
ish_probe() error path.
So current intel-ish-ipc provides 88 KB memory leak for each
probe/release.

The patch replaces kzalloc allocation by devm_kzalloc and removes
ishtp_device *dev deallocation by kfree.

Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: default avatarAnton Vasilyev <vasilyev@ispras.ru>
Acked-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent a1e9a9c0
...@@ -907,7 +907,8 @@ struct ishtp_device *ish_dev_init(struct pci_dev *pdev) ...@@ -907,7 +907,8 @@ struct ishtp_device *ish_dev_init(struct pci_dev *pdev)
struct ishtp_device *dev; struct ishtp_device *dev;
int i; int i;
dev = kzalloc(sizeof(struct ishtp_device) + sizeof(struct ish_hw), dev = devm_kzalloc(&pdev->dev,
sizeof(struct ishtp_device) + sizeof(struct ish_hw),
GFP_KERNEL); GFP_KERNEL);
if (!dev) if (!dev)
return NULL; return NULL;
...@@ -925,7 +926,9 @@ struct ishtp_device *ish_dev_init(struct pci_dev *pdev) ...@@ -925,7 +926,9 @@ struct ishtp_device *ish_dev_init(struct pci_dev *pdev)
for (i = 0; i < IPC_TX_FIFO_SIZE; ++i) { for (i = 0; i < IPC_TX_FIFO_SIZE; ++i) {
struct wr_msg_ctl_info *tx_buf; struct wr_msg_ctl_info *tx_buf;
tx_buf = kzalloc(sizeof(struct wr_msg_ctl_info), GFP_KERNEL); tx_buf = devm_kzalloc(&pdev->dev,
sizeof(struct wr_msg_ctl_info),
GFP_KERNEL);
if (!tx_buf) { if (!tx_buf) {
/* /*
* IPC buffers may be limited or not available * IPC buffers may be limited or not available
......
...@@ -183,7 +183,6 @@ static int ish_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -183,7 +183,6 @@ static int ish_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
free_irq(pdev->irq, dev); free_irq(pdev->irq, dev);
free_device: free_device:
pci_iounmap(pdev, hw->mem_addr); pci_iounmap(pdev, hw->mem_addr);
kfree(dev);
release_regions: release_regions:
pci_release_regions(pdev); pci_release_regions(pdev);
disable_device: disable_device:
...@@ -213,7 +212,6 @@ static void ish_remove(struct pci_dev *pdev) ...@@ -213,7 +212,6 @@ static void ish_remove(struct pci_dev *pdev)
pci_release_regions(pdev); pci_release_regions(pdev);
pci_clear_master(pdev); pci_clear_master(pdev);
pci_disable_device(pdev); pci_disable_device(pdev);
kfree(ishtp_dev);
} }
static struct device __maybe_unused *ish_resume_device; static struct device __maybe_unused *ish_resume_device;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment