[Mesa-dev] [PATCH 07/25] dri/nouveau: add GLX_MESA_query_renderer support

Emil Velikov emil.l.velikov at gmail.com
Sun Feb 23 03:49:00 PST 2014


On 23/02/14 07:24, Pekka Paalanen wrote:
> On Sat, 22 Feb 2014 03:03:57 +0000
> Emil Velikov <emil.l.velikov at gmail.com> wrote:
> 
>> v2: nv04-2x cards support upto opengl 1.3.
>> v3: Include correct headers.
>>
>> Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
>> ---
>>  src/mesa/drivers/dri/nouveau/nouveau_screen.c | 83 ++++++++++++++++++++++++++-
>>  1 file changed, 82 insertions(+), 1 deletion(-)
> ...
> 
> I still think there is something funny here:
> 
>> +static int
>> +nouveau_query_renderer_integer(__DRIscreen *psp, int param,
>> +			       unsigned int *value)
>> +{
>> +   const struct nouveau_screen *const screen =
>> +      (struct nouveau_screen *) psp->driverPrivate;
>> +
>> +   switch (param) {
>> +   case __DRI2_RENDERER_VENDOR_ID:
>> +      value[0] = 0x10de;
>> +      return 0;
>> +   case __DRI2_RENDERER_DEVICE_ID: {
>> +      struct drm_nouveau_getparam gp;
>> +      int *chip_id = 0, ret;
> 
> chip_id is set to NULL.
> 
>> +
>> +      memset(&gp, 0, sizeof(gp));
>> +      gp.param = NOUVEAU_GETPARAM_PCI_DEVICE;
>> +      gp.value = (unsigned long) chip_id;
> 
> gp.value is now 0 (NULL).
> 
>> +
>> +      ret = drmCommandWriteRead(psp->fd, DRM_NOUVEAU_GETPARAM, &gp, sizeof(gp));
>> +      if (ret) {
>> +         nouveau_error("Error retrieving NOUVEAU_GETPARAM_PCI_DEVICE.\n");
>> +         *chip_id = -1;
> 
> Dereferencing NULL.
> 
>> +      }
>> +      value[0] = *chip_id;
> 
> Dereferencing NULL.
> 
> Am I missing something? You didn't mention anything about this when
> Ilia pointed it out.
> 
After Ilia pointed out my messy handling in this hunk and the
abstraction violation I've decided to go with nouveau_getparam(), thus
why I did not bring up again this flawed piece of code.

Thanks you for having a look, and pardon for the pain this may have caused.

-Emil
> 
> Thanks,
> pq
> 
>> +      return 0;
>> +   }



More information about the mesa-dev mailing list