Skip to contentSkip to conversation

drm/nouveau/acr: fix a couple NULL vs IS_ERR() checks

PATCH In review Dan Carpenter 3 participants 3 messages Nov 18, 2021 – Nov 23, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/nouveau/acr: fix a couple NULL vs IS_ERR() checks

The nvkm_acr_lsfw_add() function never returns NULL. It returns error pointers on error.

Fixes 22dcda45a3d1 ("drm/nouveau/acr: implement new subdev to replace "secure boot"")
---
 drivers/gpu/drm/nouveau/nvkm/subdev/acr/gm200.c | 6 ++++--
 drivers/gpu/drm/nouveau/nvkm/subdev/acr/gp102.c | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/nouveau/nvkm/subdev/acr/gm200.c +4 -2
index cdb1ead26d84..82b4c8e1457c 100644
@@ -207,11 +207,13 @@ int
 gm200_acr_wpr_parse(struct nvkm_acr *acr)
 {
 	const struct wpr_header *hdr = (void *)acr->wpr_fw->data;
+	struct nvkm_acr_lsfw *lsfw;
 
 	while (hdr->falcon_id != WPR_HEADER_V0_FALCON_ID_INVALID) {
 		wpr_header_dump(&acr->subdev, hdr);
-		if (!nvkm_acr_lsfw_add(NULL, acr, NULL, (hdr++)->falcon_id))
-			return -ENOMEM;
+		lsfw = nvkm_acr_lsfw_add(NULL, acr, NULL, (hdr++)->falcon_id);
+		if (IS_ERR(lsfw))
+			return PTR_ERR(lsfw);
 	}
 
 	return 0;
drivers/gpu/drm/nouveau/nvkm/subdev/acr/gp102.c +4 -2
index fb9132a39bb1..fd97a935a380 100644
@@ -161,11 +161,13 @@ int
 gp102_acr_wpr_parse(struct nvkm_acr *acr)
 {
 	const struct wpr_header_v1 *hdr = (void *)acr->wpr_fw->data;
+	struct nvkm_acr_lsfw *lsfw;
 
 	while (hdr->falcon_id != WPR_HEADER_V1_FALCON_ID_INVALID) {
 		wpr_header_v1_dump(&acr->subdev, hdr);
-		if (!nvkm_acr_lsfw_add(NULL, acr, NULL, (hdr++)->falcon_id))
-			return -ENOMEM;
+		lsfw = nvkm_acr_lsfw_add(NULL, acr, NULL, (hdr++)->falcon_id);
+		if (IS_ERR(lsfw))
+			return PTR_ERR(lsfw);
 	}
 
 	return 0;
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Dan Carpenter

The nvkm_acr_lsfw_add() function never returns NULL. It returns error pointers on error.

Fixes 22dcda45a3d1 ("drm/nouveau/acr: implement new subdev to replace "secure boot"")
Quoted 48 lines
---
 drivers/gpu/drm/nouveau/nvkm/subdev/acr/gm200.c | 6 ++++--
 drivers/gpu/drm/nouveau/nvkm/subdev/acr/gp102.c | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/nouveau/nvkm/subdev/acr/gm200.c +4 -2
index cdb1ead26d84..82b4c8e1457c 100644
@@ -207,11 +207,13 @@ int
 gm200_acr_wpr_parse(struct nvkm_acr *acr)
 {
        const struct wpr_header *hdr = (void *)acr->wpr_fw->data;
+       struct nvkm_acr_lsfw *lsfw;
 
        while (hdr->falcon_id != WPR_HEADER_V0_FALCON_ID_INVALID) {
                wpr_header_dump(&acr->subdev, hdr);
-               if (!nvkm_acr_lsfw_add(NULL, acr, NULL, (hdr++)->falcon_id))
-                       return -ENOMEM;
+               lsfw = nvkm_acr_lsfw_add(NULL, acr, NULL, (hdr++)->falcon_id);
+               if (IS_ERR(lsfw))
+                       return PTR_ERR(lsfw);
        }
 
        return 0;
drivers/gpu/drm/nouveau/nvkm/subdev/acr/gp102.c +4 -3
index fb9132a39bb1..fd97a935a380 100644
@@ -161,11 +161,13 @@ int
 gp102_acr_wpr_parse(struct nvkm_acr *acr)
 {
        const struct wpr_header_v1 *hdr = (void *)acr->wpr_fw->data;
+       struct nvkm_acr_lsfw *lsfw;
 
        while (hdr->falcon_id != WPR_HEADER_V1_FALCON_ID_INVALID) {
                wpr_header_v1_dump(&acr->subdev, hdr);
-               if (!nvkm_acr_lsfw_add(NULL, acr, NULL, (hdr++)->falcon_id))
-                       return -ENOMEM;
+               lsfw = nvkm_acr_lsfw_add(NULL, acr, NULL, (hdr++)->falcon_id);
+               if (IS_ERR(lsfw))
+                       return PTR_ERR(lsfw);
        }
 
        return 0;
--

2.20.1

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Dan Carpenter

Will push this to drm-misc in a bit

Quoted 55 lines · Dan Carpenter

The nvkm_acr_lsfw_add() function never returns NULL.  It returns error pointers on error.

Fixes 22dcda45a3d1 ("drm/nouveau/acr: implement new subdev to replace

"secure boot"")

---
 drivers/gpu/drm/nouveau/nvkm/subdev/acr/gm200.c | 6 ++++-- drivers/gpu/drm/nouveau/nvkm/subdev/acr/gp102.c | 6 ++++--

 2 files changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/nouveau/nvkm/subdev/acr/gm200.c +1 -0
index cdb1ead26d84..82b4c8e1457c 100644
@@ -207,11 +207,13 @@ int
  gm200_acr_wpr_parse(struct nvkm_acr *acr)
  {
         const struct wpr_header *hdr = (void *)acr->wpr_fw->data;
+       struct nvkm_acr_lsfw *lsfw;


        while (hdr->falcon_id != WPR_HEADER_V0_FALCON_ID_INVALID) { wpr_header_dump(&acr->subdev, hdr);
-               if (!nvkm_acr_lsfw_add(NULL, acr, NULL, (hdr++)->falcon_id)) -                       return -ENOMEM;
+               lsfw = nvkm_acr_lsfw_add(NULL, acr, NULL, (hdr++)-

Quoted 1 line

falcon_id);

+               if (IS_ERR(lsfw))
+                       return PTR_ERR(lsfw);
        }

        return 0;

drivers/gpu/drm/nouveau/nvkm/subdev/acr/gp102.c +1 -0
index fb9132a39bb1..fd97a935a380 100644
@@ -161,11 +161,13 @@ int
  gp102_acr_wpr_parse(struct nvkm_acr *acr)
  {
         const struct wpr_header_v1 *hdr = (void *)acr->wpr_fw->data;
+       struct nvkm_acr_lsfw *lsfw;


        while (hdr->falcon_id != WPR_HEADER_V1_FALCON_ID_INVALID) { wpr_header_v1_dump(&acr->subdev, hdr);
-               if (!nvkm_acr_lsfw_add(NULL, acr, NULL, (hdr++)->falcon_id)) -                       return -ENOMEM;
+               lsfw = nvkm_acr_lsfw_add(NULL, acr, NULL, (hdr++)-

Quoted 1 line

falcon_id);

+               if (IS_ERR(lsfw))
+                       return PTR_ERR(lsfw);
        }

        return 0;

Signature · 3 lines
Cheers,
 Lyude Paul (she/her)
 Software Engineer at Red Hat