From: Dan Carpenter <dan.carpenter@linaro.org>
To: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Cc: linux-media@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com
Subject: [bug report] media: subdev: Add v4l2_subdev_call_state_try() macro
Date: Thu, 7 Aug 2025 19:00:54 +0300 [thread overview]
Message-ID: <aJTNtpDUbTz7eyJc@stanley.mountain> (raw)
Hello Tomi Valkeinen,
Commit 982c0487185b ("media: subdev: Add v4l2_subdev_call_state_try()
macro") from Jul 1, 2022 (linux-next), leads to the following Smatch
static checker warning:
drivers/media/platform/st/stm32/stm32-dcmi.c:995 dcmi_try_fmt()
error: 'state' dereferencing possible ERR_PTR()
drivers/media/platform/st/stm32/stm32-dcmi.c
993
994 v4l2_fill_mbus_format(&format.format, pix, sd_fmt->mbus_code);
--> 995 ret = v4l2_subdev_call_state_try(dcmi->source, pad, set_fmt, &format);
The problem is the v4l2_subdev_call_state_try() macro:
1965 #define v4l2_subdev_call_state_try(sd, o, f, args...) \
1966 ({ \
1967 int __result; \
1968 static struct lock_class_key __key; \
1969 const char *name = KBUILD_BASENAME \
1970 ":" __stringify(__LINE__) ":state->lock"; \
1971 struct v4l2_subdev_state *state = \
1972 __v4l2_subdev_state_alloc(sd, name, &__key); \
^^^^^^^^^^^^^^^^^^^^^^^^^
If this fails
1973 v4l2_subdev_lock_state(state); \
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
then it leads to a crash.
1974 __result = v4l2_subdev_call(sd, o, f, state, ##args); \
1975 v4l2_subdev_unlock_state(state); \
1976 __v4l2_subdev_state_free(state); \
1977 __result; \
1978 })
regards,
dan carpenter
next reply other threads:[~2025-08-07 16:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-07 16:00 Dan Carpenter [this message]
2025-08-08 8:47 ` [bug report] media: subdev: Add v4l2_subdev_call_state_try() macro Tomi Valkeinen
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=aJTNtpDUbTz7eyJc@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=tomi.valkeinen@ideasonboard.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