On Thu, Mar 01, 2018 at 02:14:41PM +0000, Eric Engestrom wrote: > > > On March 1, 2018 1:31:53 PM UTC, Thierry Reding <thierry.red...@gmail.com> > wrote: > > From: Thierry Reding <tred...@nvidia.com> > > > > ARM SoCs usually have their DRM/KMS devices on the platform bus, so > > add > > support for this bus in order to allow use of the DRI_PRIME > > environment > > variable with those devices. > > > > While at it, also support the host1x bus, which is effectively the > > same > > but uses an additional layer in the bus hierarchy. > > > > Note that it isn't enough to support the bus that has the rendering > > GPU > > because the loader code will also try to construct an ID path tag for > > a > > scanout-only device if it is the default that is being opened. > > > > The ID path tag for a device can be obtained by running udevadm info > > on > > the device node: > > > > $ udevadm info /dev/dri/card0 > > > > and looking up the ID_PATH_TAG entry in the output. > > > > Signed-off-by: Thierry Reding <tred...@nvidia.com> > > --- > > src/loader/loader.c | 27 +++++++++++++++++++++++++++ > > 1 file changed, 27 insertions(+) > > > > diff --git a/src/loader/loader.c b/src/loader/loader.c > > index 92b4c5204b19..ca578b8cd232 100644 > > --- a/src/loader/loader.c > > +++ b/src/loader/loader.c > > @@ -120,6 +120,33 @@ static char > > *drm_construct_id_path_tag(drmDevicePtr device) > > device->businfo.pci->func) < 0) { > > return NULL; > > } > > + } else if (device->bustype == DRM_BUS_PLATFORM || > > + device->bustype == DRM_BUS_HOST1X) { > > + char *fullname, *name, *address; > > + > > + if (device->bustype == DRM_BUS_PLATFORM) > > + fullname = device->businfo.platform->fullname; > > + else > > + fullname = device->businfo.host1x->fullname; > > + > > + name = strrchr(fullname, '/'); > > + if (!name) > > + name = strdup(fullname); > > + else > > + name = strdup(++name); > > Looks like UB to me; how about this instead? > > name = strdup(name + 1);
I don't think the above is problematic. ++name is guaranteed to be evaluated before the call to strdup(), and name can't be overwritten by the assignment until after strdup() is done. But I have no objection to change this to your suggestion, which is slightly easier to read irrespective of UB or not. I'm honestly not exactly sure why I wrote it in this strange way. I /think/ an earlier version of the patch wasn't assigning to name but another variable and reusing the name variable, which is why it had to be incremented. But that's no longer necessary. > With that: > Reviewed-by: Eric Engestrom <e...@engestrom.ch> Thanks, Thierry
signature.asc
Description: PGP signature
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev