From: Julia Lawall <julia.lawall@lip6.fr>
To: cbou@mail.ru, dwmw2@infradead.org, linux-kernel@vger.kernel.org
Subject: question about drivers/power/88pm860x_charger.c
Date: Sat, 8 Dec 2012 17:37:45 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.02.1212081731080.1984@hadrien> (raw)
The function pm860x_charger_probe in the file
drivers/power/88pm860x_charger.c contains the following code:
count = pdev->num_resources;
for (i = 0, j = 0; i < count; i++) {
info->irq[j] = platform_get_irq(pdev, i);
if (info->irq[j] < 0)
continue;
j++;
}
info->irq_nums = j;
and then later the following code:
for (i = 0; i < ARRAY_SIZE(info->irq); i++) {
ret = request_threaded_irq(info->irq[i], NULL,
pm860x_irq_descs[i].handler,
IRQF_ONESHOT, pm860x_irq_descs[i].name, info);
...
}
and finally, in the function pm860x_charger_remove, the code:
free_irq(info->irq[0], info);
for (i = 0; i < info->irq_nums; i++)
free_irq(info->irq[i], info);
It looks like the irq_nums field is being used to record how many
platform_get_irq calls were successful, but this information is not used
in the second block of code, where request_threaded_irq is called. So it
would seem that all of the requested irqs should be freed, and not just
the first irq_nums of them.
The remove code also looks like a double free of info->irq[0].
Could I just get rid of the irq_nums field completely? It doesn't seem to
be used elsewhere. Also, I was planning to use devm_request_threaded_irq,
so then there won't be a need for the explicit frees at all.
This file also contains a kfree of devm_kzalloc'd data, which is why I
looked at it in the first place.
thanks,
julia
next reply other threads:[~2012-12-08 16:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-08 16:37 Julia Lawall [this message]
2012-12-13 18:50 ` anish kumar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.02.1212081731080.1984@hadrien \
--to=julia.lawall@lip6.fr \
--cc=cbou@mail.ru \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®