drm/imx: ignore plane updates on disabled crtcs
Subsystems (13)
Sasha Levin
maintainerPATCH 1/27 drm/imx: ignore plane updates on disabled crtcs
From: Philipp Zabel <[email protected]>
[ Upstream commit 4fb873c9648e383206e0a91cef9b03aa54066aca ]
This patch fixes backtraces like the following when sending SIGKILL to a process with a currently pending plane update:
[drm:ipu_plane_atomic_check] CRTC should be enabled
[drm:drm_framebuffer_remove] *ERROR* failed to commit
------------[ cut here ]------------
WARNING: CPU: 3 PID: 63 at drivers/gpu/drm/drm_framebuffer.c:926 drm_framebuffer_remove+0x47c/0x498 atomic remove_fb failed with -22
--- drivers/gpu/drm/imx/ipuv3-plane.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/imx/ipuv3-plane.c +2 -2
@@ -348,9 +348,9 @@ static int ipu_plane_atomic_check(struct drm_plane *plane,if (ret)return ret; -/* CRTC should be enabled */ +/* nothing to check when disabling or disabled */ if (!crtc_state->enable) -return -EINVAL ; +return 0 ;switch (plane->type) {case DRM_PLANE_TYPE_PRIMARY :
Signature · 6 lines
2.19.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 2/27 gpu: ipu-v3: Fix i.MX51 CSI control registers offset
From: Alexander Shiyan <[email protected]>
[ Upstream commit 2c0408dd0d8906b26fe8023889af7adf5e68b2c2 ]
The CSI0/CSI1 registers offset is at +0xe030000/+0xe038000 relative to the control module registers on IPUv3EX.
This patch fixes wrong values for i.MX51 CSI0/CSI1.
--- drivers/gpu/ipu-v3/ipu-common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/ipu-v3/ipu-common.c +2 -2
@@ -894,8 +894,8 @@ static struct ipu_devtype ipu_type_imx51 = { .cpmem_ofs = 0x1f000000, .srm_ofs = 0x1f040000, .tpm_ofs = 0x1f060000, - .csi0_ofs = 0x1f030000, - .csi1_ofs = 0x1f038000, + .csi0_ofs = 0x1e030000, + .csi1_ofs = 0x1e038000, .ic_ofs = 0x1e020000, .disp0_ofs = 0x1e040000, .disp1_ofs = 0x1e048000,
Signature · 6 lines
2.19.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 3/27 drm/imx: imx-ldb: add missing of_node_puts
In reply to Sasha LevinFrom: Julia Lawall <[email protected]>
[ Upstream commit aa3312012f103f91f123600bbf768b11c8f431bc ]
The device node iterators perform an of_node_get on each iteration, so a jump out of the loop requires an of_node_put.
Move the initialization channel->child = child; down to just before the call to imx_ldb_register so that intervening failures don't need to clear it. Add a label at the end of the function to do all the of_node_puts.
The semantic patch that finds part of this problem is as follows
(http://coccinelle.lip6.fr):
// <smpl>
@@
expression root,e;
local idexpression child;
iterator name for_each_child_of_node;
@@
for_each_child_of_node(root, child) {
... when != of_node_put(child)
when != e = child
(
return child;
|
* return ...;
)
...
}
// </smpl>
--- drivers/gpu/drm/imx/imx-ldb.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
drivers/gpu/drm/imx/imx-ldb.c +17 -8
@@ -652,8 +652,10 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)int bus_format; ret =of_property_read_u32 (child,"reg" , &i); -if (ret || i <0 || i >1 ) -return -EINVAL ; +if (ret || i <0 || i >1 ) { + ret = -EINVAL ; + goto free_child; + }if (!of_device_is_available (child))continue ;
@@ -666,7 +668,6 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data) channel = &imx_ldb->channel[i]; channel->ldb = imx_ldb; channel->chno = i; - channel->child = child;/* * The output port is port@4 with an external 4-port mux or
@@ -676,13 +677,13 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data) imx_ldb->lvds_mux ?4 :2 ,0 , &channel->panel, &channel->bridge);if (ret && ret != -ENODEV ) -return ret; + goto free_child;/* panel ddc only if there is no bridge */ if (!channel->bridge) { ret =imx_ldb_panel_ddc (dev, channel, child);if (ret) -return ret; + goto free_child; } bus_format =of_get_bus_format (dev, child);
@@ -698,18 +699,26 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)if (bus_format <0 ) {dev_err (dev,"could not determine data mapping: %d\n" , bus_format); -return bus_format; + ret = bus_format; + goto free_child; } channel->bus_format = bus_format; + channel->child = child; ret =imx_ldb_register (drm, channel); -if (ret) -return ret; +if (ret) { + channel->child =NULL ; + goto free_child; + } }dev_set_drvdata (dev, imx_ldb);return 0 ; + +free_child: +of_node_put (child); +return ret; } static void imx_ldb_unbind(struct device *dev, struct device *master,
Signature · 6 lines
2.19.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 4/27 gpu: ipu-v3: Fix CSI offsets for imx53
In reply to Sasha LevinFrom: Steve Longerbeam <[email protected]>
[ Upstream commit bb867d219fda7fbaabea3314702474c4eac2b91d ]
The CSI offsets are wrong for both CSI0 and CSI1. They are at physical address 0x1e030000 and 0x1e038000 respectively.
--- drivers/gpu/ipu-v3/ipu-common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/ipu-v3/ipu-common.c +2 -2
@@ -910,8 +910,8 @@ static struct ipu_devtype ipu_type_imx53 = { .cpmem_ofs = 0x07000000, .srm_ofs = 0x07040000, .tpm_ofs = 0x07060000, - .csi0_ofs = 0x07030000, - .csi1_ofs = 0x07038000, + .csi0_ofs = 0x06030000, + .csi1_ofs = 0x06038000, .ic_ofs = 0x06020000, .disp0_ofs = 0x06040000, .disp1_ofs = 0x06048000,
Signature · 6 lines
2.19.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 5/27 s390/dasd: fix using offset into zero size array error
In reply to Sasha LevinFrom: Stefan Haberland <[email protected]>
[ Upstream commit 4a8ef6999bce998fa5813023a9a6b56eea329dba ]
Dan Carpenter reported the following:
The patch 52898025cf7d: "[S390] dasd: security and PSF update patch for EMC CKD ioctl" from Mar 8, 2010, leads to the following static checker warning:
drivers/s390/block/dasd_eckd.c:4486 dasd_symm_io() error: using offset into zero size array 'psf_data[]'
drivers/s390/block/dasd_eckd.c
4458 /* Copy parms from caller */
4459 rc = -EFAULT;
4460 if (copy_from_user(&usrparm, argp, sizeof(usrparm)))
^^^^^^^The user can specify any "usrparm.psf_data_len". They choose zero by mistake.
4461 goto out;
4462 if (is_compat_task()) {
4463 /* Make sure pointers are sane even on 31 bit. */ 4464 rc = -EINVAL; 4465 if ((usrparm.psf_data >> 32) != 0) 4466 goto out; 4467 if ((usrparm.rssd_result >> 32) != 0) 4468 goto out; 4469 usrparm.psf_data &= 0x7fffffffULL; 4470 usrparm.rssd_result &= 0x7fffffffULL; 4471 } 4472 /* alloc I/O data area */ 4473 psf_data = kzalloc(usrparm.psf_data_len, GFP_KERNEL | GFP_DMA); 4474 rssd_result = kzalloc(usrparm.rssd_result_len, GFP_KERNEL | GFP_DMA);
4475 if (!psf_data || !rssd_result) {
kzalloc() returns a ZERO_SIZE_PTR (0x16).
4476 rc = -ENOMEM; 4477 goto out_free; 4478 } 4479 4480 /* get syscall header from user space */ 4481 rc = -EFAULT; 4482 if (copy_from_user(psf_data, 4483 (void __user *)(unsigned long) usrparm.psf_data, 4484 usrparm.psf_data_len))
That all works great.
4485 goto out_free; 4486 psf0 = psf_data[0]; 4487 psf1 = psf_data[1];
But now we're assuming that "->psf_data_len" was at least 2 bytes.
Fix this by checking the user specified length psf_data_len.
--- drivers/s390/block/dasd_eckd.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/s390/block/dasd_eckd.c +8 -0
@@ -4463,6 +4463,14 @@ static int dasd_symm_io(struct dasd_device *device, void __user *argp) usrparm.psf_data &=0x7fffffffULL ; usrparm.rssd_result &=0x7fffffffULL ; } +/* at least 2 bytes are accessed and should be allocated */ +if (usrparm.psf_data_len <2 ) { +DBF_DEV_EVENT (DBF_WARNING , device, +"Symmetrix ioctl invalid data length %d" , + usrparm.psf_data_len); + rc = -EINVAL ; + goto out; + }/* alloc I/O data area */ psf_data =kzalloc (usrparm.psf_data_len,GFP_KERNEL |GFP_DMA ); rssd_result =kzalloc (usrparm.rssd_result_len,GFP_KERNEL |GFP_DMA );
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 6/27 Input: pwm-vibra - prevent unbalanced regulator
In reply to Sasha LevinFrom: Jonathan Bakker <[email protected]>
[ Upstream commit 3ca232df9921f083c3b37ba5fbc76f4d9046268b ]
pwm_vibrator_stop disables the regulator, but it can be called from multiple places, even when the regulator is already disabled. Fix this by using regulator_is_enabled check when starting and stopping device.
--- drivers/input/misc/pwm-vibra.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/input/misc/pwm-vibra.c +12 -5
@@ -34,6 +34,7 @@ struct pwm_vibrator {struct work_struct play_work;u16 level;u32 direction_duty_cycle; +bool vcc_on; };static int pwm_vibrator_start (struct pwm_vibrator *vibrator)
@@ -42,10 +43,13 @@ static int pwm_vibrator_start(struct pwm_vibrator *vibrator)struct pwm_state state;int err; - err =regulator_enable (vibrator->vcc); -if (err) { -dev_err (pdev,"failed to enable regulator: %d" , err); -return err; +if (!vibrator->vcc_on) { + err =regulator_enable (vibrator->vcc); +if (err) { +dev_err (pdev,"failed to enable regulator: %d" , err); +return err; + } + vibrator->vcc_on = true; }pwm_get_state (vibrator->pwm, &state);
@@ -76,7 +80,10 @@ static int pwm_vibrator_start(struct pwm_vibrator *vibrator)static void pwm_vibrator_stop (struct pwm_vibrator *vibrator) { -regulator_disable (vibrator->vcc); +if (vibrator->vcc_on) { +regulator_disable (vibrator->vcc); + vibrator->vcc_on = false; + }if (vibrator->pwm_dir)pwm_disable (vibrator->pwm_dir);
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 7/27 Input: pwm-vibra - stop regulator after disabling pwm, not before
In reply to Sasha LevinFrom: Paweł Chmiel <[email protected]>
[ Upstream commit 94803aef3533676194c772383472636c453e3147 ]
This patch fixes order of disable calls in pwm_vibrator_stop. Currently when starting device, we first enable vcc regulator and then setup and enable pwm. When stopping, we should do this in oposite order, so first disable pwm and then disable regulator.
Previously order was the same as in start.
--- drivers/input/misc/pwm-vibra.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/input/misc/pwm-vibra.c +4 -4
@@ -80,14 +80,14 @@ static int pwm_vibrator_start(struct pwm_vibrator *vibrator)static void pwm_vibrator_stop (struct pwm_vibrator *vibrator) { +if (vibrator->pwm_dir) +pwm_disable (vibrator->pwm_dir); +pwm_disable (vibrator->pwm); +if (vibrator->vcc_on) {regulator_disable (vibrator->vcc); vibrator->vcc_on = false; } - -if (vibrator->pwm_dir) -pwm_disable (vibrator->pwm_dir); -pwm_disable (vibrator->pwm); }static void pwm_vibrator_play_work (struct work_struct *work)
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 8/27 ARM: OMAP2+: Variable "reg" in function omap4_dsi_mux_pads() could be uninitialized
In reply to Sasha LevinFrom: Yizhuo <[email protected]>
[ Upstream commit dc30e70391376ba3987aeb856ae6d9c0706534f1 ]
In function omap4_dsi_mux_pads(), local variable "reg" could be uninitialized if function regmap_read() returns -EINVAL. However, it will be used directly in the later context, which is potentially unsafe.
--- arch/arm/mach-omap2/display.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/arm/mach-omap2/display.c +6 -1
@@ -84,6 +84,7 @@ static int omap4_dsi_mux_pads(int dsi_id, unsigned lanes)u32 enable_mask, enable_shift;u32 pipd_mask, pipd_shift;u32 reg; +int ret;if (dsi_id ==0 ) { enable_mask =OMAP4_DSI1_LANEENABLE_MASK ;
@@ -99,7 +100,11 @@ static int omap4_dsi_mux_pads(int dsi_id, unsigned lanes)return -ENODEV ; } -regmap_read (omap4_dsi_mux_syscon,OMAP4_DSIPHY_SYSCON_OFFSET , ®); + ret =regmap_read (omap4_dsi_mux_syscon, +OMAP4_DSIPHY_SYSCON_OFFSET , + ®); +if (ret) +return ret; reg &= ~enable_mask; reg &= ~pipd_mask;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 9/27 ASoC: dapm: fix out-of-bounds accesses to DAPM lookup tables
In reply to Sasha LevinFrom: Pierre-Louis Bossart <[email protected]>
[ Upstream commit c16e12010060c6c7a31f08b4a99513064cb53b7d ]
KASAN reports and additional traces point to out-of-bounds accesses to the dapm_up_seq and dapm_down_seq lookup tables. The indices used are larger than the array definition.
Fix by adding missing entries for the new widget types in these two lookup tables, and align them with PGA values.
Also the sequences for the following widgets were not defined. Since their values defaulted to zero, assign them explicitly
snd_soc_dapm_input
snd_soc_dapm_output
snd_soc_dapm_vmid
snd_soc_dapm_siggen
snd_soc_dapm_sink
--- sound/soc/soc-dapm.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
sound/soc/soc-dapm.c +24 -0
@@ -75,12 +75,16 @@ static int dapm_up_seq[] = { [snd_soc_dapm_clock_supply] = 1, [snd_soc_dapm_supply] = 2, [snd_soc_dapm_micbias] = 3, + [snd_soc_dapm_vmid] = 3, [snd_soc_dapm_dai_link] = 2, [snd_soc_dapm_dai_in] = 4, [snd_soc_dapm_dai_out] = 4, [snd_soc_dapm_aif_in] = 4, [snd_soc_dapm_aif_out] = 4, [snd_soc_dapm_mic] = 5, + [snd_soc_dapm_siggen] = 5, + [snd_soc_dapm_input] = 5, + [snd_soc_dapm_output] = 5, [snd_soc_dapm_mux] = 6, [snd_soc_dapm_demux] = 6, [snd_soc_dapm_dac] = 7,
@@ -88,11 +92,19 @@ static int dapm_up_seq[] = { [snd_soc_dapm_mixer] = 8, [snd_soc_dapm_mixer_named_ctl] = 8, [snd_soc_dapm_pga] = 9, + [snd_soc_dapm_buffer] = 9, + [snd_soc_dapm_scheduler] = 9, + [snd_soc_dapm_effect] = 9, + [snd_soc_dapm_src] = 9, + [snd_soc_dapm_asrc] = 9, + [snd_soc_dapm_encoder] = 9, + [snd_soc_dapm_decoder] = 9, [snd_soc_dapm_adc] = 10, [snd_soc_dapm_out_drv] = 11, [snd_soc_dapm_hp] = 11, [snd_soc_dapm_spk] = 11, [snd_soc_dapm_line] = 11, + [snd_soc_dapm_sink] = 11, [snd_soc_dapm_kcontrol] = 12, [snd_soc_dapm_post] = 13, };
@@ -105,13 +117,25 @@ static int dapm_down_seq[] = { [snd_soc_dapm_spk] = 3, [snd_soc_dapm_line] = 3, [snd_soc_dapm_out_drv] = 3, + [snd_soc_dapm_sink] = 3, [snd_soc_dapm_pga] = 4, + [snd_soc_dapm_buffer] = 4, + [snd_soc_dapm_scheduler] = 4, + [snd_soc_dapm_effect] = 4, + [snd_soc_dapm_src] = 4, + [snd_soc_dapm_asrc] = 4, + [snd_soc_dapm_encoder] = 4, + [snd_soc_dapm_decoder] = 4, [snd_soc_dapm_switch] = 5, [snd_soc_dapm_mixer_named_ctl] = 5, [snd_soc_dapm_mixer] = 5, [snd_soc_dapm_dac] = 6, [snd_soc_dapm_mic] = 7, + [snd_soc_dapm_siggen] = 7, + [snd_soc_dapm_input] = 7, + [snd_soc_dapm_output] = 7, [snd_soc_dapm_micbias] = 8, + [snd_soc_dapm_vmid] = 8, [snd_soc_dapm_mux] = 9, [snd_soc_dapm_demux] = 9, [snd_soc_dapm_aif_in] = 10,
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 10/27 ASoC: rsnd: fixup rsnd_ssi_master_clk_start() user count check
In reply to Sasha LevinFrom: Kuninori Morimoto <[email protected]>
[ Upstream commit d9111d36024de07784f2e1ba2ccf70b16035f378 ]
commit 4d230d1271064 ("ASoC: rsnd: fixup not to call clk_get/set under non-atomic") added new rsnd_ssi_prepare() and moved rsnd_ssi_master_clk_start() to .prepare.
But, ssi user count (= ssi->usrcnt) is incremented at .init (= rsnd_ssi_init()).
Because of these timing exchange, ssi->usrcnt check at rsnd_ssi_master_clk_start() should be adjusted. Otherwise, 2nd master clock setup will be no check. This patch fixup this issue.
--- sound/soc/sh/rcar/ssi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/sh/rcar/ssi.c +1 -1
@@ -280,7 +280,7 @@ static int rsnd_ssi_master_clk_start(struct rsnd_mod *mod,if (rsnd_ssi_is_multi_slave (mod, io))return 0 ; -if (ssi->usrcnt >1 ) { +if (ssi->usrcnt >0 ) {if (ssi->rate != rate) {dev_err (dev,"SSI parent/child should use same rate\n" );return -EINVAL ;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 11/27 KVM: arm/arm64: Reset the VCPU without preemption and vcpu state loaded
In reply to Sasha LevinFrom: Christoffer Dall <[email protected]>
[ Upstream commit e761a927bc9a7ee6ceb7c4f63d5922dbced87f0d ]
We have two ways to reset a vcpu:
- either through VCPU_INIT
- or through a PSCI_ON call
The first one is easy to reason about. The second one is implemented in a more bizarre way, as it is the vcpu that handles PSCI_ON that resets the vcpu that is being powered-on. As we need to turn the logic around and have the target vcpu to reset itself, we must take some preliminary steps.
Resetting the VCPU state modifies the system register state in memory, but this may interact with vcpu_load/vcpu_put if running with preemption disabled, which in turn may lead to corrupted system register state.
Address this by disabling preemption and doing put/load if required around the reset logic.
--- arch/arm64/kvm/reset.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)
arch/arm64/kvm/reset.c +24 -2
@@ -95,16 +95,33 @@ int kvm_arch_dev_ioctl_check_extension(struct kvm *kvm, long ext)* This function finds the right table above and sets the registers on * the virtual CPU struct to their architecturally defined reset * values. +* +* Note: This function can be called from two paths: The KVM_ARM_VCPU_INIT +* ioctl or as part of handling a request issued by another VCPU in the PSCI +* handling code. In the first case, the VCPU will not be loaded, and in the +* second case the VCPU will be loaded. Because this function operates purely +* on the memory-backed valus of system registers, we want to do a full put if +* we were loaded (handling a request) and load the values back at the end of +* the function. Otherwise we leave the state alone. In both cases, we +* disable preemption around the vcpu reset as we would otherwise race with +* preempt notifiers which also call put/load. */ int kvm_reset_vcpu (struct kvm_vcpu *vcpu) {const struct kvm_regs *cpu_reset; +int ret = -EINVAL ; +bool loaded; + +preempt_disable (); + loaded = (vcpu->cpu !=-1 ); +if (loaded) +kvm_arch_vcpu_put (vcpu);switch (vcpu->arch.target) {default :if (test_bit (KVM_ARM_VCPU_EL1_32BIT , vcpu->arch.features)) {if (!cpu_has_32bit_el1 ()) -return -EINVAL ; + goto out; cpu_reset = &default_regs_reset32; }else { cpu_reset = &default_regs_reset;
@@ -127,5 +144,10 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu) vcpu->arch.workaround_flags |=VCPU_WORKAROUND_2_FLAG ;/* Reset timer */ -return kvm_timer_vcpu_reset (vcpu); + ret =kvm_timer_vcpu_reset (vcpu); +out: +if (loaded) +kvm_arch_vcpu_load (vcpu,smp_processor_id ()); +preempt_enable (); +return ret; }
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 12/27 ARM: OMAP2+: fix lack of timer interrupts on CPU1 after hotplug
In reply to Sasha LevinFrom: Russell King <[email protected]>
[ Upstream commit 50d6b3cf9403879911e06d69c7ef41e43f8f7b4b ]
If we have a kernel configured for periodic timer interrupts, and we have cpuidle enabled, then we end up with CPU1 losing timer interupts after a hotplug.
This can manifest itself in RCU stall warnings, or userspace becoming unresponsive.
The problem is that the kernel initially wants to use the TWD timer for interrupts, but the TWD loses context when we enter the C3 cpuidle state. Nothing reprograms the TWD after idle.
We have solved this in the past by switching to broadcast timer ticks, and cpuidle44xx switches to that mode at boot time. However, there is nothing to switch from periodic mode local timers after a hotplug operation.
We call tick_broadcast_enter() in omap_enter_idle_coupled(), which one would expect would take care of the issue, but internally this only deals with one-shot local timers - tick_broadcast_enable() on the other hand only deals with periodic local timers. So, we need to call both.
--- arch/arm/mach-omap2/cpuidle44xx.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
arch/arm/mach-omap2/cpuidle44xx.c +4 -12
@@ -152,6 +152,10 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev, mpuss_can_lose_context = (cx->mpu_state ==PWRDM_POWER_RET ) && (cx->mpu_logic_state ==PWRDM_POWER_OFF ); +/* Enter broadcast mode for periodic timers */ +tick_broadcast_enable (); + +/* Enter broadcast mode for one-shot timers */ tick_broadcast_enter ();/*
@@ -218,15 +222,6 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev,return index; } -/* -* For each cpu, setup the broadcast timer because local timers -* stops for the states above C1. -*/ -static void omap_setup_broadcast_timer (void *arg) -{ -tick_broadcast_enable (); -} -static struct cpuidle_driver omap4_idle_driver = { .name ="omap4_idle" , .owner =THIS_MODULE ,
@@ -319,8 +314,5 @@ int __init omap4_idle_init(void)if (!cpu_clkdm[0 ] || !cpu_clkdm[1 ])return -ENODEV ; -/* Configure the broadcast timer on each cpu */ -on_each_cpu (omap_setup_broadcast_timer,NULL ,1 ); -return cpuidle_register (idle_driver, cpu_online_mask); }
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 13/27 Input: cap11xx - switch to using set_brightness_blocking()
In reply to Sasha LevinFrom: Dmitry Torokhov <[email protected]>
[ Upstream commit 628442880af8c201d307a45f3862a7a17df8a189 ]
Updating LED state requires access to regmap and therefore we may sleep, so we could not do that directly form set_brightness() method. Historically we used private work to adjust the brightness, but with the introduction of set_brightness_blocking() we no longer need it.
As a bonus, not having our own work item means we do not have use-after-free issue as we neglected to cancel outstanding work on driver unbind.
--- drivers/input/keyboard/cap11xx.c | 35 ++++++++++---------------------- 1 file changed, 11 insertions(+), 24 deletions(-)
drivers/input/keyboard/cap11xx.c +11 -24
@@ -75,9 +75,7 @@struct cap11xx_led {struct cap11xx_priv *priv;struct led_classdev cdev; -struct work_struct work;u32 reg; -enum led_brightness new_brightness; };#endif
@@ -233,30 +231,21 @@ static void cap11xx_input_close(struct input_dev *idev) }#ifdef CONFIG_LEDS_CLASS -static void cap11xx_led_work (struct work_struct *work) +static int cap11xx_led_set (struct led_classdev *cdev, +enum led_brightness value) { - struct cap11xx_led *led = container_of(work, struct cap11xx_led, work); + struct cap11xx_led *led = container_of(cdev, struct cap11xx_led, cdev);struct cap11xx_priv *priv = led->priv; -int value = led->new_brightness;/* -* All LEDs share the same duty cycle as this is a HW limitation. -* Brightness levels per LED are either 0 (OFF) and 1 (ON). +* All LEDs share the same duty cycle as this is a HW +* limitation. Brightness levels per LED are either +* 0 (OFF) and 1 (ON). */ -regmap_update_bits (priv->regmap,CAP11XX_REG_LED_OUTPUT_CONTROL , -BIT (led->reg), value ?BIT (led->reg) :0 ); -} - -static void cap11xx_led_set (struct led_classdev *cdev, -enum led_brightness value) -{ - struct cap11xx_led *led = container_of(cdev, struct cap11xx_led, cdev); - -if (led->new_brightness == value) -return ; - - led->new_brightness = value; -schedule_work (&led->work); +return regmap_update_bits (priv->regmap, +CAP11XX_REG_LED_OUTPUT_CONTROL , +BIT (led->reg), + value ?BIT (led->reg) :0 ); } static int cap11xx_init_leds(struct device *dev,
@@ -299,7 +288,7 @@ static int cap11xx_init_leds(struct device *dev, led->cdev.default_trigger =of_get_property (child,"linux,default-trigger" ,NULL ); led->cdev.flags =0 ; - led->cdev.brightness_set = cap11xx_led_set; + led->cdev.brightness_set_blocking = cap11xx_led_set; led->cdev.max_brightness =1 ; led->cdev.brightness =LED_OFF ;
@@ -312,8 +301,6 @@ static int cap11xx_init_leds(struct device *dev, led->reg = reg; led->priv = priv; -INIT_WORK (&led->work, cap11xx_led_work); - error =devm_led_classdev_register (dev, &led->cdev);if (error) {of_node_put (child);
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 14/27 Input: ps2-gpio - flush TX work when closing port
In reply to Sasha LevinFrom: Dmitry Torokhov <[email protected]>
[ Upstream commit 33a841ce5cef4ca6c18ad333248b6d273f54c839 ]
To ensure that TX work is not running after serio port has been torn down, let's flush it when closing the port.
--- drivers/input/serio/ps2-gpio.c | 1 + 1 file changed, 1 insertion(+)
drivers/input/serio/ps2-gpio.c +1 -0
@@ -76,6 +76,7 @@ static void ps2_gpio_close(struct serio *serio) {struct ps2_gpio_data *drvdata = serio->port_data; +flush_delayed_work (&drvdata->tx_work);disable_irq (drvdata->irq); }
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 15/27 Input: matrix_keypad - use flush_delayed_work()
In reply to Sasha LevinFrom: Dmitry Torokhov <[email protected]>
[ Upstream commit a342083abe576db43594a32d458a61fa81f7cb32 ]
We should be using flush_delayed_work() instead of flush_work() in matrix_keypad_stop() to ensure that we are not missing work that is scheduled but not yet put in the workqueue (i.e. its delay timer has not expired yet).
--- drivers/input/keyboard/matrix_keypad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/keyboard/matrix_keypad.c +1 -1
@@ -222,7 +222,7 @@ static void matrix_keypad_stop(struct input_dev *dev) keypad->stopped = true;spin_unlock_irq (&keypad->lock); -flush_work (&keypad->work.work); +flush_delayed_work (&keypad->work);/* * matrix_keypad_scan() will leave IRQs enabled; * we should disable them now.
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 16/27 mac80211: Fix Tx aggregation session tear down with ITXQs
In reply to Sasha LevinFrom: Ilan Peer <[email protected]>
[ Upstream commit 6157ca0d6bfe437691b1e98a62e2efe12b6714da ]
When mac80211 requests the low level driver to stop an ongoing Tx aggregation, the low level driver is expected to call ieee80211_stop_tx_ba_cb_irqsafe() to indicate that it is ready to stop the session. The callback in turn schedules a worker to complete the session tear down, which in turn also handles the relevant state for the intermediate Tx queue.
However, as this flow in asynchronous, the intermediate queue should be stopped and not continue servicing frames, as in such a case frames that are dequeued would be marked as part of an aggregation, although the aggregation is already been stopped.
Fix this by stopping the intermediate Tx queue, before calling the low level driver to stop the Tx aggregation.
--- net/mac80211/agg-tx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/mac80211/agg-tx.c +3 -1
@@ -8,7 +8,7 @@* Copyright 2007, Michael Wu <[email protected]> * Copyright 2007-2010, Intel Corporation * Copyright(c) 2015-2017 Intel Deutschland GmbH -* Copyright (C) 2018 Intel Corporation +* Copyright (C) 2018 - 2019 Intel Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
@@ -361,6 +361,8 @@ int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,set_bit (HT_AGG_STATE_STOPPING , &tid_tx->state); +ieee80211_agg_stop_txq (sta, tid); +spin_unlock_bh (&sta->lock); ht_dbg(sta->sdata, "Tx BA session stop requested for %pM tid %u\n",
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 17/27 ipvs: fix dependency on nf_defrag_ipv6
In reply to Sasha LevinFrom: Andrea Claudi <[email protected]>
[ Upstream commit 098e13f5b21d3398065fce8780f07a3ef62f4812 ]
ipvs relies on nf_defrag_ipv6 module to manage IPv6 fragmentation, but lacks proper Kconfig dependencies and does not explicitly request defrag features.
As a result, if netfilter hooks are not loaded, when IPv6 fragmented packet are handled by ipvs only the first fragment makes through.
Fix it properly declaring the dependency on Kconfig and registering netfilter hooks on ip_vs_add_service() and ip_vs_new_dest().
--- net/netfilter/ipvs/Kconfig | 1 + net/netfilter/ipvs/ip_vs_core.c | 10 ++++------ net/netfilter/ipvs/ip_vs_ctl.c | 10 ++++++++++ 3 files changed, 15 insertions(+), 6 deletions(-)
net/netfilter/ipvs/Kconfig +1 -0
@@ -29,6 +29,7 @@ config IP_VS_IPV6 bool "IPv6 support for IPVS" depends on IPV6 = y || IP_VS = IPV6 select IP6_NF_IPTABLES + select NF_DEFRAG_IPV6 ---help--- Add IPv6 support to IPVS.
net/netfilter/ipvs/ip_vs_core.c +4 -6
@@ -1524,14 +1524,12 @@ ip_vs_try_to_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,/* sorry, all this trouble for a no-hit :) */ IP_VS_DBG_PKT (12 , af, pp, skb, iph->off,"ip_vs_in: packet continues traversal as normal" ); -if (iph->fragoffs) { -/* Fragment that couldn't be mapped to a conn entry -* is missing module nf_defrag_ipv6 -*/ -IP_VS_DBG_RL ("Unhandled frag, load nf_defrag_ipv6\n" ); + +/* Fragment couldn't be mapped to a conn entry */ +if (iph->fragoffs)IP_VS_DBG_PKT (7 , af, pp, skb, iph->off,"unhandled fragment" ); - } + *verdict =NF_ACCEPT ;return 0 ; }
net/netfilter/ipvs/ip_vs_ctl.c +10 -0
@@ -43,6 +43,7 @@#ifdef CONFIG_IP_VS_IPV6 #include <net/ipv6.h> #include <net/ip6_route.h> +#include <net/netfilter/ipv6/nf_defrag_ipv6.h> #endif #include <net/route.h> #include <net/sock.h>
@@ -888,6 +889,7 @@ ip_vs_new_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest, {struct ip_vs_dest *dest;unsigned int atype, i; +int ret =0 ;EnterFunction (2 );
@@ -898,6 +900,10 @@ ip_vs_new_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest, atype & IPV6_ADDR_LINKLOCAL) && !__ip_vs_addr_is_local_v6(svc->ipvs->net, &udest->addr.in6)) return -EINVAL; + + ret =nf_defrag_ipv6_enable (svc->ipvs->net); +if (ret) +return ret; } else#endif {
@@ -1221,6 +1227,10 @@ ip_vs_add_service(struct netns_ipvs *ipvs, struct ip_vs_service_user_kern *u, ret = -EINVAL ; goto out_err; } + + ret =nf_defrag_ipv6_enable (ipvs->net); +if (ret) + goto out_err; }#endif
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 18/27 floppy: check_events callback should not return a negative number
In reply to Sasha LevinFrom: Yufen Yu <[email protected]>
[ Upstream commit 96d7cb932e826219ec41ac02e5af037ffae6098c ]
floppy_check_events() is supposed to return bit flags to say which events occured. We should return zero to say that no event flags are set. Only BIT(0) and BIT(1) are used in the caller. And .check_events interface also expect to return an unsigned int value.
However, after commit a0c80efe5956, it may return -EINTR (-4u). Here, both BIT(0) and BIT(1) are cleared. So this patch shouldn't affect runtime, but it obviously is still worth fixing.
--- drivers/block/floppy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/floppy.c +1 -1
@@ -4079,7 +4079,7 @@ static unsigned int floppy_check_events(struct gendisk *disk,if (time_after (jiffies,UDRS ->last_checked +UDP ->checkfreq)) {if (lock_fdc (drive)) -return -EINTR ; +return 0 ;poll_drive (false,0 );process_fd_request (); }
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 19/27 NFS: Don't use page_file_mapping after removing the page
In reply to Sasha LevinFrom: Benjamin Coddington <[email protected]>
[ Upstream commit d2ceb7e57086750ea6198a31fd942d98099a0786 ]
If nfs_page_async_flush() removes the page from the mapping, then we can't use page_file_mapping() on it as nfs_updatepate() is wont to do when receiving an error. Instead, push the mapping to the stack before the page is possibly truncated.
--- fs/nfs/write.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
fs/nfs/write.c +6 -5
@@ -236,9 +236,9 @@ static void nfs_grow_file(struct page *page, unsigned int offset, unsigned int c }/* A writeback failed: mark the page as bad, and invalidate the page cache */ -static void nfs_set_pageerror (struct page *page) +static void nfs_set_pageerror (struct address_space *mapping) { -nfs_zap_mapping (page_file_mapping (page)->host,page_file_mapping (page)); +nfs_zap_mapping (mapping->host, mapping); }/*
@@ -994,7 +994,7 @@ static void nfs_write_completion(struct nfs_pgio_header *hdr)nfs_list_remove_request (req);if (test_bit (NFS_IOHDR_ERROR , &hdr->flags) && (hdr->good_bytes < bytes)) { -nfs_set_pageerror (req->wb_page); +nfs_set_pageerror (page_file_mapping (req->wb_page));nfs_context_set_write_error (req->wb_context, hdr->error); goto remove_req; }
@@ -1330,7 +1330,8 @@ int nfs_updatepage(struct file *file, struct page *page, unsigned int offset, unsigned int count) {struct nfs_open_context *ctx =nfs_file_open_context (file); -struct inode *inode =page_file_mapping (page)->host; +struct address_space *mapping =page_file_mapping (page); +struct inode *inode = mapping->host;int status =0 ;nfs_inc_stats (inode,NFSIOS_VFSUPDATEPAGE );
@@ -1348,7 +1349,7 @@ int nfs_updatepage(struct file *file, struct page *page, status =nfs_writepage_setup (ctx, page, offset, count);if (status <0 ) -nfs_set_pageerror (page); +nfs_set_pageerror (mapping);else __set_page_dirty_nobuffers (page); out:
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 20/27 mm/gup: fix gup_pmd_range() for dax
In reply to Sasha LevinFrom: Yu Zhao <[email protected]>
[ Upstream commit 414fd080d125408cb15d04ff4907e1dd8145c8c7 ]
For dax pmd, pmd_trans_huge() returns false but pmd_huge() returns true on x86. So the function works as long as hugetlb is configured. However, dax doesn't depend on hugetlb.
--- mm/gup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
mm/gup.c +2 -1
@@ -1643,7 +1643,8 @@ static int gup_pmd_range(pud_t pud, unsigned long addr, unsigned long end,if (!pmd_present (pmd))return 0 ; -if (unlikely (pmd_trans_huge (pmd) ||pmd_huge (pmd))) { +if (unlikely (pmd_trans_huge (pmd) ||pmd_huge (pmd) || +pmd_devmap (pmd))) {/* * NUMA hinting faults need to be handled in the GUP * slowpath for accounting purposes and so that they
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 21/27 Revert "mm: use early_pfn_to_nid in page_ext_init"
In reply to Sasha LevinFrom: Qian Cai <[email protected]>
[ Upstream commit 2f1ee0913ce58efe7f18fbd518bd54c598559b89 ]
This reverts commit fe53ca54270a ("mm: use early_pfn_to_nid in page_ext_init").
When booting a system with "page_owner=on",
start_kernel
page_ext_init
invoke_init_callbacks
init_section_page_ext
init_page_owner
init_early_allocated_pages
init_zones_in_node
init_pages_in_zone
lookup_page_ext
page_to_nid
The issue here is that page_to_nid() will not work since some page flags have no node information until later in page_alloc_init_late() due to DEFERRED_STRUCT_PAGE_INIT. Hence, it could trigger an out-of-bounds access with an invalid nid.
UBSAN: Undefined behaviour in ./include/linux/mm.h:1104:50 index 7 is out of range for type 'zone [5]'
Also, kernel will panic since flags were poisoned earlier with,
CONFIG_DEBUG_VM_PGFLAGS=yCONFIG_NODE_NOT_IN_PAGE_FLAGS=n
start_kernel
setup_arch
pagetable_init
paging_init
sparse_init
sparse_init_nid
memblock_alloc_try_nid_raw
It did not handle it well in init_pages_in_zone() which ends up calling page_to_nid().
page:ffffea0004200000 is uninitialized and poisoned
raw: ffffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffff raw: ffffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffff page dumped because: VM_BUG_ON_PAGE(PagePoisoned(p)) page_owner info is not active (free page?) kernel BUG at include/linux/mm.h:990! RIP: 0010:init_page_owner+0x486/0x520
This means that assumptions behind commit fe53ca54270a ("mm: use early_pfn_to_nid in page_ext_init") are incomplete. Therefore, revert the commit for now. A proper way to move the page_owner initialization to sooner is to hook into memmap initialization.
--- init/main.c | 3 ++- mm/page_ext.c | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-)
init/main.c +2 -1
@@ -663,7 +663,6 @@ asmlinkage __visible void __init start_kernel(void) initrd_start = 0; }#endif -page_ext_init ();kmemleak_init ();debug_objects_mem_init ();setup_per_cpu_pageset ();
@@ -1069,6 +1068,8 @@ static noinline void __init kernel_init_freeable(void)sched_init_smp ();page_alloc_init_late (); +/* Initialize page ext after all struct pages are initialized. */ +page_ext_init ();do_basic_setup ();
mm/page_ext.c +1 -3
@@ -396,10 +396,8 @@ void __init page_ext_init(void)* We know some arch can have a nodes layout such as * -------------pfn--------------> * N0 | N1 | N2 | N0 | N1 | N2|.... -* -* Take into account DEFERRED_STRUCT_PAGE_INIT. */ -if (early_pfn_to_nid (pfn) != nid) +if (pfn_to_nid (pfn) != nid)continue ;if (init_section_page_ext (pfn, nid)) goto oom;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 22/27 mm: page_alloc: fix ref bias in page_frag_alloc() for 1-byte allocs
In reply to Sasha LevinFrom: Jann Horn <[email protected]>
[ Upstream commit 2c2ade81741c66082f8211f0b96cf509cc4c0218 ]
The basic idea behind ->pagecnt_bias is: If we pre-allocate the maximum number of references that we might need to create in the fastpath later, the bump-allocation fastpath only has to modify the non-atomic bias value that tracks the number of extra references we hold instead of the atomic refcount. The maximum number of allocations we can serve (under the assumption that no allocation is made with size 0) is nc->size, so that's the bias used.
However, even when all memory in the allocation has been given away, a reference to the page is still held; and in the offset < 0 slowpath, the page may be reused if everyone else has dropped their references. This means that the necessary number of references is actually nc->size+1.
Luckily, from a quick grep, it looks like the only path that can call page_frag_alloc(fragsz=1) is TAP with the IFF_NAPI_FRAGS flag, which requires CAP_NET_ADMIN in the init namespace and is only intended to be used for kernel testing and fuzzing.
To test for this issue, put a WARN_ON(page_ref_count(page) == 0) in the offset < 0 path, below the virt_to_page() call, and then repeatedly call writev() on a TAP device with IFF_TAP|IFF_NO_PI|IFF_NAPI_FRAGS|IFF_NAPI, with a vector consisting of 15 elements containing 1 byte each.
--- mm/page_alloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
mm/page_alloc.c +4 -4
@@ -4325,11 +4325,11 @@ void *page_frag_alloc(struct page_frag_cache *nc,/* Even if we own the page, we do not use atomic_set(). * This would break get_page_unless_zero() users. */ -page_ref_add (page, size -1 ); +page_ref_add (page, size);/* reset page count bias and offset to start of new frag */ nc->pfmemalloc =page_is_pfmemalloc (page); - nc->pagecnt_bias = size; + nc->pagecnt_bias = size +1 ; nc->offset = size; }
@@ -4345,10 +4345,10 @@ void *page_frag_alloc(struct page_frag_cache *nc, size = nc->size;#endif /* OK, page count is 0, we can safely set it */ -set_page_count (page, size); +set_page_count (page, size +1 );/* reset page count bias and offset to start of new frag */ - nc->pagecnt_bias = size; + nc->pagecnt_bias = size +1 ; offset = size - fragsz; }
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 23/27 net: hns: Fix object reference leaks in hns_dsaf_roce_reset()
In reply to Sasha LevinFrom: Huang Zijiang <[email protected]>
[ Upstream commit c969c6e7ab8cb42b5c787c567615474fdbad9d6a ]
The of_find_device_by_node() takes a reference to the underlying device structure, we should release that reference.
--- drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c +2 -0
@@ -3074,6 +3074,7 @@ int hns_dsaf_roce_reset(struct fwnode_handle *dsaf_fwnode, bool dereset) dsaf_dev =dev_get_drvdata (&pdev->dev);if (!dsaf_dev) {dev_err (&pdev->dev,"dsaf_dev is NULL\n" ); +put_device (&pdev->dev);return -ENODEV ; }
@@ -3081,6 +3082,7 @@ int hns_dsaf_roce_reset(struct fwnode_handle *dsaf_fwnode, bool dereset)if (AE_IS_VER1 (dsaf_dev->dsaf_ver)) {dev_err (dsaf_dev->dev,"%s v1 chip doesn't support RoCE!\n" , dsaf_dev->ae_dev.name); +put_device (&pdev->dev);return -ENODEV ; }
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 24/27 i2c: cadence: Fix the hold bit setting
In reply to Sasha LevinFrom: Shubhrajyoti Datta <[email protected]>
[ Upstream commit d358def706880defa4c9e87381c5bf086a97d5f9 ]
In case the hold bit is not needed we are carrying the old values. Fix the same by resetting the bit when not needed.
Fixes the sporadic i2c bus lockups on National Instruments Zynq-based devices.
--- drivers/i2c/busses/i2c-cadence.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-cadence.c +7 -2
@@ -382,8 +382,10 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id)* Check for the message size against FIFO depth and set the * 'hold bus' bit if it is greater than FIFO depth. */ -if (id->recv_count >CDNS_I2C_FIFO_DEPTH ) +if ((id->recv_count >CDNS_I2C_FIFO_DEPTH ) || id->bus_hold_flag) ctrl_reg |=CDNS_I2C_CR_HOLD ; +else + ctrl_reg = ctrl_reg & ~CDNS_I2C_CR_HOLD ;cdns_i2c_writereg (ctrl_reg,CDNS_I2C_CR_OFFSET );
@@ -440,8 +442,11 @@ static void cdns_i2c_msend(struct cdns_i2c *id)* Check for the message size against FIFO depth and set the * 'hold bus' bit if it is greater than FIFO depth. */ -if (id->send_count >CDNS_I2C_FIFO_DEPTH ) +if ((id->send_count >CDNS_I2C_FIFO_DEPTH ) || id->bus_hold_flag) ctrl_reg |=CDNS_I2C_CR_HOLD ; +else + ctrl_reg = ctrl_reg & ~CDNS_I2C_CR_HOLD ; +cdns_i2c_writereg (ctrl_reg,CDNS_I2C_CR_OFFSET );/* Clear the interrupts in interrupt status register. */
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 25/27 i2c: bcm2835: Clear current buffer pointers and counts after a transfer
In reply to Sasha LevinFrom: Paul Kocialkowski <[email protected]>
[ Upstream commit f275a4659484716259cc46268d9043424e51cf0f ]
The driver's interrupt handler checks whether a message is currently being handled with the curr_msg pointer. When it is NULL, the interrupt is considered to be unexpected. Similarly, the i2c_start_transfer routine checks for the remaining number of messages to handle in num_msgs.
However, these values are never cleared and always keep the message and number relevant to the latest transfer (which might be done already and the underlying message memory might have been freed).
When an unexpected interrupt hits with the DONE bit set, the isr will then try to access the flags field of the curr_msg structure, leading to a fatal page fault.
The msg_buf and msg_buf_remaining fields are also never cleared at the end of the transfer, which can lead to similar pitfalls.
Fix these issues by introducing a cleanup function and always calling it after a transfer is finished.
--- drivers/i2c/busses/i2c-bcm2835.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/i2c/busses/i2c-bcm2835.c +12 -0
@@ -191,6 +191,15 @@ static void bcm2835_i2c_start_transfer(struct bcm2835_i2c_dev *i2c_dev)bcm2835_i2c_writel (i2c_dev,BCM2835_I2C_C , c); } +static void bcm2835_i2c_finish_transfer (struct bcm2835_i2c_dev *i2c_dev) +{ + i2c_dev->curr_msg =NULL ; + i2c_dev->num_msgs =0 ; + + i2c_dev->msg_buf =NULL ; + i2c_dev->msg_buf_remaining =0 ; +} +/* * Note about I2C_C_CLEAR on error: * The I2C_C_CLEAR on errors will take some time to resolve -- if you were in
@@ -291,6 +300,9 @@ static int bcm2835_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], time_left =wait_for_completion_timeout (&i2c_dev->completion, adap->timeout); + +bcm2835_i2c_finish_transfer (i2c_dev); +if (!time_left) {bcm2835_i2c_writel (i2c_dev,BCM2835_I2C_C ,BCM2835_I2C_C_CLEAR );
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 26/27 auxdisplay: ht16k33: fix potential user-after-free on module unload
In reply to Sasha LevinFrom: Miguel Ojeda <[email protected]>
[ Upstream commit 69ef9bc54715fb1cb7786ada15774e469e822209 ]
On module unload/remove, we need to ensure that work does not run after we have freed resources. Concretely, cancel_delayed_work() may return while the callback function is still running.
From kernel/workqueue.c:
The work callback function may still be running on return, unless it returns true and the work doesn't re-arm itself. Explicitly flush or use cancel_delayed_work_sync() to wait on it.
--- drivers/auxdisplay/ht16k33.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/auxdisplay/ht16k33.c +1 -1
@@ -517,7 +517,7 @@ static int ht16k33_remove(struct i2c_client *client)struct ht16k33_priv *priv =i2c_get_clientdata (client);struct ht16k33_fbdev *fbdev = &priv->fbdev; -cancel_delayed_work (&fbdev->work); +cancel_delayed_work_sync (&fbdev->work);unregister_framebuffer (fbdev->info);framebuffer_release (fbdev->info);free_page ((unsigned long ) fbdev->buffer);
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 27/27 Input: st-keyscan - fix potential zalloc NULL dereference
In reply to Sasha LevinFrom: Gabriel Fernandez <[email protected]>
[ Upstream commit 2439d37e1bf8a34d437573c086572abe0f3f1b15 ]
This patch fixes the following static checker warning:
drivers/input/keyboard/st-keyscan.c:156 keyscan_probe()
error: potential zalloc NULL dereference: 'keypad_data->input_dev'
--- drivers/input/keyboard/st-keyscan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/input/keyboard/st-keyscan.c +2 -2
@@ -153,6 +153,8 @@ static int keyscan_probe(struct platform_device *pdev) input_dev->id.bustype =BUS_HOST ; + keypad_data->input_dev = input_dev; + error =keypad_matrix_key_parse_dt (keypad_data);if (error)return error;
@@ -168,8 +170,6 @@ static int keyscan_probe(struct platform_device *pdev)input_set_drvdata (input_dev, keypad_data); - keypad_data->input_dev = input_dev; - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); keypad_data->base =devm_ioremap_resource (&pdev->dev, res);if (IS_ERR (keypad_data->base))
Signature · 1 line
2.19.1