imx.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: SOF: imx: Fix devm_ioremap_resource check
@ 2025-09-01 15:15 Daniel Baluta
  2025-09-01 15:35 ` Mark Brown
  2025-09-02  6:33 ` Dan Carpenter
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Baluta @ 2025-09-01 15:15 UTC (permalink / raw)
  To: broonie
  Cc: linux-sound, imx, linux-kernel, Frank.Li, robh,
	laurentiu.mihalcea, dan.carpenter, waqar.hameed, festevam, kernel,
	lgirdwood, peter.ujfalusi, yung-chuan.liao, ranjani.sridharan,
	kai.vehmanen, Daniel Baluta

devm_ioremap_resource does not return NULL on error
but an error pointer so we need to use IS_ERR to check
the return code.

Fixes: bc163baef570 ("ASoC: Use of_reserved_mem_region_to_resource() for "memory-region"")
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
---
 sound/soc/sof/imx/imx-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/sof/imx/imx-common.c b/sound/soc/sof/imx/imx-common.c
index 40debc541bf9..b3248c65215d 100644
--- a/sound/soc/sof/imx/imx-common.c
+++ b/sound/soc/sof/imx/imx-common.c
@@ -316,7 +316,7 @@ static int imx_parse_ioremap_memory(struct snd_sof_dev *sdev)
 		}
 
 		sdev->bar[blk_type] = devm_ioremap_resource(sdev->dev, res);
-		if (!sdev->bar[blk_type])
+		if (IS_ERR(sdev->bar[blk_type]))
 			return dev_err_probe(sdev->dev,
 					     -ENOMEM,
 					     "failed to ioremap %s region\n",
-- 
2.45.2


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

* Re: [PATCH] ASoC: SOF: imx: Fix devm_ioremap_resource check
  2025-09-01 15:15 [PATCH] ASoC: SOF: imx: Fix devm_ioremap_resource check Daniel Baluta
@ 2025-09-01 15:35 ` Mark Brown
  2025-09-02  6:33 ` Dan Carpenter
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2025-09-01 15:35 UTC (permalink / raw)
  To: Daniel Baluta
  Cc: linux-sound, imx, linux-kernel, Frank.Li, robh,
	laurentiu.mihalcea, dan.carpenter, waqar.hameed, festevam, kernel,
	lgirdwood, peter.ujfalusi, yung-chuan.liao, ranjani.sridharan,
	kai.vehmanen

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

On Mon, Sep 01, 2025 at 06:15:13PM +0300, Daniel Baluta wrote:
> devm_ioremap_resource does not return NULL on error
> but an error pointer so we need to use IS_ERR to check
> the return code.

>  		sdev->bar[blk_type] = devm_ioremap_resource(sdev->dev, res);
> -		if (!sdev->bar[blk_type])
> +		if (IS_ERR(sdev->bar[blk_type]))
>  			return dev_err_probe(sdev->dev,
>  					     -ENOMEM,
>  					     "failed to ioremap %s region\n",

If it's returning an error code we should feed that into dev_err_probe()
rather than hard coding to -ENOMEM.

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

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

* Re: [PATCH] ASoC: SOF: imx: Fix devm_ioremap_resource check
  2025-09-01 15:15 [PATCH] ASoC: SOF: imx: Fix devm_ioremap_resource check Daniel Baluta
  2025-09-01 15:35 ` Mark Brown
@ 2025-09-02  6:33 ` Dan Carpenter
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2025-09-02  6:33 UTC (permalink / raw)
  To: Daniel Baluta
  Cc: broonie, linux-sound, imx, linux-kernel, Frank.Li, robh,
	laurentiu.mihalcea, waqar.hameed, festevam, kernel, lgirdwood,
	peter.ujfalusi, yung-chuan.liao, ranjani.sridharan, kai.vehmanen

On Mon, Sep 01, 2025 at 06:15:13PM +0300, Daniel Baluta wrote:
> devm_ioremap_resource does not return NULL on error
> but an error pointer so we need to use IS_ERR to check
> the return code.
> 
> Fixes: bc163baef570 ("ASoC: Use of_reserved_mem_region_to_resource() for "memory-region"")
> Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
> ---
>  sound/soc/sof/imx/imx-common.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/soc/sof/imx/imx-common.c b/sound/soc/sof/imx/imx-common.c
> index 40debc541bf9..b3248c65215d 100644
> --- a/sound/soc/sof/imx/imx-common.c
> +++ b/sound/soc/sof/imx/imx-common.c
> @@ -316,7 +316,7 @@ static int imx_parse_ioremap_memory(struct snd_sof_dev *sdev)
>  		}
>  
>  		sdev->bar[blk_type] = devm_ioremap_resource(sdev->dev, res);
> -		if (!sdev->bar[blk_type])
> +		if (IS_ERR(sdev->bar[blk_type]))
>  			return dev_err_probe(sdev->dev,
>  					     -ENOMEM,

It's annoying that I didn't catch this bug.  It's because the error
pointer was stored in an array instead of a a "simple" variable.
Smatch does actually have a lower quality warning for this but I
wasn't reviewing them since that check had too many false positives.

I've done a little hack around, so this bug will be caught in the
future and it found a few other similar bugs which I've fixed as well.

regards,
dan carpenter


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

end of thread, other threads:[~2025-09-02  6:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-01 15:15 [PATCH] ASoC: SOF: imx: Fix devm_ioremap_resource check Daniel Baluta
2025-09-01 15:35 ` Mark Brown
2025-09-02  6:33 ` Dan Carpenter

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