From: Dan Carpenter <error27@gmail.com>
To: Huihui Huang <hhhuang@smu.edu.sg>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Bingbu Cao <bingbu.cao@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-media@vger.kernel.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: media: ipu7: fix MMU resource leak in ipu7_psys_init()
Date: Fri, 17 Apr 2026 11:59:02 +0300 [thread overview]
Message-ID: <aeH2VjOV4_Ql_zeY@stanley.mountain> (raw)
In-Reply-To: <20260417075807.2691958-1-hhhuang@smu.edu.sg>
On Fri, Apr 17, 2026 at 03:58:07PM +0800, Huihui Huang wrote:
> There is a memory leak in drivers/staging/media/ipu7/ipu7.c.
>
> In ipu7_psys_init(), psys_adev->mmu is allocated by ipu7_mmu_init().
> When ipu7_bus_add_device() fails, the function returns without
> cleaning up the MMU resources.
>
> Add the missing ipu7_mmu_cleanup() call on the error path to free
> the MMU resources.
>
> Signed-off-by: Huihui Huang <hhhuang@smu.edu.sg>
> ---
> drivers/staging/media/ipu7/ipu7.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/staging/media/ipu7/ipu7.c b/drivers/staging/media/ipu7/ipu7.c
> index c771e763f8c5..4039e548dc8f 100644
> --- a/drivers/staging/media/ipu7/ipu7.c
> +++ b/drivers/staging/media/ipu7/ipu7.c
> @@ -2228,6 +2228,7 @@ ipu7_psys_init(struct pci_dev *pdev, struct device *parent,
>
> ret = ipu7_bus_add_device(psys_adev);
> if (ret) {
> + ipu7_mmu_cleanup(psys_adev->mmu);
Same thing. We call ipu7_mmu_cleanup() in the caller, and it looks like
that will trigger a NULL dereference.
> kfree(pdata);
This kfree() is also wrong. We're supposed to do:
put_device(&psys_adev->auxdev.dev);
which calls ipu7_bus_release() and that frees "pdata" along with
psys_adev. In this function the first two error paths are correct
but the next two are buggy.
KTODO: Fix error handling in ipu7_psys_init()
regards,
dan carpenter
prev parent reply other threads:[~2026-04-17 8:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-17 7:58 [PATCH] staging: media: ipu7: fix MMU resource leak in ipu7_psys_init() Huihui Huang
2026-04-17 8:59 ` Dan Carpenter [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=aeH2VjOV4_Ql_zeY@stanley.mountain \
--to=error27@gmail.com \
--cc=bingbu.cao@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=hhhuang@smu.edu.sg \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox