<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/drivers/rtc/class.c, branch v6.1.152</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v6.1.152</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v6.1.152'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2025-06-27T10:07:05Z</updated>
<entry>
<title>rtc: Fix offset calculation for .start_secs &lt; 0</title>
<updated>2025-06-27T10:07:05Z</updated>
<author>
<name>Alexandre Mergnat</name>
<email>amergnat@baylibre.com</email>
</author>
<published>2025-04-28T10:06:48Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=a81e605aa285df7755a4bd11eab863e54aac7011'/>
<id>urn:sha1:a81e605aa285df7755a4bd11eab863e54aac7011</id>
<content type='text'>
commit fe9f5f96cfe8b82d0f24cbfa93718925560f4f8d upstream.

The comparison

        rtc-&gt;start_secs &gt; rtc-&gt;range_max

has a signed left-hand side and an unsigned right-hand side.
So the comparison might become true for negative start_secs which is
interpreted as a (possibly very large) positive value.

As a negative value can never be bigger than an unsigned value
the correct representation of the (mathematical) comparison

        rtc-&gt;start_secs &gt; rtc-&gt;range_max

in C is:

        rtc-&gt;start_secs &gt;= 0 &amp;&amp; rtc-&gt;start_secs &gt; rtc-&gt;range_max

Use that to fix the offset calculation currently used in the
rtc-mt6397 driver.

Fixes: 989515647e783 ("rtc: Add one offset seconds to expand RTC range")
Signed-off-by: Alexandre Mergnat &lt;amergnat@baylibre.com&gt;
Reviewed-by: Uwe Kleine-König &lt;u.kleine-koenig@baylibre.com&gt;
Link: https://lore.kernel.org/r/20250428-enable-rtc-v4-2-2b2f7e3f9349@baylibre.com
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Signed-off-by: Uwe Kleine-König &lt;u.kleine-koenig@baylibre.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>rtc: class: Fix potential memleak in devm_rtc_allocate_device()</title>
<updated>2022-12-31T12:32:49Z</updated>
<author>
<name>Shang XiaoJing</name>
<email>shangxiaojing@huawei.com</email>
</author>
<published>2022-11-10T09:08:10Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=59457a0f079eae19aaf322b3cc1c8ba66f55c5f3'/>
<id>urn:sha1:59457a0f079eae19aaf322b3cc1c8ba66f55c5f3</id>
<content type='text'>
[ Upstream commit 60da73808298ff2cfa9f165d55eb3d7aa7078601 ]

devm_rtc_allocate_device() will alloc a rtc_device first, and then run
dev_set_name(). If dev_set_name() failed, the rtc_device will memleak.
Move devm_add_action_or_reset() in front of dev_set_name() to prevent
memleak.

unreferenced object 0xffff888110a53000 (size 2048):
  comm "python3", pid 470, jiffies 4296078308 (age 58.882s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 08 30 a5 10 81 88 ff ff  .........0......
    08 30 a5 10 81 88 ff ff 00 00 00 00 00 00 00 00  .0..............
  backtrace:
    [&lt;000000004aac0364&gt;] kmalloc_trace+0x21/0x110
    [&lt;000000000ff02202&gt;] devm_rtc_allocate_device+0xd4/0x400
    [&lt;000000001bdf5639&gt;] devm_rtc_device_register+0x1a/0x80
    [&lt;00000000351bf81c&gt;] rx4581_probe+0xdd/0x110 [rtc_rx4581]
    [&lt;00000000f0eba0ae&gt;] spi_probe+0xde/0x130
    [&lt;00000000bff89ee8&gt;] really_probe+0x175/0x3f0
    [&lt;00000000128e8d84&gt;] __driver_probe_device+0xe6/0x170
    [&lt;00000000ee5bf913&gt;] device_driver_attach+0x32/0x80
    [&lt;00000000f3f28f92&gt;] bind_store+0x10b/0x1a0
    [&lt;000000009ff812d8&gt;] drv_attr_store+0x49/0x70
    [&lt;000000008139c323&gt;] sysfs_kf_write+0x8d/0xb0
    [&lt;00000000b6146e01&gt;] kernfs_fop_write_iter+0x214/0x2d0
    [&lt;00000000ecbe3895&gt;] vfs_write+0x61a/0x7d0
    [&lt;00000000aa2196ea&gt;] ksys_write+0xc8/0x190
    [&lt;0000000046a600f5&gt;] do_syscall_64+0x37/0x90
    [&lt;00000000541a336f&gt;] entry_SYSCALL_64_after_hwframe+0x63/0xcd

Fixes: 24d23181e43d ("rtc: class: check return value when calling dev_set_name()")
Signed-off-by: Shang XiaoJing &lt;shangxiaojing@huawei.com&gt;
Reviewed-by: Yang Yingliang &lt;yangyingliang@huawei.com&gt;
Link: https://lore.kernel.org/r/20221110090810.11225-1-shangxiaojing@huawei.com
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>rtc: Directly use ida_alloc()/free()</title>
<updated>2022-06-24T19:44:53Z</updated>
<author>
<name>keliu</name>
<email>liuke94@huawei.com</email>
</author>
<published>2022-05-27T07:36:36Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=592ff0c8d0648610511f4e4fb532f100168e6e0d'/>
<id>urn:sha1:592ff0c8d0648610511f4e4fb532f100168e6e0d</id>
<content type='text'>
Use ida_alloc()/ida_free() instead of deprecated
ida_simple_get()/ida_simple_remove() .

Signed-off-by: keliu &lt;liuke94@huawei.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20220527073636.2474546-1-liuke94@huawei.com
</content>
</entry>
<entry>
<title>rtc: remove uie_unsupported</title>
<updated>2022-03-23T18:58:41Z</updated>
<author>
<name>Alexandre Belloni</name>
<email>alexandre.belloni@bootlin.com</email>
</author>
<published>2022-03-09T16:23:00Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=1a31d63632553a54af6c0c3c5b5930e931a94ee4'/>
<id>urn:sha1:1a31d63632553a54af6c0c3c5b5930e931a94ee4</id>
<content type='text'>
uie_unsupported is not used by any drivers anymore, remove it.

Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20220309162301.61679-29-alexandre.belloni@bootlin.com
</content>
</entry>
<entry>
<title>rtc: fix use-after-free on device removal</title>
<updated>2022-02-15T22:06:19Z</updated>
<author>
<name>Vincent Whitchurch</name>
<email>vincent.whitchurch@axis.com</email>
</author>
<published>2021-12-10T16:09:51Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=c8fa17d9f08a448184f03d352145099b5beb618e'/>
<id>urn:sha1:c8fa17d9f08a448184f03d352145099b5beb618e</id>
<content type='text'>
If the irqwork is still scheduled or running while the RTC device is
removed, a use-after-free occurs in rtc_timer_do_work().  Cleanup the
timerqueue and ensure the work is stopped to fix this.

 BUG: KASAN: use-after-free in mutex_lock+0x94/0x110
 Write of size 8 at addr ffffff801d846338 by task kworker/3:1/41

 Workqueue: events rtc_timer_do_work
 Call trace:
  mutex_lock+0x94/0x110
  rtc_timer_do_work+0xec/0x630
  process_one_work+0x5fc/0x1344
  ...

 Allocated by task 551:
  kmem_cache_alloc_trace+0x384/0x6e0
  devm_rtc_allocate_device+0xf0/0x574
  devm_rtc_device_register+0x2c/0x12c
  ...

 Freed by task 572:
  kfree+0x114/0x4d0
  rtc_device_release+0x64/0x80
  device_release+0x8c/0x1f4
  kobject_put+0x1c4/0x4b0
  put_device+0x20/0x30
  devm_rtc_release_device+0x1c/0x30
  devm_action_release+0x54/0x90
  release_nodes+0x124/0x310
  devres_release_group+0x170/0x240
  i2c_device_remove+0xd8/0x314
  ...

 Last potentially related work creation:
  insert_work+0x5c/0x330
  queue_work_on+0xcc/0x154
  rtc_set_time+0x188/0x5bc
  rtc_dev_ioctl+0x2ac/0xbd0
  ...

Signed-off-by: Vincent Whitchurch &lt;vincent.whitchurch@axis.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20211210160951.7718-1-vincent.whitchurch@axis.com
</content>
</entry>
<entry>
<title>rtc: expose RTC_FEATURE_UPDATE_INTERRUPT</title>
<updated>2021-10-18T15:25:52Z</updated>
<author>
<name>Alexandre Belloni</name>
<email>alexandre.belloni@bootlin.com</email>
</author>
<published>2021-10-18T15:23:36Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=adb17a053e460f20740d713c4843d6966e66b1b1'/>
<id>urn:sha1:adb17a053e460f20740d713c4843d6966e66b1b1</id>
<content type='text'>
Set RTC_FEATURE_UPDATE_INTERRUPT by default and clear it when it is not
supported.

Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20211018152337.78732-1-alexandre.belloni@bootlin.com
</content>
</entry>
<entry>
<title>rtc: expose correction feature</title>
<updated>2021-10-18T15:20:50Z</updated>
<author>
<name>Alexandre Belloni</name>
<email>alexandre.belloni@bootlin.com</email>
</author>
<published>2021-10-18T15:19:29Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=2268551935dbf1abcbb4d4fb7b1ad74dbe0d1be0'/>
<id>urn:sha1:2268551935dbf1abcbb4d4fb7b1ad74dbe0d1be0</id>
<content type='text'>
Add a new feature for RTCs able to correct the oscillator imprecision. This
is also called offset or trimming. Such drivers have a .set_offset callback,
use that to set the feature bit from the core.

Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20211018151933.76865-4-alexandre.belloni@bootlin.com
</content>
</entry>
<entry>
<title>rtc: class: check return value when calling dev_set_name()</title>
<updated>2021-10-15T19:06:10Z</updated>
<author>
<name>Yang Yingliang</name>
<email>yangyingliang@huawei.com</email>
</author>
<published>2021-10-12T04:16:29Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=24d23181e43d72ca692a479e70dfe5b0b5dd33f1'/>
<id>urn:sha1:24d23181e43d72ca692a479e70dfe5b0b5dd33f1</id>
<content type='text'>
I got a null-ptr-deref report when doing fault injection test:

BUG: kernel NULL pointer dereference, address: 0000000000000000
RIP: 0010:strcmp+0xc/0x20
Call Trace:
 __devm_rtc_register_device.cold.7+0x16a/0x2df
 rv3029_probe+0x4b1/0x770 [rtc_rv3029c2]
 rv3029_i2c_probe+0x141/0x180 [rtc_rv3029c2]
 i2c_device_probe+0xa07/0xbb0
 really_probe+0x285/0xc30

If dev_set_name() fails, dev_name() is null, it causes null-ptr-deref,
we need check the return value of dev_set_name().

Reported-by: Hulk Robot &lt;hulkci@huawei.com&gt;
Signed-off-by: Yang Yingliang &lt;yangyingliang@huawei.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20211012041629.2504158-1-yangyingliang@huawei.com
</content>
</entry>
<entry>
<title>rtc: class: don't call cdev_device_del() when cdev_device_add() failed</title>
<updated>2021-10-15T19:05:33Z</updated>
<author>
<name>Yang Yingliang</name>
<email>yangyingliang@huawei.com</email>
</author>
<published>2021-10-11T13:21:14Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=789c1093f02c436b320d78a739f9610c8271cb73'/>
<id>urn:sha1:789c1093f02c436b320d78a739f9610c8271cb73</id>
<content type='text'>
I got a null-ptr-deref report when doing fault injection test:

general protection fault, probably for non-canonical address 0xdffffc0000000022: 0000 [#1] SMP KASAN PTI
KASAN: null-ptr-deref in range [0x0000000000000110-0x0000000000000117]
RIP: 0010:device_del+0x132/0xdc0
Call Trace:
 cdev_device_del+0x1a/0x80
 devm_rtc_unregister_device+0x37/0x80
 release_nodes+0xc3/0x3b0

If cdev_device_add() fails, 'dev-&gt;p' is not set, it causes
null-ptr-deref when calling cdev_device_del(). Registering
character device is optional, we don't return error code
here, so introduce a new flag 'RTC_NO_CDEV' to indicate
if it has character device, cdev_device_del() is called
when this bit is not set.

Reported-by: Hulk Robot &lt;hulkci@huawei.com&gt;
Signed-off-by: Yang Yingliang &lt;yangyingliang@huawei.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20211011132114.3663509-1-yangyingliang@huawei.com
</content>
</entry>
<entry>
<title>rtc: class: remove bogus documentation</title>
<updated>2021-02-05T23:58:24Z</updated>
<author>
<name>Alexandre Belloni</name>
<email>alexandre.belloni@bootlin.com</email>
</author>
<published>2021-02-02T11:21:58Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=d5328499bf017f25412eedfc6769f108f43dce2c'/>
<id>urn:sha1:d5328499bf017f25412eedfc6769f108f43dce2c</id>
<content type='text'>
rtc_device_unregister is gone since commit fdcfd854333b ("rtc: rework
rtc_register_device() resource management"). Remove its documentation.

Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Link: https://lore.kernel.org/r/20210202112219.3610853-2-alexandre.belloni@bootlin.com
</content>
</entry>
</feed>
