Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2423608rwb; Fri, 16 Dec 2022 01:40:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXsaJiwfFFhnQ1Zg0FFAP6bO9Timb5wF6KZqMQoxDA4wbXRsdt8zLP9ExCMds4hyV9vJrVWr X-Received: by 2002:a17:906:390f:b0:7dd:5c07:a3ff with SMTP id f15-20020a170906390f00b007dd5c07a3ffmr2366772eje.49.1671183644079; Fri, 16 Dec 2022 01:40:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671183644; cv=none; d=google.com; s=arc-20160816; b=FTnghJFBScCmqhe+WY0j2sQqSD4Htb75KW32GB8QedJXChuCtx/6MN2ZllxEuXjq0O QX4hmA9OPq906wdp0C6poBfN0f3WuD4I/NP4HZTUeU2T8OW2XFUiu0YXYZevqAc5HscU /pRaWaBc0klF9Xg4puIzgn1N4z0AOwve3QJrq2zLAs7lTw4leTWsY/P2Q5WUcUg0iiGI zh0Cwal+MtlsKvEnyrAS+062pHhPim/qquc5Fd/NKvKvzQFEF3SIqhVQQbbk87Tblhzo O/UJzQJDwYN9H/1bdRbI1oWSpScO+QuB3GfvlfsOA0KWrEYX9Zh7zDPazWYZabDh2kSC yuwA== 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=Zyf2Lp7qWE3VHF7MkvtRXhVwyAR5v67l5rA+bfCzD2I=; b=Tl890/9Q/HnLEqWpdPWmFo2rR1WA7BDZ5g5e84sNuVFbTfQbaOvHIvKz3lSz9b/8oa jlAqeAtjtohS6uVh02aAJVJ+f4Qf+1IzCfG7YivLzSJEWVKmcyeYYKmJmdNuE5pIj/AX BiIeJVxJeDUOytV2RPX5/aXDmEbyXeBHfFfGR/8SRfJiS/lZsOYZMZ1wiKEY0S933ADS +a1a22/OUxiiFNrauCHA3nxqNu9PY4Y0vD3L9Te/WBlb+yCDFgACX5fW1Ghl9Lak3ogL ZuoZPuRVeAym5lZh34IZA7kXk9qvjfjQBmOwyqTrmv1vvZJgnVGEgEM1aTP3U1kZjc3K FnWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ktB9kE3c; 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 hd16-20020a170907969000b007aeb99bbb99si2217483ejc.48.2022.12.16.01.40.27; Fri, 16 Dec 2022 01:40:44 -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=ktB9kE3c; 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 S229743AbiLPIgZ (ORCPT + 68 others); Fri, 16 Dec 2022 03:36:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229705AbiLPIgW (ORCPT ); Fri, 16 Dec 2022 03:36:22 -0500 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E0CE36C67; Fri, 16 Dec 2022 00:36:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1671179782; x=1702715782; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=x4KOJKV9zJa7Q5/qcA2VHSVtGXnaPAHP82to8WMzGIg=; b=ktB9kE3c20QSmMrnWKaz4EwRDWcO2XJwSO0p8RSR2w3VefLAiY8IkcfQ XGtF+AzoxiCjbeBTfWxdEBzJy7/37EfMB8keOtOpPFM6EQOFf6Vdg6/bG EKXqQRMrXCT3eGCA/gKjh1OsiPCrYf4ENe5GyH7Hj6jn7P+BotB2h7Xg8 1V2ZRY6lUy7vw6D6OPx8mDtDLwv91JEQ53bLz0kxgYsGfG3Te0d+C8yqk gsnPGgD0c/0d0Vkar8N5EU8Y4J5jMnHicenjdq/wqr2qHnKNxOLQzHoOL X4kocFeMtWOb2HN1WJsrvuZsKHPuTicyaEoU8Bhq+bJ81dJboivGlCq/p Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10562"; a="298588968" X-IronPort-AV: E=Sophos;i="5.96,249,1665471600"; d="scan'208";a="298588968" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Dec 2022 00:36:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10562"; a="738465028" X-IronPort-AV: E=Sophos;i="5.96,249,1665471600"; d="scan'208";a="738465028" Received: from yilunxu-optiplex-7050.sh.intel.com (HELO localhost) ([10.239.159.165]) by FMSMGA003.fm.intel.com with ESMTP; 16 Dec 2022 00:36:19 -0800 Date: Fri, 16 Dec 2022 16:26:25 +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=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,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 don't know if the previous one fell through cracks so resending this. I'll pick this when v6.2-rc1 comes. Acked-by: Xu Yilun > > 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 >