Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp953120pxb; Wed, 6 Apr 2022 05:12:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdcGz7BMIq21VioTbMunu9Lh9LvE2LA98Q7VH3i9ox8FeGb/ZeYHp1H32YJiLS3mI42WR9 X-Received: by 2002:a17:902:a581:b0:154:8c7d:736a with SMTP id az1-20020a170902a58100b001548c7d736amr8445147plb.74.1649247125971; Wed, 06 Apr 2022 05:12:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649247125; cv=none; d=google.com; s=arc-20160816; b=ePESrARFSmnebndsYHg1nXrapYwKJfCCGWeL6yg06EtqFd/VD2/iBDqLXBXoE2cF2C AJW1G13d/RKypCGuSKH7jWNZBOlIYKKhTepyIKYETwUnnUz/e/3rd0i/QXemlxZyd/pg J1i2pfnCvx8L60DdnKu/jN7dk8YS3uVbT7+8XD0XjWyJ3GZ4TbEyTtpn7V0cOqpgG+Rb Q8LJSJL8I2FTlKKzJMUBILX0aiXQnTL38zrCbV8BphmusgnsRBVMkMGFWlpRryjUuep0 hFTxq0dDSpqZJCFE9GV/YAkjVPznYxnxF4XzvPY9lFhp8dmJXg9gzRVoY+5yy/aisjCL XwJA== 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=exXLsvBtVbat4V0zz3+tepYkWKgjjHfXMEmxQdhBJDk=; b=CMN/FBXof2H60yZ1XwIOFykeb7+jH1Fk21jmajr/YLgyQJsgoKVQNFvDhc0reJ+6Xh 9wIfTL6U7jM3fTFyx/xC9PKURRdbvNFmsU0E81eoEXRfJSCXntiaXPI8D/eFu8U6geN6 xpdLE44R4XnnAZ3uhNW+NNxeFJOeC7k793jirj1iLMYUbqFKHduDKCPD2P2rBWCUtVfh EYXI+l2BBrCZkIZvDby9Ibyzus7v0hXvkN2f8SLDop/2oFasJLSd3JKEKRkeE2wIUrve fvh+qKGo1u0ygoZJVtuNP+lFcPl6Q/Cm50Xp6OWL2yarV6IYh9RR1FctQVB4EJQzk7Xj dnEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="J/NrTTTf"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id y30-20020a056a001c9e00b004fa9a8cc0ccsi13947130pfw.100.2022.04.06.05.12.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 05:12:05 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="J/NrTTTf"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D998150E47D; Wed, 6 Apr 2022 03:49:42 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1838132AbiDFAuQ (ORCPT + 99 others); Tue, 5 Apr 2022 20:50:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348865AbiDEJsm (ORCPT ); Tue, 5 Apr 2022 05:48:42 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3BEBB8229; Tue, 5 Apr 2022 02:36:44 -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 ams.source.kernel.org (Postfix) with ESMTPS id 7F21CB81C86; Tue, 5 Apr 2022 09:36:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5699C385A2; Tue, 5 Apr 2022 09:36:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151402; bh=/g8dXg0JypJ/RhYmeXw7ZH3eC2NvExYfPtmWzLtqMqs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J/NrTTTfoLtc2MhNFKYIXe+AZFOIeq17AIC0zVMfGkHKEkTKslvPjb5kYcMMWa7qS 2hqgNRuB7uBIu48QkEQxtTFoUcxxfoLtvcmc0znf8KdsHql1TEbG+iOMFqK5+LhlLZ 9e4VedL5iUCanii/b9U85XxexgUjXxjsQMuu7UOw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhou Qingyang , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 401/913] drm/amd/display: Fix a NULL pointer dereference in amdgpu_dm_connector_add_common_modes() Date: Tue, 5 Apr 2022 09:24:23 +0200 Message-Id: <20220405070351.867418564@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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: Zhou Qingyang [ Upstream commit 588a70177df3b1777484267584ef38ab2ca899a2 ] In amdgpu_dm_connector_add_common_modes(), amdgpu_dm_create_common_mode() is assigned to mode and is passed to drm_mode_probed_add() directly after that. drm_mode_probed_add() passes &mode->head to list_add_tail(), and there is a dereference of it in list_add_tail() without recoveries, which could lead to NULL pointer dereference on failure of amdgpu_dm_create_common_mode(). Fix this by adding a NULL check of mode. This bug was found by a static analyzer. Builds with 'make allyesconfig' show no new warnings, and our static analyzer no longer warns about this code. Fixes: e7b07ceef2a6 ("drm/amd/display: Merge amdgpu_dm_types and amdgpu_dm") Signed-off-by: Zhou Qingyang Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index cd611444ad17..7983c01c007d 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -7554,6 +7554,9 @@ static void amdgpu_dm_connector_add_common_modes(struct drm_encoder *encoder, mode = amdgpu_dm_create_common_mode(encoder, common_modes[i].name, common_modes[i].w, common_modes[i].h); + if (!mode) + continue; + drm_mode_probed_add(connector, mode); amdgpu_dm_connector->num_modes++; } -- 2.34.1