Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1650719pxy; Mon, 2 Aug 2021 07:05:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjUJrFEDZqC+Dfhb/3ELZzeJlAHqlFucu87Load3oLBrMJ8ifRRhFImAJiemtbAXTiowT5 X-Received: by 2002:a17:906:acf:: with SMTP id z15mr15848075ejf.512.1627913149807; Mon, 02 Aug 2021 07:05:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627913149; cv=none; d=google.com; s=arc-20160816; b=MEWPGhI5TnBYXUHQznMinYEr6tBRM01hF6TCXbveJGKCaKL/iG+VDaYqsRYCoXTN0Q 8fTIgIlg4B5vLq+1/vfs3LrRxqDXb2PrTrAuDgXmkX+l/bSEwNpBgaE/broHPagiOm8h TsFl0qdyeDRmB4SIS12VsgdjtGD0pdwfuOBRIsidbjCjn1zwSbU4zLKPzBGUPrU8xhVx nBpyLa/JizYf2CLxhikUaqnNKd9UgRm86A7LbNsfuoEl3MZwwAqWJhqLec+WIHi1GRPJ F5DOTrLMkDUTDA54kLTfcpQZ45zNSW9a6JD1zX7eVvZMJjbJsfbymifKD7Yj1g47v0+w W7sA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XP47Vdlw5EnbzwMGR4MfZAjl489m512VPOP7+Gzc9t8=; b=o9JGITDHNFoqTygzWmt903IhLc5qshJZDtb+yotJ+sY2reIjksvnoVCfy3437ucf9h ftmOashr5WvktF2WY6roagg2A0ehlRIrCB1WKpnhK/ZTpz6LAjWjcu2zHxf7o3VY+IIz ngfrLyDuci2FZSqhZ2E4d+/zpxca/eMAsmpJNdxcmUtW3JrAnnljAw6UbJa0eztVKD36 a+roAYCK7qfdiFo8EZohmR92q7g1dZt12YAtnS3m9EjLVM5/DA0i/A08e8iJv0OfK7Mo +poXj2Nf+H760wWq3Uknbxk4Z/LIvC7E1MGAIgYsSlcTs5w1EjtVmKHsjmwyQKvGJM6s ovMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1cXFaK57; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n14si9729519edv.569.2021.08.02.07.05.26; Mon, 02 Aug 2021 07:05:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1cXFaK57; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236205AbhHBODN (ORCPT + 99 others); Mon, 2 Aug 2021 10:03:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:40708 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235365AbhHBNz2 (ORCPT ); Mon, 2 Aug 2021 09:55:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 98E99611C2; Mon, 2 Aug 2021 13:53:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912435; bh=wRvpam9wRRmddnFA/h83MnJHXmly/iKG/iGbSVRRF2Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1cXFaK57n2FYJP+TWBWMOVDwJzncPDMXN0mrkBq/+W9y2A5qfD0uFCUtFS8bLzBK6 C3UajVq4UlQfZW8QTJQiJhkGY3Bz+fzKO9LMDc3LxS9WDvDE4gtb249ghF06mZiRIi NyU1dbsc3i9oLN4A0OFIryi6EHLFVun7AKTl+gpU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vojtech Pavlik , Jiri Kosina , Alex Deucher Subject: [PATCH 5.10 24/67] drm/amdgpu: Fix resource leak on probe error path Date: Mon, 2 Aug 2021 15:44:47 +0200 Message-Id: <20210802134339.842433681@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134339.023067817@linuxfoundation.org> References: <20210802134339.023067817@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiri Kosina commit d47255d3f87338164762ac56df1f28d751e27246 upstream. This reverts commit 4192f7b5768912ceda82be2f83c87ea7181f9980. It is not true (as stated in the reverted commit changelog) that we never unmap the BAR on failure; it actually does happen properly on amdgpu_driver_load_kms() -> amdgpu_driver_unload_kms() -> amdgpu_device_fini() error path. What's worse, this commit actually completely breaks resource freeing on probe failure (like e.g. failure to load microcode), as amdgpu_driver_unload_kms() notices adev->rmmio being NULL and bails too early, leaving all the resources that'd normally be freed in amdgpu_acpi_fini() and amdgpu_device_fini() still hanging around, leading to all sorts of oopses when someone tries to, for example, access the sysfs and procfs resources which are still around while the driver is gone. Fixes: 4192f7b57689 ("drm/amdgpu: unmap register bar on device init failure") Reported-by: Vojtech Pavlik Signed-off-by: Jiri Kosina Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -3322,13 +3322,13 @@ int amdgpu_device_init(struct amdgpu_dev r = amdgpu_device_get_job_timeout_settings(adev); if (r) { dev_err(adev->dev, "invalid lockup_timeout parameter syntax\n"); - goto failed_unmap; + return r; } /* early init functions */ r = amdgpu_device_ip_early_init(adev); if (r) - goto failed_unmap; + return r; /* doorbell bar mapping and doorbell index init*/ amdgpu_device_doorbell_init(adev); @@ -3532,10 +3532,6 @@ failed: if (boco) vga_switcheroo_fini_domain_pm_ops(adev->dev); -failed_unmap: - iounmap(adev->rmmio); - adev->rmmio = NULL; - return r; }