diff mbox series

soundwire: amd: fix an IS_ERR() vs NULL bug

Message ID 3be30516-a1b0-412b-8379-06011855e46f@kili.mountain (mailing list archive)
State New, archived
Headers show
Series soundwire: amd: fix an IS_ERR() vs NULL bug | expand

Commit Message

Dan Carpenter April 6, 2023, 8:56 a.m. UTC
The devm_ioremap() function returns NULL on error.  It never returns
error pointers.  Update the error checking accordingly.

Fixes: a673a8dfc214 ("soundwire: amd: Add support for AMD Manager driver")
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
 drivers/soundwire/amd_manager.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Claudiu.Beznea--- via Alsa-devel April 6, 2023, 12:02 p.m. UTC | #1
On 06/04/23 14:26, Dan Carpenter wrote:
> The devm_ioremap() function returns NULL on error.  It never returns
> error pointers.  Update the error checking accordingly.
>
> Fixes: a673a8dfc214 ("soundwire: amd: Add support for AMD Manager driver")
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
>  drivers/soundwire/amd_manager.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/soundwire/amd_manager.c b/drivers/soundwire/amd_manager.c
> index 9fb7f91ca182..9bb8ae8c5f32 100644
> --- a/drivers/soundwire/amd_manager.c
> +++ b/drivers/soundwire/amd_manager.c
> @@ -910,9 +910,9 @@ static int amd_sdw_manager_probe(struct platform_device *pdev)
>  		return -ENOMEM;
>  
>  	amd_manager->acp_mmio = devm_ioremap(dev, res->start, resource_size(res));
> -	if (IS_ERR(amd_manager->mmio)) {
> +	if (!amd_manager->mmio) {
This will break the functionality.  Condition should be
if (!amd_manager->acp_mmio)

>  		dev_err(dev, "mmio not found\n");
> -		return PTR_ERR(amd_manager->mmio);
> +		return -ENOMEM;
>  	}
>  	amd_manager->instance = pdata->instance;
>  	amd_manager->mmio = amd_manager->acp_mmio +
Dan Carpenter April 6, 2023, 12:17 p.m. UTC | #2
On Thu, Apr 06, 2023 at 05:32:21PM +0530, Mukunda,Vijendar wrote:
> On 06/04/23 14:26, Dan Carpenter wrote:
> > The devm_ioremap() function returns NULL on error.  It never returns
> > error pointers.  Update the error checking accordingly.
> >
> > Fixes: a673a8dfc214 ("soundwire: amd: Add support for AMD Manager driver")
> > Signed-off-by: Dan Carpenter <error27@gmail.com>
> > ---
> >  drivers/soundwire/amd_manager.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/soundwire/amd_manager.c b/drivers/soundwire/amd_manager.c
> > index 9fb7f91ca182..9bb8ae8c5f32 100644
> > --- a/drivers/soundwire/amd_manager.c
> > +++ b/drivers/soundwire/amd_manager.c
> > @@ -910,9 +910,9 @@ static int amd_sdw_manager_probe(struct platform_device *pdev)
> >  		return -ENOMEM;
> >  
> >  	amd_manager->acp_mmio = devm_ioremap(dev, res->start, resource_size(res));
> > -	if (IS_ERR(amd_manager->mmio)) {
> > +	if (!amd_manager->mmio) {
> This will break the functionality.  Condition should be
> if (!amd_manager->acp_mmio)
> 
> >  		dev_err(dev, "mmio not found\n");
> > -		return PTR_ERR(amd_manager->mmio);
> > +		return -ENOMEM;

Ah crap.  You're right.  Thanks.  I will resend.

regards,
dan carpenter
diff mbox series

Patch

diff --git a/drivers/soundwire/amd_manager.c b/drivers/soundwire/amd_manager.c
index 9fb7f91ca182..9bb8ae8c5f32 100644
--- a/drivers/soundwire/amd_manager.c
+++ b/drivers/soundwire/amd_manager.c
@@ -910,9 +910,9 @@  static int amd_sdw_manager_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	amd_manager->acp_mmio = devm_ioremap(dev, res->start, resource_size(res));
-	if (IS_ERR(amd_manager->mmio)) {
+	if (!amd_manager->mmio) {
 		dev_err(dev, "mmio not found\n");
-		return PTR_ERR(amd_manager->mmio);
+		return -ENOMEM;
 	}
 	amd_manager->instance = pdata->instance;
 	amd_manager->mmio = amd_manager->acp_mmio +