* [PATCH] powerpc/pseries: avoid blocking in irq when queuing hotplug events
@ 2019-05-28 23:28 Nathan Lynch
2019-06-30 8:37 ` Michael Ellerman
0 siblings, 1 reply; 2+ messages in thread
From: Nathan Lynch @ 2019-05-28 23:28 UTC (permalink / raw)
To: linuxppc-dev
A couple of bugs in queue_hotplug_event():
1. Unchecked kmalloc result which could lead to an oops.
2. Use of GFP_KERNEL allocations in interrupt context (this code's
only caller is ras_hotplug_interrupt()).
Use kmemdup to avoid open-coding the allocation+copy and check for
failure; use GFP_ATOMIC for both allocations.
Ultimately it probably would be better to avoid or reduce allocations
in this path if possible.
Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
---
Found by inspection, built but not runtime-tested.
arch/powerpc/platforms/pseries/dlpar.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
index 17958043e7f7..d70f9b925378 100644
--- a/arch/powerpc/platforms/pseries/dlpar.c
+++ b/arch/powerpc/platforms/pseries/dlpar.c
@@ -386,11 +386,11 @@ void queue_hotplug_event(struct pseries_hp_errorlog *hp_errlog)
struct pseries_hp_work *work;
struct pseries_hp_errorlog *hp_errlog_copy;
- hp_errlog_copy = kmalloc(sizeof(struct pseries_hp_errorlog),
- GFP_KERNEL);
- memcpy(hp_errlog_copy, hp_errlog, sizeof(struct pseries_hp_errorlog));
+ hp_errlog_copy = kmemdup(hp_errlog, sizeof(*hp_errlog), GFP_ATOMIC);
+ if (!hp_errlog_copy)
+ return;
- work = kmalloc(sizeof(struct pseries_hp_work), GFP_KERNEL);
+ work = kmalloc(sizeof(struct pseries_hp_work), GFP_ATOMIC);
if (work) {
INIT_WORK((struct work_struct *)work, pseries_hp_work_fn);
work->errlog = hp_errlog_copy;
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] powerpc/pseries: avoid blocking in irq when queuing hotplug events
2019-05-28 23:28 [PATCH] powerpc/pseries: avoid blocking in irq when queuing hotplug events Nathan Lynch
@ 2019-06-30 8:37 ` Michael Ellerman
0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2019-06-30 8:37 UTC (permalink / raw)
To: Nathan Lynch, linuxppc-dev
On Tue, 2019-05-28 at 23:28:01 UTC, Nathan Lynch wrote:
> A couple of bugs in queue_hotplug_event():
>
> 1. Unchecked kmalloc result which could lead to an oops.
> 2. Use of GFP_KERNEL allocations in interrupt context (this code's
> only caller is ras_hotplug_interrupt()).
>
> Use kmemdup to avoid open-coding the allocation+copy and check for
> failure; use GFP_ATOMIC for both allocations.
>
> Ultimately it probably would be better to avoid or reduce allocations
> in this path if possible.
>
> Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/348ea30f51fc63ce3c7fd7dba6043e8e3ee0ef34
cheers
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-30 8:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-28 23:28 [PATCH] powerpc/pseries: avoid blocking in irq when queuing hotplug events Nathan Lynch
2019-06-30 8:37 ` Michael Ellerman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).