Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp519172rdg; Tue, 10 Oct 2023 18:34:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHvT7opYduBmJJlH/1LrTnJUOWDsHgsGmUUuYd1jjovt9UxpM4TsPYJeczbRaKy9RMR7tW X-Received: by 2002:a05:6808:1582:b0:3af:63ad:a610 with SMTP id t2-20020a056808158200b003af63ada610mr28332299oiw.14.1696988068124; Tue, 10 Oct 2023 18:34:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696988068; cv=none; d=google.com; s=arc-20160816; b=jVWn94t6+cPIES4Ua/3BA0avPIYLeyzTZmd+pXyW9u28qnkBvKbQxY9dT15t3TSYD9 4G/Jjp08ksvXO2nyxMfJI24bY30yEP1CQcG1LNVqrNt94EKI8zMVJ1k7p47cui/uTRaR CRRfYPYQgkHl/ikH0o9leA89RMW06PSaDD9xQXXAxTDrU742VmN9N17DPp8dE9UHlyr4 qOWYOz+WI4Op/sbpTZ2QbjQw9PhnYiSmaLLGdIbCoBSUcm1Vy/nYpasVLMVzK6XAJ5TY Nh0Lx6kaz9SOAIrUp8pgHPkHKlyr7fAg4E5y2TCSDSAOy1jp0B83cJGO2kwFycsKwrJm a6Mg== 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=WIGsWAH/iA3oJPpW3K+uYoJ9SzV46v5QlbmbaUJ1e3A=; fh=+CviFvHMHPddon431hnC54sunrbbSN/YrKON4Gr8oMs=; b=Si5v5+LRgZQlmJEPfbU3zNIxpClVmwVcKBy6IPkTmYWkiszqewTO/G4CS2I/Ktq5Di S4GzPECqGP/rzkMMa9HN82XsTSbsHzVF7iSn5MVMOst71gHnERMbsvkIDnxumozbqz8+ jTsQbMEyqK/w3WXvsPAmYT7HjSjACQK0R197rU5xu2N5ECvru1olekGdAOaZWCr8FePt Cf99sYKvKqnSJmxQa/7iEMOXS+G+x9ZvDrdyJq6f0MTPcXHuer7Qu522d7bl6xarekil S3OEbEf7XgTxYiH6qIwnmqY/H2K35pYVTLcSHQXDNTYLsAOIgzVmWKUxs88BTW+iv/yK YP2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=hpwCytQP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id v62-20020a638941000000b0057884435a71si12562884pgd.396.2023.10.10.18.34.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 18:34:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=hpwCytQP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 2C9E080408E7; Tue, 10 Oct 2023 18:34:27 -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 S1344484AbjJKBeV (ORCPT + 99 others); Tue, 10 Oct 2023 21:34:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344233AbjJKBeU (ORCPT ); Tue, 10 Oct 2023 21:34:20 -0400 Received: from m15.mail.163.com (m15.mail.163.com [45.254.50.219]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A5D7691 for ; Tue, 10 Oct 2023 18:34:18 -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=WIGsW AH/iA3oJPpW3K+uYoJ9SzV46v5QlbmbaUJ1e3A=; b=hpwCytQPT6y4uIuhxlcTO GtPuYOYjDD4hpsUMwH76G9WQ0RHFIH55gSiHAaYxgALiZYmgxl7vXuxKeRJVE5VJ 3P7DcdplD+F9++G75VdRhgIXvmZbtmzV9uP6zEriNnfUNp8LntZLx3xLA6Jn2Wun gtcZoaL0/KywX40nw25AEw= Received: from icess-ProLiant-DL380-Gen10.. (unknown [183.174.60.14]) by zwqz-smtp-mta-g0-2 (Coremail) with SMTP id _____wDn76Jd+yVlvWboAA--.39607S4; Wed, 11 Oct 2023 09:33:24 +0800 (CST) From: Ma Ke To: maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, daniel@ffwll.ch Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Ma Ke Subject: [PATCH] drm/edid: fix a possible null pointer dereference Date: Wed, 11 Oct 2023 09:33:16 +0800 Message-Id: <20231011013316.4091845-1-make_ruc2021@163.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: _____wDn76Jd+yVlvWboAA--.39607S4 X-Coremail-Antispam: 1Uf129KBjvdXoWrurW5Zr1fAry7KF4Uuw48Zwb_yoW3Wwc_uF y8X39xGrnrua48ArsrZayfZrySyF1rZFW8Gr1Uta4Sy3yDCF15J347KFnYqryxWa1jyF9r Ja4Uua1fCF47GjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRKhL07UUUUU== X-Originating-IP: [183.174.60.14] X-CM-SenderInfo: 5pdnvshuxfjiisr6il2tof0z/1tbiyAUGC1p7MF401AAAsv 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,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]); Tue, 10 Oct 2023 18:34:27 -0700 (PDT) In drm_mode_std(), the return value of drm_gtf_mode(), drm_gtf_mode() and drm_cvt_mode() is assigned to mode, which will lead to a NULL pointer dereference on failure of drm_gtf_mode(), drm_gtf_mode() and drm_cvt_mode(). Add a check to avoid null point dereference. Signed-off-by: Ma Ke --- drivers/gpu/drm/drm_edid.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 340da8257b51..e2c154c2b896 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -3381,6 +3381,8 @@ static struct drm_display_mode *drm_mode_std(struct drm_connector *connector, false); break; } + if (!mode) + return NULL; return mode; } -- 2.37.2