From: Dan Carpenter <dan.carpenter@linaro.org>
To: Siddarth G <siddarthsgml@gmail.com>
Cc: slongerbeam@gmail.com, p.zabel@pengutronix.de,
mchehab@kernel.org, gregkh@linuxfoundation.org,
shawnguo@kernel.org, s.hauer@pengutronix.de,
kernel@pengutronix.de, festevam@gmail.com,
linux-media@vger.kernel.org, linux-staging@lists.linux.dev,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, skhan@linuxfoundation.org
Subject: Re: [PATCH] staging/media/imx: fix null pointer dereference
Date: Thu, 10 Apr 2025 09:17:40 +0300 [thread overview]
Message-ID: <0d496695-ce20-4774-8e86-4d5c98dc220b@stanley.mountain> (raw)
In-Reply-To: <20250409211727.62710-1-siddarthsgml@gmail.com>
On Thu, Apr 10, 2025 at 02:47:27AM +0530, Siddarth G wrote:
> Cppcheck warnings:
>
> drivers/staging/media/imx/imx-media-fim.c:79:6:
> error: Null pointer dereference: fi [ctunullpointer]
> if (fi->denominator == 0) {
>
> drivers/staging/media/imx/imx-media-csi.c:795:27:
> note: Calling function imx_media_fim_set_stream, 2nd argument is null
> imx_media_fim_set_stream(priv->fim, NULL, false);
^^^^^
This is a false positive. The false means that we don't call
update_fim_nominal(). Btw, Smatch parses this one correctly.
>
> drivers/staging/media/imx/imx-media-fim.c:388:3:
> note: Calling function update_fim_nominal, 2nd argument is null
> update_fim_nominal(fim, fi);
>
> drivers/staging/media/imx/imx-media-fim.c:79:6:
> note: Dereferencing argument fi that is null
> if (fi->denominator == 0) {
>
> To fix the issue, add a check to validate that the 'fi' is not
> null before accessing its members.
>
> Signed-off-by: Siddarth G <siddarthsgml@gmail.com>
Don't resend because we just ignore false positives instead of
trying to silence them. But if this were a real bug then it
would need a Fixes tag.
> ---
> drivers/staging/media/imx/imx-media-fim.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/staging/media/imx/imx-media-fim.c b/drivers/staging/media/imx/imx-media-fim.c
> index ccbc0371fba2..25f79d0f87b9 100644
> --- a/drivers/staging/media/imx/imx-media-fim.c
> +++ b/drivers/staging/media/imx/imx-media-fim.c
> @@ -76,6 +76,9 @@ static bool icap_enabled(struct imx_media_fim *fim)
> static void update_fim_nominal(struct imx_media_fim *fim,
> const struct v4l2_fract *fi)
> {
> + if (!fi)
> + return;
If this were a real bug, then probably the NULL check would be better in
the caller.
regards,
dan carpenter
> +
> if (fi->denominator == 0) {
> dev_dbg(fim->sd->dev, "no frame interval, FIM disabled\n");
> fim->enabled = false;
> --
> 2.43.0
>
prev parent reply other threads:[~2025-04-10 6:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-09 21:17 Siddarth G
2025-04-10 6:17 ` 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=0d496695-ce20-4774-8e86-4d5c98dc220b@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=festevam@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=mchehab@kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=siddarthsgml@gmail.com \
--cc=skhan@linuxfoundation.org \
--cc=slongerbeam@gmail.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
all inboxes | Powered by JetHome®