Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3721572pxb; Mon, 24 Jan 2022 16:18:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJzT5bNbp/eGGRtMs/0J/wjp+BX9HKrJ/ZVLXNV/ddPIYBm58xzxNzOcMXruSQE3h0CN+8sc X-Received: by 2002:a17:902:6bcc:b0:14a:bd99:1ae9 with SMTP id m12-20020a1709026bcc00b0014abd991ae9mr16427117plt.62.1643069926476; Mon, 24 Jan 2022 16:18:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643069926; cv=none; d=google.com; s=arc-20160816; b=0Til98id2qC4jAr1OYcyFit6dS38VL+SEg17LP3gULi1ofcFYqka5p7jXTVyVM3Xsd WzcnoEAtG6KlV3sSadSQnkiSvauiTU6nU/FWnbAthlw+Ml9A4ML/l4o103k/fJvh+Om7 gckXqjHzx97DM/mQhreCL9MX4OS8IrqGXPZ9O630zWjJ1OhElZNcgScVmh1kacLzHh/+ BIgJJSBine/2U5GOLhPd9lxZ87iMgwRXQQ3xuP9Bz84Op2Ok9oMT3+EGvFej8BBoTlHa 2QS7jnKtfHkZeNJD0ioPVe+66bBVpWFgk6W/N4hzcC6Z/jqs/5M3ihLMhLmaWiJlyB9E Oi/g== 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=/aJl7nYbeKblog8qVxUxWGvzWO49JMCFKRZjdH4g6sU=; b=xlU+SbO/pRH9pl6Xt+64yAS8I91cmEPMIY13xxKCodyBsD8sbq6xZvN6ocq1ZwC9gJ CtJQFHoFLXFkR4ylHU+Vyaua2UmzLfFUzo3GEKg3NqjmsAuo1Q0x8BMFRRg70FtV37rn IJWAFIRlXgQ6/zUgQSJUdH/zyedVNjw2sEQVDDa8xD9rz1hhon5GFbjN3486k2tbGmiI rol99OAF/kuSxl8yF6M8mcNOtNwL2UTJH+6Sut3X+wDInmAhOFmC+Kki2inNaYvRM8l0 /eNEw15kbzZ65tUZfWJB9xPZTf2PN03+0p37lXU5WvHtOsamltlo7S4GKLqcbVWVVpuw 97lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=r7VfP5Aj; 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 pj2si791132pjb.87.2022.01.24.16.18.34; Mon, 24 Jan 2022 16:18:46 -0800 (PST) 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=r7VfP5Aj; 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 S2373005AbiAYAMx (ORCPT + 99 others); Mon, 24 Jan 2022 19:12:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1849657AbiAXX0Z (ORCPT ); Mon, 24 Jan 2022 18:26:25 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4ED03C061245; Mon, 24 Jan 2022 11:10:25 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DFD6860918; Mon, 24 Jan 2022 19:10:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7139C340E5; Mon, 24 Jan 2022 19:10:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051424; bh=OcShTilfpp1LyDQG1WS6FNKo03gOhrTiA8dOuv6tF4c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r7VfP5AjzymIIrNNbav2JCGpIt6C9HyAaCGAblOmRRbZLRQ09JPOipR1cNbVBei79 9cwb1KGZUYHgKxjVlnp17Y/zV+3lNTd6rDXnYnXXsltiOwHyUQ6zo7lGE1ugupJ8K2 YvMBbDU8oimuMFIrbbRi2mfZ6sTwiSMJY5BVNrXg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Christian=20K=C3=B6nig?= , Jan Stancek , Borislav Petkov , Alex Deucher Subject: [PATCH 4.14 158/186] drm/radeon: fix error handling in radeon_driver_open_kms Date: Mon, 24 Jan 2022 19:43:53 +0100 Message-Id: <20220124183942.180878929@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183937.101330125@linuxfoundation.org> References: <20220124183937.101330125@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: Christian König commit 4722f463896cc0ef1a6f1c3cb2e171e949831249 upstream. The return value was never initialized so the cleanup code executed when it isn't even necessary. Just add proper error handling. Fixes: ab50cb9df889 ("drm/radeon/radeon_kms: Fix a NULL pointer dereference in radeon_driver_open_kms()") Signed-off-by: Christian König Tested-by: Jan Stancek Tested-by: Borislav Petkov Reviewed-by: Alex Deucher Signed-off-by: Alex Deucher Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/radeon/radeon_kms.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) --- a/drivers/gpu/drm/radeon/radeon_kms.c +++ b/drivers/gpu/drm/radeon/radeon_kms.c @@ -673,18 +673,18 @@ int radeon_driver_open_kms(struct drm_de fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL); if (unlikely(!fpriv)) { r = -ENOMEM; - goto out_suspend; + goto err_suspend; } if (rdev->accel_working) { vm = &fpriv->vm; r = radeon_vm_init(rdev, vm); if (r) - goto out_fpriv; + goto err_fpriv; r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false); if (r) - goto out_vm_fini; + goto err_vm_fini; /* map the ib pool buffer read only into * virtual address space */ @@ -692,7 +692,7 @@ int radeon_driver_open_kms(struct drm_de rdev->ring_tmp_bo.bo); if (!vm->ib_bo_va) { r = -ENOMEM; - goto out_vm_fini; + goto err_vm_fini; } r = radeon_vm_bo_set_addr(rdev, vm->ib_bo_va, @@ -700,19 +700,21 @@ int radeon_driver_open_kms(struct drm_de RADEON_VM_PAGE_READABLE | RADEON_VM_PAGE_SNOOPED); if (r) - goto out_vm_fini; + goto err_vm_fini; } file_priv->driver_priv = fpriv; } - if (!r) - goto out_suspend; + pm_runtime_mark_last_busy(dev->dev); + pm_runtime_put_autosuspend(dev->dev); + return 0; -out_vm_fini: +err_vm_fini: radeon_vm_fini(rdev, vm); -out_fpriv: +err_fpriv: kfree(fpriv); -out_suspend: + +err_suspend: pm_runtime_mark_last_busy(dev->dev); pm_runtime_put_autosuspend(dev->dev); return r;