Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp762143rdb; Fri, 6 Oct 2023 20:25:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYudFZRR4NDNdkkmeP+F4uI1TjXdUl56tnkXnd+f/XJ/niVXOXpz8+2hZ46l7UsswnDbPI X-Received: by 2002:a05:6a00:17a1:b0:691:fd26:f54a with SMTP id s33-20020a056a0017a100b00691fd26f54amr11421284pfg.20.1696649108446; Fri, 06 Oct 2023 20:25:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696649108; cv=none; d=google.com; s=arc-20160816; b=beTGmUlohFfP0GFGVG5kZjgDRjUXxD3Z78RnDiJSBFVFrFtKcqB74/s86aLCUtsRBY qDIbnpo5ojasnU0KlZVPLakr+LRMmU9FQq+++CCBUIxi+eidzoyPap6ayRPLIwM53DaX slMx6ORzogRTTllOS8TPWoG/nlU/HIIYLgyJLkzI03FgB5Bluhy5LbPz2LOI3bPaP0Ch nH5Qnt0NnmD2lpwDo1MZckDhs0bcT3mN8TPaXW94+xSvcK41b1ikiBG5wvFFCt91TwCZ gmgNddJrNpCEU9sqC+9xKR3JPPdtF2NKWJte+j7IIn2XHZFJ9xGYIO+sYAFgDBnpPsQM gqgA== 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=7aZx2QKxrK4aACi0XwiI3PbFPdSP9h54OxsoE6ZvLhw=; fh=k45MbHmgXbaWKOw+lqhBbGiaSa0QZBat7g/3PZVnTO4=; b=l4r5L6k7cYhwDD3bx2sB4WVYtpiIBTsgpMrBH9V//AME6P/QceASSZYAjHsBligAVR X6FrYRvAgLaVQNcVJExkfZoNugZdW6uh4S7hUH2gRhIfVfktaflTcdv9sIkf1QKpsnQQ ZtfTNF7XW5GfVqj8R6b+TfjZaFWaFt6MouHNRoh01A4EGm0Qp9Q4+O98pMZrQvvMpKXi yl7wlZxpXQWdeRj892X2oqJCbXPiXxAaqABXpNrcu9qoUApR2PK8lfcxn+aJjQuBa7VF vmfsVPAr8KRw7jIO4HBU72H+PoX3u8NW/fUeZ51vyvKCJohvJW3yHe9EaFFGkP1qFkOU TvKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=I3nu3INg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id m11-20020aa78a0b000000b0068e48477befsi2631254pfa.211.2023.10.06.20.25.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 20:25:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=I3nu3INg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 1CDE780A64F0; Fri, 6 Oct 2023 20:25:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343513AbjJGDYq (ORCPT + 99 others); Fri, 6 Oct 2023 23:24:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343512AbjJGDYp (ORCPT ); Fri, 6 Oct 2023 23:24:45 -0400 Received: from m12.mail.163.com (m12.mail.163.com [220.181.12.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2E13BBD for ; Fri, 6 Oct 2023 20:24:41 -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=7aZx2 QKxrK4aACi0XwiI3PbFPdSP9h54OxsoE6ZvLhw=; b=I3nu3INgoTCiVl0F60AUk qx0F2E6Iy+qkt6b+b3oBnq/6petdfTX+AxsOC0Hu9GVeisSrCke64IBtARnVNQxU kL2pXVtMaNQKjPmS7XFKA3EU56Ud0BMDxYlVElZ+VkDi1L5r461qLJ5BCsdejvaQ epwUD1N/SwehPkz5pmhLpg= Received: from icess-ProLiant-DL380-Gen10.. (unknown [183.174.60.14]) by zwqz-smtp-mta-g3-2 (Coremail) with SMTP id _____wCnnYRGzyBlPFAgEA--.50459S4; Sat, 07 Oct 2023 11:24:00 +0800 (CST) From: Ma Ke To: kherbst@redhat.com, lyude@redhat.com, dakr@redhat.com, airlied@gmail.com, daniel@ffwll.ch, noralf@tronnes.org, tzimmermann@suse.de, mripard@kernel.org, jani.nikula@intel.com, make_ruc2021@163.com Cc: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/nouveau/dispnv04: fix a possible null pointer dereference Date: Sat, 7 Oct 2023 11:23:49 +0800 Message-Id: <20231007032349.3997387-1-make_ruc2021@163.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: _____wCnnYRGzyBlPFAgEA--.50459S4 X-Coremail-Antispam: 1Uf129KBjvdXoWrtF1rZr4fAF45tF47AF4Dtwb_yoWfArcEkr y8Zr97Gr17ua1vyr4DAw1xAr9Ikw4Uua1Iy3Z2gFy0yF9rJrn0qry7K34rXFyUuFy8WFyD JanrZw15KrnrGjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRK6wZ7UUUUU== X-Originating-IP: [183.174.60.14] X-CM-SenderInfo: 5pdnvshuxfjiisr6il2tof0z/1tbivhACC1ZcjAJZEgAAso X-Spam-Status: No, score=3.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email 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 (fry.vger.email [0.0.0.0]); Fri, 06 Oct 2023 20:25:06 -0700 (PDT) X-Spam-Level: ** In nv17_tv_get_ld_modes(), 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. Signed-off-by: Ma Ke --- drivers/gpu/drm/nouveau/dispnv04/tvnv17.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c index 670c9739e5e1..4a08e61f3336 100644 --- a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c +++ b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c @@ -209,6 +209,8 @@ static int nv17_tv_get_ld_modes(struct drm_encoder *encoder, struct drm_display_mode *mode; mode = drm_mode_duplicate(encoder->dev, tv_mode); + if (!mode) + continue; mode->clock = tv_norm->tv_enc_mode.vrefresh * mode->htotal / 1000 * -- 2.37.2