From: Jiasheng Jiang <jiashengjiangcool@gmail.com>
To: vadim.fedorenko@linux.dev, arkadiusz.kubalewski@intel.com,
jiri@resnulli.us, davem@davemloft.net, jan.glaza@intel.com,
przemyslaw.kitszel@intel.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Jiasheng Jiang <jiashengjiangcool@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH] dpll: Add a check before kfree() to match the existing check before kmemdup()
Date: Sun, 23 Feb 2025 20:17:09 +0000 [thread overview]
Message-ID: <20250223201709.4917-1-jiashengjiangcool@gmail.com> (raw)
When src->freq_supported is not NULL but src->freq_supported_num is 0,
dst->freq_supported is equal to src->freq_supported.
In this case, if the subsequent kstrdup() fails, src->freq_supported may
be freed without being set to NULL, potentially leading to a
use-after-free or double-free error.
Fixes: 830ead5fb0c5 ("dpll: fix pin dump crash for rebound module")
Cc: <stable@vger.kernel.org> # v6.8+
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
---
drivers/dpll/dpll_core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
index 32019dc33cca..7d147adf8455 100644
--- a/drivers/dpll/dpll_core.c
+++ b/drivers/dpll/dpll_core.c
@@ -475,7 +475,8 @@ static int dpll_pin_prop_dup(const struct dpll_pin_properties *src,
err_panel_label:
kfree(dst->board_label);
err_board_label:
- kfree(dst->freq_supported);
+ if (src->freq_supported_num)
+ kfree(dst->freq_supported);
return -ENOMEM;
}
--
2.25.1
next reply other threads:[~2025-02-23 20:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-23 20:17 Jiasheng Jiang [this message]
2025-02-24 9:31 ` Kubalewski, Arkadiusz
2025-02-24 12:04 ` Jiri Pirko
2025-02-24 16:47 ` Jiasheng Jiang
2025-02-25 12:08 ` Jiri Pirko
2025-02-26 3:09 ` [PATCH v2] dpll: Add an assertion to check freq_supported_num Jiasheng Jiang
2025-02-26 14:24 ` Jiri Pirko
2025-02-26 19:37 ` [PATCH v3 net-next] " Jiasheng Jiang
2025-02-27 5:21 ` Przemek Kitszel
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=20250223201709.4917-1-jiashengjiangcool@gmail.com \
--to=jiashengjiangcool@gmail.com \
--cc=arkadiusz.kubalewski@intel.com \
--cc=davem@davemloft.net \
--cc=jan.glaza@intel.com \
--cc=jiri@resnulli.us \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=przemyslaw.kitszel@intel.com \
--cc=stable@vger.kernel.org \
--cc=vadim.fedorenko@linux.dev \
/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®