Re: [PATCH 2/2] drm/dp: Don't trust drm_dp_downstream_id()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Quoting Jani Nikula (2017-07-21 08:22:27)
> On Thu, 20 Jul 2017, Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> wrote:
> > Before we interpret drm_dp_downstream_id() as a string, make sure it is
> > NULL terminated, even when drm_dp_downtsream_id() fails.
> >
> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101660
> > Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
> > ---
> >  drivers/gpu/drm/drm_dp_helper.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
> > index 1d9e30f0dbf8..08af8d6b844b 100644
> > --- a/drivers/gpu/drm/drm_dp_helper.c
> > +++ b/drivers/gpu/drm/drm_dp_helper.c
> > @@ -544,7 +544,7 @@ void drm_dp_downstream_debug(struct seq_file *m,
> >                                DP_DETAILED_CAP_INFO_AVAILABLE;
> >       int clk;
> >       int bpc;
> > -     char id[6];
> > +     char id[7];
> >       int len;
> >       uint8_t rev[2];
> >       int type = port_cap[0] & DP_DS_PORT_TYPE_MASK;
> > @@ -583,6 +583,7 @@ void drm_dp_downstream_debug(struct seq_file *m,
> >               seq_puts(m, "        Type: N/A\n");
> >       }
> >  
> > +     memset(id, 0, sizeof(id));
> >       drm_dp_downstream_id(aux, id);
> >       seq_printf(m, "        ID: %s\n", id);
> 
> Reviewed-by: Jani Nikula <jani.nikula@xxxxxxxxx>
> 
> although I'd probably have gone for checking the return value of
> drm_dp_downstream_id() and using %*pE format with strnlen for the
> length.

I'm also wondering if we should treat it as a string? Print hexadecimal
+ ascii? There's probably a printf specifier for that as well.
-Chris
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux