* [PATCH] rtc: mxc_v2: unlock on error in mxc_rtc_set_alarm()
@ 2018-03-14 7:37 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2018-03-14 7:37 UTC (permalink / raw)
To: Alessandro Zummo, Patrick Bruenn
Cc: Alexandre Belloni, linux-rtc, kernel-janitors
We need to unlock if time is more than U32_MAX.
Fixes: 83c880f79e88 ("rtc: add mxc driver for i.MX53 SRTC")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/rtc/rtc-mxc_v2.c b/drivers/rtc/rtc-mxc_v2.c
index 9e14efb990b2..90c9ab68688f 100644
--- a/drivers/rtc/rtc-mxc_v2.c
+++ b/drivers/rtc/rtc-mxc_v2.c
@@ -243,12 +243,14 @@ static int mxc_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
const time64_t time = rtc_tm_to_time64(&alrm->time);
struct mxc_rtc_data *pdata = dev_get_drvdata(dev);
- int ret = mxc_rtc_lock(pdata);
+ int ret;
+ ret = mxc_rtc_lock(pdata);
if (ret)
return ret;
if (time > U32_MAX) {
+ mxc_rtc_unlock(pdata);
dev_err(dev, "Hopefully I am out of service by then :-(\n");
return -EINVAL;
}
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] rtc: mxc_v2: unlock on error in mxc_rtc_set_alarm()
@ 2018-03-14 7:37 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2018-03-14 7:37 UTC (permalink / raw)
To: Alessandro Zummo, Patrick Bruenn
Cc: Alexandre Belloni, linux-rtc, kernel-janitors
We need to unlock if time is more than U32_MAX.
Fixes: 83c880f79e88 ("rtc: add mxc driver for i.MX53 SRTC")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/rtc/rtc-mxc_v2.c b/drivers/rtc/rtc-mxc_v2.c
index 9e14efb990b2..90c9ab68688f 100644
--- a/drivers/rtc/rtc-mxc_v2.c
+++ b/drivers/rtc/rtc-mxc_v2.c
@@ -243,12 +243,14 @@ static int mxc_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
const time64_t time = rtc_tm_to_time64(&alrm->time);
struct mxc_rtc_data *pdata = dev_get_drvdata(dev);
- int ret = mxc_rtc_lock(pdata);
+ int ret;
+ ret = mxc_rtc_lock(pdata);
if (ret)
return ret;
if (time > U32_MAX) {
+ mxc_rtc_unlock(pdata);
dev_err(dev, "Hopefully I am out of service by then :-(\n");
return -EINVAL;
}
^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: [PATCH] rtc: mxc_v2: unlock on error in mxc_rtc_set_alarm()
2018-03-14 7:37 ` Dan Carpenter
@ 2018-03-15 11:12 ` Patrick Brünn
-1 siblings, 0 replies; 6+ messages in thread
From: Patrick Brünn @ 2018-03-15 11:12 UTC (permalink / raw)
To: Dan Carpenter, Alessandro Zummo
Cc: Alexandre Belloni, linux-rtc, kernel-janitors
>From: Dan Carpenter [mailto:dan.carpenter@oracle.com]
>Sent: Mittwoch, 14. März 2018 08:37
>
>We need to unlock if time is more than U32_MAX.
>
you are right, that's a bug.
But I would move the mxc_rtc_lock() entirely behind the (time > U32_MAX) check. IMHO that would make the code even cleaner. sorry for broken patch:
> const time64_t time = rtc_tm_to_time64(&alrm->time);
> struct mxc_rtc_data *pdata = dev_get_drvdata(dev);
>- int ret = mxc_rtc_lock(pdata);
>+ int ret;
>-
>- if (ret)
>- return ret;
>
> if (time > U32_MAX) {
> dev_err(dev, "Hopefully I am out of service by then :-(\n");
> return -EINVAL;
> }
>+
>+ ret = mxc_rtc_lock(pdata);
>+ if (ret)
>+ return ret;
---
Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans Beckhoff
Registered office: Verl, Germany | Register court: Guetersloh HRA 7075
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH] rtc: mxc_v2: unlock on error in mxc_rtc_set_alarm()
@ 2018-03-15 11:12 ` Patrick Brünn
0 siblings, 0 replies; 6+ messages in thread
From: Patrick Brünn @ 2018-03-15 11:12 UTC (permalink / raw)
To: Dan Carpenter, Alessandro Zummo
Cc: Alexandre Belloni, linux-rtc, kernel-janitors
>From: Dan Carpenter [mailto:dan.carpenter@oracle.com]
>Sent: Mittwoch, 14. März 2018 08:37
>
>We need to unlock if time is more than U32_MAX.
>
you are right, that's a bug.
But I would move the mxc_rtc_lock() entirely behind the (time > U32_MAX) check. IMHO that would make the code even cleaner. sorry for broken patch:
> const time64_t time = rtc_tm_to_time64(&alrm->time);
> struct mxc_rtc_data *pdata = dev_get_drvdata(dev);
>- int ret = mxc_rtc_lock(pdata);
>+ int ret;
>-
>- if (ret)
>- return ret;
>
> if (time > U32_MAX) {
> dev_err(dev, "Hopefully I am out of service by then :-(\n");
> return -EINVAL;
> }
>+
>+ ret = mxc_rtc_lock(pdata);
>+ if (ret)
>+ return ret;
---
Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans Beckhoff
Registered office: Verl, Germany | Register court: Guetersloh HRA 7075
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] rtc: mxc_v2: unlock on error in mxc_rtc_set_alarm()
2018-03-15 11:12 ` Patrick Brünn
@ 2018-03-15 11:26 ` Dan Carpenter
-1 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2018-03-15 11:26 UTC (permalink / raw)
To: Patrick Brünn
Cc: Alessandro Zummo, Alexandre Belloni, linux-rtc, kernel-janitors
On Thu, Mar 15, 2018 at 11:12:04AM +0000, Patrick Brünn wrote:
> >From: Dan Carpenter [mailto:dan.carpenter@oracle.com]
> >Sent: Mittwoch, 14. März 2018 08:37
> >
> >We need to unlock if time is more than U32_MAX.
> >
> you are right, that's a bug.
> But I would move the mxc_rtc_lock() entirely behind the (time > U32_MAX) check.
Yes, of course. I will resend.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] rtc: mxc_v2: unlock on error in mxc_rtc_set_alarm()
@ 2018-03-15 11:26 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2018-03-15 11:26 UTC (permalink / raw)
To: Patrick Brünn
Cc: Alessandro Zummo, Alexandre Belloni, linux-rtc, kernel-janitors
On Thu, Mar 15, 2018 at 11:12:04AM +0000, Patrick Brünn wrote:
> >From: Dan Carpenter [mailto:dan.carpenter@oracle.com]
> >Sent: Mittwoch, 14. März 2018 08:37
> >
> >We need to unlock if time is more than U32_MAX.
> >
> you are right, that's a bug.
> But I would move the mxc_rtc_lock() entirely behind the (time > U32_MAX) check.
Yes, of course. I will resend.
regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-03-15 11:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-14 7:37 [PATCH] rtc: mxc_v2: unlock on error in mxc_rtc_set_alarm() Dan Carpenter
2018-03-14 7:37 ` Dan Carpenter
2018-03-15 11:12 ` Patrick Brünn
2018-03-15 11:12 ` Patrick Brünn
2018-03-15 11:26 ` Dan Carpenter
2018-03-15 11:26 ` Dan Carpenter
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.