Skip to content

Commit 52c73b6

Browse files
root3315gregkh
authored andcommitted
rtc: msc313: fix NULL deref in shared IRQ handler at probe
[ Upstream commit a369f48 ] 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: be7d9c9 ("rtc: Add support for the MSTAR MSC313 RTC") Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com> Link: https://patch.msgid.link/20260511032703.48262-1-sozdayvek@gmail.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 3186a30 commit 52c73b6

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/rtc/rtc-msc313.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ static const struct rtc_class_ops msc313_rtc_ops = {
160160

161161
static irqreturn_t msc313_rtc_interrupt(s32 irq, void *dev_id)
162162
{
163-
struct msc313_rtc *priv = dev_get_drvdata(dev_id);
163+
struct msc313_rtc *priv = dev_id;
164164
u16 reg;
165165

166166
reg = readw(priv->rtc_base + REG_RTC_STATUS_INT);
@@ -206,7 +206,7 @@ static int msc313_rtc_probe(struct platform_device *pdev)
206206
priv->rtc_dev->range_max = U32_MAX;
207207

208208
ret = devm_request_irq(dev, irq, msc313_rtc_interrupt, IRQF_SHARED,
209-
dev_name(&pdev->dev), &pdev->dev);
209+
dev_name(&pdev->dev), priv);
210210
if (ret) {
211211
dev_err(dev, "Could not request IRQ\n");
212212
return ret;

0 commit comments

Comments
 (0)