1. 30 May, 2018 36 commits
  2. 25 May, 2018 4 commits
    • Greg Kroah-Hartman's avatar
      Linux 4.9.103 · aa4b4ace
      Greg Kroah-Hartman authored
      aa4b4ace
    • Colin Ian King's avatar
      rtc: tx4939: avoid unintended sign extension on a 24 bit shift · 0c600456
      Colin Ian King authored
      [ Upstream commit 347876ad ]
      
      The shifting of buf[5] by 24 bits to the left will be promoted to
      a 32 bit signed int and then sign-extended to an unsigned long. If
      the top bit of buf[5] is set then all then all the upper bits sec
      end up as also being set because of the sign-extension. Fix this by
      casting buf[5] to an unsigned long before the shift.
      
      Detected by CoverityScan, CID#1465292 ("Unintended sign extension")
      
      Fixes: 0e149233 ("rtc: add rtc-tx4939 driver")
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0c600456
    • Alexandre Belloni's avatar
      rtc: hctosys: Ensure system time doesn't overflow time_t · dd6b3e0a
      Alexandre Belloni authored
      [ Upstream commit b3a5ac42 ]
      
      On 32bit platforms, time_t is still a signed 32bit long. If it is
      overflowed, userspace and the kernel cant agree on the current system time.
      This causes multiple issues, in particular with systemd:
      https://github.com/systemd/systemd/issues/1143
      
      A good workaround is to simply avoid using hctosys which is something I
      greatly encourage as the time is better set by userspace.
      
      However, many distribution enable it and use systemd which is rendering the
      system unusable in case the RTC holds a date after 2038 (and more so after
      2106). Many drivers have workaround for this case and they should be
      eliminated so there is only one place left to fix when userspace is able to
      cope with dates after the 31bit overflow.
      Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dd6b3e0a
    • Bryan O'Donoghue's avatar
      rtc: snvs: Fix usage of snvs_rtc_enable · 36ce931c
      Bryan O'Donoghue authored
      [ Upstream commit 1485991c ]
      
      commit 179a502f ("rtc: snvs: add Freescale rtc-snvs driver") introduces
      the SNVS RTC driver with a function snvs_rtc_enable().
      
      snvs_rtc_enable() can return an error on the enable path however this
      driver does not currently trap that failure on the probe() path and
      consequently if enabling the RTC fails we encounter a later error spinning
      forever in rtc_write_sync_lp().
      
      [   36.093481] [<c010d630>] (__irq_svc) from [<c0c2e9ec>] (_raw_spin_unlock_irqrestore+0x34/0x44)
      [   36.102122] [<c0c2e9ec>] (_raw_spin_unlock_irqrestore) from [<c072e32c>] (regmap_read+0x4c/0x5c)
      [   36.110938] [<c072e32c>] (regmap_read) from [<c085d0f4>] (rtc_write_sync_lp+0x6c/0x98)
      [   36.118881] [<c085d0f4>] (rtc_write_sync_lp) from [<c085d160>] (snvs_rtc_alarm_irq_enable+0x40/0x4c)
      [   36.128041] [<c085d160>] (snvs_rtc_alarm_irq_enable) from [<c08567b4>] (rtc_timer_do_work+0xd8/0x1a8)
      [   36.137291] [<c08567b4>] (rtc_timer_do_work) from [<c01441b8>] (process_one_work+0x28c/0x76c)
      [   36.145840] [<c01441b8>] (process_one_work) from [<c01446cc>] (worker_thread+0x34/0x58c)
      [   36.153961] [<c01446cc>] (worker_thread) from [<c014aee4>] (kthread+0x138/0x150)
      [   36.161388] [<c014aee4>] (kthread) from [<c0107e14>] (ret_from_fork+0x14/0x20)
      [   36.168635] rcu_sched kthread starved for 2602 jiffies! g496 c495 f0x2 RCU_GP_WAIT_FQS(3) ->state=0x0 ->cpu=0
      [   36.178564] rcu_sched       R  running task        0     8      2 0x00000000
      [   36.185664] [<c0c288b0>] (__schedule) from [<c0c29134>] (schedule+0x3c/0xa0)
      [   36.192739] [<c0c29134>] (schedule) from [<c0c2db80>] (schedule_timeout+0x78/0x4e0)
      [   36.200422] [<c0c2db80>] (schedule_timeout) from [<c01a7ab0>] (rcu_gp_kthread+0x648/0x1864)
      [   36.208800] [<c01a7ab0>] (rcu_gp_kthread) from [<c014aee4>] (kthread+0x138/0x150)
      [   36.216309] [<c014aee4>] (kthread) from [<c0107e14>] (ret_from_fork+0x14/0x20)
      
      This patch fixes by parsing the result of rtc_write_sync_lp() and
      propagating both in the probe and elsewhere. If the RTC doesn't start we
      don't proceed loading the driver and don't get into this loop mess later
      on.
      
      Fixes: 179a502f ("rtc: snvs: add Freescale rtc-snvs driver")
      Signed-off-by: default avatarBryan O'Donoghue <pure.logic@nexus-software.ie>
      Acked-by: default avatarShawn Guo <shawn.guo@linaro.org>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      36ce931c