From: sashiko-bot@kernel.org
To: "Hangxiang Ma" <hangxiang.ma@oss.qualcomm.com>
Cc: robh@kernel.org, linux-media@vger.kernel.org,
conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v14 2/5] media: qcom: camss: Add Kaanapali compatible camss driver
Date: Mon, 01 Jun 2026 15:59:20 +0000 [thread overview]
Message-ID: <20260601155921.2A9831F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260601-kaanapali-camss-v14-2-e76f26aa6691@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Unconditional dereference of `camss->genpd` during error handling and driver unbind when the PM domain was not successfully attached.
- [High] devm_ managed lifetime of driver structures conflicts with V4L2 video device file descriptor lifetime, causing a Use-After-Free on sysfs unbind.
--
commit d11af4da6f46342576374344948cc4914a3b8685
Author: Hangxiang Ma <hangxiang.ma@oss.qualcomm.com>
media: qcom: camss: Add Kaanapali compatible camss driver
Add support for Kaanapali in the camss driver. Add high level resource
information along with the bus bandwidth votes. Module level detailed
resource information will be enumerated in the following patches of the
series.
> diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
> index 2123f6388e3d7..40d74966ef9b6 100644
> --- a/drivers/media/platform/qcom/camss/camss.c
> +++ b/drivers/media/platform/qcom/camss/camss.c
[ ... ]
> @@ -5507,6 +5521,13 @@ static void camss_remove(struct platform_device *pdev)
> camss_genpd_cleanup(camss);
[Severity: High]
This isn't a bug introduced by this patch, but does this unconditionally
dereference camss->genpd during error handling and driver unbind when the power
domain was not successfully attached?
In camss_configure_pd(), if camss->genpd_num > 1 but camss->genpd_num <=
vfepd_num, it returns 0 early without attaching top power domains, leaving
camss->genpd as null:
drivers/media/platform/qcom/camss/camss.c:camss_configure_pd() {
...
if (!(camss->genpd_num > vfepd_num))
return 0;
...
}
Later, during cleanup in camss_genpd_cleanup(), the code skips cleanup only if
camss->genpd_num == 1:
drivers/media/platform/qcom/camss/camss.c:camss_genpd_cleanup() {
...
if (camss->genpd_num == 1)
return;
...
dev_pm_domain_detach(camss->genpd, true);
...
}
dev_pm_domain_detach() does not check for a null device pointer and immediately
dereferences dev->pm_domain, which can cause a panic on probe failure or driver
unbind for valid hardware configurations where genpd_num > 1.
[Severity: High]
This is a pre-existing issue, but does the devm_ managed lifetime of driver
structures conflict with the v4l2 video device file descriptor lifetime here?
The driver allocates its core state using devm_kzalloc and devm_kcalloc:
drivers/media/platform/qcom/camss/camss.c:camss_probe() {
...
camss = devm_kzalloc(dev, sizeof(*camss), GFP_KERNEL);
...
camss->vfe = devm_kcalloc(dev, camss->res->vfe_num,
sizeof(*camss->vfe), GFP_KERNEL);
...
}
When the driver is unbound via sysfs, camss_remove() executes and returns,
causing devres to immediately free all devm_ memory. However, if a user process
holds an open file descriptor to the video node during unbind, the v4l2 core
retains a reference to the video_device.
When the user later closes the file descriptor, v4l2_release() calls
msm_video_release(), which accesses video->camss->ref_count within the already
freed memory:
drivers/media/platform/qcom/camss/camss-video.c:msm_video_release() {
...
if (atomic_dec_and_test(&video->camss->ref_count))
camss_delete(video->camss);
...
}
Can this lead to a use-after-free?
> }
>
> +static const struct camss_resources kaanapali_resources = {
> + .version = CAMSS_KAANAPALI,
> + .pd_name = "top",
> + .icc_res = icc_res_kaanapali,
> + .icc_path_num = ARRAY_SIZE(icc_res_kaanapali),
> +};
> +
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260601-kaanapali-camss-v14-0-e76f26aa6691@oss.qualcomm.com?part=2
next prev parent reply other threads:[~2026-06-01 15:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-01 15:31 [PATCH v14 0/5] media: qcom: camss: Add Kaanapali support Hangxiang Ma
2026-06-01 15:31 ` [PATCH v14 1/5] media: dt-bindings: Add CAMSS device for Kaanapali Hangxiang Ma
2026-06-01 15:31 ` [PATCH v14 2/5] media: qcom: camss: Add Kaanapali compatible camss driver Hangxiang Ma
2026-06-01 15:59 ` sashiko-bot [this message]
2026-06-01 15:31 ` [PATCH v14 3/5] media: qcom: camss: csiphy: Add support for v2.4.0 two-phase CSIPHY Hangxiang Ma
2026-06-01 15:31 ` [PATCH v14 4/5] media: qcom: camss: csid: Add support for CSID gen4 Hangxiang Ma
2026-06-01 16:27 ` sashiko-bot
2026-06-01 15:31 ` [PATCH v14 5/5] media: qcom: camss: vfe: Add support for VFE gen4 Hangxiang Ma
2026-06-01 16:44 ` sashiko-bot
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=20260601155921.2A9831F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=hangxiang.ma@oss.qualcomm.com \
--cc=linux-media@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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