@@ -86,14 +86,17 @@ static int
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))) {
- int ret = engine->func->info(engine, mthd, data);
- nvkm_engine_unref(&engine);
- return ret;
- }
- }
- return -ENOSYS;
+ int ret;
+
+ if (!engine->func->info)
+ return -ENOSYS;
+
+ engine = nvkm_engine_ref(engine);
+ if (IS_ERR(engine))
+ return PTR_ERR(engine);
+ ret = engine->func->info(engine, mthd, data);
+ nvkm_engine_unref(&engine);
+ return ret;
}
static int
The nvkm_engine_ref() function returns error pointers, not NULL on error. I fixed that but I also had to reverse some of the checks so it didn't become too convoluted. Fixes: c5c9127b25b2 ("drm/nouveau/device: implement a generic method to query device-specific properties") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>