2014-02-10 13:00:41

by Tomasz Nowicki

[permalink] [raw]
Subject: [PATCH 1/2] ACPI, PCI, ISA: Call ISA-specific code only for architectures which support ISA.

This commit enables ISA-specific code if and only if CONFIG_{E}ISA is set
in the kernel configuration so that we do not have to maintain
acpi_isa_irq_to_gsi() function for architectures which do not support ISA.

Signed-off-by: Tomasz Nowicki <[email protected]>
---
drivers/acpi/pci_irq.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index 41c5e1b..b0e31b6 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -418,6 +418,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
* driver reported one, then use it. Exit in any case.
*/
if (gsi < 0) {
+#if IS_ENABLED(CONFIG_ISA) || IS_ENABLED(CONFIG_EISA)
u32 dev_gsi;
/* Interrupt Line values above 0xF are forbidden */
if (dev->irq > 0 && (dev->irq <= 0xF) &&
@@ -427,10 +428,9 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
acpi_register_gsi(&dev->dev, dev_gsi,
ACPI_LEVEL_SENSITIVE,
ACPI_ACTIVE_LOW);
- } else {
- dev_warn(&dev->dev, "PCI INT %c: no GSI\n",
- pin_name(pin));
- }
+ } else
+#endif
+ dev_warn(&dev->dev, "PCI INT %c: no GSI\n", pin_name(pin));

return 0;
}
--
1.7.9.5


2014-02-10 13:00:46

by Tomasz Nowicki

[permalink] [raw]
Subject: [PATCH 2/2] ACPI, PCI, ISA: Fix memory leak when there is no IRQ in the ACPI subsystem.

Whenever we register ISA interrupt or not, we need to free the IRQ routing
table entry.

Signed-off-by: Tomasz Nowicki <[email protected]>
---
drivers/acpi/pci_irq.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index b0e31b6..6ec0f36 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -432,6 +432,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
#endif
dev_warn(&dev->dev, "PCI INT %c: no GSI\n", pin_name(pin));

+ kfree(entry);
return 0;
}

--
1.7.9.5

2014-02-15 00:50:19

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH 1/2] ACPI, PCI, ISA: Call ISA-specific code only for architectures which support ISA.

On Monday, February 10, 2014 02:00:10 PM Tomasz Nowicki wrote:
> This commit enables ISA-specific code if and only if CONFIG_{E}ISA is set
> in the kernel configuration so that we do not have to maintain
> acpi_isa_irq_to_gsi() function for architectures which do not support ISA.
>
> Signed-off-by: Tomasz Nowicki <[email protected]>
> ---
> drivers/acpi/pci_irq.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
> index 41c5e1b..b0e31b6 100644
> --- a/drivers/acpi/pci_irq.c
> +++ b/drivers/acpi/pci_irq.c
> @@ -418,6 +418,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
> * driver reported one, then use it. Exit in any case.
> */
> if (gsi < 0) {
> +#if IS_ENABLED(CONFIG_ISA) || IS_ENABLED(CONFIG_EISA)

Can you please move the code in question into a separate function and make
that function depend on the above (with an empty stub for when they are not
enabled)?

> u32 dev_gsi;
> /* Interrupt Line values above 0xF are forbidden */
> if (dev->irq > 0 && (dev->irq <= 0xF) &&
> @@ -427,10 +428,9 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
> acpi_register_gsi(&dev->dev, dev_gsi,
> ACPI_LEVEL_SENSITIVE,
> ACPI_ACTIVE_LOW);
> - } else {
> - dev_warn(&dev->dev, "PCI INT %c: no GSI\n",
> - pin_name(pin));
> - }
> + } else
> +#endif
> + dev_warn(&dev->dev, "PCI INT %c: no GSI\n", pin_name(pin));
>
> return 0;
> }
>

--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

2014-02-18 00:48:05

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH 2/2] ACPI, PCI, ISA: Fix memory leak when there is no IRQ in the ACPI subsystem.

On Monday, February 10, 2014 02:00:11 PM Tomasz Nowicki wrote:
> Whenever we register ISA interrupt or not, we need to free the IRQ routing
> table entry.
>
> Signed-off-by: Tomasz Nowicki <[email protected]>
> ---
> drivers/acpi/pci_irq.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
> index b0e31b6..6ec0f36 100644
> --- a/drivers/acpi/pci_irq.c
> +++ b/drivers/acpi/pci_irq.c
> @@ -432,6 +432,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
> #endif
> dev_warn(&dev->dev, "PCI INT %c: no GSI\n", pin_name(pin));
>
> + kfree(entry);

If I'm not mistaken, entry is always NULL here, isn't it?

> return 0;
> }
>
>

--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

2014-02-18 10:21:37

by Tomasz Nowicki

[permalink] [raw]
Subject: Re: [PATCH 2/2] ACPI, PCI, ISA: Fix memory leak when there is no IRQ in the ACPI subsystem.

On 18.02.2014 02:02, Rafael J. Wysocki wrote:
> On Monday, February 10, 2014 02:00:11 PM Tomasz Nowicki wrote:
>> Whenever we register ISA interrupt or not, we need to free the IRQ routing
>> table entry.
>>
>> Signed-off-by: Tomasz Nowicki <[email protected]>
>> ---
>> drivers/acpi/pci_irq.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
>> index b0e31b6..6ec0f36 100644
>> --- a/drivers/acpi/pci_irq.c
>> +++ b/drivers/acpi/pci_irq.c
>> @@ -432,6 +432,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
>> #endif
>> dev_warn(&dev->dev, "PCI INT %c: no GSI\n", pin_name(pin));
>>
>> + kfree(entry);
>
> If I'm not mistaken, entry is always NULL here, isn't it?
acpi_pci_link_allocate_irq() can return negative gsi even if entry !=
NULL. For that case we'd have memory leak.
>
>> return 0;
>> }
>>
>>
>

2014-02-18 15:11:50

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH 2/2] ACPI, PCI, ISA: Fix memory leak when there is no IRQ in the ACPI subsystem.

On Tuesday, February 18, 2014 11:21:39 AM Tomasz Nowicki wrote:
> On 18.02.2014 02:02, Rafael J. Wysocki wrote:
> > On Monday, February 10, 2014 02:00:11 PM Tomasz Nowicki wrote:
> >> Whenever we register ISA interrupt or not, we need to free the IRQ routing
> >> table entry.
> >>
> >> Signed-off-by: Tomasz Nowicki <[email protected]>
> >> ---
> >> drivers/acpi/pci_irq.c | 1 +
> >> 1 file changed, 1 insertion(+)
> >>
> >> diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
> >> index b0e31b6..6ec0f36 100644
> >> --- a/drivers/acpi/pci_irq.c
> >> +++ b/drivers/acpi/pci_irq.c
> >> @@ -432,6 +432,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
> >> #endif
> >> dev_warn(&dev->dev, "PCI INT %c: no GSI\n", pin_name(pin));
> >>
> >> + kfree(entry);
> >
> > If I'm not mistaken, entry is always NULL here, isn't it?
>
> acpi_pci_link_allocate_irq() can return negative gsi even if entry !=
> NULL. For that case we'd have memory leak.

And that's what your changelog should be saying, isn't it?

Queued up for 3.14 and marked for -stable. I had to rebase it, though, so
please check the result in linux-pm.git/linux-next.

Thanks!

--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

2014-02-19 10:27:12

by Tomasz Nowicki

[permalink] [raw]
Subject: Re: [PATCH 2/2] ACPI, PCI, ISA: Fix memory leak when there is no IRQ in the ACPI subsystem.

On 18.02.2014 16:26, Rafael J. Wysocki wrote:
> On Tuesday, February 18, 2014 11:21:39 AM Tomasz Nowicki wrote:
>> On 18.02.2014 02:02, Rafael J. Wysocki wrote:
>>> On Monday, February 10, 2014 02:00:11 PM Tomasz Nowicki wrote:
>>>> Whenever we register ISA interrupt or not, we need to free the IRQ routing
>>>> table entry.
>>>>
>>>> Signed-off-by: Tomasz Nowicki <[email protected]>
>>>> ---
>>>> drivers/acpi/pci_irq.c | 1 +
>>>> 1 file changed, 1 insertion(+)
>>>>
>>>> diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
>>>> index b0e31b6..6ec0f36 100644
>>>> --- a/drivers/acpi/pci_irq.c
>>>> +++ b/drivers/acpi/pci_irq.c
>>>> @@ -432,6 +432,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
>>>> #endif
>>>> dev_warn(&dev->dev, "PCI INT %c: no GSI\n", pin_name(pin));
>>>>
>>>> + kfree(entry);
>>>
>>> If I'm not mistaken, entry is always NULL here, isn't it?
>>
>> acpi_pci_link_allocate_irq() can return negative gsi even if entry !=
>> NULL. For that case we'd have memory leak.
>
> And that's what your changelog should be saying, isn't it?
It should, sorry.
>
> Queued up for 3.14 and marked for -stable. I had to rebase it, though, so
> please check the result in linux-pm.git/linux-next.
It's OK. Thanks.

Tomasz

2014-02-19 10:28:03

by Tomasz Nowicki

[permalink] [raw]
Subject: Re: [PATCH 1/2] ACPI, PCI, ISA: Call ISA-specific code only for architectures which support ISA.



On 15.02.2014 02:05, Rafael J. Wysocki wrote:
> On Monday, February 10, 2014 02:00:10 PM Tomasz Nowicki wrote:
>> This commit enables ISA-specific code if and only if CONFIG_{E}ISA is set
>> in the kernel configuration so that we do not have to maintain
>> acpi_isa_irq_to_gsi() function for architectures which do not support ISA.
>>
>> Signed-off-by: Tomasz Nowicki <[email protected]>
>> ---
>> drivers/acpi/pci_irq.c | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
>> index 41c5e1b..b0e31b6 100644
>> --- a/drivers/acpi/pci_irq.c
>> +++ b/drivers/acpi/pci_irq.c
>> @@ -418,6 +418,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
>> * driver reported one, then use it. Exit in any case.
>> */
>> if (gsi < 0) {
>> +#if IS_ENABLED(CONFIG_ISA) || IS_ENABLED(CONFIG_EISA)
>
> Can you please move the code in question into a separate function and make
> that function depend on the above (with an empty stub for when they are not
> enabled)?
Thanks for suggestion, I will resend as next version.
>
>> u32 dev_gsi;
>> /* Interrupt Line values above 0xF are forbidden */
>> if (dev->irq > 0 && (dev->irq <= 0xF) &&
>> @@ -427,10 +428,9 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
>> acpi_register_gsi(&dev->dev, dev_gsi,
>> ACPI_LEVEL_SENSITIVE,
>> ACPI_ACTIVE_LOW);
>> - } else {
>> - dev_warn(&dev->dev, "PCI INT %c: no GSI\n",
>> - pin_name(pin));
>> - }
>> + } else
>> +#endif
>> + dev_warn(&dev->dev, "PCI INT %c: no GSI\n", pin_name(pin));
>>
>> return 0;
>> }
>>
>