drm/nouveau/core: ERR_PTR vs NULL bug in nvkm_engine_info()
authorBen Skeggs <bskeggs@redhat.com>
Thu, 14 Jun 2018 21:59:28 +0000 (07:59 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Mon, 16 Jul 2018 08:06:29 +0000 (18:06 +1000)
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nvkm/core/engine.c

index d0322ce85172a3f20748a074b9d90f854ae37a03..1a47c40e171b36e0e2ee519ea30851357ca99f05 100644 (file)
@@ -87,11 +87,12 @@ nvkm_engine_info(struct nvkm_subdev *subdev, u64 mthd, u64 *data)
 {
        struct nvkm_engine *engine = nvkm_engine(subdev);
        if (engine->func->info) {
-               if ((engine = nvkm_engine_ref(engine))) {
+               if (!IS_ERR((engine = nvkm_engine_ref(engine)))) {
                        int ret = engine->func->info(engine, mthd, data);
                        nvkm_engine_unref(&engine);
                        return ret;
                }
+               return PTR_ERR(engine);
        }
        return -ENOSYS;
 }