mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiasheng Jiang <jiashengjiangcool@gmail.com>
To: jiri@resnulli.us
Cc: arkadiusz.kubalewski@intel.com, davem@davemloft.net,
	jan.glaza@intel.com, jiashengjiangcool@gmail.com,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	przemyslaw.kitszel@intel.com, stable@vger.kernel.org,
	vadim.fedorenko@linux.dev
Subject: [PATCH v2] dpll: Add an assertion to check freq_supported_num
Date: Wed, 26 Feb 2025 03:09:30 +0000	[thread overview]
Message-ID: <20250226030930.20574-1-jiashengjiangcool@gmail.com> (raw)
In-Reply-To: <txrxpe7tmpsyiu4cwjd2gbs3udogmzdo5ertjwmhbeynu23iep@dcryfdoi7o5x>

Since the driver is broken in the case that src->freq_supported is not
NULL but src->freq_supported_num is 0, add an assertion for it.

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>
---
Changelog:

v1 -> v2:

1. Replace the check with an assertion.
---
 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..3296776c1ebb 100644
--- a/drivers/dpll/dpll_core.c
+++ b/drivers/dpll/dpll_core.c
@@ -443,8 +443,9 @@ static void dpll_pin_prop_free(struct dpll_pin_properties *prop)
 static int dpll_pin_prop_dup(const struct dpll_pin_properties *src,
 			     struct dpll_pin_properties *dst)
 {
+	BUG_ON(src->freq_supported && !src->freq_supported_num);
 	memcpy(dst, src, sizeof(*dst));
-	if (src->freq_supported && src->freq_supported_num) {
+	if (src->freq_supported) {
 		size_t freq_size = src->freq_supported_num *
 				   sizeof(*src->freq_supported);
 		dst->freq_supported = kmemdup(src->freq_supported,
-- 
2.25.1


  reply	other threads:[~2025-02-26  3:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-23 20:17 [PATCH] dpll: Add a check before kfree() to match the existing check before kmemdup() Jiasheng Jiang
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         ` Jiasheng Jiang [this message]
2025-02-26 14:24           ` [PATCH v2] dpll: Add an assertion to check freq_supported_num 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=20250226030930.20574-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®