Skip to content

Commit 8be9576

Browse files
ZhouyangJiagregkh
authored andcommitted
rtc: bq4802: add error handling for devm_ioremap
[ Upstream commit 7874b91 ] When devm_ioremap fails, the lack of error-handling code may cause unexpected results. This patch adds error-handling code after calling devm_ioremap. Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bb2874b commit 8be9576

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

drivers/rtc/rtc-bq4802.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ static int bq4802_probe(struct platform_device *pdev)
164164
} else if (p->r->flags & IORESOURCE_MEM) {
165165
p->regs = devm_ioremap(&pdev->dev, p->r->start,
166166
resource_size(p->r));
167+
if (!p->regs){
168+
err = -ENOMEM;
169+
goto out;
170+
}
167171
p->read = bq4802_read_mem;
168172
p->write = bq4802_write_mem;
169173
} else {

0 commit comments

Comments
 (0)