netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] octeon_ep: Add missing check for ioremap
@ 2023-06-15  3:34 Jiasheng Jiang
  2023-06-15  3:40 ` Kalesh Anakkur Purayil
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jiasheng Jiang @ 2023-06-15  3:34 UTC (permalink / raw)
  To: kuba
  Cc: vburru, aayarekar, davem, edumazet, pabeni, sburla, netdev,
	linux-kernel, Jiasheng Jiang

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


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

* Re: [PATCH v2] octeon_ep: Add missing check for ioremap
  2023-06-15  3:34 [PATCH v2] octeon_ep: Add missing check for ioremap Jiasheng Jiang
@ 2023-06-15  3:40 ` Kalesh Anakkur Purayil
  2023-06-15 15:44 ` [EXT] " Veerasenareddy Burru
  2023-06-15 22:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Kalesh Anakkur Purayil @ 2023-06-15  3:40 UTC (permalink / raw)
  To: Jiasheng Jiang
  Cc: kuba, vburru, aayarekar, davem, edumazet, pabeni, sburla, netdev,
	linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 1696 bytes --]

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

-- 
Regards,
Kalesh A P

[-- Attachment #1.2: Type: text/html, Size: 2653 bytes --]

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4239 bytes --]

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

* RE: [EXT] [PATCH v2] octeon_ep: Add missing check for ioremap
  2023-06-15  3:34 [PATCH v2] octeon_ep: Add missing check for ioremap Jiasheng Jiang
  2023-06-15  3:40 ` Kalesh Anakkur Purayil
@ 2023-06-15 15:44 ` Veerasenareddy Burru
  2023-06-15 22:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Veerasenareddy Burru @ 2023-06-15 15:44 UTC (permalink / raw)
  To: Jiasheng Jiang, kuba@kernel.org
  Cc: Abhijit Ayarekar, davem@davemloft.net, edumazet@google.com,
	pabeni@redhat.com, Satananda Burla, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org



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


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

* Re: [PATCH v2] octeon_ep: Add missing check for ioremap
  2023-06-15  3:34 [PATCH v2] octeon_ep: Add missing check for ioremap Jiasheng Jiang
  2023-06-15  3:40 ` Kalesh Anakkur Purayil
  2023-06-15 15:44 ` [EXT] " Veerasenareddy Burru
@ 2023-06-15 22:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-06-15 22:10 UTC (permalink / raw)
  To: Jiasheng Jiang
  Cc: kuba, vburru, aayarekar, davem, edumazet, pabeni, sburla, netdev,
	linux-kernel

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2023-06-15 22:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-15  3:34 [PATCH v2] octeon_ep: Add missing check for ioremap Jiasheng Jiang
2023-06-15  3:40 ` Kalesh Anakkur Purayil
2023-06-15 15:44 ` [EXT] " Veerasenareddy Burru
2023-06-15 22:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).