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 954E411C8F for ; Mon, 8 May 2023 10:58:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFA22C433D2; Mon, 8 May 2023 10:58:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1683543535; bh=O9OEPqL8n1K9QQlTf6lbACmDaUQTy6seLjxY/nnSzN8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H7ci+USGTCyoS95LlAIm8T6IHQkSJagBZqMTqYTKUbSt1EclDr9gKOlVj7cfZksOu zbwO+GXldTb7MLH1h4ZYjfIsXEn/Y3M2Gv72DDEaqml6uRiQjINH0JgcoMkasSL4E1 EH+AgXjLvq4ZsmyZu6JVpXkhQzyi7fFqhjIAxIBk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tanmay Shah , Michal Simek , Mathieu Poirier Subject: [PATCH 6.3 122/694] mailbox: zynqmp: Fix counts of child nodes Date: Mon, 8 May 2023 11:39:17 +0200 Message-Id: <20230508094436.426379378@linuxfoundation.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230508094432.603705160@linuxfoundation.org> References: <20230508094432.603705160@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Tanmay Shah commit f72f805e72882c361e2a612c64a6e549f3da7152 upstream. If child mailbox node status is disabled it causes crash in interrupt handler. Fix this by assigning only available child node during driver probe. Fixes: 4981b82ba2ff ("mailbox: ZynqMP IPI mailbox controller") Signed-off-by: Tanmay Shah Acked-by: Michal Simek Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20230311012407.1292118-2-tanmay.shah@amd.com Signed-off-by: Mathieu Poirier Signed-off-by: Greg Kroah-Hartman --- drivers/mailbox/zynqmp-ipi-mailbox.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/drivers/mailbox/zynqmp-ipi-mailbox.c +++ b/drivers/mailbox/zynqmp-ipi-mailbox.c @@ -634,7 +634,12 @@ static int zynqmp_ipi_probe(struct platf struct zynqmp_ipi_mbox *mbox; int num_mboxes, ret = -EINVAL; - num_mboxes = of_get_child_count(np); + num_mboxes = of_get_available_child_count(np); + if (num_mboxes == 0) { + dev_err(dev, "mailbox nodes not available\n"); + return -EINVAL; + } + pdata = devm_kzalloc(dev, struct_size(pdata, ipi_mboxes, num_mboxes), GFP_KERNEL); if (!pdata)