2023-06-15 03:45:21

by Jiasheng Jiang

[permalink] [raw]
Subject: [PATCH v2] octeon_ep: Add missing check for ioremap

Add check for ioremap() and return the error if it fails in order to
guarantee the success of ioremap().

Fixes: 862cd659a6fb ("octeon_ep: Add driver framework and device initialization")
Signed-off-by: Jiasheng Jiang <[email protected]>
---
Changelog:

v1-> v2:

1. Rewrite the error handling.
---
drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
index e1853da280f9..43eb6e871351 100644
--- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
+++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
@@ -981,6 +981,9 @@ int octep_device_setup(struct octep_device *oct)
oct->mmio[i].hw_addr =
ioremap(pci_resource_start(oct->pdev, i * 2),
pci_resource_len(oct->pdev, i * 2));
+ if (!oct->mmio[i].hw_addr)
+ goto unmap_prev;
+
oct->mmio[i].mapped = 1;
}

@@ -1015,7 +1018,9 @@ int octep_device_setup(struct octep_device *oct)
return 0;

unsupported_dev:
- for (i = 0; i < OCTEP_MMIO_REGIONS; i++)
+ i = OCTEP_MMIO_REGIONS;
+unmap_prev:
+ while (i--)
iounmap(oct->mmio[i].hw_addr);

kfree(oct->conf);
--
2.25.1



2023-06-15 15:49:31

by Veerasenareddy Burru

[permalink] [raw]
Subject: RE: [EXT] [PATCH v2] octeon_ep: Add missing check for ioremap



> -----Original Message-----
> From: Jiasheng Jiang <[email protected]>
> Sent: Wednesday, June 14, 2023 8:34 PM
> To: [email protected]
> Cc: Veerasenareddy Burru <[email protected]>; Abhijit Ayarekar
> <[email protected]>; [email protected]; [email protected];
> [email protected]; Satananda Burla <[email protected]>;
> [email protected]; [email protected]; Jiasheng Jiang
> <[email protected]>
> Subject: [EXT] [PATCH v2] octeon_ep: Add missing check for ioremap
>
> External Email
>
> ----------------------------------------------------------------------
> Add check for ioremap() and return the error if it fails in order to guarantee the
> success of ioremap().
>
> Fixes: 862cd659a6fb ("octeon_ep: Add driver framework and device
> initialization")
> Signed-off-by: Jiasheng Jiang <[email protected]>
> ---
> Changelog:
>
> v1-> v2:
>
> 1. Rewrite the error handling.
> ---
> drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
> b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
> index e1853da280f9..43eb6e871351 100644
> --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
> +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
> @@ -981,6 +981,9 @@ int octep_device_setup(struct octep_device *oct)
> oct->mmio[i].hw_addr =
> ioremap(pci_resource_start(oct->pdev, i * 2),
> pci_resource_len(oct->pdev, i * 2));
> + if (!oct->mmio[i].hw_addr)
> + goto unmap_prev;
> +
> oct->mmio[i].mapped = 1;
> }
>
> @@ -1015,7 +1018,9 @@ int octep_device_setup(struct octep_device *oct)
> return 0;
>
> unsupported_dev:
> - for (i = 0; i < OCTEP_MMIO_REGIONS; i++)
> + i = OCTEP_MMIO_REGIONS;
> +unmap_prev:
> + while (i--)
> iounmap(oct->mmio[i].hw_addr);
>
> kfree(oct->conf);

Ack
changes look good. Thank you.

> --
> 2.25.1


2023-06-15 22:37:15

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH v2] octeon_ep: Add missing check for ioremap

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

On Thu, 15 Jun 2023 11:34:00 +0800 you wrote:
> Add check for ioremap() and return the error if it fails in order to
> guarantee the success of ioremap().
>
> Fixes: 862cd659a6fb ("octeon_ep: Add driver framework and device initialization")
> Signed-off-by: Jiasheng Jiang <[email protected]>
> ---
> Changelog:
>
> [...]

Here is the summary with links:
- [v2] octeon_ep: Add missing check for ioremap
https://git.kernel.org/netdev/net/c/9a36e2d44d12

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html