drm/nouveau/clk: Fix potential NULL pointer access when there is no fb subdev
authorKarol Herbst <karolherbst@gmail.com>
Tue, 12 Jul 2016 19:36:08 +0000 (21:36 +0200)
committerBen Skeggs <bskeggs@redhat.com>
Wed, 12 Oct 2016 07:29:18 +0000 (17:29 +1000)
Signed-off-by: Karol Herbst <karolherbst@gmail.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c

index 7102c25320fc273c64da5534e9339c7ff27cabce..1defd3215ed376d6bce0d7ebe266ebce61789f4d 100644 (file)
@@ -175,7 +175,7 @@ static int
 nvkm_pstate_prog(struct nvkm_clk *clk, int pstatei)
 {
        struct nvkm_subdev *subdev = &clk->subdev;
-       struct nvkm_ram *ram = subdev->device->fb->ram;
+       struct nvkm_fb *fb = subdev->device->fb;
        struct nvkm_pci *pci = subdev->device->pci;
        struct nvkm_pstate *pstate;
        int ret, idx = 0;
@@ -190,7 +190,8 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstatei)
 
        nvkm_pcie_set_link(pci, pstate->pcie_speed, pstate->pcie_width);
 
-       if (ram && ram->func->calc) {
+       if (fb && fb->ram && fb->ram->func->calc) {
+               struct nvkm_ram *ram = fb->ram;
                int khz = pstate->base.domain[nv_clk_src_mem];
                do {
                        ret = ram->func->calc(ram, khz);