@@ -765,6 +765,7 @@ int ni_init_microcode(struct radeon_device *rdev)
pr_err("ni_cp: Bogus length %zu in firmware \"%s\"\n",
rdev->me_fw->size, fw_name);
err = -EINVAL;
+ goto out;
}
snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", rlc_chip_name);
@@ -775,6 +776,7 @@ int ni_init_microcode(struct radeon_device *rdev)
pr_err("ni_rlc: Bogus length %zu in firmware \"%s\"\n",
rdev->rlc_fw->size, fw_name);
err = -EINVAL;
+ goto out;
}
/* no MC ucode on TN */
@@ -787,6 +789,7 @@ int ni_init_microcode(struct radeon_device *rdev)
pr_err("ni_mc: Bogus length %zu in firmware \"%s\"\n",
rdev->mc_fw->size, fw_name);
err = -EINVAL;
+ goto out;
}
}
@@ -795,9 +798,7 @@ int ni_init_microcode(struct radeon_device *rdev)
err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev);
if (err) {
pr_err("smc: error loading firmware \"%s\"\n", fw_name);
- release_firmware(rdev->smc_fw);
- rdev->smc_fw = NULL;
- err = 0;
+ err = -EINVAL;
} else if (rdev->smc_fw->size != smc_req_size) {
pr_err("ni_mc: Bogus length %zu in firmware \"%s\"\n",
rdev->smc_fw->size, fw_name);
@@ -818,6 +819,8 @@ int ni_init_microcode(struct radeon_device *rdev)
rdev->rlc_fw = NULL;
release_firmware(rdev->mc_fw);
rdev->mc_fw = NULL;
+ release_firmware(rdev->smc_fw);
+ rdev->smc_fw = NULL;
}
return err;
}
'smc_fw' is not released when its size is not as expected, causing memory leak. And when other firmware sizes do not meet expectations, 'err' is assigned but does not jump to 'out'. Signed-off-by: Lu Yao <yaolu@kylinos.cn> --- drivers/gpu/drm/radeon/ni.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)