lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160831154002.GC14379@lukather>
Date:   Wed, 31 Aug 2016 17:40:02 +0200
From:   Maxime Ripard <maxime.ripard@...e-electrons.com>
To:     Chen-Yu Tsai <wens@...e.org>
Cc:     David Airlie <airlied@...ux.ie>,
        dri-devel <dri-devel@...ts.freedesktop.org>,
        linux-arm-kernel <linux-arm-kernel@...ts.infradead.org>,
        linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] drm/sun4i: Clear encoder->bridge if a bridge is not found

On Tue, Aug 30, 2016 at 11:51:26PM +0800, Chen-Yu Tsai wrote:
> On Tue, Aug 30, 2016 at 8:56 PM, Maxime Ripard
> <maxime.ripard@...e-electrons.com> wrote:
> > Hi,
> >
> > On Tue, Aug 30, 2016 at 08:22:23PM +0800, Chen-Yu Tsai wrote:
> >> The KMS helpers (drm_atomic_helper_check_modeset/mode_fixup) pass
> >> encoder->bridge directly to drm_bridge_mode_fixup, which expects a
> >> valid pointer, or NULL (in which case it just returns).
> >>
> >> Clear encoder->bridge if a bridge is not found, instead of keeping
> >> the ERR_PTR value.
> >>
> >> Since other drm_bridge functions also follow this pattern of checking
> >> for a non-NULL pointer, we can drop the ifs around the calls and just
> >> pass the pointer directly.
> >>
> >> Fixes: 894f5a9f4b4a ("drm/sun4i: Add bridge support")
> >> Signed-off-by: Chen-Yu Tsai <wens@...e.org>
> >> ---
> >>  drivers/gpu/drm/sun4i/sun4i_rgb.c | 11 ++++++-----
> >>  1 file changed, 6 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/sun4i/sun4i_rgb.c b/drivers/gpu/drm/sun4i/sun4i_rgb.c
> >> index d4e52522ec53..ee0795152a33 100644
> >> --- a/drivers/gpu/drm/sun4i/sun4i_rgb.c
> >> +++ b/drivers/gpu/drm/sun4i/sun4i_rgb.c
> >> @@ -154,8 +154,7 @@ static void sun4i_rgb_encoder_enable(struct drm_encoder *encoder)
> >>       if (!IS_ERR(tcon->panel))
> >>               drm_panel_enable(tcon->panel);
> >>
> >> -     if (!IS_ERR(encoder->bridge))
> >> -             drm_bridge_enable(encoder->bridge);
> >> +     drm_bridge_enable(encoder->bridge);
> >>
> >>       sun4i_tcon_channel_enable(tcon, 0);
> >>  }
> >> @@ -170,8 +169,7 @@ static void sun4i_rgb_encoder_disable(struct drm_encoder *encoder)
> >>
> >>       sun4i_tcon_channel_disable(tcon, 0);
> >>
> >> -     if (!IS_ERR(encoder->bridge))
> >> -             drm_bridge_disable(encoder->bridge);
> >> +     drm_bridge_disable(encoder->bridge);
> >
> > I'd rather keep those changes, it makes it obvious that it's something
> > optionnal, that can be set to NULL.
> 
> OK.
> 
> >>       if (!IS_ERR(tcon->panel))
> >>               drm_panel_disable(tcon->panel);
> >> @@ -230,6 +228,9 @@ int sun4i_rgb_init(struct drm_device *drm)
> >>               return 0;
> >>       }
> >>
> >> +     if (IS_ERR(encoder->bridge))
> >> +             encoder->bridge = NULL;
> >> +
> >
> > And that could be the else condition of the if statement below.
> 
> That would be a bit confusing, changing it after calling drm_encoder_init.
> The code says it ok to do though.

The magic really happens only after the encoder has been attached to
something, so it's really safe.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

Download attachment "signature.asc" of type "application/pgp-signature" (820 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ