diff mbox

ata: fix return value check in ahci_seattle_get_port_info()

Message ID 1465864009-26774-1-git-send-email-weiyj_lk@163.com
State Not Applicable
Delegated to: David Miller
Headers show

Commit Message

weiyj_lk@163.com June 14, 2016, 12:26 a.m. UTC
From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

In case of error, the function devm_kzalloc() returns NULL pointer
not ERR_PTR(). The IS_ERR() test in the return value check should
be replaced with NULL test.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
 drivers/ata/ahci_seattle.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)



--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Brijesh Singh June 14, 2016, 3:02 a.m. UTC | #1
> On Jun 13, 2016, at 7:26 PM, weiyj_lk@163.com wrote:
> 
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> 
> In case of error, the function devm_kzalloc() returns NULL pointer
> not ERR_PTR(). The IS_ERR() test in the return value check should
> be replaced with NULL test.
> 
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> ---
> drivers/ata/ahci_seattle.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/ata/ahci_seattle.c b/drivers/ata/ahci_seattle.c
> index 6e702ab..1d31c0c 100644
> --- a/drivers/ata/ahci_seattle.c
> +++ b/drivers/ata/ahci_seattle.c
> @@ -137,7 +137,7 @@ static const struct ata_port_info *ahci_seattle_get_port_info(
> 	u32 val;
> 
> 	plat_data = devm_kzalloc(dev, sizeof(*plat_data), GFP_KERNEL);
> -	if (IS_ERR(plat_data))
> +	if (!plat_data)
> 		return &ahci_port_info;
> 
> 	plat_data->sgpio_ctrl = devm_ioremap_resource(dev,
> 
> 

Acked-by: Brijesh Singh <brijesh.singh@amd.com>

-Brijesh


--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tejun Heo June 15, 2016, 6:31 p.m. UTC | #2
On Tue, Jun 14, 2016 at 12:26:49AM +0000, weiyj_lk@163.com wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> 
> In case of error, the function devm_kzalloc() returns NULL pointer
> not ERR_PTR(). The IS_ERR() test in the return value check should
> be replaced with NULL test.
> 
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

Applied to libata/for-4.7-fixes.

Thanks.
diff mbox

Patch

diff --git a/drivers/ata/ahci_seattle.c b/drivers/ata/ahci_seattle.c
index 6e702ab..1d31c0c 100644
--- a/drivers/ata/ahci_seattle.c
+++ b/drivers/ata/ahci_seattle.c
@@ -137,7 +137,7 @@  static const struct ata_port_info *ahci_seattle_get_port_info(
 	u32 val;
 
 	plat_data = devm_kzalloc(dev, sizeof(*plat_data), GFP_KERNEL);
-	if (IS_ERR(plat_data))
+	if (!plat_data)
 		return &ahci_port_info;
 
 	plat_data->sgpio_ctrl = devm_ioremap_resource(dev,