Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp683654rdg; Thu, 12 Oct 2023 19:09:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGfBokim796Au+NMA/h7+A4lEF8iLwMftdn1P8xEHYCuomG0vP5XQiuUk64TEhRcB4oCmct X-Received: by 2002:a05:6808:354:b0:3af:d7dc:a47e with SMTP id j20-20020a056808035400b003afd7dca47emr18618703oie.42.1697162969901; Thu, 12 Oct 2023 19:09:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697162969; cv=none; d=google.com; s=arc-20160816; b=ZskXQnp7n3RDG3l7rkD6/eAuqPYfHq3HKnMGDs06+4OCCdCBkfaKO/yA4HlwFkaZvN nBbUMjbXgI25BNfz635v6dZE1Su4+XdwtuKQ8Wrq22mRoCmuaH2eAyo2UKqIhB4XQ8/i SofQB9CAhsuvSzMJVSaZUkwYCp/LNkgNPEHLXHN9Ud96zHfqKJ9Suk8hnxl9OgjtX8RJ rJ1McPOzKZHSZmUM4RlNG9qclHuBB6661Wz0J386ccP6/Z5VxIavvfVQPxIp5ugc2WPy aBjwNHeTrr+T9DovwyVbK5uUc+QjG9CcbMAtA3WNL6+PH79BCnJCMLRUBetkgm8eG5Ht ejYg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=l7hzrlfLhpSLoZQc2BwbgrP4SPxkiJtn7f4bO6Xpa44=; fh=NGqq3RkGnWL+5T2b95k19uSgJpvitWrq+0EfYDSfpSk=; b=csOSotByuWnYWV4zfqzoF810yMWsB3k8SZCCSigiktWGmyQL4WxyeEYpVTPJMB+O4e Hd8np/RJdOz8XhEqanhFWvLv0zhTSFwD1SelfYLKZTz8T3bC7Mvn8qgHP6sm2UvMmjLz fuAz+p8qLuKZ9yWROy2cXzhAHH5agJXHQes6n81iNHqV1nc1KAJiPi9rtT1+TpjO3pz4 xa0DLWkh9ncp9eWXFCjWcVRn0v/K506KFM94XiATATd1KxKZw7DYeAlLnPmML1gFMIHk 830uzMKd0KuOfcqovo8YqhiHuaPU3bNM/eaWBXy8K7sgyM4aYiTT8cDPLLXkF/iMw7fP Opdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=h4ip7ZIx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id e26-20020a631e1a000000b005641315d956si3625918pge.147.2023.10.12.19.09.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 19:09:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=h4ip7ZIx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4E07D80A1844; Thu, 12 Oct 2023 19:09:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229461AbjJMCJ0 (ORCPT + 99 others); Thu, 12 Oct 2023 22:09:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbjJMCJ0 (ORCPT ); Thu, 12 Oct 2023 22:09:26 -0400 Received: from m12.mail.163.com (m12.mail.163.com [220.181.12.215]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7BEECB7 for ; Thu, 12 Oct 2023 19:09:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=l7hzr lfLhpSLoZQc2BwbgrP4SPxkiJtn7f4bO6Xpa44=; b=h4ip7ZIxibWNomTfIzriV DYVi2p5AoTrOvtWCQlRgORTK1YcGAbVofGE375knqtTq6GbJQRHwZfs43psyC391 Q6o/uTXAEcihCeIetA+32WNoPkHnKilUIz0nJevdSFXOvurSNV7lyaxi4Clj7Yxk O/AXKbTL4VwJGofdru296Q= Received: from icess-ProLiant-DL380-Gen10.. (unknown [183.174.60.14]) by zwqz-smtp-mta-g3-0 (Coremail) with SMTP id _____wD337u6pihlYTiWAQ--.28260S4; Fri, 13 Oct 2023 10:09:07 +0800 (CST) From: Ma Ke To: alexander.deucher@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Ma Ke Subject: [PATCH] drm/radeon: fix a possible null pointer dereference Date: Fri, 13 Oct 2023 10:08:57 +0800 Message-Id: <20231013020857.372163-1-make_ruc2021@163.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: _____wD337u6pihlYTiWAQ--.28260S4 X-Coremail-Antispam: 1Uf129KBjvdXoWruryxAF1xKr43KFW5WF4fGrg_yoWfZFX_uF yvqa9rXa909asYvF17u3Z3Zr9I93y0yw4ktF1xta4S93s2qF1fGFy3tF1rZw47Xay5AFn8 J34rK3W3Ar4xGjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRKfOzJUUUUU== X-Originating-IP: [183.174.60.14] X-CM-SenderInfo: 5pdnvshuxfjiisr6il2tof0z/1tbiyBAIC1p7MIObKgABs5 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_BL, RCVD_IN_MSPIKE_L4,SPF_HELO_NONE,SPF_PASS 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 19:09:28 -0700 (PDT) In radeon_add_common_modes(), the return value of drm_cvt_mode() is assigned to mode, which will lead to a NULL pointer dereference on failure of drm_cvt_mode(). Add a check to avoid null pointer dereference. Signed-off-by: Ma Ke --- drivers/gpu/drm/radeon/radeon_connectors.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c index d2f02c3dfce2..9f7d8ab980e6 100644 --- a/drivers/gpu/drm/radeon/radeon_connectors.c +++ b/drivers/gpu/drm/radeon/radeon_connectors.c @@ -520,6 +520,8 @@ static void radeon_add_common_modes(struct drm_encoder *encoder, struct drm_conn continue; mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h, 60, false, false, false); + if (!mode) + continue; drm_mode_probed_add(connector, mode); } } -- 2.37.2