From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C1486C433EF for ; Thu, 5 May 2022 14:57:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 5788C83EC0; Thu, 5 May 2022 14:57:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5dU3XtxJSLkX; Thu, 5 May 2022 14:57:25 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 4CB5C83EEF; Thu, 5 May 2022 14:57:25 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1CDC2C0039; Thu, 5 May 2022 14:57:25 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 72967C002D for ; Thu, 5 May 2022 14:57:23 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 608E4607BC for ; Thu, 5 May 2022 14:57:23 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp3.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=collabora.com Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hKa1oshQ51P3 for ; Thu, 5 May 2022 14:57:22 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by smtp3.osuosl.org (Postfix) with ESMTPS id 02D8C606C0 for ; Thu, 5 May 2022 14:57:21 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id 5F7D01F4589E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1651762640; bh=852xH/KcBe3CUteZgRNyrG66GO4E9q7U2O3+DhPjsUM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=YWDw1Y2G4i8MWiG6/sJvV4mWgfsBcV7yg6XtgOeF95Bx6aCIwxDNJvqrRuIOoC1qt 58q5In4zFxu4BDJWGH6/v8asx74ifrFLhfhQUBIUNXaec25iuW6Xzb3e8s1EE3eBVA GyddmwMKa0DTzCgWBGAXNK03eA2ORbVbKr3gKq36g0yZ8hAcCJu1+joONFTHWKt48n pxLDyUGTZDeezP/3QA1nZ9nBbwhhXpbb0vWmF6PFXTevYGBAF50J3poKbXvnqHAS9X TnkUn6m9u/UeYgHMaefak1qkV+6/0D8CK3yR2zIpqBChIFeCx6N+2X1S+VEhfww07W IdwJAegQHk9Dg== Message-ID: Date: Thu, 5 May 2022 16:57:17 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v3] iommu/mediatek: Fix NULL pointer dereference when printing dev_name Content-Language: en-US To: Miles Chen , Yong Wu , Joerg Roedel , Will Deacon , Matthias Brugger , Mauro Carvalho Chehab , Hans Verkuil References: <20220505132731.21628-1-miles.chen@mediatek.com> From: AngeloGioacchino Del Regno In-Reply-To: <20220505132731.21628-1-miles.chen@mediatek.com> Cc: Joerg Roedel , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, linux-mediatek@lists.infradead.org, Robin Murphy , linux-arm-kernel@lists.infradead.org X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" Il 05/05/22 15:27, Miles Chen ha scritto: > When larbdev is NULL (in the case I hit, the node is incorrectly set > iommus = <&iommu NUM>), it will cause device_link_add() fail and > kernel crashes when we try to print dev_name(larbdev). > > Let's fail the probe if a larbdev is NULL to avoid invalid inputs from > dts. > > It should work for normal correct setting and avoid the crash caused > by my incorrect setting. > > Error log: > [ 18.189042][ T301] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000050 > ... > [ 18.344519][ T301] pstate: a0400005 (NzCv daif +PAN -UAO) > [ 18.345213][ T301] pc : mtk_iommu_probe_device+0xf8/0x118 [mtk_iommu] > [ 18.346050][ T301] lr : mtk_iommu_probe_device+0xd0/0x118 [mtk_iommu] > [ 18.346884][ T301] sp : ffffffc00a5635e0 > [ 18.347392][ T301] x29: ffffffc00a5635e0 x28: ffffffd44a46c1d8 > [ 18.348156][ T301] x27: ffffff80c39a8000 x26: ffffffd44a80cc38 > [ 18.348917][ T301] x25: 0000000000000000 x24: ffffffd44a80cc38 > [ 18.349677][ T301] x23: ffffffd44e4da4c6 x22: ffffffd44a80cc38 > [ 18.350438][ T301] x21: ffffff80cecd1880 x20: 0000000000000000 > [ 18.351198][ T301] x19: ffffff80c439f010 x18: ffffffc00a50d0c0 > [ 18.351959][ T301] x17: ffffffffffffffff x16: 0000000000000004 > [ 18.352719][ T301] x15: 0000000000000004 x14: ffffffd44eb5d420 > [ 18.353480][ T301] x13: 0000000000000ad2 x12: 0000000000000003 > [ 18.354241][ T301] x11: 00000000fffffad2 x10: c0000000fffffad2 > [ 18.355003][ T301] x9 : a0d288d8d7142d00 x8 : a0d288d8d7142d00 > [ 18.355763][ T301] x7 : ffffffd44c2bc640 x6 : 0000000000000000 > [ 18.356524][ T301] x5 : 0000000000000080 x4 : 0000000000000001 > [ 18.357284][ T301] x3 : 0000000000000000 x2 : 0000000000000005 > [ 18.358045][ T301] x1 : 0000000000000000 x0 : 0000000000000000 > [ 18.360208][ T301] Hardware name: MT6873 (DT) > [ 18.360771][ T301] Call trace: > [ 18.361168][ T301] dump_backtrace+0xf8/0x1f0 > [ 18.361737][ T301] dump_stack_lvl+0xa8/0x11c > [ 18.362305][ T301] dump_stack+0x1c/0x2c > [ 18.362816][ T301] mrdump_common_die+0x184/0x40c [mrdump] > [ 18.363575][ T301] ipanic_die+0x24/0x38 [mrdump] > [ 18.364230][ T301] atomic_notifier_call_chain+0x128/0x2b8 > [ 18.364937][ T301] die+0x16c/0x568 > [ 18.365394][ T301] __do_kernel_fault+0x1e8/0x214 > [ 18.365402][ T301] do_page_fault+0xb8/0x678 > [ 18.366934][ T301] do_translation_fault+0x48/0x64 > [ 18.368645][ T301] do_mem_abort+0x68/0x148 > [ 18.368652][ T301] el1_abort+0x40/0x64 > [ 18.368660][ T301] el1h_64_sync_handler+0x54/0x88 > [ 18.368668][ T301] el1h_64_sync+0x68/0x6c > [ 18.368673][ T301] mtk_iommu_probe_device+0xf8/0x118 [mtk_iommu] > ... > > Cc: Robin Murphy > Cc: Yong Wu > Reported-by: kernel test robot > Fixes: 635319a4a744 ("media: iommu/mediatek: Add device_link between the consumer and the larb devices") > Signed-off-by: Miles Chen Reviewed-by: AngeloGioacchino Del Regno _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu