public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v7] devcoredump: change gfp_t parameter of kzalloc to GFP_KERNEL
@ 2022-06-28  3:44 Duoming Zhou
  2022-06-28  6:09 ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Duoming Zhou @ 2022-06-28  3:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: rafael, gregkh, johannes, Duoming Zhou

The dev_coredumpv() and dev_coredumpm() could not be used in atomic
context, because they call kvasprintf_const() and kstrdup() with
GFP_KERNEL parameter. The process is shown below:

dev_coredumpv(.., gfp_t gfp)
  dev_coredumpm(.., gfp_t gfp)
    kzalloc(.., gfp);
    dev_set_name
      kobject_set_name_vargs
        kvasprintf_const(GFP_KERNEL, ...); //may sleep
          kstrdup(s, GFP_KERNEL); //may sleep

This patch changes the gfp_t parameter of kzalloc() in dev_coredumpm() to
GFP_KERNEL in order to show they could not be used in atomic context.

What's more, this patch does not remove the gfp_t parameter in
dev_coredumpv() and dev_coredumpm() in order that it will not influence
other new users that are added in other trees.

Fixes: 833c95456a70 ("device coredump: add new device coredump class")
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
---
Changes in v7:
  - change gfp_t parameter of kzalloc in dev_coredumpm() to GFP_KERNEL.

 drivers/base/devcoredump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/devcoredump.c b/drivers/base/devcoredump.c
index f4d794d6bb8..cf60aacf8a8 100644
--- a/drivers/base/devcoredump.c
+++ b/drivers/base/devcoredump.c
@@ -268,7 +268,7 @@ void dev_coredumpm(struct device *dev, struct module *owner,
 	if (!try_module_get(owner))
 		goto free;
 
-	devcd = kzalloc(sizeof(*devcd), gfp);
+	devcd = kzalloc(sizeof(*devcd), GFP_KERNEL);
 	if (!devcd)
 		goto put_module;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-06-28 13:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-28  3:44 [PATCH v7] devcoredump: change gfp_t parameter of kzalloc to GFP_KERNEL Duoming Zhou
2022-06-28  6:09 ` Greg KH
2022-06-28 11:06   ` duoming
2022-06-28 12:18     ` Greg KH
2022-06-28 13:57       ` duoming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox