summaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-bq4802.c
diff options
context:
space:
mode:
authorZhouyang Jia <jiazhouyang09@gmail.com>2018-06-12 06:40:03 +0200
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2018-07-11 20:41:01 +0200
commit7874b919866ba91bac253fa219d3d4c82bb944df (patch)
tree0772e33b396510ae0d2a64b5e14c460bf071573b /drivers/rtc/rtc-bq4802.c
parentrtc: ds1685: remove sysfs access to control registers (diff)
downloadlinux-7874b919866ba91bac253fa219d3d4c82bb944df.tar.xz
linux-7874b919866ba91bac253fa219d3d4c82bb944df.zip
rtc: bq4802: add error handling for devm_ioremap
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>
Diffstat (limited to 'drivers/rtc/rtc-bq4802.c')
-rw-r--r--drivers/rtc/rtc-bq4802.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-bq4802.c b/drivers/rtc/rtc-bq4802.c
index d768f6747961..113493b52149 100644
--- a/drivers/rtc/rtc-bq4802.c
+++ b/drivers/rtc/rtc-bq4802.c
@@ -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 {