All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/nouveau/core: ERR_PTR vs NULL bug in nvkm_engine_info()
@ 2018-05-30 10:17 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2018-05-30 10:17 UTC (permalink / raw)
  To: Ben Skeggs
  Cc: David Airlie, nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

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>

diff --git a/drivers/gpu/drm/nouveau/nvkm/core/engine.c b/drivers/gpu/drm/nouveau/nvkm/core/engine.c
index d0322ce85172..ee3fbee905e6 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/engine.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/engine.c
@@ -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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] drm/nouveau/core: ERR_PTR vs NULL bug in nvkm_engine_info()
@ 2018-05-30 10:17 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2018-05-30 10:17 UTC (permalink / raw)
  To: Ben Skeggs
  Cc: David Airlie, nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

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>

diff --git a/drivers/gpu/drm/nouveau/nvkm/core/engine.c b/drivers/gpu/drm/nouveau/nvkm/core/engine.c
index d0322ce85172..ee3fbee905e6 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/engine.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/engine.c
@@ -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
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-30 10:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-30 10:17 [PATCH] drm/nouveau/core: ERR_PTR vs NULL bug in nvkm_engine_info() Dan Carpenter
2018-05-30 10:17 ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.