[Nouveau] [PATCH 2/2] gr/gf100: do not assume a PMU is present

Alexandre Courbot gnurou at gmail.com
Thu Sep 3 00:11:26 PDT 2015


On Thu, Sep 3, 2015 at 4:08 PM, Ben Skeggs <skeggsb at gmail.com> wrote:
> On 3 September 2015 at 16:32, Alexandre Courbot <acourbot at nvidia.com> wrote:
>> Some devices may not have a PMU. Avoid a NULL pointer dereference in
>> such cases.
>>
>> Signed-off-by: Alexandre Courbot <acourbot at nvidia.com>
>> ---
>>  drm/nouveau/nvkm/engine/gr/gf100.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drm/nouveau/nvkm/engine/gr/gf100.c b/drm/nouveau/nvkm/engine/gr/gf100.c
>> index f1358a564e3e..f252fa2d7cf9 100644
>> --- a/drm/nouveau/nvkm/engine/gr/gf100.c
>> +++ b/drm/nouveau/nvkm/engine/gr/gf100.c
>> @@ -1499,7 +1499,8 @@ gf100_gr_oneinit(struct nvkm_gr *base)
>>         struct nvkm_device *device = gr->base.engine.subdev.device;
>>         int ret, i, j;
>>
>> -       nvkm_pmu_pgob(device->pmu, false);
>> +       if (device->pmu)
>> +               nvkm_pmu_pgob(device->pmu, false);
> I'd probably just change the condition in nvkm_pmu_pgob() to (pmu &&
> pmu->func->pgob) ?

It seems logical to me that the caller should check that the object it
tries to call a method on is valid (just like in C++ you don't expect
methods to check whether this == NULL), but your call.


More information about the Nouveau mailing list