Skip to content

Commit

Permalink
rtc: bq4802: add error handling for devm_ioremap
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Zhouyang Jia authored and Alexandre Belloni committed Jul 11, 2018
1 parent a41efe0 commit 7874b91
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/rtc/rtc-bq4802.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ static int bq4802_probe(struct platform_device *pdev)
} else if (p->r->flags & IORESOURCE_MEM) {
p->regs = devm_ioremap(&pdev->dev, p->r->start,
resource_size(p->r));
if (!p->regs){
err = -ENOMEM;
goto out;
}
p->read = bq4802_read_mem;
p->write = bq4802_write_mem;
} else {
Expand Down

0 comments on commit 7874b91

Please sign in to comment.