提交 b701c0b1 编写于 作者: A Alexei Starovoitov 提交者: Bjorn Helgaas

PCI/MSI: Fix memory leak in free_msi_irqs()

free_msi_irqs() is leaking memory, since list_for_each_entry(entry,
&dev->msi_list, list) {...} is never executed, because dev->msi_list is
made empty by the loop just above this one.

Fix it by relying on zero termination of attribute array like
populate_msi_sysfs() does.

Fixes: 1c51b50c ("PCI/MSI: Export MSI mode using attributes, not kobjects")
Signed-off-by: NAlexei Starovoitov <ast@plumgrid.com>
Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
Acked-by: NNeil Horman <nhorman@tuxdriver.com>
Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
CC: stable@vger.kernel.org	# v3.14+
上级 843a85ce
......@@ -413,7 +413,7 @@ static void free_msi_irqs(struct pci_dev *dev)
if (dev->msi_irq_groups) {
sysfs_remove_groups(&dev->dev.kobj, dev->msi_irq_groups);
msi_attrs = dev->msi_irq_groups[0]->attrs;
list_for_each_entry(entry, &dev->msi_list, list) {
while (msi_attrs[count]) {
dev_attr = container_of(msi_attrs[count],
struct device_attribute, attr);
kfree(dev_attr->attr.name);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册