From: Sui Jingfeng <15330273260@189.cn>
To: Gencen Gan <gangecen@hust.edu.cn>,
Gerd Hoffmann <kraxel@redhat.com>,
David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>
Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
virtualization@lists.linux-foundation.org
Subject: Re: [PING] drm/bochs: replace ioremap with devm_ioremap to avoid immo leak
Date: Fri, 31 Mar 2023 23:10:57 +0800 [thread overview]
Message-ID: <45b623af-e72e-f728-5ce6-dce014a772ed@189.cn> (raw)
In-Reply-To: <20230329052655.3487616-1-gangecen@hust.edu.cn>
Hi,
I'm noticed you patch, interesting!
On 2023/3/29 13:26, Gencen Gan wrote:
> From: Gan Gecen <gangecen@hust.edu.cn>
>
> Smatch reports:
>
> drivers/gpu/drm/tiny/bochs.c:290 bochs_hw_init()
> warn: 'bochs->mmio' from ioremap() not released on
> lines: 246,250,254.
>
> In the function bochs_load() that calls bochs_hw_init()
> only, if bochs_hw_init(dev) returns -ENODEV(-19), it
> will jumps to err_free_dev instead of err_hw_fini, so
> bochs->immo won't be freed.
`mmio`, not `immo`, you should also fix the typos in you patch's
commit title.
> We would prefer to replace ioremap with devm_ioremap
> to avoid adding lengthy error handling. The function
> `devm_ioremap` will automatically release the allocated
> resources after use.
Yet, I notice that there is iounmap in bochs_hw_fini() function, does
double free will happen?
static void bochs_hw_fini(struct drm_device *dev)
{
struct bochs_device *bochs = dev->dev_private;
// ...
if (bochs->mmio)
iounmap(bochs->mmio);
// ...
}
I still advise you free it by adding error handling code, free it manually.
Because still there other ioremap() function in the driver.
But you can choose to heard other reviewer's voice, I can only help to
review.
> Signed-off-by: Gan Gecen <gangecen@hust.edu.cn>
> ---
> drivers/gpu/drm/tiny/bochs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/tiny/bochs.c b/drivers/gpu/drm/tiny/bochs.c
> index 024346054c70..0d7e119a732f 100644
> --- a/drivers/gpu/drm/tiny/bochs.c
> +++ b/drivers/gpu/drm/tiny/bochs.c
> @@ -223,7 +223,7 @@ static int bochs_hw_init(struct drm_device *dev)
> }
> ioaddr = pci_resource_start(pdev, 2);
> iosize = pci_resource_len(pdev, 2);
> - bochs->mmio = ioremap(ioaddr, iosize);
> + bochs->mmio = devm_ioremap(&pdev->dev, ioaddr, iosize);
> if (bochs->mmio == NULL) {
> DRM_ERROR("Cannot map mmio region\n");
> return -ENOMEM;
prev parent reply other threads:[~2023-03-31 15:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-29 5:26 [PING PATCH] " Gencen Gan
2023-03-31 15:10 ` Sui Jingfeng [this message]
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=45b623af-e72e-f728-5ce6-dce014a772ed@189.cn \
--to=15330273260@189.cn \
--cc=airlied@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=gangecen@hust.edu.cn \
--cc=kraxel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®