Skip to content

Commit 3469660

Browse files
Wei Yongjundavem330
authored andcommitted
net: ethernet: ti: fix some return value check of cpsw_ale_create()
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, and the caller using IS_ERR() instead of NULL test. Fixes: 4b41d34 ("net: ethernet: ti: cpsw: allow untagged traffic on host port") Reported-by: Hulk Robot <[email protected]> Signed-off-by: Wei Yongjun <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d28ea1f commit 3469660

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

drivers/net/ethernet/ti/cpsw_ale.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)
955955

956956
ale = devm_kzalloc(params->dev, sizeof(*ale), GFP_KERNEL);
957957
if (!ale)
958-
return NULL;
958+
return ERR_PTR(-ENOMEM);
959959

960960
ale->p0_untag_vid_mask =
961961
devm_kmalloc_array(params->dev, BITS_TO_LONGS(VLAN_N_VID),

drivers/net/ethernet/ti/cpsw_priv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,9 @@ int cpsw_init_common(struct cpsw_common *cpsw, void __iomem *ss_regs,
490490
ale_params.ale_ports = CPSW_ALE_PORTS_NUM;
491491

492492
cpsw->ale = cpsw_ale_create(&ale_params);
493-
if (!cpsw->ale) {
493+
if (IS_ERR(cpsw->ale)) {
494494
dev_err(dev, "error initializing ale engine\n");
495-
return -ENODEV;
495+
return PTR_ERR(cpsw->ale);
496496
}
497497

498498
dma_params.dev = dev;

drivers/net/ethernet/ti/netcp_ethss.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3704,9 +3704,9 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev,
37043704
ale_params.nu_switch_ale = true;
37053705
}
37063706
gbe_dev->ale = cpsw_ale_create(&ale_params);
3707-
if (!gbe_dev->ale) {
3707+
if (IS_ERR(gbe_dev->ale)) {
37083708
dev_err(gbe_dev->dev, "error initializing ale engine\n");
3709-
ret = -ENODEV;
3709+
ret = PTR_ERR(gbe_dev->ale);
37103710
goto free_sec_ports;
37113711
} else {
37123712
dev_dbg(gbe_dev->dev, "Created a gbe ale engine\n");

0 commit comments

Comments
 (0)