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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00A5FC433F5 for ; Thu, 28 Oct 2021 05:52:20 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B689B6023B for ; Thu, 28 Oct 2021 05:52:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B689B6023B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=E4N1/QggcVPKKS6MU41FscWsaJm1A4h1OQB4clIxiSY=; b=FAa+TAhHNF7LJg 71ShZRygP38QLR1z0Lumsjhz3LpYfcMR24qftKRmy9nVGItecEhmmLbRwsKK7Zcgrry6tE2LbbUV6 sbNQSCf/whX9KKr8DJl7w+rPW//SBvXzl70qBGYW6IhPRYQxgIij18nwVTuBh0uh7GUckHTzaqjQn K3MnMHt8fUihKMrfYHklqWmJBK12Ll5lvwv7Zau8w2bDGzpAoNmB1Z5ir0FzFSraxNYlk4k0lVmRB o91WbWFPHcESWLhJ3mMgmq0mZ3fcESih0E+h9VlYWgQ7VR6K5EbTn+Uec2sjFsqEnswiJRU2DAHmz Loc7JHrOPdh1aMwbXtBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfyJi-006uot-Bg; Thu, 28 Oct 2021 05:51:10 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfyJd-006unv-99; Thu, 28 Oct 2021 05:51:06 +0000 X-UUID: 47c0cf0942264e92a3e5373641f852c1-20211027 X-UUID: 47c0cf0942264e92a3e5373641f852c1-20211027 Received: from mtkcas68.mediatek.inc [(172.29.94.19)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1699719921; Wed, 27 Oct 2021 22:51:02 -0700 Received: from mtkmbs10n1.mediatek.inc (172.21.101.34) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 27 Oct 2021 22:51:00 -0700 Received: from mtkmbs10n1.mediatek.inc (172.21.101.34) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Thu, 28 Oct 2021 13:50:59 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkmbs10n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Thu, 28 Oct 2021 13:50:58 +0800 From: Yong Wu To: Krzysztof Kozlowski , Matthias Brugger CC: Krzysztof Kozlowski , Joerg Roedel , Will Deacon , Robin Murphy , "Tomasz Figa" , , , , , , , , , , , Ikjoon Jang Subject: [PATCH] memory: mtk-smi: Fix a null dereference for the ostd Date: Thu, 28 Oct 2021 13:50:56 +0800 Message-ID: <20211028055056.26378-1-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211027_225105_349240_0A722AB2 X-CRM114-Status: GOOD ( 15.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org We add the ostd setting for mt8195. It introduces a abort for the previous SoC which doesn't have ostd setting. This is the log: Unable to handle kernel NULL pointer dereference at virtual address 0000000000000080 ... pc : mtk_smi_larb_config_port_gen2_general+0x64/0x130 lr : mtk_smi_larb_resume+0x54/0x98 ... Call trace: mtk_smi_larb_config_port_gen2_general+0x64/0x130 pm_generic_runtime_resume+0x2c/0x48 __genpd_runtime_resume+0x30/0xa8 genpd_runtime_resume+0x94/0x2c8 __rpm_callback+0x44/0x150 rpm_callback+0x6c/0x78 rpm_resume+0x310/0x558 __pm_runtime_resume+0x3c/0x88 In the code: larbostd = larb->larb_gen->ostd[larb->larbid], if "larb->larb_gen->ostd" is null, the "larbostd" is the offset, it is also a valid value, thus, use the larb->larb_gen->ostd as the condition inside the "for" loop. Signed-off-by: Yong Wu --- Hi Krzysztof, Could you help review and conside this as a fix for the mt8195 patchset? The mt8195 patchset are not in mainline, thus, I don't know its sha-id, and don't add Fixes tag. Thanks --- drivers/memory/mtk-smi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c index b883dcc0bbfa..0262a59a2d6e 100644 --- a/drivers/memory/mtk-smi.c +++ b/drivers/memory/mtk-smi.c @@ -257,7 +257,7 @@ static void mtk_smi_larb_config_port_gen2_general(struct device *dev) if (MTK_SMI_CAPS(flags_general, MTK_SMI_FLAG_SW_FLAG)) writel_relaxed(SMI_LARB_SW_FLAG_1, larb->base + SMI_LARB_SW_FLAG); - for (i = 0; i < SMI_LARB_PORT_NR_MAX && larbostd && !!larbostd[i]; i++) + for (i = 0; i < SMI_LARB_PORT_NR_MAX && larb->larb_gen->ostd && !!larbostd[i]; i++) writel_relaxed(larbostd[i], larb->base + SMI_LARB_OSTDL_PORTx(i)); for_each_set_bit(i, (unsigned long *)larb->mmu, 32) { -- 2.18.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel