Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1740671 > unrolled thread
| Started by | Jeffy Chen <jeffy.chen@rock-chips.com> |
|---|---|
| First post | 2017-09-27 14:30 +0200 |
| Last post | 2017-09-28 06:40 +0200 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] irq/generic-chip: Fix memory leak of domain->name Jeffy Chen <jeffy.chen@rock-chips.com> - 2017-09-27 14:30 +0200
Re: [PATCH] irq/generic-chip: Fix memory leak of domain->name Thomas Gleixner <tglx@linutronix.de> - 2017-09-27 15:40 +0200
Re: [PATCH] irq/generic-chip: Fix memory leak of domain->name jeffy <jeffy.chen@rock-chips.com> - 2017-09-28 05:20 +0200
Re: [PATCH] irq/generic-chip: Fix memory leak of domain->name jeffy <jeffy.chen@rock-chips.com> - 2017-09-28 06:40 +0200
| From | Jeffy Chen <jeffy.chen@rock-chips.com> |
|---|---|
| Date | 2017-09-27 14:30 +0200 |
| Subject | [PATCH] irq/generic-chip: Fix memory leak of domain->name |
| Message-ID | <uujDs-2nV-17@gated-at.bofh.it> |
Free domain->name when IRQ_DOMAIN_NAME_ALLOCATED been set.
Fixes: d59f6617eef0 ("genirq: Allow fwnode to carry name information only")
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
kernel/irq/generic-chip.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/irq/generic-chip.c b/kernel/irq/generic-chip.c
index f7086b78ad6e..174dae8ee7fe 100644
--- a/kernel/irq/generic-chip.c
+++ b/kernel/irq/generic-chip.c
@@ -322,6 +322,10 @@ int __irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip,
/* Calc pointer to the next generic chip */
tmp += sizeof(*gc) + num_ct * sizeof(struct irq_chip_type);
}
+ if (d->flags & IRQ_DOMAIN_NAME_ALLOCATED) {
+ kfree(d->name);
+ d->flags &= ~IRQ_DOMAIN_NAME_ALLOCATED;
+ }
d->name = name;
return 0;
}
--
2.11.0
[toc] | [next] | [standalone]
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2017-09-27 15:40 +0200 |
| Message-ID | <uukJb-3qZ-3@gated-at.bofh.it> |
| In reply to | #1740671 |
On Wed, 27 Sep 2017, Jeffy Chen wrote:
> Free domain->name when IRQ_DOMAIN_NAME_ALLOCATED been set.
I can see that from the patch, but you fail to explain what the problem
is.
It's actually more than just a memory leak. If the domain gets destroyed
then the domain free code would try to free d->name which might be a string
constant .....
> + if (d->flags & IRQ_DOMAIN_NAME_ALLOCATED) {
> + kfree(d->name);
> + d->flags &= ~IRQ_DOMAIN_NAME_ALLOCATED;
> + }
> d->name = name;
I don't think that this is the proper thing to do. There is no reason why
the domain should have the same name as the irq chip. So we rather should
do:
if (!d->name)
d->name = name;
Along with a proper comment.
Thanks,
tglx
[toc] | [prev] | [next] | [standalone]
| From | jeffy <jeffy.chen@rock-chips.com> |
|---|---|
| Date | 2017-09-28 05:20 +0200 |
| Message-ID | <uuxwK-3uo-11@gated-at.bofh.it> |
| In reply to | #1740729 |
Hi Thomas,
Thanks for your review.
On 09/27/2017 09:29 PM, Thomas Gleixner wrote:
> On Wed, 27 Sep 2017, Jeffy Chen wrote:
>
>> Free domain->name when IRQ_DOMAIN_NAME_ALLOCATED been set.
>
> I can see that from the patch, but you fail to explain what the problem
> is.
>
> It's actually more than just a memory leak. If the domain gets destroyed
> then the domain free code would try to free d->name which might be a string
> constant .....
ok, i'll add that to commit msg.
>
>> + if (d->flags & IRQ_DOMAIN_NAME_ALLOCATED) {
>> + kfree(d->name);
>> + d->flags &= ~IRQ_DOMAIN_NAME_ALLOCATED;
>> + }
>> d->name = name;
>
> I don't think that this is the proper thing to do. There is no reason why
> the domain should have the same name as the irq chip. So we rather should
> do:
>
> if (!d->name)
> d->name = name;
>
> Along with a proper comment.
that is better, will do it in next version :)
>
> Thanks,
>
> tglx
>
>
>
>
[toc] | [prev] | [next] | [standalone]
| From | jeffy <jeffy.chen@rock-chips.com> |
|---|---|
| Date | 2017-09-28 06:40 +0200 |
| Message-ID | <uuyMa-4cw-27@gated-at.bofh.it> |
| In reply to | #1741147 |
Hi Thomas, On 09/28/2017 11:18 AM, jeffy wrote: >> >> I don't think that this is the proper thing to do. There is no reason why >> the domain should have the same name as the irq chip. So we rather should >> do: >> >> if (!d->name) >> d->name = name; >> >> Along with a proper comment. > that is better, will do it in next version :) it looks like the __irq_domain_add() would guarantee every domain has a valid name, maybe we can just remove this?
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web