From: Jakub Kicinski <kuba@kernel.org>
To: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Cc: vburru@marvell.com, aayarekar@marvell.com, davem@davemloft.net,
edumazet@google.com, pabeni@redhat.com, sburla@marvell.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] octeon_ep: Add missing check for ioremap
Date: Wed, 14 Jun 2023 12:53:04 -0700 [thread overview]
Message-ID: <20230614125304.294dd2ef@kernel.org> (raw)
In-Reply-To: <20230614032347.32940-1-jiasheng@iscas.ac.cn>
On Wed, 14 Jun 2023 11:23:47 +0800 Jiasheng Jiang wrote:
> @@ -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);
Assuming @i is not changed by the rest of the function is a bit fragile.
Better way of handling this situation is:
unsupported_dev:
i = OCTEP_MMIO_REGIONS;
unmap_prev:
while (i--)
iounmap(oct->mmio[i].hw_addr);
and jump to unmap_prev
--
pw-bot: cr
next prev parent reply other threads:[~2023-06-14 19:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-14 3:23 [PATCH] octeon_ep: Add missing check for ioremap Jiasheng Jiang
2023-06-14 6:03 ` Kalesh Anakkur Purayil
2023-06-14 19:51 ` Jakub Kicinski
2023-06-14 19:53 ` Jakub Kicinski [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-06-15 3:24 Jiasheng Jiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230614125304.294dd2ef@kernel.org \
--to=kuba@kernel.org \
--cc=aayarekar@marvell.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jiasheng@iscas.ac.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sburla@marvell.com \
--cc=vburru@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.