From: Maxime Ripard <maxime.ripard@bootlin.com>
To: Jani Nikula <jani.nikula@linux.intel.com>
Cc: eben@raspberrypi.org, David Airlie <airlied@linux.ie>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
dri-devel@lists.freedesktop.org,
Paul Kocialkowski <paul.kocialkowski@bootlin.com>,
Sean Paul <seanpaul@chromium.org>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Daniel Vetter <daniel.vetter@intel.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v4 02/12] drm/client: Restrict the plane_state scope
Date: Fri, 14 Jun 2019 16:12:11 +0200 [thread overview]
Message-ID: <20190614141211.rl7ihqgzllcai634@flea> (raw)
In-Reply-To: <87wohouz90.fsf@intel.com>
[-- Attachment #1.1: Type: text/plain, Size: 2479 bytes --]
Hi Jani,
On Fri, Jun 14, 2019 at 03:28:59PM +0300, Jani Nikula wrote:
> On Fri, 14 Jun 2019, Maxime Ripard <maxime.ripard@bootlin.com> wrote:
> > The drm_client_modeset_commit_atomic function uses two times the
> > plane_state variable in inner blocks of code, but the variable has a scope
> > global to this function.
> >
> > This will lead to inadvertent devs to reuse the variable in the second
> > block with the value left by the first, without any warning from the
> > compiler since value would have been initialized.
> >
> > Fix this by moving the variable declaration to the proper scope.
>
> This is an improvement, but I'd consider renaming also to not shadow
> variables.
>
> > Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
> > ---
> > drivers/gpu/drm/drm_client_modeset.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c
> > index 006bf7390e7d..8264c3a732b0 100644
> > --- a/drivers/gpu/drm/drm_client_modeset.c
> > +++ b/drivers/gpu/drm/drm_client_modeset.c
> > @@ -861,7 +861,6 @@ EXPORT_SYMBOL(drm_client_panel_rotation);
> > static int drm_client_modeset_commit_atomic(struct drm_client_dev *client, bool active)
> > {
> > struct drm_device *dev = client->dev;
> > - struct drm_plane_state *plane_state;
> > struct drm_plane *plane;
> > struct drm_atomic_state *state;
> > struct drm_modeset_acquire_ctx ctx;
> > @@ -879,6 +878,8 @@ static int drm_client_modeset_commit_atomic(struct drm_client_dev *client, bool
> > state->acquire_ctx = &ctx;
> > retry:
> > drm_for_each_plane(plane, dev) {
> > + struct drm_plane_state *plane_state;
> > +
> > plane_state = drm_atomic_get_plane_state(state, plane);
> > if (IS_ERR(plane_state)) {
> > ret = PTR_ERR(plane_state);
> > @@ -901,6 +902,8 @@ static int drm_client_modeset_commit_atomic(struct drm_client_dev *client, bool
> > unsigned int rotation;
> >
> > if (drm_client_panel_rotation(mode_set, &rotation)) {
> > + struct drm_plane_state *plane_state;
> > +
That's not super clear from that patch, but this variable will not
shadow the first one.
The code layout is pretty much this one:
loop () {
struct drm_plane_state *plane_state;
[...]
}
loop () {
loop () {
struct drm_plane_state *plane_state;
[...]
}
}
so the shadowing doesn't exist
Maxime
--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
[-- Attachment #2: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-06-14 14:12 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-14 12:13 [PATCH v4 00/12] drm/vc4: Allow for more boot-time configuration Maxime Ripard
2019-06-14 12:13 ` [PATCH v4 01/12] drm/connector: Add documentation for drm_cmdline_mode Maxime Ripard
2019-06-15 8:51 ` Noralf Trønnes
2019-06-14 12:13 ` [PATCH v4 02/12] drm/client: Restrict the plane_state scope Maxime Ripard
2019-06-14 12:28 ` Jani Nikula
2019-06-14 14:12 ` Maxime Ripard [this message]
2019-06-17 9:27 ` Jani Nikula
2019-06-15 8:52 ` Noralf Trønnes
2019-06-14 12:13 ` [PATCH v4 03/12] drm/client: Restrict the rotation check to the rotation itself Maxime Ripard
2019-06-15 8:59 ` Noralf Trønnes
2019-06-14 12:13 ` [PATCH v4 04/12] drm/client: Change drm_client_panel_rotation name Maxime Ripard
2019-06-15 9:01 ` Noralf Trønnes
2019-06-14 12:13 ` [PATCH v4 05/12] drm/modes: Rewrite the command line parser Maxime Ripard
2019-06-15 9:11 ` Noralf Trønnes
2019-06-14 12:13 ` [PATCH v4 06/12] drm/modes: Support modes names on the command line Maxime Ripard
2019-06-14 12:13 ` [PATCH v4 07/12] drm/modes: Allow to specify rotation and reflection on the commandline Maxime Ripard
2019-06-15 9:21 ` Noralf Trønnes
2019-06-14 12:13 ` [PATCH v4 08/12] drm/connector: Introduce a TV margins structure Maxime Ripard
2019-06-15 14:54 ` Noralf Trønnes
2019-06-14 12:13 ` [PATCH v4 09/12] drm/atomic: Add a function to reset connector TV properties Maxime Ripard
2019-06-15 15:30 ` Noralf Trønnes
2019-06-14 12:13 ` [PATCH v4 10/12] drm/modes: Parse overscan properties Maxime Ripard
2019-06-15 15:40 ` Noralf Trønnes
2019-06-16 9:54 ` Noralf Trønnes
2019-06-14 12:13 ` [PATCH v4 11/12] drm/selftests: Add command line parser selftests Maxime Ripard
2019-06-14 12:13 ` [PATCH v4 12/12] drm/vc4: hdmi: Set default state margin at reset Maxime Ripard
2019-06-15 15:43 ` Noralf Trønnes
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=20190614141211.rl7ihqgzllcai634@flea \
--to=maxime.ripard@bootlin.com \
--cc=airlied@linux.ie \
--cc=daniel.vetter@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=eben@raspberrypi.org \
--cc=jani.nikula@linux.intel.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=paul.kocialkowski@bootlin.com \
--cc=seanpaul@chromium.org \
--cc=thomas.petazzoni@bootlin.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;
as well as URLs for NNTP newsgroup(s).