Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3091396rdb; Wed, 15 Nov 2023 22:52:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IG7HseoCTxNXkIAwe2oRZqQyD16hB8jX76oojsqTlTwW1+UhsDHdJAkwo1pBG11/UiDx+3X X-Received: by 2002:a17:90b:38d1:b0:283:23d9:2bb1 with SMTP id nn17-20020a17090b38d100b0028323d92bb1mr11691600pjb.20.1700117542675; Wed, 15 Nov 2023 22:52:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700117542; cv=none; d=google.com; s=arc-20160816; b=lImhuDL5fMAkFV9OEji7akHF3mY91mjKIyMr4owXV3AzDDL1gcW3iecVyJO9C8PQEI 6oicMdsZzgwHR0GZ2c5cMq9ipcE3CXGghkqrAVrdSKwEKZfToQ/B0WcOBDqAQE2eJtdI D+AxWmrF8ZtdWDpVJLO46jeDZSKJZHno6UCFP8kGywONpPuhZbr6lL8ZxDTZzhAKStzw FO/IjqsbjuJc5PdNVcki7hrsyR3fJgjeZlGRVmk/b2qjbHubJzfVnnQnY5NxsiOQZGnK XQdha3lTZLlSR7V3eDadjP5PsqCkedtirE6VnT5HPsclSLoYbIIBoz2PJR5AnuZeBl8C VNyQ== 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=slQoXLuKNqUxMuSKi0/M+r6G1yK9uO5VvovN4cga41c=; fh=231+0uNteEx4gI320e7VQeiwgGdtH2c/Ve0JNDN8lII=; b=aHWL/6yYtKdGaZiA5MRKPlY2l/fZfByzqj6KLMv/2UIQz0utnGzJagYMsCi1NrKNTy tr5I1r9MISJtX7Rv+E0/R7UOVZnsS0czuu1stCtym+l7SzzVICaY/t0Se95TYqE6ch+L xr1npf11/eoQjCh4i2Lf3WUU26jH18gnIL18GsSBakQfijqikWZVvbusFRR61/X8ZVLx t05ldUytErEZV8WkkeDMA7czVD12zDHOSQNd8DcbmGLLo6rJfxFquTXfuUU+qELkaV/4 Saf0Ux2GZXOC7wlHVtGjMqbRSNNtL3CN1AW734WgeHUi/1wgImsLyUSyqI3LLR86llYe Q+cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nppct.ru header.s=dkim header.b=fzvySR4T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id my17-20020a17090b4c9100b00276571c0d34si1487298pjb.6.2023.11.15.22.52.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 22:52:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@nppct.ru header.s=dkim header.b=fzvySR4T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 97BA481338BC; Wed, 15 Nov 2023 22:52:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233700AbjKPGwV (ORCPT + 99 others); Thu, 16 Nov 2023 01:52:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229638AbjKPGwU (ORCPT ); Thu, 16 Nov 2023 01:52:20 -0500 Received: from mail.nppct.ru (mail.nppct.ru [195.133.245.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 250E8196 for ; Wed, 15 Nov 2023 22:52:14 -0800 (PST) Received: from mail.nppct.ru (localhost [127.0.0.1]) by mail.nppct.ru (Postfix) with ESMTP id 331291C0D49 for ; Thu, 16 Nov 2023 09:52:11 +0300 (MSK) Authentication-Results: mail.nppct.ru (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=nppct.ru DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nppct.ru; h= content-transfer-encoding:mime-version:x-mailer:message-id:date :date:subject:subject:to:from:from; s=dkim; t=1700117530; x= 1700981531; bh=K3YRmKofc6N6uINNSmeFkKZnxYRW32B+l0K9TQS6g74=; b=f zvySR4TFRoqaZp0rWO0uVqXf6kj06TaABLkINcz/GlJYHCU0hlf/jg9RV07mrSBE s90tYgzMV+Jy2RGLb8SWeo1HFpQZJdKikzGZufvwTa9qjeEGC4d0keLQMNV+LSZF YnPDYb/UzYF2CG8zQbNrJ7wYiBX7b9GdwUqwNEZa3g= X-Virus-Scanned: Debian amavisd-new at mail.nppct.ru Received: from mail.nppct.ru ([127.0.0.1]) by mail.nppct.ru (mail.nppct.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id MWzU3XDIG0GN for ; Thu, 16 Nov 2023 09:52:10 +0300 (MSK) Received: from localhost.localdomain (mail.dev-ai-melanoma.ru [185.130.227.204]) by mail.nppct.ru (Postfix) with ESMTPSA id D04BC1C061A; Thu, 16 Nov 2023 09:52:07 +0300 (MSK) From: Andrey Shumilin To: Karol Herbst Cc: Andrey Shumilin , Lyude Paul , Danilo Krummrich , David Airlie , Daniel Vetter , Maxime Ripard , Thomas Zimmermann , =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= , Jani Nikula , dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, khoroshilov@ispras.ru, ykarpov@ispras.ru, vmerzlyakov@ispras.ru, vefanov@ispras.ru Subject: [PATCH] tvnv17.c: Adding a NULL pointer check. Date: Thu, 16 Nov 2023 09:51:59 +0300 Message-Id: <20231116065159.37876-1-shum.sdl@nppct.ru> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 15 Nov 2023 22:52:21 -0800 (PST) It is possible to dereference a null pointer if drm_mode_duplicate() returns NULL. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Andrey Shumilin --- drivers/gpu/drm/nouveau/dispnv04/tvnv17.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c index 670c9739e5e1..1f0c5f4a5fd2 100644 --- a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c +++ b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c @@ -209,7 +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 == NULL) + continue; mode->clock = tv_norm->tv_enc_mode.vrefresh * mode->htotal / 1000 * mode->vtotal / 1000; @@ -258,6 +259,8 @@ static int nv17_tv_get_hd_modes(struct drm_encoder *encoder, if (modes[i].hdisplay == output_mode->hdisplay && modes[i].vdisplay == output_mode->vdisplay) { mode = drm_mode_duplicate(encoder->dev, output_mode); + if (mode == NULL) + continue; mode->type |= DRM_MODE_TYPE_PREFERRED; } else { -- 2.30.2