From: Alexandra Diupina <adiupina@astralinux.ru> To: Nishanth Menon <nm@ti.com> Cc: Alexandra Diupina <adiupina@astralinux.ru>, Tero Kristo <kristo@kernel.org>, Santosh Shilimkar <ssantosh@kernel.org>, Michael Turquette <mturquette@baylibre.com>, Stephen Boyd <sboyd@kernel.org>, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] clk: keystone: sci-clk: check devm_kmalloc_array() return value Date: Wed, 10 Jan 2024 16:46:21 +0300 [thread overview] Message-ID: <20240110134621.17209-1-adiupina@astralinux.ru> (raw) devm_kmalloc_array() may return NULL, so check return value to avoid null pointer dereferencing Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 3c13933c6033 ("clk: keystone: sci-clk: add support for dynamically probing clocks") Signed-off-by: Alexandra Diupina <adiupina@astralinux.ru> --- drivers/clk/keystone/sci-clk.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c index 35fe197dd303..a2fa24e4f88a 100644 --- a/drivers/clk/keystone/sci-clk.c +++ b/drivers/clk/keystone/sci-clk.c @@ -459,6 +459,9 @@ static int ti_sci_scan_clocks_from_fw(struct sci_clk_provider *provider) tmp_clks = devm_kmalloc_array(dev, max_clks + 64, sizeof(sci_clk), GFP_KERNEL); + if (!tmp_clks) + return -ENOMEM; + memcpy(tmp_clks, clks, max_clks * sizeof(sci_clk)); if (max_clks) devm_kfree(dev, clks); -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: Alexandra Diupina <adiupina@astralinux.ru> To: Nishanth Menon <nm@ti.com> Cc: Alexandra Diupina <adiupina@astralinux.ru>, Tero Kristo <kristo@kernel.org>, Santosh Shilimkar <ssantosh@kernel.org>, Michael Turquette <mturquette@baylibre.com>, Stephen Boyd <sboyd@kernel.org>, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] clk: keystone: sci-clk: check devm_kmalloc_array() return value Date: Wed, 10 Jan 2024 16:46:21 +0300 [thread overview] Message-ID: <20240110134621.17209-1-adiupina@astralinux.ru> (raw) devm_kmalloc_array() may return NULL, so check return value to avoid null pointer dereferencing Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 3c13933c6033 ("clk: keystone: sci-clk: add support for dynamically probing clocks") Signed-off-by: Alexandra Diupina <adiupina@astralinux.ru> --- drivers/clk/keystone/sci-clk.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c index 35fe197dd303..a2fa24e4f88a 100644 --- a/drivers/clk/keystone/sci-clk.c +++ b/drivers/clk/keystone/sci-clk.c @@ -459,6 +459,9 @@ static int ti_sci_scan_clocks_from_fw(struct sci_clk_provider *provider) tmp_clks = devm_kmalloc_array(dev, max_clks + 64, sizeof(sci_clk), GFP_KERNEL); + if (!tmp_clks) + return -ENOMEM; + memcpy(tmp_clks, clks, max_clks * sizeof(sci_clk)); if (max_clks) devm_kfree(dev, clks); -- 2.30.2
next reply other threads:[~2024-01-10 13:47 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-01-10 13:46 Alexandra Diupina [this message] 2024-01-10 13:46 ` [PATCH] clk: keystone: sci-clk: check devm_kmalloc_array() return value Alexandra Diupina 2024-02-01 12:02 ` Александра Дюпина 2024-02-01 12:02 ` Александра Дюпина
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=20240110134621.17209-1-adiupina@astralinux.ru \ --to=adiupina@astralinux.ru \ --cc=kristo@kernel.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-clk@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=lvc-project@linuxtesting.org \ --cc=mturquette@baylibre.com \ --cc=nm@ti.com \ --cc=sboyd@kernel.org \ --cc=ssantosh@kernel.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: linkBe 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.