Skip to content

Commit

Permalink
net: sparx5: fix return value check in sparx5_create_targets()
Browse files Browse the repository at this point in the history
In case of error, the function devm_ioremap() returns NULL pointer
not ERR_PTR(). The IS_ERR() test in the return value check should
be replaced with NULL test.

Fixes: 3cfa11b ("net: sparx5: add the basic sparx5 driver")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Yang Yingliang authored and David S. Miller committed Jun 28, 2021
1 parent f00af5c commit 8f4c38f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/net/ethernet/microchip/sparx5/sparx5_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ static int sparx5_create_targets(struct sparx5 *sparx5)
iores[idx]->start,
iores[idx]->end - iores[idx]->start
+ 1);
if (IS_ERR(iomem[idx])) {
if (!iomem[idx]) {
dev_err(sparx5->dev, "Unable to get switch registers: %s\n",
iores[idx]->name);
return PTR_ERR(iomem[idx]);
return -ENOMEM;
}
begin[idx] = iomem[idx] - sparx5_main_iomap[range_id[idx]].offset;
}
Expand Down

0 comments on commit 8f4c38f

Please sign in to comment.