Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp192180lfo; Tue, 17 May 2022 21:55:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzr7WpVaWranG5gO5cFPokvSj0A/cBsUKXKSgKN3pAKuBo5OpXt8dqiAJnZPNihLUBM9+X X-Received: by 2002:a05:6a00:22d4:b0:510:6d75:e3da with SMTP id f20-20020a056a0022d400b005106d75e3damr25737367pfj.3.1652849703039; Tue, 17 May 2022 21:55:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652849703; cv=none; d=google.com; s=arc-20160816; b=CNJ+IKXef1Km4HNFCedJpaejZQIT0fBbqAG1mtG1jyTpPBwmA9nlBNPJcRZp1clazN 3A/c7XcHxYGmKqBW1ANIM9ipBiOMYm7H7wRXz2SUT7ev5PcxlCgYnvvELuiIUXXbai3w XWzU38+BC8yzTS/EGYnCsIk51T7dQd0Ip8X2dzKLa2QxmnyGeQRIkshSIh/3ZU0iulWH OsWUkvRMOjFJoqG6ETTeyUtHNj/spMuDNbFL6w2vFlQ27Xf2jmeG5ZA5aXA++Bi+Aj8i BMIxBmzq10ecaUyH1sUWhJNeL7Z4DMFPTtRlQASnnLmPukCAnhi8rHwSZA88wy4rl8C+ D2pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=esDt/ygm4WEDZW7NMBdetNiik4xOkEth8NzDieBlCmM=; b=RW2sceI0TOJtO4BIcaHB/t9XCNcjNk24v6Iya+GMXHN/2RlCA2ywQlKguxy5VDY/zY h9P/fcP1MPqUlCSUycUR6gLdG7KQNpwe9cc1+/u+DVIkKn7ncP0GoVVCKaXuATtvBHqW owi99GGkp/46lDvi1GelluAU7EqYJl2vhEPNg2TT5KJWEvusvgR0lri1mT/seChO+QrP o8B9C80BPGkZhGW3+IZNVHcFJTNGk86TXRrygRJ2DG/PJ5CplNGdu2OY/Xg18KhQCXHo LyuJyCVAZJO+NmEyjXAYq3ozpfnxM1L4rXAJrLQEWs8GNRsjGra7aSq2OAiSPpFaAPYW Y0pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gKPmFVts; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 124-20020a630482000000b003f5f9e173c2si1340326pge.504.2022.05.17.21.55.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 21:55:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gKPmFVts; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9B5B76E8FC; Tue, 17 May 2022 21:03:00 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353102AbiEQUyk (ORCPT + 99 others); Tue, 17 May 2022 16:54:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353060AbiEQUyc (ORCPT ); Tue, 17 May 2022 16:54:32 -0400 Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [IPv6:2607:f8b0:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57868532D8 for ; Tue, 17 May 2022 13:54:23 -0700 (PDT) Received: by mail-oi1-x235.google.com with SMTP id y63so301897oia.7 for ; Tue, 17 May 2022 13:54:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=esDt/ygm4WEDZW7NMBdetNiik4xOkEth8NzDieBlCmM=; b=gKPmFVts67I2YaFCueBVBPv+QGDtrzBVPTDht4HFOb5YFVrVAJavab1X62rwiHplrN VncmnllGh57N9jrTzqfTqGc5yIPFpxPnljl/ZjIipTZTdtqC6C8zpFQf2s/qjCk33CJh 8k12YFzRsrSu6fZp+UzNMxc9epUCkGnAnpBfTrytYfRjNFrn2EIHyS7UU++CwnQR70OU sM7VXfNgZZqhxwygU9E0tuwvWtOec/6A9sb7cgHCJaEOhxl/SScAbGLsrSIebHComKlX lnRhLgoCnY+rfY3t9H2mEbFQWJc1L0KeLSTYt9Kho1f4lacmL2xHeR2LD7E3OuxKacqq A2Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=esDt/ygm4WEDZW7NMBdetNiik4xOkEth8NzDieBlCmM=; b=bgeEwoVgR9SBga12DIhsmKUVmJRgkLhEgXPGDf+hPxPWyU8YjzWJ64x15TpCwEUMiA 6sbIoo8CUdCvriOpO2KEl9VRGgVtMVnBfm0w6aRmH72a3u/s2XUWQuyM0quGyHTvWKtE uAEAd7oPrfyblAtQhX+9n7j8/K35ivHw5WNbG8y8xRCvaH8wTXoXxJbh7JSdDaFBd4Ok nthtG2svU1XbohoSTjZf/+TYLFDKlrlC4EJn67eVMc6n4BrKLkD0dxTfRVamO9ddAonE 0F+i58YwwmJARcVS4NY0dWVAT0cNJWfgZMsnhs8yPA68MXT6HQVk25XeTgcFxk4LF5vr t5sQ== X-Gm-Message-State: AOAM533KhqkJdMFi2gfSHPOSRWl+cQadPzilZLQwpjl/l7D2GvNj1w57 qXMUlv4x0w4vlP2yHEkiQJZX46odGuP23XtKZrVtX+DG X-Received: by 2002:a05:6808:f8e:b0:328:a601:a425 with SMTP id o14-20020a0568080f8e00b00328a601a425mr12159725oiw.253.1652820862717; Tue, 17 May 2022 13:54:22 -0700 (PDT) MIME-Version: 1.0 References: <20220517095700.7291-1-ruc_gongyuanjun@163.com> In-Reply-To: <20220517095700.7291-1-ruc_gongyuanjun@163.com> From: Alex Deucher Date: Tue, 17 May 2022 16:54:11 -0400 Message-ID: Subject: Re: [PATCH 1/1] radeon: fix a possible null pointer dereference To: Yuanjun Gong Cc: Alex Deucher , =?UTF-8?Q?Christian_K=C3=B6nig?= , amd-gfx list , LKML Content-Type: text/plain; charset="UTF-8" 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 Applied. Thanks! On Tue, May 17, 2022 at 9:13 AM Yuanjun Gong wrote: > > 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 >