Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp1352240rwl; Sun, 25 Dec 2022 20:20:25 -0800 (PST) X-Google-Smtp-Source: AMrXdXs1gjj8zmkrGAdQUn9IN/wiuCfGdtdExrZj8rtRjFX63dMW9l+JeE9jrv0/m7JBakZSzZZO X-Received: by 2002:a17:907:b9d8:b0:7c1:6040:2318 with SMTP id xa24-20020a170907b9d800b007c160402318mr15506197ejc.35.1672028424919; Sun, 25 Dec 2022 20:20:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672028424; cv=none; d=google.com; s=arc-20160816; b=I/wYWOYeouH2xsjQvYgqecyOAUtcMPNIq6TWZMYf42KcAlVlbBG5vNn67mBg70hX8g Olm/fFaQ0wL/dBXxDVtixQtrRsyekJciIiLzpLlsGp4971yXsJ1/yCCRK5HStH2bYXlO dREAFkbHmuQHAbtfRPEpP9IxwV9l6WGsSDfnBxVptEYM9ZDZh+y/mjoB702m4rV6jLiu o+RO3x8hC8BJevyYYPgzVdiuc8StgGTUVBnuGmjfqAWP4m/er7FAGOakTFPHm/vtUcAC MLOeP5CxKlzKozSTcXK+KhNNINIeZR3ME6W2lyBnabMOXW43hVA289ayynYhuNA1wU2M cI8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=8gSS3rl74jLhgoxxrWqk621zeVprXnzrE3SewVN6koo=; b=RHCt17G7qzXJymk8br6fzvsDAYd6J/forf84BUti8hS7+YoGSN6S4RxLNNqUUM4REz /6V1SdA67VAyLCj0WDhMJJLt/dDDFozA8kO+MM2Agqzb289ioPyOV6vuh723HgtVRX3e /WifknVANdrSDuMg6XsFBgxzKrZaHPld0Eb3WvKCmx4NCpvxBH/WdxckY+IJ1sCHrLaF nVS63X1OQlzuNSb/izSVyiHariaIEHDttu7Qw5y/RV/31DUuZ0yDT0fTe6fZuZGYwnsC oTcCQFJeekz2MAfBbRSUbk8yqL2l71Uysbex6Axd8479D6817hsMm849r5ZfVdT3qoJe vgMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eTBMRSp8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nc31-20020a1709071c1f00b007b961545a0dsi7991735ejc.500.2022.12.25.20.20.09; Sun, 25 Dec 2022 20:20:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eTBMRSp8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231548AbiLZD6V (ORCPT + 67 others); Sun, 25 Dec 2022 22:58:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229595AbiLZD6U (ORCPT ); Sun, 25 Dec 2022 22:58:20 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5057F26D4; Sun, 25 Dec 2022 19:58:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672027099; x=1703563099; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=Zg69wlDFLaNoP+dcrRtsKjwz24O2TMBqloyI+EYtQ6w=; b=eTBMRSp8j+dcx7i79/CLL4me/HpzdjzmrbRg+esQjg8198SFr6fKE9Hk CPlVi8Zn6THoRhP+Mxpi+g6VJxOV1+2C1Ehb4MhYoWY0Bf+2Od6+1V90E sMGiPAyHGqabojhIBl3iJc6qPcYW9EC+1mYGnMbkjxDirFD02DxQTbw/W SOufQyzf6vx9g/spKPspv3D9nbBp5JtcYmSWRYXYWceLti8XqNgykEE33 JqBATeSqHAjuPdjSYQxoqLObq0og9unCoThxRhvVvl6IdtsL1/C3P2WNj 2wh5K2APbqF2AVgiUYMlTc7W2a7EFQzILjXMocEKIECzB3cTpbBDJoZH0 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10571"; a="347708222" X-IronPort-AV: E=Sophos;i="5.96,274,1665471600"; d="scan'208";a="347708222" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Dec 2022 19:58:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10571"; a="794985158" X-IronPort-AV: E=Sophos;i="5.96,274,1665471600"; d="scan'208";a="794985158" Received: from yilunxu-optiplex-7050.sh.intel.com (HELO localhost) ([10.239.159.165]) by fmsmga001.fm.intel.com with ESMTP; 25 Dec 2022 19:58:16 -0800 Date: Mon, 26 Dec 2022 11:48:12 +0800 From: Xu Yilun To: Ilpo =?iso-8859-1?Q?J=E4rvinen?= Cc: Russ Weight , Moritz Fischer , Wu Hao , Tom Rix , linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, Matthew Gerlach , Marco Pagani Subject: Re: [PATCH v2 1/1] fpga: m10bmc-sec: Fix probe rollback Message-ID: References: <20221214144952.8392-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20221214144952.8392-1-ilpo.jarvinen@linux.intel.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Reviewed-by: Russ Weight > Reviewed-by: Marco Pagani > Signed-off-by: Ilpo J?rvinen 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 >