Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp131453rwl; Tue, 28 Mar 2023 22:32:06 -0700 (PDT) X-Google-Smtp-Source: AKy350bUqXCLPIuu52PxtVd49X7qZz0BbunJqBy3wzaab0XQdOQPcAdD1Ha3DkhrEHtGHDB8yFqw X-Received: by 2002:a17:906:7243:b0:932:4cbf:5bbb with SMTP id n3-20020a170906724300b009324cbf5bbbmr19258971ejk.19.1680067926545; Tue, 28 Mar 2023 22:32:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680067926; cv=none; d=google.com; s=arc-20160816; b=wpRuqxNNwWXcIAs15hDaGP/M2UwCA/kmOQVDf3Hyw3vAEoXDIcwzXZgvGHsKGQLSIf sjZp4gjOgim6FVdRVxkAtwt/LhvMTdYWa/KysZRj+V5ILzeIIVVRWqXpjuiWFYZ05MWk mHjNbsQ5aaSBudag9B/67HnCLh2oOZ++DY5lUEt4Acka9R+DxNdJZHtM/cKh9t7tJWLw JmNBKSWHT5uF7oCtv20kFsG1AXilHgS0S82pgAgIyq0fTVbaljRESOeGplYM2BH9ieIM dxZrXoibYWOOLVgbsuxq3u0S62UeheruHfKGRlLRpAx4WGa6KwbcF6qAfHbjKrUf+cen B3gA== 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; bh=Ld/Rh+Ba/3F5e9D5S2Rys+fLQdofNg9svsA3RUBX4Ag=; b=auNlqcB7SwXlD5hlM1ibDH6b/8BxKZBWQzAr691iJPjzQ0mTWcUCicQo1huaNFsVqp 9apsBcu/B3YrJCcHObBvu6hIXlyAgJ/GO1JoBRKFS1cOpsCR7JS75LhuCIO3nRtAPBlO S/QpP4Y0G7ocVyt5e8NTU+1bC0UEQojTzSHrOXzjkORgn5e/IyPDsDo8MDJuzzS8ARuq X8THzgUgxM2PBNUjMMToM5O38Uwf0KXHax9JTin4robct/PEi3vRs1U1S3X92vwh+P8I MwLZiAOCXQ7IXS/5gFwJ+bhEAVjsQDAQltW1n1vh/FMIOYzaORDUSd16Hw69zNPoDFjg 746Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n15-20020a170906118f00b0092fa562c84fsi34859699eja.33.2023.03.28.22.31.40; Tue, 28 Mar 2023 22:32:06 -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; 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 S229626AbjC2F2I (ORCPT + 99 others); Wed, 29 Mar 2023 01:28:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229531AbjC2F2I (ORCPT ); Wed, 29 Mar 2023 01:28:08 -0400 Received: from hust.edu.cn (unknown [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA15D30FF for ; Tue, 28 Mar 2023 22:28:06 -0700 (PDT) Received: from liber-MS-7D42.. ([10.12.190.56]) (user=gangecen@hust.edu.cn mech=LOGIN bits=0) by mx1.hust.edu.cn with ESMTP id 32T5R4WY022782-32T5R4WZ022782 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 29 Mar 2023 13:27:10 +0800 From: Gencen Gan To: Gerd Hoffmann , David Airlie , Daniel Vetter Cc: Gan Gecen , virtualization@lists.linux-foundation.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PING PATCH] drm/bochs: replace ioremap with devm_ioremap to avoid immo leak Date: Wed, 29 Mar 2023 13:26:55 +0800 Message-Id: <20230329052655.3487616-1-gangecen@hust.edu.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-FEAS-AUTH-USER: gangecen@hust.edu.cn X-Spam-Status: No, score=-0.0 required=5.0 tests=SPF_HELO_PASS,SPF_PASS 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 From: Gan Gecen Smatch reports: drivers/gpu/drm/tiny/bochs.c:290 bochs_hw_init() warn: 'bochs->mmio' from ioremap() not released on lines: 246,250,254. In the function bochs_load() that calls bochs_hw_init() only, if bochs_hw_init(dev) returns -ENODEV(-19), it will jumps to err_free_dev instead of err_hw_fini, so bochs->immo won't be freed. We would prefer to replace ioremap with devm_ioremap to avoid adding lengthy error handling. The function `devm_ioremap` will automatically release the allocated resources after use. Signed-off-by: Gan Gecen --- drivers/gpu/drm/tiny/bochs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/tiny/bochs.c b/drivers/gpu/drm/tiny/bochs.c index 024346054c70..0d7e119a732f 100644 --- a/drivers/gpu/drm/tiny/bochs.c +++ b/drivers/gpu/drm/tiny/bochs.c @@ -223,7 +223,7 @@ static int bochs_hw_init(struct drm_device *dev) } ioaddr = pci_resource_start(pdev, 2); iosize = pci_resource_len(pdev, 2); - bochs->mmio = ioremap(ioaddr, iosize); + bochs->mmio = devm_ioremap(&pdev->dev, ioaddr, iosize); if (bochs->mmio == NULL) { DRM_ERROR("Cannot map mmio region\n"); return -ENOMEM; -- 2.34.1