aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorAnton Vasilyev <vasilyev@ispras.ru>2018-08-01 07:26:51 -0400
committerJiri Kosina <jkosina@suse.cz>2018-08-02 07:27:54 -0400
commit50fa92594a2bc76265f4bb357f9a25dd3bdb2c0a (patch)
treec5a30ab184359bf83808e116c5ef975330e4c0f5 /drivers/hid
parenta1e9a9c0dfe47a3f13734be489b7953a2f8bdd83 (diff)
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: Anton Vasilyev <vasilyev@ispras.ru> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/intel-ish-hid/ipc/ipc.c9
-rw-r--r--drivers/hid/intel-ish-hid/ipc/pci-ish.c2
2 files changed, 6 insertions, 5 deletions
diff --git a/drivers/hid/intel-ish-hid/ipc/ipc.c b/drivers/hid/intel-ish-hid/ipc/ipc.c
index 9a60ec13cb10..bfbca7ec54ce 100644
--- a/drivers/hid/intel-ish-hid/ipc/ipc.c
+++ b/drivers/hid/intel-ish-hid/ipc/ipc.c
@@ -907,8 +907,9 @@ struct ishtp_device *ish_dev_init(struct pci_dev *pdev)
907 struct ishtp_device *dev; 907 struct ishtp_device *dev;
908 int i; 908 int i;
909 909
910 dev = kzalloc(sizeof(struct ishtp_device) + sizeof(struct ish_hw), 910 dev = devm_kzalloc(&pdev->dev,
911 GFP_KERNEL); 911 sizeof(struct ishtp_device) + sizeof(struct ish_hw),
912 GFP_KERNEL);
912 if (!dev) 913 if (!dev)
913 return NULL; 914 return NULL;
914 915
@@ -925,7 +926,9 @@ struct ishtp_device *ish_dev_init(struct pci_dev *pdev)
925 for (i = 0; i < IPC_TX_FIFO_SIZE; ++i) { 926 for (i = 0; i < IPC_TX_FIFO_SIZE; ++i) {
926 struct wr_msg_ctl_info *tx_buf; 927 struct wr_msg_ctl_info *tx_buf;
927 928
928 tx_buf = kzalloc(sizeof(struct wr_msg_ctl_info), GFP_KERNEL); 929 tx_buf = devm_kzalloc(&pdev->dev,
930 sizeof(struct wr_msg_ctl_info),
931 GFP_KERNEL);
929 if (!tx_buf) { 932 if (!tx_buf) {
930 /* 933 /*
931 * IPC buffers may be limited or not available 934 * IPC buffers may be limited or not available
diff --git a/drivers/hid/intel-ish-hid/ipc/pci-ish.c b/drivers/hid/intel-ish-hid/ipc/pci-ish.c
index 4a55eab39b88..050f9872f5c0 100644
--- a/drivers/hid/intel-ish-hid/ipc/pci-ish.c
+++ b/drivers/hid/intel-ish-hid/ipc/pci-ish.c
@@ -183,7 +183,6 @@ free_irq:
183 free_irq(pdev->irq, dev); 183 free_irq(pdev->irq, dev);
184free_device: 184free_device:
185 pci_iounmap(pdev, hw->mem_addr); 185 pci_iounmap(pdev, hw->mem_addr);
186 kfree(dev);
187release_regions: 186release_regions:
188 pci_release_regions(pdev); 187 pci_release_regions(pdev);
189disable_device: 188disable_device:
@@ -213,7 +212,6 @@ static void ish_remove(struct pci_dev *pdev)
213 pci_release_regions(pdev); 212 pci_release_regions(pdev);
214 pci_clear_master(pdev); 213 pci_clear_master(pdev);
215 pci_disable_device(pdev); 214 pci_disable_device(pdev);
216 kfree(ishtp_dev);
217} 215}
218 216
219static struct device __maybe_unused *ish_resume_device; 217static struct device __maybe_unused *ish_resume_device;