Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3976302pxb; Tue, 25 Jan 2022 00:26:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJwht+dFmIWSyZITunZICiZjj9f+xSjyofowi3+HocDWotEgP+/pnKnQ9+8Pppb9Ddv64F2h X-Received: by 2002:a17:903:32c6:b0:14b:3f5b:e9c6 with SMTP id i6-20020a17090332c600b0014b3f5be9c6mr10905749plr.136.1643099203299; Tue, 25 Jan 2022 00:26:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643099203; cv=none; d=google.com; s=arc-20160816; b=mP3hDAZwCK2T3uiTypW04K1bmconqfu6EWfo1c6elvIT/sp2rbMawXYkXZVnokXjzw fOWQS7hh8jIV2JqEvQQlfo6D7mXtNwgIzlS+GIYyBYJUTkTkxIUChgVi6XENyVPOsReP jCqrF53heFj/fyZNE2S5WftvLIztF/IaZyGvJwWEbadCVKSfHfwzzy6P9iz2qJWUpkPc zdbRC3ZVVplvLbb3DneOKzYAQTnI6ShBNSnBD7cDpbaer4dXTinxOituM0GW+qpl95mA F4a6YsAOS55ZOubJwSl0mX0pvN7gH/3ld0CIoRj2CDsDXt1P16G9FmPZ52zuuzcBgVL5 oXgA== 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=x+oped3mx9Du3Gbl4PiPYjXBbaF4LHoN215N1O1eppE=; b=Pukmewwn1L9mhMcz+dHYXE251Bs/N/jc9oMzvToEf2bFSvUfhGePYv6UGHQYxrfTUM pvQvm6feryBNH/69MmvbRvN/qJ8SL6lxCOGEOUMf3Pdg2ls3IRu7bor63XZGdtYz69UK Scwhe6WDr8RLUyLCqeyEqcDpm0Pf7AQBEOJIy+tVHW7nwTM/cZRTjhYgRLQYyObnOPGB +TctqxLvk2aoy2YBkxcrcgdgppk2bjYJTNuGVtuw1RUb6ZLec3N1OPO3z07722ja8T5+ dWKDrW3smhuRdr3gUFysLcNigNL0HwbgZpLPgb2B9sBqTth7hBxgHSbRUS4TQtQ6k5c0 O6WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MnQ2o+rC; 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 y15si14903633plr.199.2022.01.25.00.26.31; Tue, 25 Jan 2022 00:26:43 -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=MnQ2o+rC; 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 S3422397AbiAYCbH (ORCPT + 99 others); Mon, 24 Jan 2022 21:31:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379630AbiAXUSc (ORCPT ); Mon, 24 Jan 2022 15:18:32 -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 4F519C075953; Mon, 24 Jan 2022 11:38:35 -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 182CCB8122A; Mon, 24 Jan 2022 19:38:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41097C340E7; Mon, 24 Jan 2022 19:38:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643053112; bh=J3h6L2kwUZJ7G0s0Kn2R/BUw7Zxwyn30CVsABOeUez4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MnQ2o+rCDG+eV3jR4yMSFYxbFT7XyNfKfzSNN9CKs/iIz3ZJgTMlmy7Cb8XlSNXUk tVCJbKxS9cJsfE1SlPb1KnZziOOBNnVwDbwkdZ9g0qHKtiDlOeLpt+HlR/T0Dcdh13 ayaPe2FTUMGJZaxk83hYYp3iRKkipiHpI7aRpz5E= 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.4 273/320] drm/radeon: fix error handling in radeon_driver_open_kms Date: Mon, 24 Jan 2022 19:44:17 +0100 Message-Id: <20220124184003.262333170@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183953.750177707@linuxfoundation.org> References: <20220124183953.750177707@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 @@ -652,18 +652,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 */ @@ -671,7 +671,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, @@ -679,19 +679,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;