diff mbox series

[v2] octeon_ep: Add missing check for ioremap

Message ID 20230615033400.2971-1-jiasheng@iscas.ac.cn (mailing list archive)
State Accepted
Commit 9a36e2d44d122fe73a2a76ba73f1d50a65cf8210
Delegated to: Netdev Maintainers
Headers show
Series [v2] octeon_ep: Add missing check for ioremap | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 19 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jiasheng Jiang June 15, 2023, 3:34 a.m. UTC
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 <jiasheng@iscas.ac.cn>
---
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(-)

Comments

Kalesh Anakkur Purayil June 15, 2023, 3:40 a.m. UTC | #1
On Thu, Jun 15, 2023 at 9:04 AM Jiasheng Jiang <jiasheng@iscas.ac.cn> 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 <jiasheng@iscas.ac.cn>
>

Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

> ---
> 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
>
>
>
Veerasenareddy Burru June 15, 2023, 3:44 p.m. UTC | #2
> -----Original Message-----
> From: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> Sent: Wednesday, June 14, 2023 8:34 PM
> To: kuba@kernel.org
> Cc: Veerasenareddy Burru <vburru@marvell.com>; Abhijit Ayarekar
> <aayarekar@marvell.com>; davem@davemloft.net; edumazet@google.com;
> pabeni@redhat.com; Satananda Burla <sburla@marvell.com>;
> netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Jiasheng Jiang
> <jiasheng@iscas.ac.cn>
> 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 <jiasheng@iscas.ac.cn>
> ---
> 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
patchwork-bot+netdevbpf@kernel.org June 15, 2023, 10:10 p.m. UTC | #3
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

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 <jiasheng@iscas.ac.cn>
> ---
> 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!
diff mbox series

Patch

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);