diff mbox

platform/x86: mlx-platform: Fix an ERR_PTR vs NULL issue

Message ID 20180206124536.GA9445@mwanda (mailing list archive)
State Accepted, archived
Delegated to: Darren Hart
Headers show

Commit Message

Dan Carpenter Feb. 6, 2018, 12:45 p.m. UTC
devm_ioport_map() returns NULL on error but we accidentally check for
error pointers instead.

Fixes: c6acad68eb2d ("platform/mellanox: mlxreg-hotplug: Modify to use a regmap interface")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Comments

Vadim Pasternak Feb. 6, 2018, 12:55 p.m. UTC | #1
> -----Original Message-----
> From: Dan Carpenter [mailto:dan.carpenter@oracle.com]
> Sent: Tuesday, February 06, 2018 2:46 PM
> To: Vadim Pasternak <vadimp@mellanox.com>
> Cc: Darren Hart <dvhart@infradead.org>; Andy Shevchenko
> <andy@infradead.org>; platform-driver-x86@vger.kernel.org; kernel-
> janitors@vger.kernel.org
> Subject: [PATCH] platform/x86: mlx-platform: Fix an ERR_PTR vs NULL issue
> 
> devm_ioport_map() returns NULL on error but we accidentally check for error
> pointers instead.
> 
> Fixes: c6acad68eb2d ("platform/mellanox: mlxreg-hotplug: Modify to use a
> regmap interface")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Acked-by: Vadim Pasternak <vadimp@melanox.com>

> 
> diff --git a/drivers/platform/x86/mlx-platform.c b/drivers/platform/x86/mlx-
> platform.c
> index dfecba4407ac..27de29961f5e 100644
> --- a/drivers/platform/x86/mlx-platform.c
> +++ b/drivers/platform/x86/mlx-platform.c
> @@ -522,8 +522,8 @@ static int __init mlxplat_init(void)
> 
>  	mlxplat_mlxcpld_regmap_ctx.base = devm_ioport_map(&mlxplat_dev-
> >dev,
>  			       mlxplat_lpc_resources[1].start, 1);
> -	if (IS_ERR(mlxplat_mlxcpld_regmap_ctx.base)) {
> -		err = PTR_ERR(mlxplat_mlxcpld_regmap_ctx.base);
> +	if (!mlxplat_mlxcpld_regmap_ctx.base) {
> +		err = -ENOMEM;
>  		goto fail_platform_mux_register;
>  	}
>
Darren Hart Feb. 6, 2018, 3:42 p.m. UTC | #2
On Tue, Feb 06, 2018 at 12:55:58PM +0000, Vadim Pasternak wrote:
> 
> 
> > -----Original Message-----
> > From: Dan Carpenter [mailto:dan.carpenter@oracle.com]
> > Sent: Tuesday, February 06, 2018 2:46 PM
> > To: Vadim Pasternak <vadimp@mellanox.com>
> > Cc: Darren Hart <dvhart@infradead.org>; Andy Shevchenko
> > <andy@infradead.org>; platform-driver-x86@vger.kernel.org; kernel-
> > janitors@vger.kernel.org
> > Subject: [PATCH] platform/x86: mlx-platform: Fix an ERR_PTR vs NULL issue
> > 
> > devm_ioport_map() returns NULL on error but we accidentally check for error
> > pointers instead.
> > 
> > Fixes: c6acad68eb2d ("platform/mellanox: mlxreg-hotplug: Modify to use a
> > regmap interface")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> Acked-by: Vadim Pasternak <vadimp@melanox.com>

Queued up for today's PR for 4.16. Thanks.
diff mbox

Patch

diff --git a/drivers/platform/x86/mlx-platform.c b/drivers/platform/x86/mlx-platform.c
index dfecba4407ac..27de29961f5e 100644
--- a/drivers/platform/x86/mlx-platform.c
+++ b/drivers/platform/x86/mlx-platform.c
@@ -522,8 +522,8 @@  static int __init mlxplat_init(void)
 
 	mlxplat_mlxcpld_regmap_ctx.base = devm_ioport_map(&mlxplat_dev->dev,
 			       mlxplat_lpc_resources[1].start, 1);
-	if (IS_ERR(mlxplat_mlxcpld_regmap_ctx.base)) {
-		err = PTR_ERR(mlxplat_mlxcpld_regmap_ctx.base);
+	if (!mlxplat_mlxcpld_regmap_ctx.base) {
+		err = -ENOMEM;
 		goto fail_platform_mux_register;
 	}