kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] rtc: rtc-rv8803: Fix a couple locking bugs
@ 2015-11-04 13:40 Dan Carpenter
  2015-11-04 13:59 ` Alexandre Belloni
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2015-11-04 13:40 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: rtc-linux, kernel-janitors

There was one missing unlock on error in rv8803_set_alarm() and one
unlock in rv8803_ioctl() which was missing altogether.

Fixes: 2f370c4a1a44 ('rtc: Add a driver for Micro Crystal RV8803')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Presumably the IOCTL issue was a last minute change after the driver had
been tested...

diff --git a/drivers/rtc/rtc-rv8803.c b/drivers/rtc/rtc-rv8803.c
index 63244eb..9508de4 100644
--- a/drivers/rtc/rtc-rv8803.c
+++ b/drivers/rtc/rtc-rv8803.c
@@ -240,8 +240,10 @@ static int rv8803_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 	spin_lock_irqsave(&rv8803->flags_lock, irqflags);
 
 	ret = i2c_smbus_read_i2c_block_data(client, RV8803_FLAG, 2, ctrl);
-	if (ret != 2)
+	if (ret != 2) {
+		spin_unlock_irqrestore(&rv8803->flags_lock, irqflags);
 		return ret < 0 ? ret : -EIO;
+	}
 
 	alarmvals[0] = bin2bcd(alrm->time.tm_min);
 	alarmvals[1] = bin2bcd(alrm->time.tm_hour);
@@ -338,6 +340,7 @@ static int rv8803_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
 	case RTC_VL_READ:
 		spin_lock_irqsave(&rv8803->flags_lock, irqflags);
 		flags = i2c_smbus_read_byte_data(client, RV8803_FLAG);
+		spin_unlock_irqrestore(&rv8803->flags_lock, irqflags);
 		if (flags < 0)
 			return flags;
 

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

* Re: [patch] rtc: rtc-rv8803: Fix a couple locking bugs
  2015-11-04 13:40 [patch] rtc: rtc-rv8803: Fix a couple locking bugs Dan Carpenter
@ 2015-11-04 13:59 ` Alexandre Belloni
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2015-11-04 13:59 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Alessandro Zummo, rtc-linux, kernel-janitors

Hi,

On 04/11/2015 at 16:40:45 +0300, Dan Carpenter wrote :
> There was one missing unlock on error in rv8803_set_alarm() and one
> unlock in rv8803_ioctl() which was missing altogether.
> 
> Fixes: 2f370c4a1a44 ('rtc: Add a driver for Micro Crystal RV8803')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Presumably the IOCTL issue was a last minute change after the driver had
> been tested...
> 

Yeah, I already fixed the first one and the lock in rv8803_ioctl is
actually unnecessary.

Thanks for the info.

> diff --git a/drivers/rtc/rtc-rv8803.c b/drivers/rtc/rtc-rv8803.c
> index 63244eb..9508de4 100644
> --- a/drivers/rtc/rtc-rv8803.c
> +++ b/drivers/rtc/rtc-rv8803.c
> @@ -240,8 +240,10 @@ static int rv8803_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
>  	spin_lock_irqsave(&rv8803->flags_lock, irqflags);
>  
>  	ret = i2c_smbus_read_i2c_block_data(client, RV8803_FLAG, 2, ctrl);
> -	if (ret != 2)
> +	if (ret != 2) {
> +		spin_unlock_irqrestore(&rv8803->flags_lock, irqflags);
>  		return ret < 0 ? ret : -EIO;
> +	}
>  
>  	alarmvals[0] = bin2bcd(alrm->time.tm_min);
>  	alarmvals[1] = bin2bcd(alrm->time.tm_hour);
> @@ -338,6 +340,7 @@ static int rv8803_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
>  	case RTC_VL_READ:
>  		spin_lock_irqsave(&rv8803->flags_lock, irqflags);
>  		flags = i2c_smbus_read_byte_data(client, RV8803_FLAG);
> +		spin_unlock_irqrestore(&rv8803->flags_lock, irqflags);
>  		if (flags < 0)
>  			return flags;
>  

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

end of thread, other threads:[~2015-11-04 13:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-04 13:40 [patch] rtc: rtc-rv8803: Fix a couple locking bugs Dan Carpenter
2015-11-04 13:59 ` 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).