Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp577580iog; Mon, 13 Jun 2022 08:28:25 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tuSem2DujJKUGAPbHZNFEg2fNBfJjItlqxTbUonoPrz/6KZ9UiyojSKVAHaXGdlR+n5j5R X-Received: by 2002:a17:90b:1b4d:b0:1e8:70ea:141d with SMTP id nv13-20020a17090b1b4d00b001e870ea141dmr368026pjb.146.1655134105086; Mon, 13 Jun 2022 08:28:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655134105; cv=none; d=google.com; s=arc-20160816; b=q/bfgFOxMx+dZz9EMxa9NVDCcl0JXV4PNYk7H6kTGNhi5stOvv7LSSAaJJ5Re5Cwfp Iz2QZSVcB1q0Wz9TF8IWlisF/r0mgrqobngIeocyVJK8JGzgbd5uiI3kFdTKKD52PtF1 fLPsDWO3iXbgq74GvhRtlG36KYPp/PikRpu2gsWsW4G6MkZDBE7mgbFc3Yki1YohW8pJ E7w3+jWCMcESpHc0PDyQkn9a496RZIWxkWvPUrcHx6MpHhlv/bpr7J25EG9x3LSPheDg M+3VS7qKsLQEa3y0zCklNHVU9/FytLX/X9fGSu2EvC0Wf1BxpeGnFoE7iID60VjHL7ol nM+Q== 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=Q2qGuyxb2tqKAEyw9wFTKrGeKF0+jpPI9J1tsUpvWXM=; b=xAJ56H5KYnoFms/bp/u3i2DRpy77S2DrrridkDKCU+05043pVeDVOKN+QKMPN9H44H DEM/Ftxmw1lSfYDJhNQX4e3FcHf9cyVK8WP33qtx6JJJ2I+x1Qy9PWcgSU1XDb1VQmJC mc1out9pvnwX4mrwJs/z0U/widP6ikW8bgIQlBxzuz41q72JqykWiKzZnWj4pxPbvmYW H01+YnyjW+WinGDmNx1iLsqcGlqHZNabmoX5tnt9sgcc30iGth41CXDt35+PB9OA7st8 dD0W8K7++nqlFjCknHSIsY923uGDqyLfTeh3E35CjhtCVCqzsr9st31/nn6/BFlm2ZqN PQBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TFCGyHUa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l12-20020a170903120c00b00168bedf2b1bsi11607052plh.598.2022.06.13.08.28.10; Mon, 13 Jun 2022 08:28:25 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TFCGyHUa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352338AbiFMLMF (ORCPT + 99 others); Mon, 13 Jun 2022 07:12:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352202AbiFMLJ2 (ORCPT ); Mon, 13 Jun 2022 07:09:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38EB4A1B9; Mon, 13 Jun 2022 03:35:34 -0700 (PDT) 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 E687460EF5; Mon, 13 Jun 2022 10:35:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04A08C34114; Mon, 13 Jun 2022 10:35:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116533; bh=Vn10bNQPc5pbtkyvWaaTmAUvAzjVuNIpxar3jUlAj00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TFCGyHUaJRzCu5YbWw41gavVUc6xuRCELZIFslGXREjbuIqpSBcui942rvQwaAWFA qWOkjBmSMyvOxiSOiZKYkyKZz74voZ90wtevnKugnHsW2gJfQgAnlyghC64mvHy1zk mUMjr7YD/EaT7axzM4xZ4AVsFKissiJPHchCeZHI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gong Yuanjun , Alex Deucher , Sasha Levin Subject: [PATCH 4.14 199/218] drm/radeon: fix a possible null pointer dereference Date: Mon, 13 Jun 2022 12:10:57 +0200 Message-Id: <20220613094926.658172989@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094908.257446132@linuxfoundation.org> References: <20220613094908.257446132@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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: Gong Yuanjun [ Upstream commit a2b28708b645c5632dc93669ab06e97874c8244f ] In radeon_fp_native_mode(), the return value of drm_mode_duplicate() is assigned to mode, which will lead to a NULL pointer dereference on failure of drm_mode_duplicate(). Add a check to avoid npd. The failure status of drm_cvt_mode() on the other path is checked too. Signed-off-by: Gong Yuanjun Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/radeon/radeon_connectors.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c index fc021b8e4077..dd7d771d13b5 100644 --- a/drivers/gpu/drm/radeon/radeon_connectors.c +++ b/drivers/gpu/drm/radeon/radeon_connectors.c @@ -489,6 +489,8 @@ static struct drm_display_mode *radeon_fp_native_mode(struct drm_encoder *encode native_mode->vdisplay != 0 && native_mode->clock != 0) { mode = drm_mode_duplicate(dev, native_mode); + if (!mode) + return NULL; mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER; drm_mode_set_name(mode); @@ -503,6 +505,8 @@ static struct drm_display_mode *radeon_fp_native_mode(struct drm_encoder *encode * simpler. */ mode = drm_cvt_mode(dev, native_mode->hdisplay, native_mode->vdisplay, 60, true, false, false); + if (!mode) + return NULL; mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER; DRM_DEBUG_KMS("Adding cvt approximation of native panel mode %s\n", mode->name); } -- 2.35.1