All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiasheng Jiang <jiasheng@iscas.ac.cn>
To: mturquette@baylibre.com, sboyd@kernel.org,
	matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com,
	wenst@chromium.org, msp@baylibre.com, amergnat@baylibre.com,
	frank.li@vivo.com, robh@kernel.org, owen.chen@mediatek.com,
	mars.cheng@mediatek.com, macpaul.lin@mediatek.com,
	cw00.choi@samsung.com, u.kleine-koenig@pengutronix.de,
	wendell.lin@mediatek.com, luca.ceresoli@bootlin.com,
	kevin-cw.chen@mediatek.com, ryder.lee@mediatek.com,
	wenzhen.yu@mediatek.com
Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org,
	Jiasheng Jiang <jiasheng@iscas.ac.cn>
Subject: [PATCH 3/5] clk: mediatek: clk-mt6797: Add check for mtk_alloc_clk_data
Date: Tue, 12 Sep 2023 17:34:05 +0800	[thread overview]
Message-ID: <20230912093407.21505-3-jiasheng@iscas.ac.cn> (raw)
In-Reply-To: <20230912093407.21505-1-jiasheng@iscas.ac.cn>

Add the check for the return value of mtk_alloc_clk_data() in order to
avoid NULL pointer dereference.

Fixes: 96596aa06628 ("clk: mediatek: add clk support for MT6797")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/clk/mediatek/clk-mt6797.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/clk/mediatek/clk-mt6797.c b/drivers/clk/mediatek/clk-mt6797.c
index 2ebd25f0ce71..f12d4e9ff0bb 100644
--- a/drivers/clk/mediatek/clk-mt6797.c
+++ b/drivers/clk/mediatek/clk-mt6797.c
@@ -390,6 +390,8 @@ static int mtk_topckgen_init(struct platform_device *pdev)
 		return PTR_ERR(base);
 
 	clk_data = mtk_alloc_clk_data(CLK_TOP_NR);
+	if (!clk_data)
+		return -ENOMEM;
 
 	mtk_clk_register_factors(top_fixed_divs, ARRAY_SIZE(top_fixed_divs),
 				 clk_data);
@@ -545,6 +547,8 @@ static void mtk_infrasys_init_early(struct device_node *node)
 
 	if (!infra_clk_data) {
 		infra_clk_data = mtk_alloc_clk_data(CLK_INFRA_NR);
+		if (!infra_clk_data)
+			return;
 
 		for (i = 0; i < CLK_INFRA_NR; i++)
 			infra_clk_data->hws[i] = ERR_PTR(-EPROBE_DEFER);
@@ -570,6 +574,8 @@ static int mtk_infrasys_init(struct platform_device *pdev)
 
 	if (!infra_clk_data) {
 		infra_clk_data = mtk_alloc_clk_data(CLK_INFRA_NR);
+		if (!infra_clk_data)
+			return -ENOMEM;
 	} else {
 		for (i = 0; i < CLK_INFRA_NR; i++) {
 			if (infra_clk_data->hws[i] == ERR_PTR(-EPROBE_DEFER))
-- 
2.25.1


WARNING: multiple messages have this Message-ID (diff)
From: Jiasheng Jiang <jiasheng@iscas.ac.cn>
To: mturquette@baylibre.com, sboyd@kernel.org,
	matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com,
	wenst@chromium.org, msp@baylibre.com, amergnat@baylibre.com,
	frank.li@vivo.com, robh@kernel.org, owen.chen@mediatek.com,
	mars.cheng@mediatek.com, macpaul.lin@mediatek.com,
	cw00.choi@samsung.com, u.kleine-koenig@pengutronix.de,
	wendell.lin@mediatek.com, luca.ceresoli@bootlin.com,
	kevin-cw.chen@mediatek.com, ryder.lee@mediatek.com,
	wenzhen.yu@mediatek.com
Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org,
	Jiasheng Jiang <jiasheng@iscas.ac.cn>
Subject: [PATCH 3/5] clk: mediatek: clk-mt6797: Add check for mtk_alloc_clk_data
Date: Tue, 12 Sep 2023 17:34:05 +0800	[thread overview]
Message-ID: <20230912093407.21505-3-jiasheng@iscas.ac.cn> (raw)
In-Reply-To: <20230912093407.21505-1-jiasheng@iscas.ac.cn>

Add the check for the return value of mtk_alloc_clk_data() in order to
avoid NULL pointer dereference.

Fixes: 96596aa06628 ("clk: mediatek: add clk support for MT6797")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/clk/mediatek/clk-mt6797.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/clk/mediatek/clk-mt6797.c b/drivers/clk/mediatek/clk-mt6797.c
index 2ebd25f0ce71..f12d4e9ff0bb 100644
--- a/drivers/clk/mediatek/clk-mt6797.c
+++ b/drivers/clk/mediatek/clk-mt6797.c
@@ -390,6 +390,8 @@ static int mtk_topckgen_init(struct platform_device *pdev)
 		return PTR_ERR(base);
 
 	clk_data = mtk_alloc_clk_data(CLK_TOP_NR);
+	if (!clk_data)
+		return -ENOMEM;
 
 	mtk_clk_register_factors(top_fixed_divs, ARRAY_SIZE(top_fixed_divs),
 				 clk_data);
@@ -545,6 +547,8 @@ static void mtk_infrasys_init_early(struct device_node *node)
 
 	if (!infra_clk_data) {
 		infra_clk_data = mtk_alloc_clk_data(CLK_INFRA_NR);
+		if (!infra_clk_data)
+			return;
 
 		for (i = 0; i < CLK_INFRA_NR; i++)
 			infra_clk_data->hws[i] = ERR_PTR(-EPROBE_DEFER);
@@ -570,6 +574,8 @@ static int mtk_infrasys_init(struct platform_device *pdev)
 
 	if (!infra_clk_data) {
 		infra_clk_data = mtk_alloc_clk_data(CLK_INFRA_NR);
+		if (!infra_clk_data)
+			return -ENOMEM;
 	} else {
 		for (i = 0; i < CLK_INFRA_NR; i++) {
 			if (infra_clk_data->hws[i] == ERR_PTR(-EPROBE_DEFER))
-- 
2.25.1


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

  parent reply	other threads:[~2023-09-12  9:34 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-12  9:34 [PATCH 1/5] clk: mediatek: clk-mt6765: Add check for mtk_alloc_clk_data Jiasheng Jiang
2023-09-12  9:34 ` Jiasheng Jiang
2023-09-12  9:34 ` [PATCH 2/5] clk: mediatek: clk-mt6779: " Jiasheng Jiang
2023-09-12  9:34   ` Jiasheng Jiang
2023-09-12 10:02   ` AngeloGioacchino Del Regno
2023-09-12 10:02     ` AngeloGioacchino Del Regno
2023-10-19  1:15   ` Stephen Boyd
2023-10-19  1:15     ` Stephen Boyd
2023-09-12  9:34 ` Jiasheng Jiang [this message]
2023-09-12  9:34   ` [PATCH 3/5] clk: mediatek: clk-mt6797: " Jiasheng Jiang
2023-09-12 10:02   ` AngeloGioacchino Del Regno
2023-09-12 10:02     ` AngeloGioacchino Del Regno
2023-10-19  1:15   ` Stephen Boyd
2023-10-19  1:15     ` Stephen Boyd
2023-09-12  9:34 ` [PATCH 4/5] clk: mediatek: clk-mt7629-eth: " Jiasheng Jiang
2023-09-12  9:34   ` Jiasheng Jiang
2023-09-12 10:02   ` AngeloGioacchino Del Regno
2023-09-12 10:02     ` AngeloGioacchino Del Regno
2023-10-19  1:15   ` Stephen Boyd
2023-10-19  1:15     ` Stephen Boyd
2023-09-12  9:34 ` [PATCH 5/5] clk: mediatek: clk-mt7629: " Jiasheng Jiang
2023-09-12  9:34   ` Jiasheng Jiang
2023-09-12 10:02   ` AngeloGioacchino Del Regno
2023-09-12 10:02     ` AngeloGioacchino Del Regno
2023-10-19  1:16   ` Stephen Boyd
2023-10-19  1:16     ` Stephen Boyd
2023-09-12 10:02 ` [PATCH 1/5] clk: mediatek: clk-mt6765: " AngeloGioacchino Del Regno
2023-09-12 10:02   ` AngeloGioacchino Del Regno
2023-10-19  1:15 ` Stephen Boyd
2023-10-19  1:15   ` Stephen Boyd

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=20230912093407.21505-3-jiasheng@iscas.ac.cn \
    --to=jiasheng@iscas.ac.cn \
    --cc=amergnat@baylibre.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=cw00.choi@samsung.com \
    --cc=frank.li@vivo.com \
    --cc=kevin-cw.chen@mediatek.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=luca.ceresoli@bootlin.com \
    --cc=macpaul.lin@mediatek.com \
    --cc=mars.cheng@mediatek.com \
    --cc=matthias.bgg@gmail.com \
    --cc=msp@baylibre.com \
    --cc=mturquette@baylibre.com \
    --cc=owen.chen@mediatek.com \
    --cc=robh@kernel.org \
    --cc=ryder.lee@mediatek.com \
    --cc=sboyd@kernel.org \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=wendell.lin@mediatek.com \
    --cc=wenst@chromium.org \
    --cc=wenzhen.yu@mediatek.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.