All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Alessandro Zummo <a.zummo@towertech.it>,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: rtc-linux@googlegroups.com, kernel-janitors@vger.kernel.org
Subject: [patch] rtc: rtc-rv8803: Fix a couple locking bugs
Date: Wed, 04 Nov 2015 13:40:45 +0000	[thread overview]
Message-ID: <20151104134045.GJ20966@mwanda> (raw)

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;
 

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Alessandro Zummo <a.zummo@towertech.it>,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: rtc-linux@googlegroups.com, kernel-janitors@vger.kernel.org
Subject: [rtc-linux] [patch] rtc: rtc-rv8803: Fix a couple locking bugs
Date: Wed, 4 Nov 2015 16:40:45 +0300	[thread overview]
Message-ID: <20151104134045.GJ20966@mwanda> (raw)

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;
 

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

             reply	other threads:[~2015-11-04 13:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-04 13:40 Dan Carpenter [this message]
2015-11-04 13:40 ` [rtc-linux] [patch] rtc: rtc-rv8803: Fix a couple locking bugs Dan Carpenter
2015-11-04 13:59 ` Alexandre Belloni
2015-11-04 13:59   ` [rtc-linux] " Alexandre Belloni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151104134045.GJ20966@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=rtc-linux@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.