From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EDEF53563EF for ; Fri, 13 Mar 2026 09:49:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773395342; cv=none; b=J+8RpqvOv+aB3WXdrIHDi9IxqXBhmNSrDxHIR4UpkZbZOyJQvh7dUgKWayQMhj0doWPAGujW0v3NC8ESxhLl9P9v2xlSqYTHJFUrRMEjtWKWW0fECVhtV+eAY4c57vwrZBrO3tah5mHtP2L+zucLFftwxRJL1T4p65DHq6BGgZk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773395342; c=relaxed/simple; bh=oAgFwrScPql2AWiBscKgibXmMr5JSzF2SqWNp5f2qZA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=iAOo8CmnhgKAULmry7RMBkeEDU7WYLy+Rym1j5R13qh0dl1DQfC4fxj566RIT6Qheoc0YbHMImdQZXU2jCzwOvFte1olFmzW/HH8cCh76Pf/d2hsoVsBI7SMTJyjSk1GR3BozUDlYCXWS9B5u0FTW67tSNIypoA3X/fm3PwQgVA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kTw1ztA3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kTw1ztA3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3000C2BC86; Fri, 13 Mar 2026 09:48:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773395341; bh=oAgFwrScPql2AWiBscKgibXmMr5JSzF2SqWNp5f2qZA=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=kTw1ztA3KdCSP6Mv215qu8SBoPDb5oJ/cwv4S7mrqECq33qLuVHX/kyqNV3+oUyjF nG+oU4DcMcQt+fXw6U7b1T0x6YE0K2N8AYSLzHhpMQzmRL0cQ7paognxx6gFHGHLtE pmWm4TygnnqMZwLMLUVhNBuhGp4m/5On8thpLrkKqLHe6xQh3UcFgLF/vOFnUoR8kO 27KkcAsLYKGaRAA9dvTNKpYfOIbTNJHmiXU3tKiy6GxVI/sy2JcpxFPElSJOl4HdnL xAH63oGiBMy+hHpuZF5TZtYENpYXxJgnGPVkigzqijfmLIhLSrOakYngzhFkQa6Xlt VPhmZddj+fQaQ== Message-ID: <7e0425c2-debe-448a-a5f9-26039de71db5@kernel.org> Date: Fri, 13 Mar 2026 10:48:54 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] soc: fsl: qe: Fix potential NULL pointer dereference in qe_reset() To: Wang Jun <1742789905@qq.com>, Qiang Zhao , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, gszhai@bjtu.edu.cn, 25125332@bjtu.edu.cn, 25125283@bjtu.edu.cn, 23120469@bjtu.edu.cn References: Content-Language: fr-FR From: "Christophe Leroy (CS GROUP)" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Le 10/03/2026 à 13:11, Wang Jun a écrit : > [Vous ne recevez pas souvent de courriers de 1742789905@qq.com. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ] > > The function qe_reset() uses qe_immr without checking if it is NULL, > which could happen if ioremap() failed earlier. Add a NULL check and > perform ioremap() if needed; if it still fails, print an error and > return to avoid crashing the system. I don't understand what you are trying to say here. What you say is already what qe_reset() does: it does a NULL check and performs ioremap() when it is NULL: if (qe_immr == NULL) qe_immr = ioremap(get_qe_base(), QE_IMMAP_SIZE); You are adding a second NULL check and return early from qe_reset(). But it doesn't really fix the problem because qe_immr is used in many other places so you are just delaying the problem. What needs to be done is that if qe_immr remap fails, all drivers depending on it don't get probed. > > Signed-off-by: Wang Jun <1742789905@qq.com> > --- > drivers/soc/fsl/qe/qe.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/soc/fsl/qe/qe.c b/drivers/soc/fsl/qe/qe.c > index 70b6eddb867b..6dcfa340970a 100644 > --- a/drivers/soc/fsl/qe/qe.c > +++ b/drivers/soc/fsl/qe/qe.c > @@ -86,8 +86,13 @@ static phys_addr_t get_qe_base(void) > > void qe_reset(void) > { > - if (qe_immr == NULL) > + if (qe_immr == NULL) { > qe_immr = ioremap(get_qe_base(), QE_IMMAP_SIZE); > + if (qe_immr == NULL) { > + pr_err("QE: cannot remap IMMR\n"); > + return; > + } > + } > > qe_snums_init(); > > -- > 2.43.0 >