From patchwork Wed Jun 7 03:43:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 104225 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3051vqr; Tue, 6 Jun 2023 21:22:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4l1Nq3es40TIzymRn7OwIRR5GAMlaBqTG9QEbmCFVkQABSP0KQZDD+KmS4SOEUqBEvRgoO X-Received: by 2002:a05:6870:3882:b0:196:bc25:5c61 with SMTP id y2-20020a056870388200b00196bc255c61mr3888589oan.57.1686111727532; Tue, 06 Jun 2023 21:22:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686111727; cv=none; d=google.com; s=arc-20160816; b=HiCLYCY7Jishgx75iTFwrFWXtjj0iftCWlisG3F5tKYQ9yB2qZ0TX2qoDW9dkwSgoG IailYh/WFxCdqOv7QGvsE/Js3oXyj7WpghjP8aDl5mqWvcfujAaNS1QgFGcFrNELjgXi nECzECbFXUnj42qlm88EKBGNze8UjEdzjyLyqEa97PTun2ATmscqEKGOMgIYdBsZ4NOG EY/5cCA9LqGjdgWxzJtt++bVv1UetYIP8FZIofuNkw38WAh0h6Dh+rJMkCShe8VAps1Y N9bZLM70hQTAqei7IT5bd30a7iNqfzdAaR/XIF9y5XYGToD9nf8IdrVSl2QQVA6mUxK/ hi9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Vsw4nTEjEEb5K6Souj9KEFRncsnkC2vYIzwLEjIUgKw=; b=lq/dbfOWQMP2fkSa+1dzL4xUuIIrdjQcIBHOPs02zEvNmjZP6cD2efobu4GQHlCHjx wiB1ISsoPWJsnL8ueWgns2VjgdEX9iH2aRpIJfhUcip958FNbdi/DvGyz+0TsR8S6ibl 0KjeKb2dWsWk1qiB8RgtjEweLqrhtf0ksWOVJrtFq2dET8Y0Uzu1D2/I6jDFWlTScEp3 /Mnt9+YBSWG/8WoYa/lLk9Sqi86B+UGH+IuPuLutxDOGuNXxZIIVggDlhowP2tNDo16C ldP4J7q9FaqzqaJPYld50wmzB/diJ/3oijXSEKd2g0K0lo1kFXdbU79v5i7NeeY5iVO/ NEhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=LFPsXmVo; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f5-20020a170902860500b001ac404445c9si8138678plo.139.2023.06.06.21.21.53; Tue, 06 Jun 2023 21:22:07 -0700 (PDT) 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=@wanadoo.fr header.s=t20230301 header.b=LFPsXmVo; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240835AbjFGDnu (ORCPT + 99 others); Tue, 6 Jun 2023 23:43:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240769AbjFGDno (ORCPT ); Tue, 6 Jun 2023 23:43:44 -0400 Received: from smtp.smtpout.orange.fr (smtp-14.smtpout.orange.fr [80.12.242.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8942E19B7 for ; Tue, 6 Jun 2023 20:43:42 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id 6k5DqKVya0npV6k5DqF86c; Wed, 07 Jun 2023 05:43:40 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1686109420; bh=Vsw4nTEjEEb5K6Souj9KEFRncsnkC2vYIzwLEjIUgKw=; h=From:To:Cc:Subject:Date; b=LFPsXmVoZeGCrj9LEepN9HOWdJEOKUNXgNCfHrR/EF5X719rwDjIU1emqNswpDMML zva1tCKFZQG/RWWVZQnaR1Dd7fK8r/WHzhAvko6g5UP3ddIylL9D3Gwgt3hJw20s92 JK9Scr8H/QbsbDvK16D0dbTJ6MfqfnpxfFnj+4ptxJa6tlrhcfEEh5lLd9jml/BlGh Nj5ZKP1sCj8f0hNUKjkwMcUgC4uAPooR/OCHfxWW9fDqCh3nKUslQ6SrnZJGroD+WW RHdAa2Q7XmOF9cRcXgguHcAKxnmGF7E11AK2NGCiBvKbx9UFbqojisCRkknouIDTiy 7VKhQU6sHlFXw== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Wed, 07 Jun 2023 05:43:40 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Dinh Nguyen , Greg Kroah-Hartman , Richard Gong , Alan Tull Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH v2] firmware: stratix10-svc: Fix a potential resource leak in svc_create_memory_pool() Date: Wed, 7 Jun 2023 05:43:37 +0200 Message-Id: <783e9dfbba34e28505c9efa8bba41f97fd0fa1dc.1686109400.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768014503029593632?= X-GMAIL-MSGID: =?utf-8?q?1768016290381508616?= svc_create_memory_pool() is only called from stratix10_svc_drv_probe(). Most of resources in the probe are managed, but not this memremap() call. There is also no memunmap() call in the file. So switch to devm_memremap() to avoid a resource leak. Fixes: 7ca5ce896524 ("firmware: add Intel Stratix10 service layer driver") Signed-off-by: Christophe JAILLET --- v2: add Fixes tag --- drivers/firmware/stratix10-svc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/stratix10-svc.c b/drivers/firmware/stratix10-svc.c index 80f4e2d14e04..2d674126160f 100644 --- a/drivers/firmware/stratix10-svc.c +++ b/drivers/firmware/stratix10-svc.c @@ -755,7 +755,7 @@ svc_create_memory_pool(struct platform_device *pdev, end = rounddown(sh_memory->addr + sh_memory->size, PAGE_SIZE); paddr = begin; size = end - begin; - va = memremap(paddr, size, MEMREMAP_WC); + va = devm_memremap(dev, paddr, size, MEMREMAP_WC); if (!va) { dev_err(dev, "fail to remap shared memory\n"); return ERR_PTR(-EINVAL);