Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp441156iog; Mon, 13 Jun 2022 06:04:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwoVRNnggqu/72E/qa/dH0bWmywWeyWnNaQXI7eLWnM7n8MabMt+MFTwKdD0P70O0aWEHhu X-Received: by 2002:a65:6d0b:0:b0:408:7ced:3ca1 with SMTP id bf11-20020a656d0b000000b004087ced3ca1mr4552255pgb.476.1655125409865; Mon, 13 Jun 2022 06:03:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125409; cv=none; d=google.com; s=arc-20160816; b=zUirDwRikGU853oZyfLGzRQBU63PKMKGLnrmf5akPeclvDlz3uxW0Mtn1k9UlOaj50 2AQO15f5PGcvx1wbYM3AD3M1MyO5NPx9hF6lUhszM9FmK/VsG2km2gb9oU3beGuBTeOv MIto/lRTJYdLlwWCAE253LvRGw7mvsaKqJAMNzDEgLJ1L67OWYKCL0JtsL25ybN0bDvJ BuZJC79PCEBtp9llFjzzXRj0L31FCdEytBRyd67Xpd9nhgOMQdVNjytpiVNOUs5N+Fzk wPaPdRvHvrpRgQba+sm3c03Fw/XnALtDerfxHFTcy8XAkYaHfeozgrzDsFEtZykHMrvx B5IA== 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=JyUPfsCaPOHzPZnsMklysDx/nHsHlmum0plwihm8NtE=; b=06v7tFPUVIW4K9PWHmuH+l847gkfhNkGpSS6tyE/rD4RTESWNiWRwfuGsSsNA7ArNh PMoYUZYzbCHHo7U4yv+/2KXKyPGZlo8plTbvyGCxA6YYHmKMug15gtq60STNvaF1jzj6 LP2MRiAsGYbkVsawDe38R4BmnQqfazxKFcjkX7tOO2pzFeSNNDEM2SiSL5gHoP4bmFGg DmqAhAzkMGU4MheHb0Ax46pUeXbCi4TX17qvNaJY3d+oI8Y9fGn8eFcMMA7rBFlo9egt QsW9BzhjsYTkqFnyOtI1e/3eqOUgUI0B0VlLMIf9CzerQX95a5y9aSWA03blLeYEIlru wgBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GunpOyh+; 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 u17-20020a170902e81100b001636be51af5si11349919plg.258.2022.06.13.06.03.12; Mon, 13 Jun 2022 06:03:29 -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=GunpOyh+; 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 S1356915AbiFMLwC (ORCPT + 99 others); Mon, 13 Jun 2022 07:52:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357535AbiFMLqU (ORCPT ); Mon, 13 Jun 2022 07:46:20 -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 0D951AE71; Mon, 13 Jun 2022 03:52:33 -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 165386135F; Mon, 13 Jun 2022 10:52:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22755C34114; Mon, 13 Jun 2022 10:52:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655117552; bh=jKvlRLiX/pLSuJlbO74Zn3Gv8I0bAvcaloQk1F8KwSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GunpOyh+S7/5fJZX2eo6mFuR7O/G/G4f22BVq0mePhMlDhxK72wAWpIKoY3KNGuUI zd9nwVJurd3FtKzGmJ2Nsimj6s0LdQ4fjU8q45dPSB4MtHwN6D69mncFbSws/Kp+7p uPMmHk0VRsFWgwkNfGDVlnVBLnU5l+mWStZCxUyM= 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 5.4 389/411] drm/radeon: fix a possible null pointer dereference Date: Mon, 13 Jun 2022 12:11:02 +0200 Message-Id: <20220613094940.337055872@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@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 bc63f4cecf5d..ca6ccd69424e 100644 --- a/drivers/gpu/drm/radeon/radeon_connectors.c +++ b/drivers/gpu/drm/radeon/radeon_connectors.c @@ -477,6 +477,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); @@ -491,6 +493,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