linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtc: rtc-bq4802: add error handling for devm_ioremap
@ 2018-06-12  4:40 Zhouyang Jia
  2018-06-20 10:46 ` Alexandre Belloni
  0 siblings, 1 reply; 2+ messages in thread
From: Zhouyang Jia @ 2018-06-12  4:40 UTC (permalink / raw)
  Cc: Zhouyang Jia, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	linux-kernel

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>
---
 drivers/rtc/rtc-bq4802.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/rtc/rtc-bq4802.c b/drivers/rtc/rtc-bq4802.c
index bd170cb..5747a54 100644
--- a/drivers/rtc/rtc-bq4802.c
+++ b/drivers/rtc/rtc-bq4802.c
@@ -164,6 +164,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 {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] rtc: rtc-bq4802: add error handling for devm_ioremap
  2018-06-12  4:40 [PATCH] rtc: rtc-bq4802: add error handling for devm_ioremap Zhouyang Jia
@ 2018-06-20 10:46 ` Alexandre Belloni
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2018-06-20 10:46 UTC (permalink / raw)
  To: Zhouyang Jia; +Cc: Alessandro Zummo, linux-rtc, linux-kernel

On 12/06/2018 12:40:03+0800, Zhouyang Jia wrote:
> 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>
> ---
>  drivers/rtc/rtc-bq4802.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
Applied, thanks.

-- 
Alexandre Belloni, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-20 10:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-12  4:40 [PATCH] rtc: rtc-bq4802: add error handling for devm_ioremap Zhouyang Jia
2018-06-20 10:46 ` Alexandre Belloni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).