Skip to content

Commit

Permalink
Merge tag 'rtc-4.20-2' of git://git.kernel.org/pub/scm/linux/kernel/g…
Browse files Browse the repository at this point in the history
…it/abelloni/linux

Pull RTC driver fixes from Alexandre Belloni:

 - cmos: stop exporting alarms when not supported

 - hctosys: correctly report range error

 - pcf2127: fix a memory leak

* tag 'rtc-4.20-2' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux:
  rtc: pcf2127: fix a kmemleak caused in pcf2127_i2c_gather_write
  rtc: hctosys: Add missing range error reporting
  rtc: cmos: Do not export alarm rtc_ops when we do not support alarms
  • Loading branch information
Linus Torvalds committed Nov 14, 2018
2 parents 47e624c + 9bde0af commit b7bbf99
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
4 changes: 3 additions & 1 deletion drivers/rtc/hctosys.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ static int __init rtc_hctosys(void)
tv64.tv_sec = rtc_tm_to_time64(&tm);

#if BITS_PER_LONG == 32
if (tv64.tv_sec > INT_MAX)
if (tv64.tv_sec > INT_MAX) {
err = -ERANGE;
goto err_read;
}
#endif

err = do_settimeofday64(&tv64);
Expand Down
16 changes: 12 additions & 4 deletions drivers/rtc/rtc-cmos.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ static int cmos_read_alarm(struct device *dev, struct rtc_wkalrm *t)
struct cmos_rtc *cmos = dev_get_drvdata(dev);
unsigned char rtc_control;

/* This not only a rtc_op, but also called directly */
if (!is_valid_irq(cmos->irq))
return -EIO;

Expand Down Expand Up @@ -452,6 +453,7 @@ static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t)
unsigned char mon, mday, hrs, min, sec, rtc_control;
int ret;

/* This not only a rtc_op, but also called directly */
if (!is_valid_irq(cmos->irq))
return -EIO;

Expand Down Expand Up @@ -516,9 +518,6 @@ static int cmos_alarm_irq_enable(struct device *dev, unsigned int enabled)
struct cmos_rtc *cmos = dev_get_drvdata(dev);
unsigned long flags;

if (!is_valid_irq(cmos->irq))
return -EINVAL;

spin_lock_irqsave(&rtc_lock, flags);

if (enabled)
Expand Down Expand Up @@ -579,6 +578,12 @@ static const struct rtc_class_ops cmos_rtc_ops = {
.alarm_irq_enable = cmos_alarm_irq_enable,
};

static const struct rtc_class_ops cmos_rtc_ops_no_alarm = {
.read_time = cmos_read_time,
.set_time = cmos_set_time,
.proc = cmos_procfs,
};

/*----------------------------------------------------------------*/

/*
Expand Down Expand Up @@ -855,9 +860,12 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq);
goto cleanup1;
}

cmos_rtc.rtc->ops = &cmos_rtc_ops;
} else {
cmos_rtc.rtc->ops = &cmos_rtc_ops_no_alarm;
}

cmos_rtc.rtc->ops = &cmos_rtc_ops;
cmos_rtc.rtc->nvram_old_abi = true;
retval = rtc_register_device(cmos_rtc.rtc);
if (retval)
Expand Down
3 changes: 3 additions & 0 deletions drivers/rtc/rtc-pcf2127.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ static int pcf2127_i2c_gather_write(void *context,
memcpy(buf + 1, val, val_size);

ret = i2c_master_send(client, buf, val_size + 1);

kfree(buf);

if (ret != val_size + 1)
return ret < 0 ? ret : -EIO;

Expand Down

0 comments on commit b7bbf99

Please sign in to comment.