From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 AF9CE3E8C65; Wed, 30 Sep 2026 18:45:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790793957; cv=none; b=cTUNj9OqjSeHw1slhcZKeeNnErYXr6I79HpR0ybzdI0BGRZ0dh3y6Ljp1D3wqYcvhmsHjWkCY9Q5+q1t1BH98oAj2JM8xJzBJAEEeRzgHXjAyxFNYfElRfiCglCUN1uzUCJGuHRXFNjbCG8SJMcvWTNOhf0PJBo/3jeT6OZAXFU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790793957; c=relaxed/simple; bh=ahAXqnFy0UhYy1r273pXLTzEF+OvRDnRSY6mK2PYTBI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WUjvl3kFQHeRZPPskCDPrLE07uCPAm7ZXnbiU+GoO96dwour1d5a6qprhmzWuLotnxfY1zYLIui25UfvOPKZ81FB0tJabbpJQdyxeM99U0jkfdL/dOdrqwbwGEnsOt/KMQeJrRJJk4JsQNvL6J1/ZTSHeP7DkJYoLpIE2BJZ5As= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kKY5R0Ec; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="kKY5R0Ec" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D60AD1F000FF; Wed, 30 Sep 2026 18:45:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790793955; bh=TxP9lXMjt6JoTNKHihH+GGn9HLmhYgs1J84G0Rnh0uA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kKY5R0EcUhGWbT6c6VJ8ZePG/iohwBa5KIggqbZaDdE3811xbbJISnDpHWLUMsNY0 ErO7uLtAohVSJImKHrwFLjZRcybNVp1nQcu9g+gtXmg6iveTCJkkp6wLPYU40lv0Jd lPnS0opEgQwvC5cTiEVJb/UKwRitP4HhFk0f8P0s= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Stepan Ionichev , Bartosz Golaszewski , Ulf Hansson , Sasha Levin Subject: [PATCH 6.6 0040/1193] mmc: davinci: avoid NULL deref of host->data in IRQ handler Date: Wed, 30 Sep 2026 17:12:04 +0200 Message-ID: <20260930152435.175450185@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152434.301151190@linuxfoundation.org> References: <20260930152434.301151190@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stepan Ionichev [ Upstream commit 4f28846aaf8db9668e338b8987973f8935edff34 ] mmc_davinci_irq() returns early only when both host->cmd and host->data are NULL: if (host->cmd == NULL && host->data == NULL) { ... return IRQ_NONE; } So we may legitimately reach the rest of the handler with host->data == NULL (and therefore data == NULL). The DATDNE branch already guards against this with an explicit "if (data != NULL)" check, but the subsequent TOUTRD ("read data timeout") and CRCWR/CRCRD ("data CRC error") branches dereference data unconditionally: if (qstatus & MMCST0_TOUTRD) { data->error = -ETIMEDOUT; <-- NULL deref ... davinci_abort_data(host, data); } if (qstatus & (MMCST0_CRCWR | MMCST0_CRCRD)) { data->error = -EILSEQ; <-- NULL deref ... } If either bit is set in qstatus while host->data is NULL, the kernel will crash inside the IRQ handler. smatch flags this: drivers/mmc/host/davinci_mmc.c:933 mmc_davinci_irq() error: we previously assumed 'data' could be null (see line 914) Gate both branches on a non-NULL data, matching the existing pattern used by the DATDNE branch. No functional change for callers where data is non-NULL, which is the only case in which these branches did meaningful work before this change. Signed-off-by: Stepan Ionichev Reviewed-by: Bartosz Golaszewski Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin --- drivers/mmc/host/davinci_mmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c index 8fa6796787f4b..f0b4c904ad6c1 100644 --- a/drivers/mmc/host/davinci_mmc.c +++ b/drivers/mmc/host/davinci_mmc.c @@ -933,7 +933,7 @@ static irqreturn_t mmc_davinci_irq(int irq, void *dev_id) } } - if (qstatus & MMCST0_TOUTRD) { + if (data && (qstatus & MMCST0_TOUTRD)) { /* Read data timeout */ data->error = -ETIMEDOUT; end_transfer = 1; @@ -945,7 +945,7 @@ static irqreturn_t mmc_davinci_irq(int irq, void *dev_id) davinci_abort_data(host, data); } - if (qstatus & (MMCST0_CRCWR | MMCST0_CRCRD)) { + if (data && (qstatus & (MMCST0_CRCWR | MMCST0_CRCRD))) { /* Data CRC error */ data->error = -EILSEQ; end_transfer = 1; -- 2.53.0