All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: ethernet: ti: fix return value check in k3_cppi_desc_pool_create_name()
@ 2020-04-27  9:33 ` Wei Yongjun
  0 siblings, 0 replies; 14+ messages in thread
From: Wei Yongjun @ 2020-04-27  9:33 UTC (permalink / raw)
  To: David S . Miller, Grygorii Strashko; +Cc: Wei Yongjun, netdev, kernel-janitors

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

Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/net/ethernet/ti/k3-cppi-desc-pool.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ti/k3-cppi-desc-pool.c b/drivers/net/ethernet/ti/k3-cppi-desc-pool.c
index ad7cfc1316ce..38cc12f9f133 100644
--- a/drivers/net/ethernet/ti/k3-cppi-desc-pool.c
+++ b/drivers/net/ethernet/ti/k3-cppi-desc-pool.c
@@ -64,8 +64,8 @@ k3_cppi_desc_pool_create_name(struct device *dev, size_t size,
 		return ERR_PTR(-ENOMEM);
 
 	pool->gen_pool = gen_pool_create(ilog2(pool->desc_size), -1);
-	if (IS_ERR(pool->gen_pool)) {
-		ret = PTR_ERR(pool->gen_pool);
+	if (!pool->gen_pool) {
+		ret = -ENOMEM;
 		dev_err(pool->dev, "pool create failed %d\n", ret);
 		kfree_const(pool_name);
 		goto gen_pool_create_fail;




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

* [PATCH net-next] net: ethernet: ti: fix return value check in k3_cppi_desc_pool_create_name()
@ 2020-04-27  9:33 ` Wei Yongjun
  0 siblings, 0 replies; 14+ messages in thread
From: Wei Yongjun @ 2020-04-27  9:33 UTC (permalink / raw)
  To: David S . Miller, Grygorii Strashko; +Cc: Wei Yongjun, netdev, kernel-janitors

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

Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/net/ethernet/ti/k3-cppi-desc-pool.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ti/k3-cppi-desc-pool.c b/drivers/net/ethernet/ti/k3-cppi-desc-pool.c
index ad7cfc1316ce..38cc12f9f133 100644
--- a/drivers/net/ethernet/ti/k3-cppi-desc-pool.c
+++ b/drivers/net/ethernet/ti/k3-cppi-desc-pool.c
@@ -64,8 +64,8 @@ k3_cppi_desc_pool_create_name(struct device *dev, size_t size,
 		return ERR_PTR(-ENOMEM);
 
 	pool->gen_pool = gen_pool_create(ilog2(pool->desc_size), -1);
-	if (IS_ERR(pool->gen_pool)) {
-		ret = PTR_ERR(pool->gen_pool);
+	if (!pool->gen_pool) {
+		ret = -ENOMEM;
 		dev_err(pool->dev, "pool create failed %d\n", ret);
 		kfree_const(pool_name);
 		goto gen_pool_create_fail;

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

* Re: [PATCH net-next] net: ethernet: ti: fix return value check in k3_cppi_desc_pool_create_name()
  2020-04-27  9:33 ` Wei Yongjun
@ 2020-04-27 20:28   ` David Miller
  -1 siblings, 0 replies; 14+ messages in thread
From: David Miller @ 2020-04-27 20:28 UTC (permalink / raw)
  To: weiyongjun1; +Cc: grygorii.strashko, netdev, kernel-janitors

From: Wei Yongjun <weiyongjun1@huawei.com>
Date: Mon, 27 Apr 2020 09:33:43 +0000

> In case of error, the function gen_pool_create() returns NULL pointer
> not ERR_PTR(). The IS_ERR() test in the return value check should be
> replaced with NULL test.
> 
> Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Applied.

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

* Re: [PATCH net-next] net: ethernet: ti: fix return value check in k3_cppi_desc_pool_create_name()
@ 2020-04-27 20:28   ` David Miller
  0 siblings, 0 replies; 14+ messages in thread
From: David Miller @ 2020-04-27 20:28 UTC (permalink / raw)
  To: weiyongjun1; +Cc: grygorii.strashko, netdev, kernel-janitors

From: Wei Yongjun <weiyongjun1@huawei.com>
Date: Mon, 27 Apr 2020 09:33:43 +0000

> In case of error, the function gen_pool_create() returns NULL pointer
> not ERR_PTR(). The IS_ERR() test in the return value check should be
> replaced with NULL test.
> 
> Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Applied.

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

* [PATCH net-next] net: ethernet: ti: fix error return code in am65_cpsw_nuss_probe()
  2020-04-27  9:33 ` Wei Yongjun
@ 2020-05-08  2:10 ` Wei Yongjun
  -1 siblings, 0 replies; 14+ messages in thread
From: Wei Yongjun @ 2020-05-08  2:10 UTC (permalink / raw)
  To: David S . Miller, Grygorii Strashko, Christophe JAILLET,
	Colin Ian King, Jakub Kicinski
  Cc: Wei Yongjun, netdev, kernel-janitors, Hulk Robot

Fix to return negative error code -ENOMEM from the cpsw_ale_create()
error handling case instead of 0, as done elsewhere in this function.

Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index f8c589929308..066ba52f57cb 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -2065,6 +2065,7 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
 	common->ale = cpsw_ale_create(&ale_params);
 	if (!common->ale) {
 		dev_err(dev, "error initializing ale engine\n");
+		ret = -ENOMEM;
 		goto err_of_clear;
 	}




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

* [PATCH net-next] net: ethernet: ti: fix error return code in am65_cpsw_nuss_probe()
@ 2020-05-08  2:10 ` Wei Yongjun
  0 siblings, 0 replies; 14+ messages in thread
From: Wei Yongjun @ 2020-05-08  2:10 UTC (permalink / raw)
  To: David S . Miller, Grygorii Strashko, Christophe JAILLET,
	Colin Ian King, Jakub Kicinski
  Cc: Wei Yongjun, netdev, kernel-janitors, Hulk Robot

Fix to return negative error code -ENOMEM from the cpsw_ale_create()
error handling case instead of 0, as done elsewhere in this function.

Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index f8c589929308..066ba52f57cb 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -2065,6 +2065,7 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
 	common->ale = cpsw_ale_create(&ale_params);
 	if (!common->ale) {
 		dev_err(dev, "error initializing ale engine\n");
+		ret = -ENOMEM;
 		goto err_of_clear;
 	}

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

* Re: [PATCH net-next] net: ethernet: ti: fix error return code in am65_cpsw_nuss_probe()
  2020-05-08  2:10 ` Wei Yongjun
@ 2020-05-08  8:54   ` Grygorii Strashko
  -1 siblings, 0 replies; 14+ messages in thread
From: Grygorii Strashko @ 2020-05-08  8:54 UTC (permalink / raw)
  To: Wei Yongjun, David S . Miller, Christophe JAILLET,
	Colin Ian King, Jakub Kicinski
  Cc: netdev, kernel-janitors, Hulk Robot



On 08/05/2020 05:10, Wei Yongjun wrote:
> Fix to return negative error code -ENOMEM from the cpsw_ale_create()
> error handling case instead of 0, as done elsewhere in this function.
> 
> Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
>   drivers/net/ethernet/ti/am65-cpsw-nuss.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> index f8c589929308..066ba52f57cb 100644
> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> @@ -2065,6 +2065,7 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
>   	common->ale = cpsw_ale_create(&ale_params);
>   	if (!common->ale) {
>   		dev_err(dev, "error initializing ale engine\n");
> +		ret = -ENOMEM;
>   		goto err_of_clear;
>   	}
> 
> 
> 

It seems not enough.

For consistency, Could you update it as below?
- cpsw_ale_create() to return PTR_ERR() in all places
- users to use IS_ERR() and ret = PTR_ERR()


-- 
Best regards,
grygorii

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

* Re: [PATCH net-next] net: ethernet: ti: fix error return code in am65_cpsw_nuss_probe()
@ 2020-05-08  8:54   ` Grygorii Strashko
  0 siblings, 0 replies; 14+ messages in thread
From: Grygorii Strashko @ 2020-05-08  8:54 UTC (permalink / raw)
  To: Wei Yongjun, David S . Miller, Christophe JAILLET,
	Colin Ian King, Jakub Kicinski
  Cc: netdev, kernel-janitors, Hulk Robot



On 08/05/2020 05:10, Wei Yongjun wrote:
> Fix to return negative error code -ENOMEM from the cpsw_ale_create()
> error handling case instead of 0, as done elsewhere in this function.
> 
> Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
>   drivers/net/ethernet/ti/am65-cpsw-nuss.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> index f8c589929308..066ba52f57cb 100644
> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> @@ -2065,6 +2065,7 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
>   	common->ale = cpsw_ale_create(&ale_params);
>   	if (!common->ale) {
>   		dev_err(dev, "error initializing ale engine\n");
> +		ret = -ENOMEM;
>   		goto err_of_clear;
>   	}
> 
> 
> 

It seems not enough.

For consistency, Could you update it as below?
- cpsw_ale_create() to return PTR_ERR() in all places
- users to use IS_ERR() and ret = PTR_ERR()


-- 
Best regards,
grygorii

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

* [PATCH net-next v2] net: ethernet: ti: fix some return value check of cpsw_ale_create()
  2020-05-08  2:10 ` Wei Yongjun
@ 2020-05-08 10:06   ` Wei Yongjun
  -1 siblings, 0 replies; 14+ messages in thread
From: Wei Yongjun @ 2020-05-08 10:06 UTC (permalink / raw)
  To: David S . Miller, Grygorii Strashko, Christophe JAILLET,
	Colin Ian King, Jakub Kicinski
  Cc: Wei Yongjun, netdev, kernel-janitors, Hulk Robot

cpsw_ale_create() can return both NULL and PTR_ERR(), but all of
the caller only check NULL for error handling. This patch convert
it to only return PTR_ERR() in all error cases, all the caller using
IS_ERR() install of NULL test.

Also fix a return negative error code from the cpsw_ale_create()
error handling case instead of 0 in am65_cpsw_nuss_probe().

Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
Fixes: 4b41d3436796 ("net: ethernet: ti: cpsw: allow untagged traffic on host port")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
v1 -> v2: fix cpsw_ale_create() to retuen PTR_ERR() in all places as Grygorii's suggest
---
 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 3 ++-
 drivers/net/ethernet/ti/cpsw_ale.c       | 2 +-
 drivers/net/ethernet/ti/cpsw_priv.c      | 4 ++--
 drivers/net/ethernet/ti/netcp_ethss.c    | 4 ++--
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index 8cdbb2b9b13a..5530d7ef77a6 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -2074,8 +2074,9 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
 	ale_params.nu_switch_ale = true;
 
 	common->ale = cpsw_ale_create(&ale_params);
-	if (!common->ale) {
+	if (IS_ERR(common->ale)) {
 		dev_err(dev, "error initializing ale engine\n");
+		ret = ERR_PTR(common->ale);
 		goto err_of_clear;
 	}
 
diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
index 0374e6936091..8dc6be11b2ff 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.c
+++ b/drivers/net/ethernet/ti/cpsw_ale.c
@@ -955,7 +955,7 @@ struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)
 
 	ale = devm_kzalloc(params->dev, sizeof(*ale), GFP_KERNEL);
 	if (!ale)
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 
 	ale->p0_untag_vid_mask =
 		devm_kmalloc_array(params->dev, BITS_TO_LONGS(VLAN_N_VID),
diff --git a/drivers/net/ethernet/ti/cpsw_priv.c b/drivers/net/ethernet/ti/cpsw_priv.c
index 9d098c802c6d..d940628bff8d 100644
--- a/drivers/net/ethernet/ti/cpsw_priv.c
+++ b/drivers/net/ethernet/ti/cpsw_priv.c
@@ -504,9 +504,9 @@ int cpsw_init_common(struct cpsw_common *cpsw, void __iomem *ss_regs,
 	ale_params.ale_ports		= CPSW_ALE_PORTS_NUM;
 
 	cpsw->ale = cpsw_ale_create(&ale_params);
-	if (!cpsw->ale) {
+	if (IS_ERR(cpsw->ale)) {
 		dev_err(dev, "error initializing ale engine\n");
-		return -ENODEV;
+		return PTR_ERR(cpsw->ale);
 	}
 
 	dma_params.dev		= dev;
diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index 9d6e27fb710e..28093923a7fb 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -3704,9 +3704,9 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev,
 		ale_params.nu_switch_ale = true;
 	}
 	gbe_dev->ale = cpsw_ale_create(&ale_params);
-	if (!gbe_dev->ale) {
+	if (IS_ERR(gbe_dev->ale)) {
 		dev_err(gbe_dev->dev, "error initializing ale engine\n");
-		ret = -ENODEV;
+		ret = PTR_ERR(gbe_dev->ale);
 		goto free_sec_ports;
 	} else {
 		dev_dbg(gbe_dev->dev, "Created a gbe ale engine\n");
-- 
2.20.1




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

* [PATCH net-next v2] net: ethernet: ti: fix some return value check of cpsw_ale_create()
@ 2020-05-08 10:06   ` Wei Yongjun
  0 siblings, 0 replies; 14+ messages in thread
From: Wei Yongjun @ 2020-05-08 10:06 UTC (permalink / raw)
  To: David S . Miller, Grygorii Strashko, Christophe JAILLET,
	Colin Ian King, Jakub Kicinski
  Cc: Wei Yongjun, netdev, kernel-janitors, Hulk Robot

cpsw_ale_create() can return both NULL and PTR_ERR(), but all of
the caller only check NULL for error handling. This patch convert
it to only return PTR_ERR() in all error cases, all the caller using
IS_ERR() install of NULL test.

Also fix a return negative error code from the cpsw_ale_create()
error handling case instead of 0 in am65_cpsw_nuss_probe().

Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
Fixes: 4b41d3436796 ("net: ethernet: ti: cpsw: allow untagged traffic on host port")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
v1 -> v2: fix cpsw_ale_create() to retuen PTR_ERR() in all places as Grygorii's suggest
---
 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 3 ++-
 drivers/net/ethernet/ti/cpsw_ale.c       | 2 +-
 drivers/net/ethernet/ti/cpsw_priv.c      | 4 ++--
 drivers/net/ethernet/ti/netcp_ethss.c    | 4 ++--
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index 8cdbb2b9b13a..5530d7ef77a6 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -2074,8 +2074,9 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
 	ale_params.nu_switch_ale = true;
 
 	common->ale = cpsw_ale_create(&ale_params);
-	if (!common->ale) {
+	if (IS_ERR(common->ale)) {
 		dev_err(dev, "error initializing ale engine\n");
+		ret = ERR_PTR(common->ale);
 		goto err_of_clear;
 	}
 
diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
index 0374e6936091..8dc6be11b2ff 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.c
+++ b/drivers/net/ethernet/ti/cpsw_ale.c
@@ -955,7 +955,7 @@ struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)
 
 	ale = devm_kzalloc(params->dev, sizeof(*ale), GFP_KERNEL);
 	if (!ale)
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 
 	ale->p0_untag_vid_mask  		devm_kmalloc_array(params->dev, BITS_TO_LONGS(VLAN_N_VID),
diff --git a/drivers/net/ethernet/ti/cpsw_priv.c b/drivers/net/ethernet/ti/cpsw_priv.c
index 9d098c802c6d..d940628bff8d 100644
--- a/drivers/net/ethernet/ti/cpsw_priv.c
+++ b/drivers/net/ethernet/ti/cpsw_priv.c
@@ -504,9 +504,9 @@ int cpsw_init_common(struct cpsw_common *cpsw, void __iomem *ss_regs,
 	ale_params.ale_ports		= CPSW_ALE_PORTS_NUM;
 
 	cpsw->ale = cpsw_ale_create(&ale_params);
-	if (!cpsw->ale) {
+	if (IS_ERR(cpsw->ale)) {
 		dev_err(dev, "error initializing ale engine\n");
-		return -ENODEV;
+		return PTR_ERR(cpsw->ale);
 	}
 
 	dma_params.dev		= dev;
diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index 9d6e27fb710e..28093923a7fb 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -3704,9 +3704,9 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev,
 		ale_params.nu_switch_ale = true;
 	}
 	gbe_dev->ale = cpsw_ale_create(&ale_params);
-	if (!gbe_dev->ale) {
+	if (IS_ERR(gbe_dev->ale)) {
 		dev_err(gbe_dev->dev, "error initializing ale engine\n");
-		ret = -ENODEV;
+		ret = PTR_ERR(gbe_dev->ale);
 		goto free_sec_ports;
 	} else {
 		dev_dbg(gbe_dev->dev, "Created a gbe ale engine\n");
-- 
2.20.1

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

* Re: [PATCH net-next v2] net: ethernet: ti: fix some return value check of cpsw_ale_create()
  2020-05-08 10:06   ` Wei Yongjun
@ 2020-05-08 11:26     ` Grygorii Strashko
  -1 siblings, 0 replies; 14+ messages in thread
From: Grygorii Strashko @ 2020-05-08 11:26 UTC (permalink / raw)
  To: Wei Yongjun, David S . Miller, Christophe JAILLET,
	Colin Ian King, Jakub Kicinski
  Cc: netdev, kernel-janitors, Hulk Robot



On 08/05/2020 13:06, Wei Yongjun wrote:
> cpsw_ale_create() can return both NULL and PTR_ERR(), but all of
> the caller only check NULL for error handling. This patch convert
> it to only return PTR_ERR() in all error cases, all the caller using
> IS_ERR() install of NULL test.
> 
> Also fix a return negative error code from the cpsw_ale_create()
> error handling case instead of 0 in am65_cpsw_nuss_probe().
> 
> Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
> Fixes: 4b41d3436796 ("net: ethernet: ti: cpsw: allow untagged traffic on host port")

^ I do not think it can be back-ported so far back.
So, or drop second "Fixes: 4b41d3436796"
or split am65-cpsw-nuss.c changes

> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
> v1 -> v2: fix cpsw_ale_create() to retuen PTR_ERR() in all places as Grygorii's suggest

Pls, do not send v2 as reply on v1.


> ---
>   drivers/net/ethernet/ti/am65-cpsw-nuss.c | 3 ++-
>   drivers/net/ethernet/ti/cpsw_ale.c       | 2 +-
>   drivers/net/ethernet/ti/cpsw_priv.c      | 4 ++--
>   drivers/net/ethernet/ti/netcp_ethss.c    | 4 ++--
>   4 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> index 8cdbb2b9b13a..5530d7ef77a6 100644
> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> @@ -2074,8 +2074,9 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
>   	ale_params.nu_switch_ale = true;
>   
>   	common->ale = cpsw_ale_create(&ale_params);
> -	if (!common->ale) {
> +	if (IS_ERR(common->ale)) {
>   		dev_err(dev, "error initializing ale engine\n");
> +		ret = ERR_PTR(common->ale);

../include/linux/err.h:24:35: note: expected ‘long int’ but argument is of type ‘struct cpsw_ale *’
  static inline void * __must_check ERR_PTR(long error)
                                    ^~~~~~~
../drivers/net/ethernet/ti/am65-cpsw-nuss.c:1900:7: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
    ret = ERR_PTR(common->ale);
        ^


>   		goto err_of_clear;
>   	}
>   
> diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
> index 0374e6936091..8dc6be11b2ff 100644
> --- a/drivers/net/ethernet/ti/cpsw_ale.c
> +++ b/drivers/net/ethernet/ti/cpsw_ale.c
> @@ -955,7 +955,7 @@ struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)
>   
>   	ale = devm_kzalloc(params->dev, sizeof(*ale), GFP_KERNEL);
>   	if (!ale)
> -		return NULL;
> +		return ERR_PTR(-ENOMEM);
>   
>   	ale->p0_untag_vid_mask =
>   		devm_kmalloc_array(params->dev, BITS_TO_LONGS(VLAN_N_VID),
> diff --git a/drivers/net/ethernet/ti/cpsw_priv.c b/drivers/net/ethernet/ti/cpsw_priv.c
> index 9d098c802c6d..d940628bff8d 100644
> --- a/drivers/net/ethernet/ti/cpsw_priv.c
> +++ b/drivers/net/ethernet/ti/cpsw_priv.c
> @@ -504,9 +504,9 @@ int cpsw_init_common(struct cpsw_common *cpsw, void __iomem *ss_regs,
>   	ale_params.ale_ports		= CPSW_ALE_PORTS_NUM;
>   
>   	cpsw->ale = cpsw_ale_create(&ale_params);
> -	if (!cpsw->ale) {
> +	if (IS_ERR(cpsw->ale)) {
>   		dev_err(dev, "error initializing ale engine\n");
> -		return -ENODEV;
> +		return PTR_ERR(cpsw->ale);
>   	}
>   
>   	dma_params.dev		= dev;
> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
> index 9d6e27fb710e..28093923a7fb 100644
> --- a/drivers/net/ethernet/ti/netcp_ethss.c
> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
> @@ -3704,9 +3704,9 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev,
>   		ale_params.nu_switch_ale = true;
>   	}
>   	gbe_dev->ale = cpsw_ale_create(&ale_params);
> -	if (!gbe_dev->ale) {
> +	if (IS_ERR(gbe_dev->ale)) {
>   		dev_err(gbe_dev->dev, "error initializing ale engine\n");
> -		ret = -ENODEV;
> +		ret = PTR_ERR(gbe_dev->ale);
>   		goto free_sec_ports;
>   	} else {
>   		dev_dbg(gbe_dev->dev, "Created a gbe ale engine\n");
> 

-- 
Best regards,
grygorii

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

* Re: [PATCH net-next v2] net: ethernet: ti: fix some return value check of cpsw_ale_create()
@ 2020-05-08 11:26     ` Grygorii Strashko
  0 siblings, 0 replies; 14+ messages in thread
From: Grygorii Strashko @ 2020-05-08 11:26 UTC (permalink / raw)
  To: Wei Yongjun, David S . Miller, Christophe JAILLET,
	Colin Ian King, Jakub Kicinski
  Cc: netdev, kernel-janitors, Hulk Robot



On 08/05/2020 13:06, Wei Yongjun wrote:
> cpsw_ale_create() can return both NULL and PTR_ERR(), but all of
> the caller only check NULL for error handling. This patch convert
> it to only return PTR_ERR() in all error cases, all the caller using
> IS_ERR() install of NULL test.
> 
> Also fix a return negative error code from the cpsw_ale_create()
> error handling case instead of 0 in am65_cpsw_nuss_probe().
> 
> Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
> Fixes: 4b41d3436796 ("net: ethernet: ti: cpsw: allow untagged traffic on host port")

^ I do not think it can be back-ported so far back.
So, or drop second "Fixes: 4b41d3436796"
or split am65-cpsw-nuss.c changes

> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
> v1 -> v2: fix cpsw_ale_create() to retuen PTR_ERR() in all places as Grygorii's suggest

Pls, do not send v2 as reply on v1.


> ---
>   drivers/net/ethernet/ti/am65-cpsw-nuss.c | 3 ++-
>   drivers/net/ethernet/ti/cpsw_ale.c       | 2 +-
>   drivers/net/ethernet/ti/cpsw_priv.c      | 4 ++--
>   drivers/net/ethernet/ti/netcp_ethss.c    | 4 ++--
>   4 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> index 8cdbb2b9b13a..5530d7ef77a6 100644
> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> @@ -2074,8 +2074,9 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
>   	ale_params.nu_switch_ale = true;
>   
>   	common->ale = cpsw_ale_create(&ale_params);
> -	if (!common->ale) {
> +	if (IS_ERR(common->ale)) {
>   		dev_err(dev, "error initializing ale engine\n");
> +		ret = ERR_PTR(common->ale);

../include/linux/err.h:24:35: note: expected ‘long int’ but argument is of type ‘struct cpsw_ale *’
  static inline void * __must_check ERR_PTR(long error)
                                    ^~~~~~~
../drivers/net/ethernet/ti/am65-cpsw-nuss.c:1900:7: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
    ret = ERR_PTR(common->ale);
        ^


>   		goto err_of_clear;
>   	}
>   
> diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
> index 0374e6936091..8dc6be11b2ff 100644
> --- a/drivers/net/ethernet/ti/cpsw_ale.c
> +++ b/drivers/net/ethernet/ti/cpsw_ale.c
> @@ -955,7 +955,7 @@ struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)
>   
>   	ale = devm_kzalloc(params->dev, sizeof(*ale), GFP_KERNEL);
>   	if (!ale)
> -		return NULL;
> +		return ERR_PTR(-ENOMEM);
>   
>   	ale->p0_untag_vid_mask >   		devm_kmalloc_array(params->dev, BITS_TO_LONGS(VLAN_N_VID),
> diff --git a/drivers/net/ethernet/ti/cpsw_priv.c b/drivers/net/ethernet/ti/cpsw_priv.c
> index 9d098c802c6d..d940628bff8d 100644
> --- a/drivers/net/ethernet/ti/cpsw_priv.c
> +++ b/drivers/net/ethernet/ti/cpsw_priv.c
> @@ -504,9 +504,9 @@ int cpsw_init_common(struct cpsw_common *cpsw, void __iomem *ss_regs,
>   	ale_params.ale_ports		= CPSW_ALE_PORTS_NUM;
>   
>   	cpsw->ale = cpsw_ale_create(&ale_params);
> -	if (!cpsw->ale) {
> +	if (IS_ERR(cpsw->ale)) {
>   		dev_err(dev, "error initializing ale engine\n");
> -		return -ENODEV;
> +		return PTR_ERR(cpsw->ale);
>   	}
>   
>   	dma_params.dev		= dev;
> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
> index 9d6e27fb710e..28093923a7fb 100644
> --- a/drivers/net/ethernet/ti/netcp_ethss.c
> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
> @@ -3704,9 +3704,9 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev,
>   		ale_params.nu_switch_ale = true;
>   	}
>   	gbe_dev->ale = cpsw_ale_create(&ale_params);
> -	if (!gbe_dev->ale) {
> +	if (IS_ERR(gbe_dev->ale)) {
>   		dev_err(gbe_dev->dev, "error initializing ale engine\n");
> -		ret = -ENODEV;
> +		ret = PTR_ERR(gbe_dev->ale);
>   		goto free_sec_ports;
>   	} else {
>   		dev_dbg(gbe_dev->dev, "Created a gbe ale engine\n");
> 

-- 
Best regards,
grygorii

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

* Re: [PATCH net-next v2] net: ethernet: ti: fix some return value check of cpsw_ale_create()
  2020-05-08 11:26     ` Grygorii Strashko
@ 2020-05-08 19:38       ` Jakub Kicinski
  -1 siblings, 0 replies; 14+ messages in thread
From: Jakub Kicinski @ 2020-05-08 19:38 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: Grygorii Strashko, David S . Miller, Christophe JAILLET,
	Colin Ian King, netdev, kernel-janitors, Hulk Robot

On Fri, 8 May 2020 14:26:27 +0300 Grygorii Strashko wrote:
> On 08/05/2020 13:06, Wei Yongjun wrote:
> > cpsw_ale_create() can return both NULL and PTR_ERR(), but all of
> > the caller only check NULL for error handling. This patch convert
> > it to only return PTR_ERR() in all error cases, all the caller using
> > IS_ERR() install of NULL test.
> > 
> > Also fix a return negative error code from the cpsw_ale_create()
> > error handling case instead of 0 in am65_cpsw_nuss_probe().
> > 
> > Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
> > Fixes: 4b41d3436796 ("net: ethernet: ti: cpsw: allow untagged traffic on host port")  
> 
> ^ I do not think it can be back-ported so far back.
> So, or drop second "Fixes: 4b41d3436796"
> or split am65-cpsw-nuss.c changes

Please also tag this commit with [net] not [net-next], 
AFAICS the problem is present in Linus's tree.

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

* Re: [PATCH net-next v2] net: ethernet: ti: fix some return value check of cpsw_ale_create()
@ 2020-05-08 19:38       ` Jakub Kicinski
  0 siblings, 0 replies; 14+ messages in thread
From: Jakub Kicinski @ 2020-05-08 19:38 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: Grygorii Strashko, David S . Miller, Christophe JAILLET,
	Colin Ian King, netdev, kernel-janitors, Hulk Robot

On Fri, 8 May 2020 14:26:27 +0300 Grygorii Strashko wrote:
> On 08/05/2020 13:06, Wei Yongjun wrote:
> > cpsw_ale_create() can return both NULL and PTR_ERR(), but all of
> > the caller only check NULL for error handling. This patch convert
> > it to only return PTR_ERR() in all error cases, all the caller using
> > IS_ERR() install of NULL test.
> > 
> > Also fix a return negative error code from the cpsw_ale_create()
> > error handling case instead of 0 in am65_cpsw_nuss_probe().
> > 
> > Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
> > Fixes: 4b41d3436796 ("net: ethernet: ti: cpsw: allow untagged traffic on host port")  
> 
> ^ I do not think it can be back-ported so far back.
> So, or drop second "Fixes: 4b41d3436796"
> or split am65-cpsw-nuss.c changes

Please also tag this commit with [net] not [net-next], 
AFAICS the problem is present in Linus's tree.

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

end of thread, other threads:[~2020-05-08 19:38 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-08  2:10 [PATCH net-next] net: ethernet: ti: fix error return code in am65_cpsw_nuss_probe() Wei Yongjun
2020-05-08  2:10 ` Wei Yongjun
2020-05-08  8:54 ` Grygorii Strashko
2020-05-08  8:54   ` Grygorii Strashko
2020-05-08 10:06 ` [PATCH net-next v2] net: ethernet: ti: fix some return value check of cpsw_ale_create() Wei Yongjun
2020-05-08 10:06   ` Wei Yongjun
2020-05-08 11:26   ` Grygorii Strashko
2020-05-08 11:26     ` Grygorii Strashko
2020-05-08 19:38     ` Jakub Kicinski
2020-05-08 19:38       ` Jakub Kicinski
  -- strict thread matches above, loose matches on Subject: below --
2020-04-27  9:33 [PATCH net-next] net: ethernet: ti: fix return value check in k3_cppi_desc_pool_create_name() Wei Yongjun
2020-04-27  9:33 ` Wei Yongjun
2020-04-27 20:28 ` David Miller
2020-04-27 20:28   ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.