mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-29 07:04:10 +08:00
fpga: m10bmc-sec: Fix probe rollback
Handle probe error rollbacks properly to avoid leaks.
Fixes: 5cd339b370
("fpga: m10bmc-sec: add max10 secure update functions")
Reviewed-by: Matthew Gerlach <matthew.gerlach@linux.intel.com>
Reviewed-by: Russ Weight <russell.h.weight@intel.com>
Reviewed-by: Marco Pagani <marpagan@redhat.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Cc: stable@vger.kernel.org
Acked-by: Xu Yilun <yilun.xu@intel.com>
Link: https://lore.kernel.org/r/20221214144952.8392-1-ilpo.jarvinen@linux.intel.com
Signed-off-by: Xu Yilun <yilun.xu@intel.com>
This commit is contained in:
parent
65ea840afd
commit
60ce26d10e
@ -574,20 +574,27 @@ static int m10bmc_sec_probe(struct platform_device *pdev)
|
|||||||
len = scnprintf(buf, SEC_UPDATE_LEN_MAX, "secure-update%d",
|
len = scnprintf(buf, SEC_UPDATE_LEN_MAX, "secure-update%d",
|
||||||
sec->fw_name_id);
|
sec->fw_name_id);
|
||||||
sec->fw_name = kmemdup_nul(buf, len, GFP_KERNEL);
|
sec->fw_name = kmemdup_nul(buf, len, GFP_KERNEL);
|
||||||
if (!sec->fw_name)
|
if (!sec->fw_name) {
|
||||||
return -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
goto fw_name_fail;
|
||||||
|
}
|
||||||
|
|
||||||
fwl = firmware_upload_register(THIS_MODULE, sec->dev, sec->fw_name,
|
fwl = firmware_upload_register(THIS_MODULE, sec->dev, sec->fw_name,
|
||||||
&m10bmc_ops, sec);
|
&m10bmc_ops, sec);
|
||||||
if (IS_ERR(fwl)) {
|
if (IS_ERR(fwl)) {
|
||||||
dev_err(sec->dev, "Firmware Upload driver failed to start\n");
|
dev_err(sec->dev, "Firmware Upload driver failed to start\n");
|
||||||
kfree(sec->fw_name);
|
ret = PTR_ERR(fwl);
|
||||||
xa_erase(&fw_upload_xa, sec->fw_name_id);
|
goto fw_uploader_fail;
|
||||||
return PTR_ERR(fwl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sec->fwl = fwl;
|
sec->fwl = fwl;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
fw_uploader_fail:
|
||||||
|
kfree(sec->fw_name);
|
||||||
|
fw_name_fail:
|
||||||
|
xa_erase(&fw_upload_xa, sec->fw_name_id);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int m10bmc_sec_remove(struct platform_device *pdev)
|
static int m10bmc_sec_remove(struct platform_device *pdev)
|
||||||
|
Loading…
Reference in New Issue
Block a user