The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] drm/radeon/r100: enhance error handling in r100_cp_init_microcode
@ 2024-05-27  1:20 Zhouyi Zhou
  2024-05-27  7:58 ` Christian König
  0 siblings, 1 reply; 4+ messages in thread
From: Zhouyi Zhou @ 2024-05-27  1:20 UTC (permalink / raw)
  To: alexander.deucher, christian.koenig, Xinhui.Pan, airlied, daniel,
	chris, amd-gfx, dri-devel, linux-kernel, rcu, lance
  Cc: Zhouyi Zhou

In r100_cp_init_microcode, if rdev->family don't match any of
if statement,  fw_name will be NULL, which will cause
gcc (11.4.0 powerpc64le-linux-gnu) complain:

In function ‘r100_cp_init_microcode’,
    inlined from ‘r100_cp_init’ at drivers/gpu/drm/radeon/r100.c:1136:7:
./include/linux/printk.h:457:44: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
  457 | #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)

Above warning is emitted during the rcutorture test in
in PPC VM of Opensource Lab of Oregon State Univerisity.

Enhance error handling in r100_cp_init_microcode, let r100_cp_init_microcode
return with -EINVAL when none of chip families is matched.

Signed-off-by: Zhouyi Zhou <zhouzhouyi@gmail.com>
---
 drivers/gpu/drm/radeon/r100.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 0b1e19345f43..4f8a1bdd9365 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -1055,6 +1055,11 @@ static int r100_cp_init_microcode(struct radeon_device *rdev)
 		   (rdev->family == CHIP_RV570)) {
 		DRM_INFO("Loading R500 Microcode\n");
 		fw_name = FIRMWARE_R520;
+	} else {
+		pr_err("radeon_cp: Failed to load firmware \"%d\"\n",
+			rdev->family);
+		err = -EINVAL;
+		goto out;
 	}
 
 	err = request_firmware(&rdev->me_fw, fw_name, rdev->dev);
@@ -1067,6 +1072,8 @@ static int r100_cp_init_microcode(struct radeon_device *rdev)
 		release_firmware(rdev->me_fw);
 		rdev->me_fw = NULL;
 	}
+
+out:
 	return err;
 }
 
-- 
2.34.1


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

end of thread, other threads:[~2024-05-28  1:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-27  1:20 [PATCH] drm/radeon/r100: enhance error handling in r100_cp_init_microcode Zhouyi Zhou
2024-05-27  7:58 ` Christian König
2024-05-28  1:36   ` Zhouyi Zhou
2024-05-28  1:45     ` Zhouyi Zhou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox