[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <0f28f75d-ac27-1f3d-2531-6b0f7504db85@redhat.com>
Date: Wed, 30 Nov 2022 18:20:31 +0100
From: Marco Pagani <marpagan@...hat.com>
To: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>,
Russ Weight <russell.h.weight@...el.com>,
Moritz Fischer <mdf@...nel.org>, Wu Hao <hao.wu@...el.com>,
Xu Yilun <yilun.xu@...el.com>, Tom Rix <trix@...hat.com>,
linux-fpga@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: Matthew Gerlach <matthew.gerlach@...ux.intel.com>
Subject: Re: [PATCH 1/1] fpga: m10bmc-sec: Fix probe rollback
On 2022-11-30 10:11, Ilpo Järvinen wrote:
> Handle probe error rollbacks properly to avoid leaks.
>
> Fixes: 5cd339b370e2 ("fpga: m10bmc-sec: add max10 secure update functions")
Reviewed-by: Marco Pagani <marpagan@...hat.com>
> Reviewed-by: Matthew Gerlach <matthew.gerlach@...ux.intel.com>
> Reviewed-by: Russ Weight <russell.h.weight@...el.com>
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
> ---
> drivers/fpga/intel-m10-bmc-sec-update.c | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/fpga/intel-m10-bmc-sec-update.c b/drivers/fpga/intel-m10-bmc-sec-update.c
> index 79d48852825e..03f1bd81c434 100644
> --- a/drivers/fpga/intel-m10-bmc-sec-update.c
> +++ b/drivers/fpga/intel-m10-bmc-sec-update.c
> @@ -574,20 +574,27 @@ static int m10bmc_sec_probe(struct platform_device *pdev)
> len = scnprintf(buf, SEC_UPDATE_LEN_MAX, "secure-update%d",
> sec->fw_name_id);
> sec->fw_name = kmemdup_nul(buf, len, GFP_KERNEL);
> - if (!sec->fw_name)
> - return -ENOMEM;
> + if (!sec->fw_name) {
> + ret = -ENOMEM;
> + goto fw_name_fail;
> + }
>
> fwl = firmware_upload_register(THIS_MODULE, sec->dev, sec->fw_name,
> &m10bmc_ops, sec);
> if (IS_ERR(fwl)) {
> dev_err(sec->dev, "Firmware Upload driver failed to start\n");
> - kfree(sec->fw_name);
> - xa_erase(&fw_upload_xa, sec->fw_name_id);
> - return PTR_ERR(fwl);
> + ret = PTR_ERR(fwl);
> + goto fw_uploader_fail;
> }
>
> sec->fwl = fwl;
> 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)
Powered by blists - more mailing lists