linux-amlogic.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Sasha Levin <sashal@kernel.org>,
	linux-amlogic@lists.infradead.org,
	Ulf Hansson <ulf.hansson@linaro.org>,
	linux-mmc@vger.kernel.org, Nicholas Mc Guire <hofrat@osadl.org>
Subject: [PATCH AUTOSEL 4.20 184/304] mmc: meson-mx-sdio: check devm_kasprintf for failure
Date: Mon, 28 Jan 2019 10:41:41 -0500	[thread overview]
Message-ID: <20190128154341.47195-184-sashal@kernel.org> (raw)
In-Reply-To: <20190128154341.47195-1-sashal@kernel.org>

From: Nicholas Mc Guire <hofrat@osadl.org>

[ Upstream commit b0d06f1cb0e2079a3c64fb6e27c19d9a55c723a1 ]

devm_kasprintf() may return NULL on failure of internal allocation thus
the assignments to  init.name  are not safe if not checked. On error
meson_mx_mmc_register_clks() returns negative values so -ENOMEM in the
(unlikely) failure case of devm_kasprintf() should be fine here.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Fixes: ed80a13bb4c4 ("mmc: meson-mx-sdio: Add a driver for the Amlogic Meson8 and Meson8b SoCs")
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/mmc/host/meson-mx-sdio.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/mmc/host/meson-mx-sdio.c b/drivers/mmc/host/meson-mx-sdio.c
index abe253c262a2..ec980bda071c 100644
--- a/drivers/mmc/host/meson-mx-sdio.c
+++ b/drivers/mmc/host/meson-mx-sdio.c
@@ -596,6 +596,9 @@ static int meson_mx_mmc_register_clks(struct meson_mx_mmc_host *host)
 	init.name = devm_kasprintf(host->controller_dev, GFP_KERNEL,
 				   "%s#fixed_factor",
 				   dev_name(host->controller_dev));
+	if (!init.name)
+		return -ENOMEM;
+
 	init.ops = &clk_fixed_factor_ops;
 	init.flags = 0;
 	init.parent_names = &clk_fixed_factor_parent;
@@ -612,6 +615,9 @@ static int meson_mx_mmc_register_clks(struct meson_mx_mmc_host *host)
 	clk_div_parent = __clk_get_name(host->fixed_factor_clk);
 	init.name = devm_kasprintf(host->controller_dev, GFP_KERNEL,
 				   "%s#div", dev_name(host->controller_dev));
+	if (!init.name)
+		return -ENOMEM;
+
 	init.ops = &clk_divider_ops;
 	init.flags = CLK_SET_RATE_PARENT;
 	init.parent_names = &clk_div_parent;
-- 
2.19.1


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

  parent reply	other threads:[~2019-01-28 15:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190128154341.47195-1-sashal@kernel.org>
2019-01-28 15:39 ` [PATCH AUTOSEL 4.20 073/304] clk: meson: meson8b: do not use cpu_div3 for cpu_scale_out_sel Sasha Levin
2019-01-28 15:39 ` [PATCH AUTOSEL 4.20 074/304] clk: meson: meson8b: fix the width of the cpu_scale_div clock Sasha Levin
2019-01-28 15:39 ` [PATCH AUTOSEL 4.20 075/304] clk: meson: meson8b: mark the CPU clock as CLK_IS_CRITICAL Sasha Levin
2019-01-28 15:39 ` [PATCH AUTOSEL 4.20 079/304] iio: adc: meson-saradc: check for devm_kasprintf failure Sasha Levin
2019-01-28 15:39 ` [PATCH AUTOSEL 4.20 080/304] iio: adc: meson-saradc: fix internal clock names Sasha Levin
2019-01-28 15:41 ` [PATCH AUTOSEL 4.20 145/304] arm64: dts: meson: Fix IRQ trigger type for macirq Sasha Levin
2019-01-28 15:41 ` Sasha Levin [this message]
2019-01-28 15:42 ` [PATCH AUTOSEL 4.20 255/304] pinctrl: meson: meson8: fix the GPIO function for the GPIOAO pins Sasha Levin
2019-01-28 15:42 ` [PATCH AUTOSEL 4.20 256/304] pinctrl: meson: meson8b: " Sasha Levin

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=20190128154341.47195-184-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=hofrat@osadl.org \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=ulf.hansson@linaro.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;
as well as URLs for NNTP newsgroup(s).