Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp137887iob; Tue, 17 May 2022 21:31:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2ga2AuXln0bMZ3AcDE2h78pduTtbVmQ2xUw8gmqLaqQW7ip7R2PwI20WpQZulXSWIgORS X-Received: by 2002:a63:5563:0:b0:3f6:89b:89f3 with SMTP id f35-20020a635563000000b003f6089b89f3mr588905pgm.419.1652848312879; Tue, 17 May 2022 21:31:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652848312; cv=none; d=google.com; s=arc-20160816; b=eHvs+l+Hl4SCKXlFZ08sfxKwJkVmKteelhoDjlJ5JShjkUqvgRs9Z1I//k5uzl5Cz9 hT+umW1sh2/XAuFZrE6qxjqwJyBgkDsAR4Lm4xn8Q4zymhagArG7j3GWLf5415fb6P0x zONmkKd+wnMm9Q5OHqSkLf1XAkZ5yKybQ1W2N3zkfgrnhPSksFhiEwwBPEVN7BNkdwWI Ovi++W0Y87S06XvnmviLo4nISk7KXWKXDmA1YMm4jm6gXXAbTkLaZ4Td3gj0/yu0bFIY uP+rN9+RaCyRfmlVDAZEl468CHeJOlS5i7tNbM4D43gN01hk4GHn/ogStpxdfUvePB18 5HKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=dAN5rQx//OjLAAbOjOsE0mviFNWECN52JE1qKyTqmK0=; b=uP+1ieuC4ISL0YebAM66eSOGp/UmygxNKA0BbZa3TN63iA86Ip5MxAfonoik3KDlaK im5EixsvG3Q82SU5SVCQ/QdJ6Hugu69GjS6H3fG7081OFmjwATGN9LEpp5bcND689gTw xmRm1tzQuaXm7Tjf31O49IAijns7P/5ePo+tEF93WRqkawdFrrnCldarb32S3AGl+Iqf aIK0YOPimyL4gqCyo889/G7wwj/YCG8yzlykz9X2xQ8QoIo7+IsAZPEiis8V4muqKHbd TqpLzBXK6bnd66aT3bQcOrrO/cqeP+i6a82U6P1/ZyD+oQhveJyAlUqOHSF68i/auDhr KWnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=DY5Reg58; 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=163.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id s24-20020a170902a51800b0015ceea6bd9esi1250264plq.550.2022.05.17.21.31.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 21:31:52 -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=@163.com header.s=s110527 header.b=DY5Reg58; 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=163.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 68D5E8DDC8; Tue, 17 May 2022 20:51:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244816AbiEQJ5f (ORCPT + 99 others); Tue, 17 May 2022 05:57:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245316AbiEQJ5a (ORCPT ); Tue, 17 May 2022 05:57:30 -0400 Received: from m12-12.163.com (m12-12.163.com [220.181.12.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 580ED3F881; Tue, 17 May 2022 02:57:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=dAN5rQx//OjLAAbOjO sE0mviFNWECN52JE1qKyTqmK0=; b=DY5Reg58DB4MSpMkgPmXwlujKIKq9An438 BIm7spLWaHMUzma0Jh7jO+Uu9RPXv7m4ScAJVq15V8pXmHKFYYmLPAzDzCv2SOBb lQU6J2+Z8yF57uWAhD0xTIom8FHP7Ad8SJcKjVeuO4XmSECZwSKw2DiPka2PH95g sR5jBA2Qs= Received: from localhost.localdomain (unknown [202.112.113.212]) by smtp8 (Coremail) with SMTP id DMCowAC3cx11cYNi12q8Cw--.34092S4; Tue, 17 May 2022 17:57:19 +0800 (CST) From: Yuanjun Gong To: Yuanjun Gong , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org Subject: [PATCH 1/1] radeon: fix a possible null pointer dereference Date: Tue, 17 May 2022 17:57:00 +0800 Message-Id: <20220517095700.7291-1-ruc_gongyuanjun@163.com> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: DMCowAC3cx11cYNi12q8Cw--.34092S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7Zw4DZFW8Cw1kZF1xXw43ZFb_yoW8XF43pF W7Gr9Iyr9ag39rGFyxAF9rWryUu348GF18Grn8u3ZrC3Z8Kry7JF17u345J3s3AF98uw1U tr18Ga429F1xCFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0piQBMZUUUUU= X-Originating-IP: [202.112.113.212] X-CM-SenderInfo: 5uxfsw5rqj53pdqm30i6rwjhhfrp/1tbiJw0E5V5vB8SlZwADs4 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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: Gong Yuanjun 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 --- 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 0cb1345c6ba4..fabe4f4ca124 100644 --- a/drivers/gpu/drm/radeon/radeon_connectors.c +++ b/drivers/gpu/drm/radeon/radeon_connectors.c @@ -473,6 +473,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); @@ -487,6 +489,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.17.1