netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 net-next] dpll: Add an assertion to check freq_supported_num
@ 2025-02-28 15:02 Jiasheng Jiang
  2025-02-28 15:22 ` Jiri Pirko
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jiasheng Jiang @ 2025-02-28 15:02 UTC (permalink / raw)
  To: przemyslaw.kitszel
  Cc: arkadiusz.kubalewski, davem, jan.glaza, jiashengjiangcool, jiri,
	linux-kernel, netdev, stable, vadim.fedorenko

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.

Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
---
Changelog:

v3 -> v4:

1. Add return after WARN_ON().

v2 -> v3:

1. Add "net-next" to the subject.
2. Remove the "Fixes" tag and "Cc: stable".
3. Replace BUG_ON with WARN_ON.

v1 -> v2:

1. Replace the check with an assertion.
---
 drivers/dpll/dpll_core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
index 32019dc33cca..940c26b9dd53 100644
--- a/drivers/dpll/dpll_core.c
+++ b/drivers/dpll/dpll_core.c
@@ -443,8 +443,11 @@ 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)
 {
+	if (WARN_ON(src->freq_supported && !src->freq_supported_num))
+		return -EINVAL;
+
 	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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 net-next] dpll: Add an assertion to check freq_supported_num
  2025-02-28 15:02 [PATCH v4 net-next] dpll: Add an assertion to check freq_supported_num Jiasheng Jiang
@ 2025-02-28 15:22 ` Jiri Pirko
  2025-02-28 16:37 ` Vadim Fedorenko
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Jiri Pirko @ 2025-02-28 15:22 UTC (permalink / raw)
  To: Jiasheng Jiang
  Cc: przemyslaw.kitszel, arkadiusz.kubalewski, davem, jan.glaza,
	linux-kernel, netdev, stable, vadim.fedorenko

Fri, Feb 28, 2025 at 04:02:10PM +0100, jiashengjiangcool@gmail.com wrote:
>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.
>
>Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>

Reviewed-by: Jiri Pirko <jiri@nvidia.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 net-next] dpll: Add an assertion to check freq_supported_num
  2025-02-28 15:02 [PATCH v4 net-next] dpll: Add an assertion to check freq_supported_num Jiasheng Jiang
  2025-02-28 15:22 ` Jiri Pirko
@ 2025-02-28 16:37 ` Vadim Fedorenko
  2025-02-28 16:42 ` Kubalewski, Arkadiusz
  2025-03-05  1:20 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Vadim Fedorenko @ 2025-02-28 16:37 UTC (permalink / raw)
  To: Jiasheng Jiang, przemyslaw.kitszel
  Cc: arkadiusz.kubalewski, davem, jan.glaza, jiri, linux-kernel,
	netdev, stable

On 28/02/2025 15:02, Jiasheng Jiang wrote:
> 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.
> 
> Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>

Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH v4 net-next] dpll: Add an assertion to check freq_supported_num
  2025-02-28 15:02 [PATCH v4 net-next] dpll: Add an assertion to check freq_supported_num Jiasheng Jiang
  2025-02-28 15:22 ` Jiri Pirko
  2025-02-28 16:37 ` Vadim Fedorenko
@ 2025-02-28 16:42 ` Kubalewski, Arkadiusz
  2025-03-05  1:20 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Kubalewski, Arkadiusz @ 2025-02-28 16:42 UTC (permalink / raw)
  To: Jiasheng Jiang, Kitszel, Przemyslaw
  Cc: davem@davemloft.net, Glaza, Jan, jiri@resnulli.us,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	stable@vger.kernel.org, vadim.fedorenko@linux.dev

>From: Jiasheng Jiang <jiashengjiangcool@gmail.com>
>Sent: Friday, February 28, 2025 4:02 PM
>
>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.
>
>Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>

LGTM, thanks!

Reviewed-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>

[..]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 net-next] dpll: Add an assertion to check freq_supported_num
  2025-02-28 15:02 [PATCH v4 net-next] dpll: Add an assertion to check freq_supported_num Jiasheng Jiang
                   ` (2 preceding siblings ...)
  2025-02-28 16:42 ` Kubalewski, Arkadiusz
@ 2025-03-05  1:20 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-03-05  1:20 UTC (permalink / raw)
  To: Jiasheng Jiang
  Cc: przemyslaw.kitszel, arkadiusz.kubalewski, davem, jan.glaza, jiri,
	linux-kernel, netdev, stable, vadim.fedorenko

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 28 Feb 2025 15:02:10 +0000 you wrote:
> 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.
> 
> Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
> ---
> Changelog:
> 
> [...]

Here is the summary with links:
  - [v4,net-next] dpll: Add an assertion to check freq_supported_num
    https://git.kernel.org/netdev/net-next/c/39e912a959c1

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-03-05  1:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-28 15:02 [PATCH v4 net-next] dpll: Add an assertion to check freq_supported_num Jiasheng Jiang
2025-02-28 15:22 ` Jiri Pirko
2025-02-28 16:37 ` Vadim Fedorenko
2025-02-28 16:42 ` Kubalewski, Arkadiusz
2025-03-05  1:20 ` patchwork-bot+netdevbpf

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).