Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3728096pxb; Mon, 24 Jan 2022 16:30:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJxVgmlUn4n2qxN5UoB+eVtsiblgTX4QccAyCoN4sPflH/A7BT7+KOJpQJT95TGrGYtK33S4 X-Received: by 2002:a17:90a:fe2:: with SMTP id 89mr816623pjz.162.1643070617249; Mon, 24 Jan 2022 16:30:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643070617; cv=none; d=google.com; s=arc-20160816; b=LnPb0O38V2tqrDFtzrgXZUWq6XNQ1bjZOIrWxwY4A2bDJ1nK6uoaA84FoAbfXF+YWK SShjfGNGPYL6oY9wlKu8otGdXAlyBYmy2fGTY++FA1ItNKDIAUiAuQ2HdK8WEWkgzud6 O2YV1HjAdmqwNMtJs3nUup8a3+Hiy+OkGYW4lgOK8NW3mWukBrbyQnrwtrKkvtCDYUEm 8gZB9MFSdToum4+4nH6QYqM6M8QI7l0QJLZm76nnWG9pX8FSzshf6Nht7DtH38+Lsz/2 lCaujmi7VoxZjp+9ZnzMSE0z09PEh7fyY0viq28K986uy1q7WXdarN2iG3+z3h0ydnuf qCeQ== 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=O10ivtKRNlT96FMm7aITeSkMxKjalKF45FNXWamJXcI=; b=CzOAFiwQN/Y3kIrcrMxBBo6YIrkCxlF/fyk6Ywr6ISE3uqrTKW1RZ0GKhlqa+JlPTx ftCZf9B9UZ7OJTcnprWfoaVhcnzmV0aG+s5D0GWHwWTDb7BOzdtH88uaLHKwmSm4qVPI mN9ZA2RcrNvDSLPe+D7nCQ+n1GUPaTJ0gRSPdW3A93IkVuF7+ATGGNZUYdgGzSr0Hf9G ORjm8I5TcIpvTRK0cvw7qbwRzrd8jBMsoC/51R1zGpER7RgOk6nCQBmjgFlqhKJkWtgg hX+VK9+yXkFVUFB4VVsLnhVuCD7GdTw5vXN/a1Yc0CvZvwm1s6WUUAQdD6pV7OSYxINR GaEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="kGPM/TQH"; 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 h3si9636862plf.203.2022.01.24.16.30.04; Mon, 24 Jan 2022 16:30:17 -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="kGPM/TQH"; 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 S3408074AbiAYAVd (ORCPT + 99 others); Mon, 24 Jan 2022 19:21:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2361672AbiAXXko (ORCPT ); Mon, 24 Jan 2022 18:40:44 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14F10C0BD489; Mon, 24 Jan 2022 13:38:47 -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 ams.source.kernel.org (Postfix) with ESMTPS id C77D9B811FB; Mon, 24 Jan 2022 21:38:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F286BC36AE9; Mon, 24 Jan 2022 21:38:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643060324; bh=ongecXjzHtP37xKEtMPAuQCBn6ybQCZN/W1veZ+7+ls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kGPM/TQHUsdCQEbrx8xzQ3lfp87V/+QiTGk6yJvUQULDi+6+8knlVkAPyDQEeWIDB dp7v4dqSdVafrVDzPr5sk1N8jLayYDhmoDt+LUGRk+1oN4On6PMzU+UiiwUPy1yXPh ICtE0/3kuXxqn2VhTNf1vwI6w+GCBDzxsoEj8W+Y= 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 5.16 0903/1039] drm/radeon: fix error handling in radeon_driver_open_kms Date: Mon, 24 Jan 2022 19:44:52 +0100 Message-Id: <20220124184155.650242882@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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 @@ -666,18 +666,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 */ @@ -685,7 +685,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, @@ -693,19 +693,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;