linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix possible NULL Pointer Dereference in 'asoc_qcom_lpass_cpu_platform_probe'
@ 2024-09-30  1:15 Gax-c
  2024-09-30 16:33 ` Markus Elfring
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Gax-c @ 2024-09-30  1:15 UTC (permalink / raw)
  To: srinivas.kandagatla, lgirdwood, broonie, perex, tiwai, rohitkr
  Cc: alsa-devel, linux-arm-msm, linux-sound, Gax-c, Zijie Zhao,
	Chenyuan Yang

A 'devm_kzalloc' in 'asoc_qcom_lpass_cpu_platform_probe' could possibly return NULL pointer.
NULL Pointer Dereference may be triggerred in 'asoc_qcom_lpass_cpu_platform_probe' without addtional check.
Add a null check for the returned pointer.

Fixes: b5022a36d28f ("ASoC: qcom: lpass: Use regmap_field for i2sctl and dmactl registers")
Signed-off-by: Zichen Xie <zichenxie0106@gmail.com>
Reported-by: Zichen Xie <zichenxie0106@gmail.com>
Reported-by: Zijie Zhao <zzjas98@gmail.com>
Reported-by: Chenyuan Yang <chenyuan0y@gmail.com>
---
 sound/soc/qcom/lpass-cpu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sound/soc/qcom/lpass-cpu.c b/sound/soc/qcom/lpass-cpu.c
index 5a47f661e0c6..a8e56f47f237 100644
--- a/sound/soc/qcom/lpass-cpu.c
+++ b/sound/soc/qcom/lpass-cpu.c
@@ -1243,6 +1243,9 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev)
 	drvdata->i2sctl = devm_kzalloc(&pdev->dev, sizeof(struct lpaif_i2sctl),
 					GFP_KERNEL);
 
+	if (!drvdata->i2sctl)
+		return -ENOMEM;
+
 	/* Initialize bitfields for dai I2SCTL register */
 	ret = lpass_cpu_init_i2sctl_bitfields(dev, drvdata->i2sctl,
 						drvdata->lpaif_map);
-- 
2.25.1


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

* Re: [PATCH] Fix possible NULL Pointer Dereference in 'asoc_qcom_lpass_cpu_platform_probe'
  2024-09-30  1:15 [PATCH] Fix possible NULL Pointer Dereference in 'asoc_qcom_lpass_cpu_platform_probe' Gax-c
@ 2024-09-30 16:33 ` Markus Elfring
  2024-09-30 18:16   ` Mark Brown
  2024-09-30 17:12 ` [PATCH] " Bjorn Andersson
  2024-10-01 19:44 ` Krzysztof Kozlowski
  2 siblings, 1 reply; 8+ messages in thread
From: Markus Elfring @ 2024-09-30 16:33 UTC (permalink / raw)
  To: Zichen Xie, alsa-devel, linux-sound, linux-arm-msm,
	Jaroslav Kysela, Liam Girdwood, Mark Brown, Rohit kumar,
	Srinivas Kandagatla, Takashi Iwai
  Cc: LKML, Zijie Zhao, Chenyuan Yang

> A 'devm_kzalloc' in 'asoc_qcom_lpass_cpu_platform_probe' could possibly return NULL pointer.
> NULL Pointer Dereference may be triggerred in 'asoc_qcom_lpass_cpu_platform_probe' without addtional check.
> Add a null check for the returned pointer.

How do you think about a wording variant like the following?

  The result from a call of the function “devm_kzalloc” was passed to
  a subsequent function call without checking for a null pointer before
  (according to a memory allocation failure).
  Thus return directly after a failed devm_kzalloc() call.


…
> Signed-off-by: Zichen Xie <zichenxie0106@gmail.com>
> Reported-by: Zichen Xie <zichenxie0106@gmail.com>
…

How good does such a tag combination fit together for the same person?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.12-rc1#n525


Can a subject like “[PATCH] ASoC: qcom: lpass-cpu: Return directly after a failed devm_kzalloc() call
in asoc_qcom_lpass_cpu_platform_probe()” be more appropriate?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.12-rc1#n613> +++ b/sound/soc/qcom/lpass-cpu.c
> @@ -1243,6 +1243,9 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev)
>  	drvdata->i2sctl = devm_kzalloc(&pdev->dev, sizeof(struct lpaif_i2sctl),
>  					GFP_KERNEL);
>
> +	if (!drvdata->i2sctl)
> +		return -ENOMEM;
…

I suggest to omit a blank line here.


By the way:
Would you become interested to omit the label “err” from this function implementation finally?

Regards,
Markus

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

* Re: [PATCH] Fix possible NULL Pointer Dereference in 'asoc_qcom_lpass_cpu_platform_probe'
  2024-09-30  1:15 [PATCH] Fix possible NULL Pointer Dereference in 'asoc_qcom_lpass_cpu_platform_probe' Gax-c
  2024-09-30 16:33 ` Markus Elfring
@ 2024-09-30 17:12 ` Bjorn Andersson
  2024-10-01 12:48   ` Markus Elfring
  2024-10-01 19:44 ` Krzysztof Kozlowski
  2 siblings, 1 reply; 8+ messages in thread
From: Bjorn Andersson @ 2024-09-30 17:12 UTC (permalink / raw)
  To: Gax-c
  Cc: srinivas.kandagatla, lgirdwood, broonie, perex, tiwai, rohitkr,
	alsa-devel, linux-arm-msm, linux-sound, Zijie Zhao, Chenyuan Yang

On Sun, Sep 29, 2024 at 08:15:22PM -0500, Gax-c wrote:
> A 'devm_kzalloc' in 'asoc_qcom_lpass_cpu_platform_probe' could possibly return NULL pointer.
> NULL Pointer Dereference may be triggerred in 'asoc_qcom_lpass_cpu_platform_probe' without addtional check.
> Add a null check for the returned pointer.
> 

Your description and patch looks good to me.


But please run git log on the changed file and add a prefix to your
subject to match other changes to this file, and please wrap your commit
message at 75 characters.

A good resource to read about this is:
https://www.kernel.org/doc/html/latest/process/submitting-patches.html#the-canonical-patch-format

Please also use the form devm_kzalloc() instead of 'devm_kzalloc' when
referring to kernel functions.

It seems reasonable to mark this for backporting to stable, so I'd also
suggest adding the following tag:

Cc: stable@vger.kernel.org
> Fixes: b5022a36d28f ("ASoC: qcom: lpass: Use regmap_field for i2sctl and dmactl registers")
> Signed-off-by: Zichen Xie <zichenxie0106@gmail.com>
> Reported-by: Zichen Xie <zichenxie0106@gmail.com>
> Reported-by: Zijie Zhao <zzjas98@gmail.com>
> Reported-by: Chenyuan Yang <chenyuan0y@gmail.com>
> ---
>  sound/soc/qcom/lpass-cpu.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/sound/soc/qcom/lpass-cpu.c b/sound/soc/qcom/lpass-cpu.c
> index 5a47f661e0c6..a8e56f47f237 100644
> --- a/sound/soc/qcom/lpass-cpu.c
> +++ b/sound/soc/qcom/lpass-cpu.c
> @@ -1243,6 +1243,9 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev)
>  	drvdata->i2sctl = devm_kzalloc(&pdev->dev, sizeof(struct lpaif_i2sctl),
>  					GFP_KERNEL);
>  

Please drop this empty line.

Regards,
Bjorn

> +	if (!drvdata->i2sctl)
> +		return -ENOMEM;
> +
>  	/* Initialize bitfields for dai I2SCTL register */
>  	ret = lpass_cpu_init_i2sctl_bitfields(dev, drvdata->i2sctl,
>  						drvdata->lpaif_map);
> -- 
> 2.25.1
> 
> 
> 
> 
> 

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

* Re: [PATCH] Fix possible NULL Pointer Dereference in 'asoc_qcom_lpass_cpu_platform_probe'
  2024-09-30 16:33 ` Markus Elfring
@ 2024-09-30 18:16   ` Mark Brown
  2024-10-01  5:30     ` Markus Elfring
  0 siblings, 1 reply; 8+ messages in thread
From: Mark Brown @ 2024-09-30 18:16 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Zichen Xie, alsa-devel, linux-sound, linux-arm-msm,
	Jaroslav Kysela, Liam Girdwood, Rohit kumar, Srinivas Kandagatla,
	Takashi Iwai, LKML, Zijie Zhao, Chenyuan Yang

[-- Attachment #1: Type: text/plain, Size: 539 bytes --]

On Mon, Sep 30, 2024 at 06:33:49PM +0200, Markus Elfring wrote:

> How do you think about a wording variant like the following?

>   The result from a call of the function “devm_kzalloc” was passed to
>   a subsequent function call without checking for a null pointer before
>   (according to a memory allocation failure).
>   Thus return directly after a failed devm_kzalloc() call.

Feel free to ignore Markus, he has a long history of sending
unhelpful review comments and continues to ignore repeated requests
to stop.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: Fix possible NULL Pointer Dereference in 'asoc_qcom_lpass_cpu_platform_probe'
  2024-09-30 18:16   ` Mark Brown
@ 2024-10-01  5:30     ` Markus Elfring
  0 siblings, 0 replies; 8+ messages in thread
From: Markus Elfring @ 2024-10-01  5:30 UTC (permalink / raw)
  To: Mark Brown, Zichen Xie, alsa-devel, linux-sound, linux-arm-msm,
	Jaroslav Kysela, Liam Girdwood, Rohit kumar, Srinivas Kandagatla,
	Takashi Iwai
  Cc: kernel-janitors, LKML, Zijie Zhao, Chenyuan Yang

>> How do you think about a wording variant like the following?
>
>>   The result from a call of the function “devm_kzalloc” was passed to
>>   a subsequent function call without checking for a null pointer before
>>   (according to a memory allocation failure).
>>   Thus return directly after a failed devm_kzalloc() call.
>
> Feel free to ignore Markus, he has a long history of sending
> unhelpful review comments and continues to ignore repeated requests
> to stop.

30 non-merge commits were published with related subjects so far.
Can you get a more constructive view from parts of public software development history?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?h=v6.12-rc1&qt=grep&q=Return+directly+after+a+failed

Regards,
Markus

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

* Re: [PATCH] Fix possible NULL Pointer Dereference in 'asoc_qcom_lpass_cpu_platform_probe'
  2024-09-30 17:12 ` [PATCH] " Bjorn Andersson
@ 2024-10-01 12:48   ` Markus Elfring
  2024-10-01 12:58     ` Mark Brown
  0 siblings, 1 reply; 8+ messages in thread
From: Markus Elfring @ 2024-10-01 12:48 UTC (permalink / raw)
  To: Bjorn Andersson, alsa-devel, linux-sound, linux-arm-msm
  Cc: LKML, Chenyuan Yang, Jaroslav Kysela, Liam Girdwood, Mark Brown,
	Rohit kumar, Srinivas Kandagatla, Takashi Iwai, Zichen Xie,
	Zijie Zhao

> > A 'devm_kzalloc' in 'asoc_qcom_lpass_cpu_platform_probe' could possibly return NULL pointer.
> > NULL Pointer Dereference may be triggerred in 'asoc_qcom_lpass_cpu_platform_probe' without addtional check.
> > Add a null check for the returned pointer.
>
> Your description and patch looks good to me.

Interesting “view” …


> But please run git log on the changed file and add a prefix to your
> subject to match other changes to this file, and please wrap your commit
> message at 75 characters.

* How does your initial information fit to this patch review advice?

* Would you like to “tolerate” any typos (at the first glance)?


Regards,
Markus

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

* Re: [PATCH] Fix possible NULL Pointer Dereference in 'asoc_qcom_lpass_cpu_platform_probe'
  2024-10-01 12:48   ` Markus Elfring
@ 2024-10-01 12:58     ` Mark Brown
  0 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2024-10-01 12:58 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Bjorn Andersson, alsa-devel, linux-sound, linux-arm-msm, LKML,
	Chenyuan Yang, Jaroslav Kysela, Liam Girdwood, Rohit kumar,
	Srinivas Kandagatla, Takashi Iwai, Zichen Xie, Zijie Zhao

[-- Attachment #1: Type: text/plain, Size: 292 bytes --]

On Tue, Oct 01, 2024 at 02:48:54PM +0200, Markus Elfring wrote:

> > Your description and patch looks good to me.

> Interesting “view” …

Feel free to ignore Markus, he has a long history of sending
unhelpful review comments and continues to ignore repeated requests
to stop.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] Fix possible NULL Pointer Dereference in 'asoc_qcom_lpass_cpu_platform_probe'
  2024-09-30  1:15 [PATCH] Fix possible NULL Pointer Dereference in 'asoc_qcom_lpass_cpu_platform_probe' Gax-c
  2024-09-30 16:33 ` Markus Elfring
  2024-09-30 17:12 ` [PATCH] " Bjorn Andersson
@ 2024-10-01 19:44 ` Krzysztof Kozlowski
  2 siblings, 0 replies; 8+ messages in thread
From: Krzysztof Kozlowski @ 2024-10-01 19:44 UTC (permalink / raw)
  To: Gax-c, srinivas.kandagatla, lgirdwood, broonie, perex, tiwai,
	rohitkr
  Cc: alsa-devel, linux-arm-msm, linux-sound, Zijie Zhao, Chenyuan Yang

On 30/09/2024 03:15, Gax-c wrote:
> A 'devm_kzalloc' in 'asoc_qcom_lpass_cpu_platform_probe' could possibly return NULL pointer.
> NULL Pointer Dereference may be triggerred in 'asoc_qcom_lpass_cpu_platform_probe' without addtional check.
> Add a null check for the returned pointer.

Please wrap commit message according to Linux coding style / submission
process (neither too early nor over the limit):
https://elixir.bootlin.com/linux/v6.4-rc1/source/Documentation/process/submitting-patches.rst#L597

> 
> Fixes: b5022a36d28f ("ASoC: qcom: lpass: Use regmap_field for i2sctl and dmactl registers")
> Signed-off-by: Zichen Xie <zichenxie0106@gmail.com>
> Reported-by: Zichen Xie <zichenxie0106@gmail.com>

Drop the unnecessary tag. You are the author.

> Reported-by: Zijie Zhao <zzjas98@gmail.com>
> Reported-by: Chenyuan Yang <chenyuan0y@gmail.com>

Why two people reported it? And where?

> ---
>  sound/soc/qcom/lpass-cpu.c | 3 +++
>  1 file changed, 3 insertions(+)


Best regards,
Krzysztof


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

end of thread, other threads:[~2024-10-01 19:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-30  1:15 [PATCH] Fix possible NULL Pointer Dereference in 'asoc_qcom_lpass_cpu_platform_probe' Gax-c
2024-09-30 16:33 ` Markus Elfring
2024-09-30 18:16   ` Mark Brown
2024-10-01  5:30     ` Markus Elfring
2024-09-30 17:12 ` [PATCH] " Bjorn Andersson
2024-10-01 12:48   ` Markus Elfring
2024-10-01 12:58     ` Mark Brown
2024-10-01 19:44 ` Krzysztof Kozlowski

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