All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xu Yilun <yilun.xu@intel.com>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: Russ Weight <russell.h.weight@intel.com>,
	Moritz Fischer <mdf@kernel.org>, Wu Hao <hao.wu@intel.com>,
	Tom Rix <trix@redhat.com>,
	linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org,
	Matthew Gerlach <matthew.gerlach@linux.intel.com>,
	Marco Pagani <marpagan@redhat.com>
Subject: Re: [PATCH v2 1/1] fpga: m10bmc-sec: Fix probe rollback
Date: Mon, 26 Dec 2022 11:48:12 +0800	[thread overview]
Message-ID: <Y6kZfHOCb18qmaeP@yilunxu-OptiPlex-7050> (raw)
In-Reply-To: <20221214144952.8392-1-ilpo.jarvinen@linux.intel.com>

On 2022-12-14 at 16:49:52 +0200, Ilpo Järvinen wrote:
> Handle probe error rollbacks properly to avoid leaks.
> 
> Fixes: 5cd339b370e2 ("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>

I assume this should be in stable kernel, so
 
 Cc: stable@vger.kernel.org

If OK, I could add it myself.

Thanks,
Yilun

> ---
> I don't know if the previous one fell through cracks so resending this.
> 
> v2:
> - Resending v1 with Marco's Rev-by
> 
>  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)
> -- 
> 2.30.2
> 

  parent reply	other threads:[~2022-12-26  3:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-14 14:49 [PATCH v2 1/1] fpga: m10bmc-sec: Fix probe rollback Ilpo Järvinen
2022-12-16  8:26 ` Xu Yilun
2022-12-26  3:48 ` Xu Yilun [this message]
2022-12-26 17:57   ` Ilpo Järvinen

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=Y6kZfHOCb18qmaeP@yilunxu-OptiPlex-7050 \
    --to=yilun.xu@intel.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=marpagan@redhat.com \
    --cc=matthew.gerlach@linux.intel.com \
    --cc=mdf@kernel.org \
    --cc=russell.h.weight@intel.com \
    --cc=trix@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.