Dear Jörg, dear Suravee,
Am 03.03.21 um 15:10 schrieb Alexander Monakov:
> On Wed, 3 Mar 2021, Suravee Suthikulpanit wrote:
>
>>> Additionally, alternative proposed solutions [1] were not considered or
>>> discussed.
>>>
>>> [1]:https://lore.kernel.org/linux-iommu/alpine.LNX.2.20.13.2006030935570.318…
>>
>> This check has been introduced early on to detect a HW issue for
>> certain platforms in the past, where the performance counters are not
>> accessible and would result in silent failure when try to use the
>> counters. This is considered legacy code, and can be removed if we
>> decide to no longer provide sanity check for such case.
>
> Which platforms? There is no such information in the code or the commit
> messages that introduced this.
>
> According to AMD's documentation, presence of performance counters is
> indicated by "PCSup" bit in the "EFR" register. I don't think the driver
> should second-guess that. If there were platforms where the CPU or the
> firmware lied to the OS (EFR[PCSup] was 1, but counters were not present),
> I think that should have been handled in a more explicit manner, e.g.
> via matching broken CPUs by cpuid.
Suravee, could you please answer the questions?
Jörg, I know you are probably busy, but the patch was applied to the
stable series (v5.11.7). There are still too many question open
regarding the patch, and Suravee has not yet addressed the comments.
It’d be great, if you could revert it.
Kind regards,
Paul
Could you please
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 3a62583c2853b0ab37a57dde79decea210b5fb89
Gitweb: https://git.kernel.org/tip/3a62583c2853b0ab37a57dde79decea210b5fb89
Author: William Roche <william.roche(a)oracle.com>
AuthorDate: Tue, 06 Apr 2021 11:28:59 -04:00
Committer: Borislav Petkov <bp(a)suse.de>
CommitterDate: Wed, 07 Apr 2021 11:52:26 +02:00
RAS/CEC: Correct ce_add_elem()'s returned values
ce_add_elem() uses different return values to signal a result from
adding an element to the collector. Commit in Fixes: broke the case
where the element being added is not found in the array. Correct that.
[ bp: Rewrite commit message, add kernel-doc comments. ]
Fixes: de0e0624d86f ("RAS/CEC: Check count_threshold unconditionally")
Signed-off-by: William Roche <william.roche(a)oracle.com>
Signed-off-by: Borislav Petkov <bp(a)suse.de>
Cc: <stable(a)vger.kernel.org>
Link: https://lkml.kernel.org/r/1617722939-29670-1-git-send-email-william.roche@o…
---
drivers/ras/cec.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/ras/cec.c b/drivers/ras/cec.c
index ddecf25..d7894f1 100644
--- a/drivers/ras/cec.c
+++ b/drivers/ras/cec.c
@@ -309,11 +309,20 @@ static bool sanity_check(struct ce_array *ca)
return ret;
}
+/**
+ * cec_add_elem - Add an element to the CEC array.
+ * @pfn: page frame number to insert
+ *
+ * Return values:
+ * - <0: on error
+ * - 0: on success
+ * - >0: when the inserted pfn was offlined
+ */
static int cec_add_elem(u64 pfn)
{
struct ce_array *ca = &ce_arr;
+ int count, err, ret = 0;
unsigned int to = 0;
- int count, ret = 0;
/*
* We can be called very early on the identify_cpu() path where we are
@@ -330,8 +339,8 @@ static int cec_add_elem(u64 pfn)
if (ca->n == MAX_ELEMS)
WARN_ON(!del_lru_elem_unlocked(ca));
- ret = find_elem(ca, pfn, &to);
- if (ret < 0) {
+ err = find_elem(ca, pfn, &to);
+ if (err < 0) {
/*
* Shift range [to-end] to make room for one more element.
*/
This is the start of the stable review cycle for the 4.19.185 release.
There are 56 patches in this series, all will be posted as a response
to this one. If anyone has any issues with these being applied, please
let me know.
Responses should be made by Wed, 07 Apr 2021 08:50:09 +0000.
Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.185-r…
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.19.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Linux 4.19.185-rc1
Du Cheng <ducheng2(a)gmail.com>
drivers: video: fbcon: fix NULL dereference in fbcon_cursor()
Atul Gopinathan <atulgopinathan(a)gmail.com>
staging: rtl8192e: Change state information from u16 to u8
Atul Gopinathan <atulgopinathan(a)gmail.com>
staging: rtl8192e: Fix incorrect source in memcpy()
Artur Petrosyan <Arthur.Petrosyan(a)synopsys.com>
usb: dwc2: Fix HPRT0.PrtSusp bit setting for HiKey 960 board.
Tong Zhang <ztong0001(a)gmail.com>
usb: gadget: udc: amd5536udc_pci fix null-ptr-dereference
Johan Hovold <johan(a)kernel.org>
USB: cdc-acm: fix use-after-free after probe failure
Johan Hovold <johan(a)kernel.org>
USB: cdc-acm: fix double free on probe failure
Oliver Neukum <oneukum(a)suse.com>
USB: cdc-acm: downgrade message to debug
Oliver Neukum <oneukum(a)suse.com>
USB: cdc-acm: untangle a circular dependency between callback and softint
Oliver Neukum <oneukum(a)suse.com>
cdc-acm: fix BREAK rx code path adding necessary calls
Chunfeng Yun <chunfeng.yun(a)mediatek.com>
usb: xhci-mtk: fix broken streams issue on 0.96 xHCI
Tony Lindgren <tony(a)atomide.com>
usb: musb: Fix suspend with devices connected for a64
Vincent Palatin <vpalatin(a)chromium.org>
USB: quirks: ignore remote wake-up on Fibocom L850-GL LTE modem
Shuah Khan <skhan(a)linuxfoundation.org>
usbip: vhci_hcd fix shift out-of-bounds in vhci_hub_control()
Zheyu Ma <zheyuma97(a)gmail.com>
firewire: nosy: Fix a use-after-free bug in nosy_ioctl()
Dinghao Liu <dinghao.liu(a)zju.edu.cn>
extcon: Fix error handling in extcon_dev_register
Krzysztof Kozlowski <krzk(a)kernel.org>
extcon: Add stubs for extcon_register_notifier_all() functions
Wang Panzhenzhuan <randy.wang(a)rock-chips.com>
pinctrl: rockchip: fix restore error in resume
Tetsuo Handa <penguin-kernel(a)i-love.sakura.ne.jp>
reiserfs: update reiserfs_xattrs_initialized() condition
Xℹ Ruoyao <xry111(a)mengyan1223.wang>
drm/amdgpu: check alignment on CPU page for bo map
Nirmoy Das <nirmoy.das(a)amd.com>
drm/amdgpu: fix offset calculation in amdgpu_vm_bo_clear_mappings()
Ilya Lipnitskiy <ilya.lipnitskiy(a)gmail.com>
mm: fix race by making init_zero_pfn() early_initcall
Steven Rostedt (VMware) <rostedt(a)goodmis.org>
tracing: Fix stack trace event size
Adrian Hunter <adrian.hunter(a)intel.com>
PM: runtime: Fix ordering in pm_runtime_get_suppliers()
Adrian Hunter <adrian.hunter(a)intel.com>
PM: runtime: Fix race getting/putting suppliers at probe
Hui Wang <hui.wang(a)canonical.com>
ALSA: hda/realtek: call alc_update_headset_mode() in hp_automute_hook
Hui Wang <hui.wang(a)canonical.com>
ALSA: hda/realtek: fix a determine_headset_type issue for a Dell AIO
Ikjoon Jang <ikjn(a)chromium.org>
ALSA: usb-audio: Apply sample rate quirk to Logitech Connect
Jesper Dangaard Brouer <brouer(a)redhat.com>
bpf: Remove MTU check in __bpf_skb_max_len
Tong Zhang <ztong0001(a)gmail.com>
net: wan/lmc: unregister device when no matching device is found
Doug Brown <doug(a)schmorgal.com>
appletalk: Fix skb allocation size in loopback case
Nathan Rossi <nathan.rossi(a)digi.com>
net: ethernet: aquantia: Handle error cleanup of start on open
Shuah Khan <skhan(a)linuxfoundation.org>
ath10k: hold RCU lock when calling ieee80211_find_sta_by_ifaddr()
Luca Pesce <luca.pesce(a)vimar.com>
brcmfmac: clear EAP/association status bits on linkdown events
zhangyi (F) <yi.zhang(a)huawei.com>
ext4: do not iput inode under running transaction in ext4_rename()
Waiman Long <longman(a)redhat.com>
locking/ww_mutex: Simplify use_ww_ctx & ww_ctx handling
Manaf Meethalavalappu Pallikunhi <manafm(a)codeaurora.org>
thermal/core: Add NULL pointer check before using cooling device stats
Sameer Pujar <spujar(a)nvidia.com>
ASoC: rt5659: Update MCLK rate in set_sysclk()
Tong Zhang <ztong0001(a)gmail.com>
staging: comedi: cb_pcidas64: fix request_irq() warn
Tong Zhang <ztong0001(a)gmail.com>
staging: comedi: cb_pcidas: fix request_irq() warn
Alexey Dobriyan <adobriyan(a)gmail.com>
scsi: qla2xxx: Fix broken #endif placement
Lv Yunlong <lyl2019(a)mail.ustc.edu.cn>
scsi: st: Fix a use after free in st_open()
Laurent Vivier <lvivier(a)redhat.com>
vhost: Fix vhost_vq_reset()
Lucas Tanure <tanureal(a)opensource.cirrus.com>
ASoC: cs42l42: Always wait at least 3ms after reset
Lucas Tanure <tanureal(a)opensource.cirrus.com>
ASoC: cs42l42: Fix mixer volume control
Lucas Tanure <tanureal(a)opensource.cirrus.com>
ASoC: cs42l42: Fix channel width support
Lucas Tanure <tanureal(a)opensource.cirrus.com>
ASoC: cs42l42: Fix Bitclock polarity inversion
Hans de Goede <hdegoede(a)redhat.com>
ASoC: es8316: Simplify adc_pga_gain_tlv table
Benjamin Rood <benjaminjrood(a)gmail.com>
ASoC: sgtl5000: set DAP_AVC_CTRL register to correct default value on probe
Hans de Goede <hdegoede(a)redhat.com>
ASoC: rt5651: Fix dac- and adc- vol-tlv values being off by a factor of 10
Hans de Goede <hdegoede(a)redhat.com>
ASoC: rt5640: Fix dac- and adc- vol-tlv values being off by a factor of 10
J. Bruce Fields <bfields(a)redhat.com>
rpc: fix NULL dereference on kmalloc failure
Zhaolong Zhang <zhangzl2013(a)126.com>
ext4: fix bh ref count on error paths
Jakub Kicinski <kuba(a)kernel.org>
ipv6: weaken the v4mapped source check
Alexander Ovechkin <ovov(a)yandex-team.ru>
tcp: relookup sock for RST+ACK packets handled by obsolete req sock
David Brazdil <dbrazdil(a)google.com>
selinux: vsock: Set SID for socket returned by accept()
-------------
Diffstat:
Makefile | 4 +-
drivers/base/power/runtime.c | 10 ++-
drivers/extcon/extcon.c | 1 +
drivers/firewire/nosy.c | 9 ++-
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 10 +--
drivers/net/ethernet/aquantia/atlantic/aq_main.c | 4 +-
drivers/net/wan/lmc/lmc_main.c | 2 +
drivers/net/wireless/ath/ath10k/wmi-tlv.c | 7 +-
.../broadcom/brcm80211/brcmfmac/cfg80211.c | 7 +-
drivers/pinctrl/pinctrl-rockchip.c | 13 ++--
drivers/scsi/qla2xxx/qla_target.h | 2 +-
drivers/scsi/st.c | 2 +-
drivers/staging/comedi/drivers/cb_pcidas.c | 2 +-
drivers/staging/comedi/drivers/cb_pcidas64.c | 2 +-
drivers/staging/rtl8192e/rtllib.h | 2 +-
drivers/staging/rtl8192e/rtllib_rx.c | 2 +-
drivers/thermal/thermal_sysfs.c | 3 +
drivers/usb/class/cdc-acm.c | 61 ++++++++++++------
drivers/usb/core/quirks.c | 4 ++
drivers/usb/dwc2/hcd.c | 2 +-
drivers/usb/gadget/udc/amd5536udc_pci.c | 10 +--
drivers/usb/host/xhci-mtk.c | 10 ++-
drivers/usb/musb/musb_core.c | 12 ++--
drivers/usb/usbip/vhci_hcd.c | 2 +
drivers/vhost/vhost.c | 2 +-
drivers/video/fbdev/core/fbcon.c | 3 +
fs/ext4/inode.c | 6 +-
fs/ext4/namei.c | 18 +++---
fs/reiserfs/xattr.h | 2 +-
include/linux/extcon.h | 23 +++++++
include/net/inet_connection_sock.h | 2 +-
kernel/locking/mutex.c | 25 ++++----
kernel/trace/trace.c | 3 +-
mm/memory.c | 2 +-
net/appletalk/ddp.c | 33 ++++++----
net/core/filter.c | 12 ++--
net/dccp/ipv6.c | 5 ++
net/ipv4/inet_connection_sock.c | 7 +-
net/ipv4/tcp_minisocks.c | 7 +-
net/ipv6/ip6_input.c | 10 ---
net/ipv6/tcp_ipv6.c | 5 ++
net/sunrpc/auth_gss/svcauth_gss.c | 11 ++--
net/vmw_vsock/af_vsock.c | 1 +
sound/pci/hda/patch_realtek.c | 3 +-
sound/soc/codecs/cs42l42.c | 74 ++++++++++------------
sound/soc/codecs/cs42l42.h | 13 ++--
sound/soc/codecs/es8316.c | 9 +--
sound/soc/codecs/rt5640.c | 4 +-
sound/soc/codecs/rt5651.c | 4 +-
sound/soc/codecs/rt5659.c | 5 ++
sound/soc/codecs/sgtl5000.c | 2 +-
sound/usb/quirks.c | 1 +
52 files changed, 293 insertions(+), 182 deletions(-)
This is the start of the stable review cycle for the 4.14.229 release.
There are 52 patches in this series, all will be posted as a response
to this one. If anyone has any issues with these being applied, please
let me know.
Responses should be made by Wed, 07 Apr 2021 08:50:09 +0000.
Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.229-r…
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.14.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Linux 4.14.229-rc1
Du Cheng <ducheng2(a)gmail.com>
drivers: video: fbcon: fix NULL dereference in fbcon_cursor()
Atul Gopinathan <atulgopinathan(a)gmail.com>
staging: rtl8192e: Change state information from u16 to u8
Atul Gopinathan <atulgopinathan(a)gmail.com>
staging: rtl8192e: Fix incorrect source in memcpy()
Tong Zhang <ztong0001(a)gmail.com>
usb: gadget: udc: amd5536udc_pci fix null-ptr-dereference
Johan Hovold <johan(a)kernel.org>
USB: cdc-acm: fix use-after-free after probe failure
Oliver Neukum <oneukum(a)suse.com>
USB: cdc-acm: downgrade message to debug
Oliver Neukum <oneukum(a)suse.com>
USB: cdc-acm: untangle a circular dependency between callback and softint
Oliver Neukum <oneukum(a)suse.com>
cdc-acm: fix BREAK rx code path adding necessary calls
Chunfeng Yun <chunfeng.yun(a)mediatek.com>
usb: xhci-mtk: fix broken streams issue on 0.96 xHCI
Tony Lindgren <tony(a)atomide.com>
usb: musb: Fix suspend with devices connected for a64
Vincent Palatin <vpalatin(a)chromium.org>
USB: quirks: ignore remote wake-up on Fibocom L850-GL LTE modem
Shuah Khan <skhan(a)linuxfoundation.org>
usbip: vhci_hcd fix shift out-of-bounds in vhci_hub_control()
Zheyu Ma <zheyuma97(a)gmail.com>
firewire: nosy: Fix a use-after-free bug in nosy_ioctl()
Dinghao Liu <dinghao.liu(a)zju.edu.cn>
extcon: Fix error handling in extcon_dev_register
Krzysztof Kozlowski <krzk(a)kernel.org>
extcon: Add stubs for extcon_register_notifier_all() functions
Wang Panzhenzhuan <randy.wang(a)rock-chips.com>
pinctrl: rockchip: fix restore error in resume
Greg Thelen <gthelen(a)google.com>
mm: writeback: use exact memcg dirty counts
Roman Gushchin <guro(a)fb.com>
mm: fix oom_kill event handling
Aaron Lu <aaron.lu(a)intel.com>
mem_cgroup: make sure moving_account, move_lock_task and stat_cpu in the same cacheline
Johannes Weiner <hannes(a)cmpxchg.org>
mm: memcg: make sure memory.events is uptodate when waking pollers
Johannes Weiner <hannes(a)cmpxchg.org>
mm: memcontrol: fix NR_WRITEBACK leak in memcg and system stats
Tetsuo Handa <penguin-kernel(a)i-love.sakura.ne.jp>
reiserfs: update reiserfs_xattrs_initialized() condition
Xℹ Ruoyao <xry111(a)mengyan1223.wang>
drm/amdgpu: check alignment on CPU page for bo map
Nirmoy Das <nirmoy.das(a)amd.com>
drm/amdgpu: fix offset calculation in amdgpu_vm_bo_clear_mappings()
Ilya Lipnitskiy <ilya.lipnitskiy(a)gmail.com>
mm: fix race by making init_zero_pfn() early_initcall
Steven Rostedt (VMware) <rostedt(a)goodmis.org>
tracing: Fix stack trace event size
Hui Wang <hui.wang(a)canonical.com>
ALSA: hda/realtek: call alc_update_headset_mode() in hp_automute_hook
Hui Wang <hui.wang(a)canonical.com>
ALSA: hda/realtek: fix a determine_headset_type issue for a Dell AIO
Ikjoon Jang <ikjn(a)chromium.org>
ALSA: usb-audio: Apply sample rate quirk to Logitech Connect
Jesper Dangaard Brouer <brouer(a)redhat.com>
bpf: Remove MTU check in __bpf_skb_max_len
Tong Zhang <ztong0001(a)gmail.com>
net: wan/lmc: unregister device when no matching device is found
Doug Brown <doug(a)schmorgal.com>
appletalk: Fix skb allocation size in loopback case
Nathan Rossi <nathan.rossi(a)digi.com>
net: ethernet: aquantia: Handle error cleanup of start on open
Luca Pesce <luca.pesce(a)vimar.com>
brcmfmac: clear EAP/association status bits on linkdown events
zhangyi (F) <yi.zhang(a)huawei.com>
ext4: do not iput inode under running transaction in ext4_rename()
Sameer Pujar <spujar(a)nvidia.com>
ASoC: rt5659: Update MCLK rate in set_sysclk()
Tong Zhang <ztong0001(a)gmail.com>
staging: comedi: cb_pcidas64: fix request_irq() warn
Tong Zhang <ztong0001(a)gmail.com>
staging: comedi: cb_pcidas: fix request_irq() warn
Alexey Dobriyan <adobriyan(a)gmail.com>
scsi: qla2xxx: Fix broken #endif placement
Lv Yunlong <lyl2019(a)mail.ustc.edu.cn>
scsi: st: Fix a use after free in st_open()
Laurent Vivier <lvivier(a)redhat.com>
vhost: Fix vhost_vq_reset()
Christophe Leroy <christophe.leroy(a)csgroup.eu>
powerpc: Force inlining of cpu_has_feature() to avoid build failure
Lucas Tanure <tanureal(a)opensource.cirrus.com>
ASoC: cs42l42: Always wait at least 3ms after reset
Lucas Tanure <tanureal(a)opensource.cirrus.com>
ASoC: cs42l42: Fix mixer volume control
Hans de Goede <hdegoede(a)redhat.com>
ASoC: es8316: Simplify adc_pga_gain_tlv table
Benjamin Rood <benjaminjrood(a)gmail.com>
ASoC: sgtl5000: set DAP_AVC_CTRL register to correct default value on probe
Hans de Goede <hdegoede(a)redhat.com>
ASoC: rt5651: Fix dac- and adc- vol-tlv values being off by a factor of 10
Hans de Goede <hdegoede(a)redhat.com>
ASoC: rt5640: Fix dac- and adc- vol-tlv values being off by a factor of 10
J. Bruce Fields <bfields(a)redhat.com>
rpc: fix NULL dereference on kmalloc failure
Zhaolong Zhang <zhangzl2013(a)126.com>
ext4: fix bh ref count on error paths
Jakub Kicinski <kuba(a)kernel.org>
ipv6: weaken the v4mapped source check
David Brazdil <dbrazdil(a)google.com>
selinux: vsock: Set SID for socket returned by accept()
-------------
Diffstat:
Makefile | 4 +-
arch/powerpc/include/asm/cpu_has_feature.h | 4 +-
drivers/extcon/extcon.c | 1 +
drivers/firewire/nosy.c | 9 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 10 +-
drivers/net/ethernet/aquantia/atlantic/aq_main.c | 4 +-
drivers/net/wan/lmc/lmc_main.c | 2 +
.../broadcom/brcm80211/brcmfmac/cfg80211.c | 7 +-
drivers/pinctrl/pinctrl-rockchip.c | 13 ++-
drivers/scsi/qla2xxx/qla_target.h | 2 +-
drivers/scsi/st.c | 2 +-
drivers/staging/comedi/drivers/cb_pcidas.c | 2 +-
drivers/staging/comedi/drivers/cb_pcidas64.c | 2 +-
drivers/staging/rtl8192e/rtllib.h | 2 +-
drivers/staging/rtl8192e/rtllib_rx.c | 2 +-
drivers/usb/class/cdc-acm.c | 60 +++++++----
drivers/usb/core/quirks.c | 4 +
drivers/usb/gadget/udc/amd5536udc_pci.c | 10 +-
drivers/usb/host/xhci-mtk.c | 10 +-
drivers/usb/musb/musb_core.c | 12 ++-
drivers/usb/usbip/vhci_hcd.c | 2 +
drivers/vhost/vhost.c | 2 +-
drivers/video/fbdev/core/fbcon.c | 3 +
fs/ext4/inode.c | 6 +-
fs/ext4/namei.c | 18 ++--
fs/reiserfs/xattr.h | 2 +-
include/linux/extcon.h | 23 +++++
include/linux/memcontrol.h | 111 +++++++++++++++------
kernel/trace/trace.c | 3 +-
mm/memcontrol.c | 54 +++++++---
mm/memory.c | 2 +-
mm/oom_kill.c | 2 +-
mm/vmscan.c | 2 +-
net/appletalk/ddp.c | 33 +++---
net/core/filter.c | 11 +-
net/dccp/ipv6.c | 5 +
net/ipv6/ip6_input.c | 10 --
net/ipv6/tcp_ipv6.c | 5 +
net/sunrpc/auth_gss/svcauth_gss.c | 11 +-
net/vmw_vsock/af_vsock.c | 1 +
sound/pci/hda/patch_realtek.c | 3 +-
sound/soc/codecs/cs42l42.c | 7 +-
sound/soc/codecs/cs42l42.h | 1 +
sound/soc/codecs/es8316.c | 9 +-
sound/soc/codecs/rt5640.c | 4 +-
sound/soc/codecs/rt5651.c | 4 +-
sound/soc/codecs/rt5659.c | 5 +
sound/soc/codecs/sgtl5000.c | 2 +-
sound/usb/quirks.c | 1 +
49 files changed, 335 insertions(+), 169 deletions(-)
This is a note to let you know that I've just added the patch titled
iio: inv_mpu6050: Fully validate gyro and accel scale writes
to my staging git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
in the staging-next branch.
The patch will show up in the next release of the linux-next tree
(usually sometime within the next 24 hours during the week.)
The patch will also be merged in the next major kernel release
during the merge window.
If you have any questions about this process, please let me know.
>From e09fe9135399807b8397798a53160e055dc6c29f Mon Sep 17 00:00:00 2001
From: Lars-Peter Clausen <lars(a)metafoo.de>
Date: Mon, 5 Apr 2021 13:44:41 +0200
Subject: iio: inv_mpu6050: Fully validate gyro and accel scale writes
When setting the gyro or accelerometer scale the inv_mpu6050 driver ignores
the integer part of the value. As a result e.g. all of 0.13309, 1.13309,
12345.13309, ... are accepted as a valid gyro scale and 0.13309 is the
scale that gets set in all those cases.
Make sure to check that the integer part of the scale value is 0 and reject
it otherwise.
Fixes: 09a642b78523 ("Invensense MPU6050 Device Driver.")
Signed-off-by: Lars-Peter Clausen <lars(a)metafoo.de>
Acked-by: Jean-Baptiste Maneyrol <jmaneyrol(a)invensense.com>
Link: https://lore.kernel.org/r/20210405114441.24167-1-lars@metafoo.de
Cc: <Stable(a)vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron(a)huawei.com>
---
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index cda7b48981c9..6244a07048df 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -731,12 +731,16 @@ inv_mpu6050_read_raw(struct iio_dev *indio_dev,
}
}
-static int inv_mpu6050_write_gyro_scale(struct inv_mpu6050_state *st, int val)
+static int inv_mpu6050_write_gyro_scale(struct inv_mpu6050_state *st, int val,
+ int val2)
{
int result, i;
+ if (val != 0)
+ return -EINVAL;
+
for (i = 0; i < ARRAY_SIZE(gyro_scale_6050); ++i) {
- if (gyro_scale_6050[i] == val) {
+ if (gyro_scale_6050[i] == val2) {
result = inv_mpu6050_set_gyro_fsr(st, i);
if (result)
return result;
@@ -767,13 +771,17 @@ static int inv_write_raw_get_fmt(struct iio_dev *indio_dev,
return -EINVAL;
}
-static int inv_mpu6050_write_accel_scale(struct inv_mpu6050_state *st, int val)
+static int inv_mpu6050_write_accel_scale(struct inv_mpu6050_state *st, int val,
+ int val2)
{
int result, i;
u8 d;
+ if (val != 0)
+ return -EINVAL;
+
for (i = 0; i < ARRAY_SIZE(accel_scale); ++i) {
- if (accel_scale[i] == val) {
+ if (accel_scale[i] == val2) {
d = (i << INV_MPU6050_ACCL_CONFIG_FSR_SHIFT);
result = regmap_write(st->map, st->reg->accl_config, d);
if (result)
@@ -814,10 +822,10 @@ static int inv_mpu6050_write_raw(struct iio_dev *indio_dev,
case IIO_CHAN_INFO_SCALE:
switch (chan->type) {
case IIO_ANGL_VEL:
- result = inv_mpu6050_write_gyro_scale(st, val2);
+ result = inv_mpu6050_write_gyro_scale(st, val, val2);
break;
case IIO_ACCEL:
- result = inv_mpu6050_write_accel_scale(st, val2);
+ result = inv_mpu6050_write_accel_scale(st, val, val2);
break;
default:
result = -EINVAL;
--
2.31.1
This is a note to let you know that I've just added the patch titled
iio: sx9310: Fix access to variable DT array
to my staging git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
in the staging-next branch.
The patch will show up in the next release of the linux-next tree
(usually sometime within the next 24 hours during the week.)
The patch will also be merged in the next major kernel release
during the merge window.
If you have any questions about this process, please let me know.
>From 6f0078ae704d94b1a93e5f3d0a44cf3d8090fa91 Mon Sep 17 00:00:00 2001
From: Gwendal Grignou <gwendal(a)chromium.org>
Date: Fri, 26 Mar 2021 11:46:02 -0700
Subject: iio: sx9310: Fix access to variable DT array
With the current code, we want to read 4 entries from DT array
"semtech,combined-sensors". If there are less, we silently fail as
of_property_read_u32_array() returns -EOVERFLOW.
First count the number of entries and if between 1 and 4, collect the
content of the array.
Fixes: 5b19ca2c78a0 ("iio: sx9310: Set various settings from DT")
Signed-off-by: Gwendal Grignou <gwendal(a)chromium.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko(a)gmail.com>
Link: https://lore.kernel.org/r/20210326184603.251683-2-gwendal@chromium.org
Cc: <stable(a)vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron(a)huawei.com>
---
drivers/iio/proximity/sx9310.c | 40 ++++++++++++++++++++++++----------
1 file changed, 28 insertions(+), 12 deletions(-)
diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c
index 394c2afe0f23..289c76bb3b02 100644
--- a/drivers/iio/proximity/sx9310.c
+++ b/drivers/iio/proximity/sx9310.c
@@ -1213,17 +1213,17 @@ static int sx9310_init_compensation(struct iio_dev *indio_dev)
}
static const struct sx9310_reg_default *
-sx9310_get_default_reg(struct sx9310_data *data, int i,
+sx9310_get_default_reg(struct sx9310_data *data, int idx,
struct sx9310_reg_default *reg_def)
{
- int ret;
const struct device_node *np = data->client->dev.of_node;
- u32 combined[SX9310_NUM_CHANNELS] = { 4, 4, 4, 4 };
+ u32 combined[SX9310_NUM_CHANNELS];
+ u32 start = 0, raw = 0, pos = 0;
unsigned long comb_mask = 0;
+ int ret, i, count;
const char *res;
- u32 start = 0, raw = 0, pos = 0;
- memcpy(reg_def, &sx9310_default_regs[i], sizeof(*reg_def));
+ memcpy(reg_def, &sx9310_default_regs[idx], sizeof(*reg_def));
if (!np)
return reg_def;
@@ -1234,15 +1234,31 @@ sx9310_get_default_reg(struct sx9310_data *data, int i,
reg_def->def |= SX9310_REG_PROX_CTRL2_SHIELDEN_GROUND;
}
- reg_def->def &= ~SX9310_REG_PROX_CTRL2_COMBMODE_MASK;
- of_property_read_u32_array(np, "semtech,combined-sensors",
- combined, ARRAY_SIZE(combined));
- for (i = 0; i < ARRAY_SIZE(combined); i++) {
- if (combined[i] <= SX9310_NUM_CHANNELS)
- comb_mask |= BIT(combined[i]);
+ count = of_property_count_elems_of_size(np, "semtech,combined-sensors",
+ sizeof(u32));
+ if (count > 0 && count <= ARRAY_SIZE(combined)) {
+ ret = of_property_read_u32_array(np, "semtech,combined-sensors",
+ combined, count);
+ if (ret)
+ break;
+ } else {
+ /*
+ * Either the property does not exist in the DT or the
+ * number of entries is incorrect.
+ */
+ break;
+ }
+ for (i = 0; i < count; i++) {
+ if (combined[i] >= SX9310_NUM_CHANNELS) {
+ /* Invalid sensor (invalid DT). */
+ break;
+ }
+ comb_mask |= BIT(combined[i]);
}
+ if (i < count)
+ break;
- comb_mask &= 0xf;
+ reg_def->def &= ~SX9310_REG_PROX_CTRL2_COMBMODE_MASK;
if (comb_mask == (BIT(3) | BIT(2) | BIT(1) | BIT(0)))
reg_def->def |= SX9310_REG_PROX_CTRL2_COMBMODE_CS0_CS1_CS2_CS3;
else if (comb_mask == (BIT(1) | BIT(2)))
--
2.31.1
This is a note to let you know that I've just added the patch titled
iio: magnetometer: yas530: Include right header
to my staging git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
in the staging-next branch.
The patch will show up in the next release of the linux-next tree
(usually sometime within the next 24 hours during the week.)
The patch will also be merged in the next major kernel release
during the merge window.
If you have any questions about this process, please let me know.
>From bb354aeb364f9dee51e16edfdf6194ce4ba9237e Mon Sep 17 00:00:00 2001
From: Linus Walleij <linus.walleij(a)linaro.org>
Date: Mon, 15 Feb 2021 16:30:32 +0100
Subject: iio: magnetometer: yas530: Include right header
To get access to the big endian byte order parsing helpers
drivers need to include <asm/unaligned.h> and nothing else.
Reported-by: kernel test robot <lkp(a)intel.com>
Suggested-by: Harvey Harrison <harvey.harrison(a)gmail.com>
Signed-off-by: Linus Walleij <linus.walleij(a)linaro.org>
Cc: <Stable(a)vger.kernel.org>
Link: https://lore.kernel.org/r/20210215153032.47962-1-linus.walleij@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron(a)huawei.com>
---
drivers/iio/magnetometer/yamaha-yas530.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/magnetometer/yamaha-yas530.c b/drivers/iio/magnetometer/yamaha-yas530.c
index cee6207d8847..2f2f8cb3c26c 100644
--- a/drivers/iio/magnetometer/yamaha-yas530.c
+++ b/drivers/iio/magnetometer/yamaha-yas530.c
@@ -32,13 +32,14 @@
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/random.h>
-#include <linux/unaligned/be_byteshift.h>
#include <linux/iio/buffer.h>
#include <linux/iio/iio.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h>
+#include <asm/unaligned.h>
+
/* This register map covers YAS530 and YAS532 but differs in YAS 537 and YAS539 */
#define YAS5XX_DEVICE_ID 0x80
#define YAS5XX_ACTUATE_INIT_COIL 0x81
--
2.31.1