2022-03-01 08:01:50

by Yang Li

[permalink] [raw]
Subject: [PATCH -next] ASoC: amd: Fix an ignored error return from platform_get_irq_byname()

The return from the call to platform_get_irq_byname() is int, it can be
a negative error code, however this is being assigned to an unsigned
int variable 'adata->i2s_irq', so assign the value to 'ret' concurrently
to solve this problem without affecting other functions.

Eliminate the following coccicheck warning:
./sound/soc/amd/acp/acp-renoir.c:286:5-19: WARNING: Unsigned expression
compared with zero: adata -> i2s_irq < 0

Reported-by: Abaci Robot <[email protected]>
Fixes: 3304a242f45a ("ASoC: amd: Use platform_get_irq_byname() to get the interrupt")
Signed-off-by: Yang Li <[email protected]>
---
sound/soc/amd/acp/acp-renoir.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/amd/acp/acp-renoir.c b/sound/soc/amd/acp/acp-renoir.c
index 738cf2e2b973..64e824161091 100644
--- a/sound/soc/amd/acp/acp-renoir.c
+++ b/sound/soc/amd/acp/acp-renoir.c
@@ -282,8 +282,8 @@ static int renoir_audio_probe(struct platform_device *pdev)
if (!adata->acp_base)
return -ENOMEM;

- adata->i2s_irq = platform_get_irq_byname(pdev, "acp_dai_irq");
- if (adata->i2s_irq < 0)
+ adata->i2s_irq = ret = platform_get_irq_byname(pdev, "acp_dai_irq");
+ if (ret < 0)
return -ENODEV;

adata->dev = dev;
--
2.20.1.7.g153144c


2022-03-01 17:37:39

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH -next] ASoC: amd: Fix an ignored error return from platform_get_irq_byname()

On Tue, Mar 01, 2022 at 02:49:20PM +0800, Yang Li wrote:

> - adata->i2s_irq = platform_get_irq_byname(pdev, "acp_dai_irq");
> - if (adata->i2s_irq < 0)
> + adata->i2s_irq = ret = platform_get_irq_byname(pdev, "acp_dai_irq");
> + if (ret < 0)
> return -ENODEV;

If an error code is being returned we should report that error code
rather than squashing it down to -ENODEV.


Attachments:
(No filename) (385.00 B)
signature.asc (499.00 B)
Download all attachments