secboot: fix inconsistent pointer checking

Submitted by Alexandre Courbot on March 15, 2017, 5:44 a.m.

Details

Message ID 20170315054434.15788-1-acourbot@nvidia.com
State New
Headers show
Series "secboot: fix inconsistent pointer checking" ( rev: 1 ) in Nouveau

Not browsing as part of any series.

Commit Message

Alexandre Courbot March 15, 2017, 5:44 a.m.
We were returning PTR_ERR() on a NULL pointer, which obviously won't
work. nvkm_engine_ref() will return an error in case something went
wrong.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drm/nouveau/nvkm/subdev/secboot/gp102.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drm/nouveau/nvkm/subdev/secboot/gp102.c b/drm/nouveau/nvkm/subdev/secboot/gp102.c
index 8570c84c8a29..f3b3c66349d2 100644
--- a/drm/nouveau/nvkm/subdev/secboot/gp102.c
+++ b/drm/nouveau/nvkm/subdev/secboot/gp102.c
@@ -59,7 +59,8 @@  gp102_run_secure_scrub(struct nvkm_secboot *sb)
 
 	nvkm_debug(subdev, "running VPR scrubber binary on NVDEC...\n");
 
-	if (!(engine = nvkm_engine_ref(&device->nvdec->engine)))
+	engine = nvkm_engine_ref(&device->nvdec->engine);
+	if (IS_ERR(engine))
 		return PTR_ERR(engine);
 	falcon = device->nvdec->falcon;