mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jia-Ju Bai <baijiaju1990@gmail.com>
To: ulf.hansson@linaro.org, andriy.shevchenko@linux.intel.com,
	wsa+renesas@sang-engineering.com,
	yoshihiro.shimoda.uh@renesas.com, adrian.hunter@intel.com,
	swboyd@chromium.org, dev@lynxeye.de
Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jia-Ju Bai <baijiaju1990@gmail.com>
Subject: [PATCH] mmc: core: check the return value of wakeup_source_register()
Date: Fri, 25 Feb 2022 04:18:58 -0800	[thread overview]
Message-ID: <20220225121858.25638-1-baijiaju1990@gmail.com> (raw)

The function wakeup_source_register() in mmc_alloc_host() can fail, so
its return value should be checked.

Fixes: b52fb259dff8 ("mmc: core: Always allow the card detect uevent to be consumed")
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
 drivers/mmc/core/host.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index cf140f4ec864..4f1a6db10ec5 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -550,6 +550,10 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
 
 	dev_set_name(&host->class_dev, "mmc%d", host->index);
 	host->ws = wakeup_source_register(NULL, dev_name(&host->class_dev));
+	if (!host->ws) {
+		kfree(host);
+		return NULL;
+	}
 
 	host->parent = dev;
 	host->class_dev.parent = dev;
-- 
2.17.1


             reply	other threads:[~2022-02-25 12:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-25 12:18 Jia-Ju Bai [this message]
2022-02-25 16:54 ` Andy Shevchenko

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=20220225121858.25638-1-baijiaju1990@gmail.com \
    --to=baijiaju1990@gmail.com \
    --cc=adrian.hunter@intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=dev@lynxeye.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=swboyd@chromium.org \
    --cc=ulf.hansson@linaro.org \
    --cc=wsa+renesas@sang-engineering.com \
    --cc=yoshihiro.shimoda.uh@renesas.com \
    /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®