From patchwork Wed Jun 7 03:40:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 104219 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3832873vqr; Tue, 6 Jun 2023 20:53:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4nuSyezSOTejwZa/38Sh2pY/RiSg09s9w/0QnPblsCtbColjSSxyUZycrWpqqR5PyuLqXl X-Received: by 2002:a17:902:e811:b0:1b2:4042:d227 with SMTP id u17-20020a170902e81100b001b24042d227mr3072441plg.12.1686110022669; Tue, 06 Jun 2023 20:53:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686110022; cv=none; d=google.com; s=arc-20160816; b=sOH9I4Wsukxua+mL7g/XgO+ow6R9B76lKppvS4+irpZuN+LPhPHZGQN+x1/z9YthK/ w7b7fgsIUvznnw7/+dy6BdPJnLWTur0BQiMeWE/Gy+NxbbmkXlqIsfJ5CmFwa1sFzb4X 5OBz+3oo9SEBjCvW7PZfte2sNLSxWWNhlC20UpIuyJjsEeM2xk8yazcNZWz4G6lJoFst zccVX4Sa2tb7hG+Uz0RkNE7J6KSDJbxSrq3kpKGFdSrezeLcJB2PKVV7h5GnMN6lj1fh ukGqLkJAcLrTWwm23eJY1lVvamsF6hm8jHTlQJmblnRVh+laNMXMr4ZsrdI0PzBfiINp GqbQ== 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=h9asTVHJogZoJLCuyX7iMMLYoCBwbTiEljds8BOdE0M=; b=cylR5IIoTbADpaQor1mjPASdG8RbbTkE8sMy1K5Jw2G8k+R0/Eoa7jgrKAKop/BKag Ph3sIIggb+BnsgE4DT5jLSuPpscNe7Kss8Y6p2BxUIm5EQnEtpfA9mHzU1hzDijHKDt5 GgK9aRWwtMLpgHvvhsQMjWinz11qKolxw7wyoXm0zrqBzrqgn4rIQT+fmQWmrA6vaHCl nSUnWJg0E9G1bTepVPGgmeHDgKWr43OPY7gTC0fcER/81VZ6IMdzLpypgRr7KcBIcJ/J ktcqKqSvUmeDOW0piku3W8fad9IeB3cTI8wOm0u6paB3YdW3UyKJdIrhjTl0KTbpIOCf TAoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=L4HgFnnU; 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 r1-20020a1709028bc100b001aaffa9923asi4208576plo.306.2023.06.06.20.53.28; Tue, 06 Jun 2023 20:53:42 -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=L4HgFnnU; 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 S234983AbjFGDlZ (ORCPT + 99 others); Tue, 6 Jun 2023 23:41:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240836AbjFGDlT (ORCPT ); Tue, 6 Jun 2023 23:41:19 -0400 Received: from smtp.smtpout.orange.fr (smtp-20.smtpout.orange.fr [80.12.242.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84A291BEA for ; Tue, 6 Jun 2023 20:41:03 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id 6k2eqmOt4fPUb6k2fqJcsz; Wed, 07 Jun 2023 05:41:01 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1686109261; bh=h9asTVHJogZoJLCuyX7iMMLYoCBwbTiEljds8BOdE0M=; h=From:To:Cc:Subject:Date; b=L4HgFnnUT2C38A8o+3dCuS2XjRBRnucHjyAxSi72ReFUDc4mlNJsa3QdfVY1T0Ufe vmJmNnAPATOlQoXqE6yCV5dAgvqjOdgEuHui+k3JaHsgYPfuhnSdK9I5EZGNSc8ej4 Y24Zp8PuhniOY36V9bnko9qUa4XgfXjHTEjqHQHDqEV/+4Lf0TRpO4RVJsdyzPabcV wKJ63Ga0w9JVXA0JNgdpbpWVJ7vM7KC6w/E68UNmLvOf3xCOkabtOdbaUL7lRCcYnr JNojSQt+FKMrR9ZCqrpMEUoRsYxyWqyaRjgSyra0sxGuteu4bs059RnCJvZZYyejYw XKof7OpgU6lng== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Wed, 07 Jun 2023 05:41:01 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Dinh Nguyen Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] firmware: stratix10-svc: Fix a potential resource leak in svc_create_memory_pool() Date: Wed, 7 Jun 2023 05:40:59 +0200 Message-Id: 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_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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?1768014503029593632?= 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. Signed-off-by: Christophe JAILLET --- 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);