From: Marco Pagani <marpagan@redhat.com>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Russ Weight" <russell.h.weight@intel.com>,
"Moritz Fischer" <mdf@kernel.org>, "Wu Hao" <hao.wu@intel.com>,
"Xu Yilun" <yilun.xu@intel.com>, "Tom Rix" <trix@redhat.com>,
linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Matthew Gerlach <matthew.gerlach@linux.intel.com>
Subject: Re: [PATCH 1/1] fpga: m10bmc-sec: Fix probe rollback
Date: Wed, 30 Nov 2022 18:20:31 +0100 [thread overview]
Message-ID: <0f28f75d-ac27-1f3d-2531-6b0f7504db85@redhat.com> (raw)
In-Reply-To: <20221130091158.4732-1-ilpo.jarvinen@linux.intel.com>
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@redhat.com>
> Reviewed-by: Matthew Gerlach <matthew.gerlach@linux.intel.com>
> Reviewed-by: Russ Weight <russell.h.weight@intel.com>
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.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)
prev parent reply other threads:[~2022-11-30 17:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-30 9:11 [PATCH 1/1] fpga: m10bmc-sec: Fix probe rollback Ilpo Järvinen
2022-11-30 17:20 ` Marco Pagani [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0f28f75d-ac27-1f3d-2531-6b0f7504db85@redhat.com \
--to=marpagan@redhat.com \
--cc=hao.wu@intel.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-fpga@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew.gerlach@linux.intel.com \
--cc=mdf@kernel.org \
--cc=russell.h.weight@intel.com \
--cc=trix@redhat.com \
--cc=yilun.xu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).