Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp267002rdb; Tue, 5 Dec 2023 05:07:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IHTueoiEJs/V+RoYJEDVdDdKoWOa2pyQzouuk5L55A3D9seQfubUizmlN5Halltz+VSG+o5 X-Received: by 2002:a05:6a20:979b:b0:18b:208b:7043 with SMTP id hx27-20020a056a20979b00b0018b208b7043mr5435620pzc.49.1701781639605; Tue, 05 Dec 2023 05:07:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701781639; cv=none; d=google.com; s=arc-20160816; b=aM/rvowVCw7aGwk69++0z/GtJPLdKQinq3VS1/YYrn0mq8OD866TrW9WdBll081NI5 /MHDzAQcHCGybzZGM21aSDNT5Fgi6pH6N/PxLCykilQRB1ursZoPG+TvkVr6A1Hsn5DC xXikYxMiIaXub4vx9L17G/9UUA3DPNYHfp5IzMq5DUdlYztjGIMKtlwewNK63iOqaoSu 45+ehL4353qHjB8sxqQOTmTC60/cEgsB4Ecoi2UXU+qVr/CcBBJ/zt40qBxMj0n7Dgpm YvVojni5aTTeLIiDwxkhp/bKLPyZEfLAdPa9RnEU3BUcIKXQ7rSsUvQiIFi5OUWSaaID aX7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dkim-filter; bh=3djYIPlIEHPAVOgGmtvfiiLsf3bNmhA0OAsSAQwtPUc=; fh=kzZfvH6RqrOZYry/5v84CQmzIPrtRBXO1vPoWx3sB/0=; b=xiU26s/DHCx0TkAO9r2lL0jIXItstbhBnlEzI4Rm8kEpUQ6Wol+/l+HjtYsUuNVl8g vzbLEzqghSxj/UEP9cMBsqHVZX3ztqd1CDaWubWq04tmF24euF6LSdKasC1ktTU8sGzE HPLMQzhUtgUJ9EWcjWCNjrgNkCjez9W0FKTBQY/s8RJI8KDaY8r8oHEUvA3h4WHZj2HJ d8XFW1uM580e/xkQ0cXL4Zl55EuVqNqW0hjKNelMucG+fkDS+1XXwH59tzwmr5HhcW0t vXX7iZ1fIYYPYvnSvBZFuoQ2MqDYnXE/7tiNHNjPaCKjzovLi4S2uRBFrtgIrMs0+F7Z YScA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=DdJ1A7OK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id k13-20020a634b4d000000b005c1b28061b0si9581917pgl.65.2023.12.05.05.07.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 05:07:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=DdJ1A7OK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id B72E080ACFD6; Tue, 5 Dec 2023 05:07:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376767AbjLENGq (ORCPT + 99 others); Tue, 5 Dec 2023 08:06:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345363AbjLENGn (ORCPT ); Tue, 5 Dec 2023 08:06:43 -0500 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A04AD187 for ; Tue, 5 Dec 2023 05:06:47 -0800 (PST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20231205130644euoutp02e192f86d6548b6a732da2c190a5e95d0~d8Vpb53Lp2191821918euoutp02S for ; Tue, 5 Dec 2023 13:06:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20231205130644euoutp02e192f86d6548b6a732da2c190a5e95d0~d8Vpb53Lp2191821918euoutp02S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1701781604; bh=3djYIPlIEHPAVOgGmtvfiiLsf3bNmhA0OAsSAQwtPUc=; h=From:To:Cc:Subject:Date:References:From; b=DdJ1A7OKT6HjpgRK2bVpGrwT74tnZe6zZxoQDYYlrQvw12JbPNsddQ8RqpAezkwUP 8aQHh9eGC/lQK386cFmR/ef3x+Bkr8hXApaO5slgAgj5m9Yr3Y3xVeyiuWDSKWyq1E 6mRPVm+55253B9bdONDWAIl/IX9fPi7PNj9siVOM= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20231205130644eucas1p2718897683fbbb32a1d4315f22d49cb64~d8Vo_RZPd0099800998eucas1p2p; Tue, 5 Dec 2023 13:06:44 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 5B.DF.09814.3602F656; Tue, 5 Dec 2023 13:06:43 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20231205130643eucas1p283a5476b78a87997fa393d00f5172418~d8VomF8yy1993619936eucas1p2-; Tue, 5 Dec 2023 13:06:43 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231205130643eusmtrp2bb6144d525e0afb546b1f00f5fcb4caa~d8VolQtwq1626416264eusmtrp2o; Tue, 5 Dec 2023 13:06:43 +0000 (GMT) X-AuditID: cbfec7f4-727ff70000002656-4c-656f20633a5d Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 70.1F.09274.3602F656; Tue, 5 Dec 2023 13:06:43 +0000 (GMT) Received: from AMDC4653.digital.local (unknown [106.120.51.32]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20231205130643eusmtip11acdc942d2dc461a40ff7332e80436f5~d8Vn_VOa42835128351eusmtip1k; Tue, 5 Dec 2023 13:06:42 +0000 (GMT) From: Marek Szyprowski To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Marek Szyprowski , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Neil Armstrong , Dmitry Baryshkov Subject: [PATCH] drm/debugfs: fix potential NULL pointer dereference Date: Tue, 5 Dec 2023 14:06:31 +0100 Message-Id: <20231205130631.3456986-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrIKsWRmVeSWpSXmKPExsWy7djP87rJCvmpBkt5LE5cX8Rk8X/bRGaL ied/sllc+fqezeLyrjlsFmuP3GW3WPhxK4tFW+cyVov3O28xWmx5M5HVgctj77cFLB47Z91l 99i0qpPN4861PWwe804GetzvPs7k0bdlFaPH5tPVHp83yQVwRnHZpKTmZJalFunbJXBlXP5w jLHgqFTFls8HWRsY54p3MXJySAiYSJy98I2ti5GLQ0hgBaPE748r2EASQgJfGCVuvc+FSHxm lPjSMp+pi5E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Tll5akKmTkF5fYKkUb WhjpGVpa6BmZWOoZGpvHWhmZKunb2aSk5mSWpRbp2yXoZVz+cIyx4KhUxZbPB1kbGOeKdzFy cEgImEjc7qnrYuTiEBJYyihxd/5Ppi5GTqC4jMTJaQ2sELawxJ9rXWwQRZ8YJbZ+2MsGkmAT MJToeguS4OAQEXCWWLY0BKSGWeABk8TmZTfAaoQFXCQWvGgHG8oioCpx480vsDivgL3Ewo/P WCAWyEvsP3iWGSIuKHFy5hOwODNQvHnrbOYJjHyzkKRmIUktYGRaxSiSWlqcm55bbKRXnJhb XJqXrpecn7uJERgl24793LKDceWrj3qHGJk4GA8xSnAwK4nwzruVnSrEm5JYWZValB9fVJqT WnyI0RTovonMUqLJ+cA4zSuJNzQzMDU0MbM0MLU0M1YS5/Us6EgUEkhPLEnNTk0tSC2C6WPi 4JRqYNrDtfXw7hPHJZIn7LE0/6v3f2e8qkJjYVBAQE9HnU9vkIjTYeHsEguBPwdsZxivFGl/ sWpyjWbq/9nHVdWm37gV6Tw9nm3h5bau02bvGJ6k5UUWHji4fOIDD8ELnTOOPUw66P9I5esa l99rL8k92mW9iSvOxT5ZmE1B3N7GetPBqz8iqgNEu7RsLhrMOPIsze2d3XfxgpDy73K3dsQL PdxZfk3z5DHfEEfNHa/2nclo9NtouFvy1p7bfexNzqy7F+x1i3kgUycYELJvfsk2geaK5Z79 W9I/1Fs8V55jLvzTsNB/29/5uU11LRJvdU6G2xvL+Ok+fdC/h+0FQ/WMTVWHIjkl/j3zFrPp +WR0QomlOCPRUIu5qDgRAHCdY20bAwAA X-CMS-MailID: 20231205130643eucas1p283a5476b78a87997fa393d00f5172418 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20231205130643eucas1p283a5476b78a87997fa393d00f5172418 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231205130643eucas1p283a5476b78a87997fa393d00f5172418 References: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Tue, 05 Dec 2023 05:07:14 -0800 (PST) encoder->funcs entry might be NULL, so check it first before calling its methods. This fixes NULL pointer dereference observed on Rasberry Pi 3b/4b boards. Fixes: caf525ed45b4 ("drm/encoder: register per-encoder debugfs dir") Signed-off-by: Marek Szyprowski --- This fixes the following issue observed on Raspberry Pi 4b: vc4-drm gpu: bound fe400000.hvs (ops vc4_hvs_ops [vc4]) vc4-drm gpu: bound fef00700.hdmi (ops vc4_hdmi_ops [vc4]) vc4-drm gpu: bound fef05700.hdmi (ops vc4_hdmi_ops [vc4]) vc4-drm gpu: bound fe004000.txp (ops vc4_txp_ops [vc4]) vc4-drm gpu: bound fe206000.pixelvalve (ops vc4_crtc_ops [vc4]) vc4-drm gpu: bound fe207000.pixelvalve (ops vc4_crtc_ops [vc4]) vc4-drm gpu: bound fe20a000.pixelvalve (ops vc4_crtc_ops [vc4]) vc4-drm gpu: bound fe216000.pixelvalve (ops vc4_crtc_ops [vc4]) 8<--- cut here --- Unable to handle kernel NULL pointer dereference at virtual address 00000010 when read [00000010] *pgd=00000000 Internal error: Oops: 5 [#1] SMP ARM Modules linked in: sha256_arm raspberrypi_hwmon cfg80211(+) hci_uart btbcm bluetooth vc4(+) ecdh_generic ecc libaes snd_soc_hdmi_codec snd_soc_core v3d drm_shmem_helper ac97_bus snd_pcm_dmaengine snd_pcm genet(+) gpu_sched snd_timer snd bcm2711_thermal soundcore drm_dma_helper CPU: 1 PID: 221 Comm: systemd-udevd Not tainted 6.7.0-rc4-next-20231205 #14267 Hardware name: BCM2711 PC is at drm_debugfs_encoder_add+0x6c/0x98 LR is at 0x0 ... drm_debugfs_encoder_add from drm_encoder_register_all+0x20/0x60 drm_encoder_register_all from drm_modeset_register_all+0x34/0x70 drm_modeset_register_all from drm_dev_register+0x24c/0x28c drm_dev_register from vc4_drm_bind+0x21c/0x2d0 [vc4] vc4_drm_bind [vc4] from try_to_bring_up_aggregate_device+0x160/0x1bc try_to_bring_up_aggregate_device from component_master_add_with_match+0xc4/0xf8 component_master_add_with_match from vc4_platform_drm_probe+0xa0/0xc0 [vc4] vc4_platform_drm_probe [vc4] from platform_probe+0x5c/0xb8 platform_probe from really_probe+0xc8/0x2dc really_probe from __driver_probe_device+0x88/0x19c __driver_probe_device from driver_probe_device+0x30/0x104 driver_probe_device from __driver_attach+0x90/0x174 __driver_attach from bus_for_each_dev+0x6c/0xb4 bus_for_each_dev from bus_add_driver+0xcc/0x1cc bus_add_driver from driver_register+0x7c/0x118 driver_register from vc4_drm_register+0x44/0x1000 [vc4] vc4_drm_register [vc4] from do_one_initcall+0x40/0x1e0 do_one_initcall from do_init_module+0x50/0x1e4 do_init_module from init_module_from_file+0x90/0xbc init_module_from_file from sys_finit_module+0x144/0x258 sys_finit_module from ret_fast_syscall+0x0/0x54 Exception stack(0xf0cf1fa8 to 0xf0cf1ff0) ... ---[ end trace 0000000000000000 ]--- --- drivers/gpu/drm/drm_debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index 02e7481758c0..f4715a67e340 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -638,7 +638,7 @@ void drm_debugfs_encoder_add(struct drm_encoder *encoder) debugfs_create_file("bridges", 0444, root, encoder, &bridges_fops); - if (encoder->funcs->debugfs_init) + if (encoder->funcs && encoder->funcs->debugfs_init) encoder->funcs->debugfs_init(encoder, root); } -- 2.34.1