[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAH-L+nM3kPWxyLn_iO7ktmd5E+URG=EfPW2FWnd6fxdSVdb7Hg@mail.gmail.com>
Date: Wed, 14 Jun 2023 11:33:17 +0530
From: Kalesh Anakkur Purayil <kalesh-anakkur.purayil@...adcom.com>
To: Jiasheng Jiang <jiasheng@...as.ac.cn>
Cc: vburru@...vell.com, aayarekar@...vell.com, davem@...emloft.net,
edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com, sburla@...vell.com,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] octeon_ep: Add missing check for ioremap
One suggestion inline.
LGTM otherwise
On Wed, Jun 14, 2023 at 8:54 AM Jiasheng Jiang <jiasheng@...as.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@...as.ac.cn>
>
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@...adcom.com>
> ---
> drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
> b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
> index e1853da280f9..06816d2baef8 100644
> --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
> +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
> @@ -969,7 +969,7 @@ static const char *octep_devid_to_str(struct
> octep_device *oct)
> int octep_device_setup(struct octep_device *oct)
> {
> struct pci_dev *pdev = oct->pdev;
> - int i, ret;
> + int i, j, ret;
>
> /* allocate memory for oct->conf */
> oct->conf = kzalloc(sizeof(*oct->conf), GFP_KERNEL);
> @@ -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 unsupported_dev;
> +
> oct->mmio[i].mapped = 1;
> }
>
> @@ -1015,8 +1018,8 @@ int octep_device_setup(struct octep_device *oct)
> return 0;
>
> unsupported_dev:
> - for (i = 0; i < OCTEP_MMIO_REGIONS; i++)
> - iounmap(oct->mmio[i].hw_addr);
> + for (j = 0; j < i; j++)
> + iounmap(oct->mmio[j].hw_addr);
>
> kfree(oct->conf);
> return -1;
>
[Kalesh]: fix to return -ENOMEM instead of -1.
> --
> 2.25.1
>
>
>
--
Regards,
Kalesh A P
Content of type "text/html" skipped
Download attachment "smime.p7s" of type "application/pkcs7-signature" (4239 bytes)
Powered by blists - more mailing lists