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 9517447127D; Tue, 21 Jul 2026 18:16:10 +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=1784657771; cv=none; b=GJHExjRwidHCaVAYTScG/mAaOeikpbE9MYQtcfy3cFT7ikmlS+IQzYXO9jDd1zy1w1nnvDxGM6a7LKaSrTR/MHYY9gShtsyzrWGuLi2+07kIy3su+85EG0/NlOatmWx+0Kt7gkxRVCrFWMNJYAKcNUFtjx2s/mhProhVln5N/Ug= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784657771; c=relaxed/simple; bh=JjFalLqobQtDdRxDqMtfwR6NTNT3znOO9Cr3RXfXvms=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qMZzS7Nrfj/w0EA4icusV038i5AY+yY91t3q0bS6m0Vt1VkIkYnTMSkMNfmTnN9LEu1o1Jj+TnpG+fnJKn0m0qGuxp90UQZPvjQkrkot7L9QhnsYZwTE7+jy1OcvmQJcNZeZa5lYH3Qh5qcc0VLUAcQuy/+zJJ28sHxVFiOlxx4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=G6OZpxGZ; 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="G6OZpxGZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 067991F000E9; Tue, 21 Jul 2026 18:16:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784657770; bh=bYdvcAiaGoLRJQOpaDwkRkAZnSfXx7S+AwbwfEuBsT4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=G6OZpxGZ2gFMXMiKC09M8LDZVT9xlcnxbRXWF9Rv3TDKbRjSIsJfxUrHPE33d4eGW U4Doegn7k9OBo/Pz45l7Pwb7OrGnsb64+B9hXIrku+ehHOJppPwg92MTR2juWVcyOQ ftHynnb2fDvBmEvXN+AIZnrElCAkO+2uOiSBEMQE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Stepan Ionichev , Alexandre Belloni , Sasha Levin Subject: [PATCH 6.18 0892/1611] rtc: msc313: fix NULL deref in shared IRQ handler at probe Date: Tue, 21 Jul 2026 17:16:48 +0200 Message-ID: <20260721152535.455594476@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152514.750365251@linuxfoundation.org> References: <20260721152514.750365251@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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stepan Ionichev [ Upstream commit a369f48be8de426a7d2bca18dbd46c2ad1138803 ] msc313_rtc_probe() calls devm_request_irq() with IRQF_SHARED and &pdev->dev as the cookie, but platform_set_drvdata() is only called later after the clock setup. With a shared IRQ line, another device on the same line can trigger the handler in that window. The handler does dev_get_drvdata() on the cookie, gets NULL, and dereferences priv->rtc_base in interrupt context. Pass priv as the cookie directly so the handler reads it from dev_id without the lookup, removing the dependency on probe order. Fixes: be7d9c9161b9 ("rtc: Add support for the MSTAR MSC313 RTC") Signed-off-by: Stepan Ionichev Link: https://patch.msgid.link/20260511032703.48262-1-sozdayvek@gmail.com Signed-off-by: Alexandre Belloni Signed-off-by: Sasha Levin --- drivers/rtc/rtc-msc313.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/rtc-msc313.c b/drivers/rtc/rtc-msc313.c index 8d7737e0e2e02c..6ef9c4efd7c92e 100644 --- a/drivers/rtc/rtc-msc313.c +++ b/drivers/rtc/rtc-msc313.c @@ -160,7 +160,7 @@ static const struct rtc_class_ops msc313_rtc_ops = { static irqreturn_t msc313_rtc_interrupt(s32 irq, void *dev_id) { - struct msc313_rtc *priv = dev_get_drvdata(dev_id); + struct msc313_rtc *priv = dev_id; u16 reg; reg = readw(priv->rtc_base + REG_RTC_STATUS_INT); @@ -206,7 +206,7 @@ static int msc313_rtc_probe(struct platform_device *pdev) priv->rtc_dev->range_max = U32_MAX; ret = devm_request_irq(dev, irq, msc313_rtc_interrupt, IRQF_SHARED, - dev_name(&pdev->dev), &pdev->dev); + dev_name(&pdev->dev), priv); if (ret) { dev_err(dev, "Could not request IRQ\n"); return ret; -- 2.53.0