5.15.86-rc1 review
Subsystems (11)
Greg Kroah-Hartman
maintainerPATCH 123/731 x86/xen: Fix memory leak in xen_smp_intr_init{_pv}()
In reply to Greg Kroah-HartmanFrom: Xiu Jianfeng <[email protected]>
[ Upstream commit 69143f60868b3939ddc89289b29db593b647295e ]
These local variables @{resched|pmu|callfunc...}_name saves the new string allocated by kasprintf(), and when bind_{v}ipi_to_irqhandler() fails, it goes to the @fail tag, and calls xen_smp_intr_free{_pv}() to free resource, however the new string is not saved, which cause a memory leak issue. fix it.
--- arch/x86/xen/smp.c | 24 ++++++++++++------------ arch/x86/xen/smp_pv.c | 12 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-)
arch/x86/xen/smp.c +12 -12
@@ -32,30 +32,30 @@ static irqreturn_t xen_reschedule_interrupt(int irq, void *dev_id)void xen_smp_intr_free (unsigned int cpu) { +kfree (per_cpu (xen_resched_irq, cpu).name); +per_cpu (xen_resched_irq, cpu).name =NULL ;if (per_cpu (xen_resched_irq, cpu).irq >=0 ) {unbind_from_irqhandler (per_cpu (xen_resched_irq, cpu).irq,NULL );per_cpu (xen_resched_irq, cpu).irq =-1 ; -kfree (per_cpu (xen_resched_irq, cpu).name); -per_cpu (xen_resched_irq, cpu).name =NULL ; } +kfree (per_cpu (xen_callfunc_irq, cpu).name); +per_cpu (xen_callfunc_irq, cpu).name =NULL ;if (per_cpu (xen_callfunc_irq, cpu).irq >=0 ) {unbind_from_irqhandler (per_cpu (xen_callfunc_irq, cpu).irq,NULL );per_cpu (xen_callfunc_irq, cpu).irq =-1 ; -kfree (per_cpu (xen_callfunc_irq, cpu).name); -per_cpu (xen_callfunc_irq, cpu).name =NULL ; } +kfree (per_cpu (xen_debug_irq, cpu).name); +per_cpu (xen_debug_irq, cpu).name =NULL ;if (per_cpu (xen_debug_irq, cpu).irq >=0 ) {unbind_from_irqhandler (per_cpu (xen_debug_irq, cpu).irq,NULL );per_cpu (xen_debug_irq, cpu).irq =-1 ; -kfree (per_cpu (xen_debug_irq, cpu).name); -per_cpu (xen_debug_irq, cpu).name =NULL ; } +kfree (per_cpu (xen_callfuncsingle_irq, cpu).name); +per_cpu (xen_callfuncsingle_irq, cpu).name =NULL ;if (per_cpu (xen_callfuncsingle_irq, cpu).irq >=0 ) {unbind_from_irqhandler (per_cpu (xen_callfuncsingle_irq, cpu).irq,NULL );per_cpu (xen_callfuncsingle_irq, cpu).irq =-1 ; -kfree (per_cpu (xen_callfuncsingle_irq, cpu).name); -per_cpu (xen_callfuncsingle_irq, cpu).name =NULL ; } }
@@ -65,6 +65,7 @@ int xen_smp_intr_init(unsigned int cpu)char *resched_name, *callfunc_name, *debug_name; resched_name =kasprintf (GFP_KERNEL ,"resched%d" , cpu); +per_cpu (xen_resched_irq, cpu).name = resched_name; rc = bind_ipi_to_irqhandler(XEN_RESCHEDULE_VECTOR, cpu, xen_reschedule_interrupt,
@@ -74,9 +75,9 @@ int xen_smp_intr_init(unsigned int cpu)if (rc <0 ) goto fail;per_cpu (xen_resched_irq, cpu).irq = rc; -per_cpu (xen_resched_irq, cpu).name = resched_name; callfunc_name =kasprintf (GFP_KERNEL ,"callfunc%d" , cpu); +per_cpu (xen_callfunc_irq, cpu).name = callfunc_name; rc = bind_ipi_to_irqhandler(XEN_CALL_FUNCTION_VECTOR, cpu, xen_call_function_interrupt,
@@ -86,10 +87,10 @@ int xen_smp_intr_init(unsigned int cpu)if (rc <0 ) goto fail;per_cpu (xen_callfunc_irq, cpu).irq = rc; -per_cpu (xen_callfunc_irq, cpu).name = callfunc_name;if (!xen_fifo_events) { debug_name =kasprintf (GFP_KERNEL ,"debug%d" , cpu); +per_cpu (xen_debug_irq, cpu).name = debug_name; rc = bind_virq_to_irqhandler(VIRQ_DEBUG, cpu, xen_debug_interrupt, IRQF_PERCPU | IRQF_NOBALANCING,
@@ -97,10 +98,10 @@ int xen_smp_intr_init(unsigned int cpu)if (rc <0 ) goto fail;per_cpu (xen_debug_irq, cpu).irq = rc; -per_cpu (xen_debug_irq, cpu).name = debug_name; } callfunc_name =kasprintf (GFP_KERNEL ,"callfuncsingle%d" , cpu); +per_cpu (xen_callfuncsingle_irq, cpu).name = callfunc_name; rc = bind_ipi_to_irqhandler(XEN_CALL_FUNCTION_SINGLE_VECTOR, cpu, xen_call_function_single_interrupt,
@@ -110,7 +111,6 @@ int xen_smp_intr_init(unsigned int cpu)if (rc <0 ) goto fail;per_cpu (xen_callfuncsingle_irq, cpu).irq = rc; -per_cpu (xen_callfuncsingle_irq, cpu).name = callfunc_name;return 0 ;
arch/x86/xen/smp_pv.c +6 -6
@@ -97,18 +97,18 @@ asmlinkage __visible void cpu_bringup_and_idle(void)void xen_smp_intr_free_pv (unsigned int cpu) { +kfree (per_cpu (xen_irq_work, cpu).name); +per_cpu (xen_irq_work, cpu).name =NULL ;if (per_cpu (xen_irq_work, cpu).irq >=0 ) {unbind_from_irqhandler (per_cpu (xen_irq_work, cpu).irq,NULL );per_cpu (xen_irq_work, cpu).irq =-1 ; -kfree (per_cpu (xen_irq_work, cpu).name); -per_cpu (xen_irq_work, cpu).name =NULL ; } +kfree (per_cpu (xen_pmu_irq, cpu).name); +per_cpu (xen_pmu_irq, cpu).name =NULL ;if (per_cpu (xen_pmu_irq, cpu).irq >=0 ) {unbind_from_irqhandler (per_cpu (xen_pmu_irq, cpu).irq,NULL );per_cpu (xen_pmu_irq, cpu).irq =-1 ; -kfree (per_cpu (xen_pmu_irq, cpu).name); -per_cpu (xen_pmu_irq, cpu).name =NULL ; } }
@@ -118,6 +118,7 @@ int xen_smp_intr_init_pv(unsigned int cpu)char *callfunc_name, *pmu_name; callfunc_name =kasprintf (GFP_KERNEL ,"irqwork%d" , cpu); +per_cpu (xen_irq_work, cpu).name = callfunc_name; rc = bind_ipi_to_irqhandler(XEN_IRQ_WORK_VECTOR, cpu, xen_irq_work_interrupt,
@@ -127,10 +128,10 @@ int xen_smp_intr_init_pv(unsigned int cpu)if (rc <0 ) goto fail;per_cpu (xen_irq_work, cpu).irq = rc; -per_cpu (xen_irq_work, cpu).name = callfunc_name;if (is_xen_pmu) { pmu_name =kasprintf (GFP_KERNEL ,"pmu%d" , cpu); +per_cpu (xen_pmu_irq, cpu).name = pmu_name; rc = bind_virq_to_irqhandler(VIRQ_XENPMU, cpu, xen_pmu_irq_handler, IRQF_PERCPU|IRQF_NOBALANCING,
@@ -138,7 +139,6 @@ int xen_smp_intr_init_pv(unsigned int cpu)if (rc <0 ) goto fail;per_cpu (xen_pmu_irq, cpu).irq = rc; -per_cpu (xen_pmu_irq, cpu).name = pmu_name; }return 0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 124/731 x86/xen: Fix memory leak in xen_init_lock_cpu()
In reply to Greg Kroah-HartmanFrom: Xiu Jianfeng <[email protected]>
[ Upstream commit ca84ce153d887b1dc8b118029976cc9faf2a9b40 ]
In xen_init_lock_cpu(), the @name has allocated new string by kasprintf(), if bind_ipi_to_irqhandler() fails, it should be freed, otherwise may lead to a memory leak issue, fix it.
--- arch/x86/xen/spinlock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/xen/spinlock.c +3 -3
@@ -75,6 +75,7 @@ void xen_init_lock_cpu(int cpu) cpu, per_cpu(lock_kicker_irq, cpu)); name =kasprintf (GFP_KERNEL ,"spinlock%d" , cpu); +per_cpu (irq_name, cpu) = name; irq = bind_ipi_to_irqhandler(XEN_SPIN_UNLOCK_VECTOR, cpu, dummy_handler,
@@ -85,7 +86,6 @@ void xen_init_lock_cpu(int cpu)if (irq >=0 ) {disable_irq (irq);/* make sure it's never delivered */ per_cpu (lock_kicker_irq, cpu) = irq; -per_cpu (irq_name, cpu) = name; }printk ("cpu %d spinlock event irq %d\n" , cpu, irq);
@@ -98,6 +98,8 @@ void xen_uninit_lock_cpu(int cpu)if (!xen_pvspin)return ; +kfree (per_cpu (irq_name, cpu)); +per_cpu (irq_name, cpu) =NULL ;/* * When booting the kernel with 'mitigations=auto,nosmt', the secondary * CPUs are not activated, and lock_kicker_irq is not initialized.
@@ -108,8 +110,6 @@ void xen_uninit_lock_cpu(int cpu)unbind_from_irqhandler (irq,NULL );per_cpu (lock_kicker_irq, cpu) =-1 ; -kfree (per_cpu (irq_name, cpu)); -per_cpu (irq_name, cpu) =NULL ; }PV_CALLEE_SAVE_REGS_THUNK (xen_vcpu_stolen);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 125/731 xen/privcmd: Fix a possible warning in privcmd_ioctl_mmap_resource()
In reply to Greg Kroah-HartmanFrom: Harshit Mogalapalli <[email protected]>
[ Upstream commit 8b997b2bb2c53b76a6db6c195930e9ab8e4b0c79 ]
As 'kdata.num' is user-controlled data, if user tries to allocate memory larger than(>=) MAX_ORDER, then kcalloc() will fail, it creates a stack trace and messes up dmesg with a warning.
Call trace:
-> privcmd_ioctl
--> privcmd_ioctl_mmap_resource
Add __GFP_NOWARN in order to avoid too large allocation warning. This is detected by static analysis using smatch.
--- drivers/xen/privcmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/xen/privcmd.c +1 -1
@@ -760,7 +760,7 @@ static long privcmd_ioctl_mmap_resource(struct file *file, goto out; } - pfns =kcalloc (kdata.num,sizeof (*pfns),GFP_KERNEL ); + pfns =kcalloc (kdata.num,sizeof (*pfns),GFP_KERNEL | __GFP_NOWARN);if (!pfns) { rc = -ENOMEM ; goto out;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 126/731 PM: runtime: Do not call __rpm_callback() from rpm_idle()
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
[ Upstream commit bc80c2e438dcbfcf748452ec0f7ad5b79ff3ad88 ]
Calling __rpm_callback() from rpm_idle() after adding device links support to the former is a clear mistake.
Not only it causes rpm_idle() to carry out unnecessary actions, but it is also against the assumption regarding the stability of PM-runtime status across __rpm_callback() invocations, because rpm_suspend() and rpm_resume() may run in parallel with __rpm_callback() when it is called by rpm_idle() and the device's PM-runtime status can be updated by any of them.
--- drivers/base/power/runtime.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/base/power/runtime.c +11 -1
@@ -484,7 +484,17 @@ static int rpm_idle(struct device *dev, int rpmflags) dev->power.idle_notification = true; - retval =__rpm_callback (callback, dev); +if (dev->power.irq_safe) +spin_unlock (&dev->power.lock); +else +spin_unlock_irq (&dev->power.lock); + + retval =callback (dev); + +if (dev->power.irq_safe) +spin_lock (&dev->power.lock); +else +spin_lock_irq (&dev->power.lock); dev->power.idle_notification = false;wake_up_all (&dev->power.wait_queue);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 127/731 platform/chrome: cros_ec_typec: Cleanup switch handle return paths
In reply to Greg Kroah-HartmanFrom: Prashant Malani <[email protected]>
[ Upstream commit 66fe238a9bcc158f75ddecf976d1ce7efe20f713 ]
Some of the return paths for the cros_typec_get_switch_handles() aren't necessary. Clean up the return paths to only undo the handle get's which succeeded.
Stable-dep-of: 9a8aadcf0b45 ("platform/chrome: cros_ec_typec: zero out stale pointers")
--- drivers/platform/chrome/cros_ec_typec.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/platform/chrome/cros_ec_typec.c +2 -4
@@ -156,12 +156,10 @@ static int cros_typec_get_switch_handles(struct cros_typec_port *port,return 0 ; role_sw_err: -usb_role_switch_put (port->role_sw); -ori_sw_err:typec_switch_put (port->ori_sw); -mux_err: +ori_sw_err:typec_mux_put (port->mux); - +mux_err:return -ENODEV ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 128/731 platform/chrome: cros_ec_typec: zero out stale pointers
In reply to Greg Kroah-HartmanFrom: Victor Ding <[email protected]>
[ Upstream commit 9a8aadcf0b459c1257b9477fd6402e1d5952ae07 ]
cros_typec_get_switch_handles allocates four pointers when obtaining type-c switch handles. These pointers are all freed if failing to obtain any of them; therefore, pointers in port become stale. The stale pointers eventually cause use-after-free or double free in later code paths. Zeroing out all pointer fields after freeing to eliminate these stale pointers.
--- drivers/platform/chrome/cros_ec_typec.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/platform/chrome/cros_ec_typec.c +2 -0
@@ -157,8 +157,10 @@ static int cros_typec_get_switch_handles(struct cros_typec_port *port, role_sw_err:typec_switch_put (port->ori_sw); + port->ori_sw =NULL ; ori_sw_err:typec_mux_put (port->mux); + port->mux =NULL ; mux_err:return -ENODEV ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 129/731 platform/x86: mxm-wmi: fix memleak in mxm_wmi_call_mx[ds|mx]()
In reply to Greg Kroah-HartmanFrom: Yu Liao <[email protected]>
[ Upstream commit 727cc0147f5066e359aca65cc6cc5e6d64cc15d8 ]
The ACPI buffer memory (out.pointer) returned by wmi_evaluate_method() is not freed after the call, so it leads to memory leak.
The method results in ACPI buffer is not used, so just pass NULL to wmi_evaluate_method() which fixes the memory leak.
--- drivers/platform/x86/mxm-wmi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/platform/x86/mxm-wmi.c +2 -6
@@ -35,13 +35,11 @@ int mxm_wmi_call_mxds(int adapter) .xarg = 1, };struct acpi_buffer input = { (acpi_size )sizeof (args), &args }; -struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER ,NULL };acpi_status status;printk ("calling mux switch %d\n" , adapter); - status =wmi_evaluate_method (MXM_WMMX_GUID ,0x0 , adapter, &input, - &output); + status =wmi_evaluate_method (MXM_WMMX_GUID ,0x0 , adapter, &input,NULL );if (ACPI_FAILURE (status))return status;
@@ -60,13 +58,11 @@ int mxm_wmi_call_mxmx(int adapter) .xarg = 1, };struct acpi_buffer input = { (acpi_size )sizeof (args), &args }; -struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER ,NULL };acpi_status status;printk ("calling mux switch %d\n" , adapter); - status =wmi_evaluate_method (MXM_WMMX_GUID ,0x0 , adapter, &input, - &output); + status =wmi_evaluate_method (MXM_WMMX_GUID ,0x0 , adapter, &input,NULL );if (ACPI_FAILURE (status))return status;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 130/731 platform/x86: intel_scu_ipc: fix possible name leak in __intel_scu_ipc_register()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 0b3d0cb7c0bed2fd6454f77ed75e7a662c6efd12 ]
In some error paths before device_register(), the names allocated by dev_set_name() are not freed. Move dev_set_name() front to device_register(), so the name can be freed while calling put_device().
--- drivers/platform/x86/intel_scu_ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/intel_scu_ipc.c +1 -1
@@ -583,7 +583,6 @@ __intel_scu_ipc_register(struct device *parent, scu->dev.parent = parent; scu->dev.class = &intel_scu_ipc_class; scu->dev.release = intel_scu_ipc_release; -dev_set_name (&scu->dev,"intel_scu_ipc" );if (!request_mem_region (scu_data->mem.start,resource_size (&scu_data->mem),"intel_scu_ipc" )) {
@@ -612,6 +611,7 @@ __intel_scu_ipc_register(struct device *parent,* After this point intel_scu_ipc_release() takes care of * releasing the SCU IPC resources once refcount drops to zero. */ +dev_set_name (&scu->dev,"intel_scu_ipc" ); err =device_register (&scu->dev);if (err) {put_device (&scu->dev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 131/731 MIPS: BCM63xx: Add check for NULL for clk in clk_enable
In reply to Greg Kroah-HartmanFrom: Anastasia Belova <[email protected]>
[ Upstream commit ee9ef11bd2a59c2fefaa0959e5efcdf040d7c654 ]
Check clk for NULL before calling clk_enable_unlocked where clk is dereferenced. There is such check in other implementations of clk_enable.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- arch/mips/bcm63xx/clk.c | 2 ++ 1 file changed, 2 insertions(+)
arch/mips/bcm63xx/clk.c +2 -0
@@ -361,6 +361,8 @@ static struct clk clk_periph = {*/ int clk_enable (struct clk *clk) { +if (!clk) +return 0 ;mutex_lock (&clocks_mutex);clk_enable_unlocked (clk);mutex_unlock (&clocks_mutex);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 132/731 MIPS: OCTEON: warn only once if deprecated link status is being used
In reply to Greg Kroah-HartmanFrom: Ladislav Michl <[email protected]>
[ Upstream commit 4c587a982603d7e7e751b4925809a1512099a690 ]
Avoid flooding kernel log with warnings.
--- arch/mips/cavium-octeon/executive/cvmx-helper-board.c | 2 +- arch/mips/cavium-octeon/executive/cvmx-helper.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/mips/cavium-octeon/executive/cvmx-helper-board.c +1 -1
@@ -211,7 +211,7 @@ union cvmx_helper_link_info __cvmx_helper_board_link_get(int ipd_port) {union cvmx_helper_link_info result; -WARN (!octeon_is_simulation (), +WARN_ONCE (!octeon_is_simulation (),"Using deprecated link status - please update your DT" );/* Unless we fix it later, all links are defaulted to down */
arch/mips/cavium-octeon/executive/cvmx-helper.c +1 -1
@@ -1100,7 +1100,7 @@ union cvmx_helper_link_info cvmx_helper_link_get(int ipd_port)if (index ==0 ) result =__cvmx_helper_rgmii_link_get (ipd_port);else { -WARN (1 ,"Using deprecated link status - please update your DT" ); +WARN_ONCE (1 ,"Using deprecated link status - please update your DT" ); result.s.full_duplex =1 ; result.s.link_up =1 ; result.s.speed =1000 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 133/731 lockd: set other missing fields when unlocking files
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 18ebd35b61b4693a0ddc270b6d4f18def232e770 ]
vfs_lock_file() expects the struct file_lock to be fully initialised by the caller. Re-exported NFSv3 has been seen to Oops if the fl_file field is NULL.
--- fs/lockd/svcsubs.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
fs/lockd/svcsubs.c +10 -7
@@ -176,7 +176,7 @@ nlm_delete_file(struct nlm_file *file) } } -static int nlm_unlock_files (struct nlm_file *file,fl_owner_t owner) +static int nlm_unlock_files (struct nlm_file *file,const struct file_lock *fl) {struct file_lock lock;
@@ -184,12 +184,15 @@ static int nlm_unlock_files(struct nlm_file *file, fl_owner_t owner) lock.fl_type =F_UNLCK ; lock.fl_start =0 ; lock.fl_end =OFFSET_MAX ; - lock.fl_owner = owner; -if (file->f_file[O_RDONLY ] && -vfs_lock_file (file->f_file[O_RDONLY ],F_SETLK , &lock,NULL )) + lock.fl_owner = fl->fl_owner; + lock.fl_pid = fl->fl_pid; + lock.fl_flags =FL_POSIX ; + + lock.fl_file = file->f_file[O_RDONLY ]; +if (lock.fl_file &&vfs_lock_file (lock.fl_file,F_SETLK , &lock,NULL )) goto out_err; -if (file->f_file[O_WRONLY ] && -vfs_lock_file (file->f_file[O_WRONLY ],F_SETLK , &lock,NULL )) + lock.fl_file = file->f_file[O_WRONLY ]; +if (lock.fl_file &&vfs_lock_file (lock.fl_file,F_SETLK , &lock,NULL )) goto out_err;return 0 ; out_err:
@@ -226,7 +229,7 @@ nlm_traverse_locks(struct nlm_host *host, struct nlm_file *file,if (match (lockhost, host)) {spin_unlock (&flctx->flc_lock); -if (nlm_unlock_files (file, fl->fl_owner)) +if (nlm_unlock_files (file, fl))return 1 ; goto again; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 134/731 fs: sysv: Fix sysv_nblocks() returns wrong value
In reply to Greg Kroah-HartmanFrom: Chen Zhongjin <[email protected]>
[ Upstream commit e0c49bd2b4d3cd1751491eb2d940bce968ac65e9 ]
sysv_nblocks() returns 'blocks' rather than 'res', which only counting the number of triple-indirect blocks and causing sysv_getattr() gets a wrong result.
[AV: this is actually a sysv counterpart of minixfs fix - 0fcd426de9d0 "[PATCH] minix block usage counting fix" in historical tree; mea culpa, should've thought to check fs/sysv back then...]
--- fs/sysv/itree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/sysv/itree.c +1 -1
@@ -438,7 +438,7 @@ static unsigned sysv_nblocks(struct super_block *s, loff_t size) res += blocks; direct =1 ; } -return blocks; +return res; } int sysv_getattr(struct user_namespace *mnt_userns, const struct path *path,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 135/731 rapidio: fix possible UAF when kfifo_alloc() fails
In reply to Greg Kroah-HartmanFrom: Wang Weiyang <[email protected]>
[ Upstream commit 02d7d89f816951e0862147d751b1150d67aaebdd ]
If kfifo_alloc() fails in mport_cdev_open(), goto err_fifo and just free priv. But priv is still in the chdev->file_list, then list traversal may cause UAF. This fixes the following smatch warning:
drivers/rapidio/devices/rio_mport_cdev.c:1930 mport_cdev_open() warn: '&priv->list' not removed from list
--- drivers/rapidio/devices/rio_mport_cdev.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/rapidio/devices/rio_mport_cdev.c +3 -4
@@ -1903,10 +1903,6 @@ static int mport_cdev_open(struct inode *inode, struct file *filp) priv->md = chdev; -mutex_lock (&chdev->file_mutex); -list_add_tail (&priv->list, &chdev->file_list); -mutex_unlock (&chdev->file_mutex); -INIT_LIST_HEAD (&priv->db_filters);INIT_LIST_HEAD (&priv->pw_filters);spin_lock_init (&priv->fifo_lock);
@@ -1925,6 +1921,9 @@ static int mport_cdev_open(struct inode *inode, struct file *filp)spin_lock_init (&priv->req_lock);mutex_init (&priv->dma_lock);#endif +mutex_lock (&chdev->file_mutex); +list_add_tail (&priv->list, &chdev->file_list); +mutex_unlock (&chdev->file_mutex); filp->private_data = priv; goto out;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 136/731 eventfd: change int to __u64 in eventfd_signal() ifndef CONFIG_EVENTFD
In reply to Greg Kroah-HartmanFrom: Zhang Qilong <[email protected]>
[ Upstream commit fd4e60bf0ef8eb9edcfa12dda39e8b6ee9060492 ]
Commit ee62c6b2dc93 ("eventfd: change int to __u64 in eventfd_signal()") forgot to change int to __u64 in the CONFIG_EVENTFD=n stub function.
--- include/linux/eventfd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/eventfd.h +1 -1
@@ -61,7 +61,7 @@ static inline struct eventfd_ctx *eventfd_ctx_fdget(int fd)return ERR_PTR (-ENOSYS ); } -static inline int eventfd_signal (struct eventfd_ctx *ctx,int n) +static inline int eventfd_signal (struct eventfd_ctx *ctx,__u64 n) {return -ENOSYS ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 137/731 relay: fix type mismatch when allocating memory in relay_create_buf()
In reply to Greg Kroah-HartmanFrom: Gavrilov Ilia <[email protected]>
[ Upstream commit 4d8586e04602fe42f0a782d2005956f8b6302678 ]
The 'padding' field of the 'rchan_buf' structure is an array of 'size_t' elements, but the memory is allocated for an array of 'size_t *' elements.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- kernel/relay.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/relay.c +2 -2
@@ -151,13 +151,13 @@ static struct rchan_buf *relay_create_buf(struct rchan *chan) {struct rchan_buf *buf; -if (chan->n_subbufs >KMALLOC_MAX_SIZE /sizeof (size_t *)) +if (chan->n_subbufs >KMALLOC_MAX_SIZE /sizeof (size_t ))return NULL ; buf =kzalloc (sizeof (struct rchan_buf ),GFP_KERNEL );if (!buf)return NULL ; - buf->padding =kmalloc_array (chan->n_subbufs,sizeof (size_t *), + buf->padding =kmalloc_array (chan->n_subbufs,sizeof (size_t ),GFP_KERNEL );if (!buf->padding) goto free_buf;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 138/731 hfs: Fix OOB Write in hfs_asc2mac
In reply to Greg Kroah-HartmanFrom: ZhangPeng <[email protected]>
[ Upstream commit c53ed55cb275344086e32a7080a6b19cb183650b ]
Syzbot reported a OOB Write bug:
loop0: detected capacity change from 0 to 64
==================================================================
BUG: KASAN: slab-out-of-bounds in hfs_asc2mac+0x467/0x9a0 fs/hfs/trans.c:133 Write of size 1 at addr ffff88801848314e by task syz-executor391/3632 Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1b1/0x28e lib/dump_stack.c:106 print_address_description+0x74/0x340 mm/kasan/report.c:284 print_report+0x107/0x1f0 mm/kasan/report.c:395 kasan_report+0xcd/0x100 mm/kasan/report.c:495 hfs_asc2mac+0x467/0x9a0 fs/hfs/trans.c:133 hfs_cat_build_key+0x92/0x170 fs/hfs/catalog.c:28 hfs_lookup+0x1ab/0x2c0 fs/hfs/dir.c:31 lookup_open fs/namei.c:3391 [inline] open_last_lookups fs/namei.c:3481 [inline] path_openat+0x10e6/0x2df0 fs/namei.c:3710 do_filp_open+0x264/0x4f0 fs/namei.c:3740
If in->len is much larger than HFS_NAMELEN(31) which is the maximum length of an HFS filename, a OOB write could occur in hfs_asc2mac(). In that case, when the dst reaches the boundary, the srclen is still greater than 0, which causes a OOB write.
Fix this by adding a check on dstlen in while() before writing to dst address.
--- fs/hfs/trans.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/hfs/trans.c +1 -1
@@ -109,7 +109,7 @@ void hfs_asc2mac(struct super_block *sb, struct hfs_name *out, const struct qstrif (nls_io) {wchar_t ch; -while (srclen >0 ) { +while (srclen >0 && dstlen >0 ) { size = nls_io->char2uni (src, srclen, &ch);if (size <0 ) { ch ='?' ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 139/731 rapidio: devices: fix missing put_device in mport_cdev_open
In reply to Greg Kroah-HartmanFrom: Cai Xinchen <[email protected]>
[ Upstream commit d5b6e6eba3af11cb2a2791fa36a2524990fcde1a ]
When kfifo_alloc fails, the refcount of chdev->dev is left incremental. We should use put_device(&chdev->dev) to decrease the ref count of chdev->dev to avoid refcount leak.
--- drivers/rapidio/devices/rio_mport_cdev.c | 1 + 1 file changed, 1 insertion(+)
drivers/rapidio/devices/rio_mport_cdev.c +1 -0
@@ -1911,6 +1911,7 @@ static int mport_cdev_open(struct inode *inode, struct file *filp)sizeof (struct rio_event ) *MPORT_EVENT_DEPTH , GFP_KERNEL);if (ret <0 ) { +put_device (&chdev->dev);dev_err (&chdev->dev,DRV_NAME ": kfifo_alloc failed\n" ); ret = -ENOMEM ; goto err_fifo;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 140/731 platform/mellanox: mlxbf-pmc: Fix event typo
In reply to Greg Kroah-HartmanFrom: James Hurley <[email protected]>
[ Upstream commit b0b698b80c56b0712f0d4346d51bf0363ba03068 ]
Had a duplicate event typo, so just fixed the 1 character typo.
--- drivers/platform/mellanox/mlxbf-pmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/mellanox/mlxbf-pmc.c +1 -1
@@ -358,7 +358,7 @@ static const struct mlxbf_pmc_events mlxbf_pmc_hnfnet_events[] = { { 0x32, "DDN_DIAG_W_INGRESS" }, { 0x33, "DDN_DIAG_C_INGRESS" }, { 0x34, "DDN_DIAG_CORE_SENT" }, - { 0x35, "NDN_DIAG_S_OUT_OF_CRED" }, + { 0x35, "NDN_DIAG_N_OUT_OF_CRED" }, { 0x36, "NDN_DIAG_S_OUT_OF_CRED" }, { 0x37, "NDN_DIAG_E_OUT_OF_CRED" }, { 0x38, "NDN_DIAG_W_OUT_OF_CRED" },
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 141/731 wifi: ath9k: hif_usb: fix memory leak of urbs in ath9k_hif_usb_dealloc_tx_urbs()
In reply to Greg Kroah-HartmanFrom: Fedor Pchelkin <[email protected]>
[ Upstream commit c2a94de38c74e86f49124ac14f093d6a5c377a90 ]
Syzkaller reports a long-known leak of urbs inath9k_hif_usb_dealloc_tx_urbs().
The cause of the leak is that usb_get_urb() is called but usb_free_urb() (or usb_put_urb()) is not called inside usb_kill_urb() as urb->dev or urb->ep fields have not been initialized and usb_kill_urb() returns immediately.
The patch removes trying to kill urbs located in hif_dev->tx.tx_buf because hif_dev->tx.tx_buf is not supposed to contain urbs which are in pending state (the pending urbs are stored in hif_dev->tx.tx_pending). The tx.tx_lock is acquired so there should not be any changes in the list.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- drivers/net/wireless/ath/ath9k/hif_usb.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/net/wireless/ath/ath9k/hif_usb.c +0 -4
@@ -781,14 +781,10 @@ static void ath9k_hif_usb_dealloc_tx_urbs(struct hif_device_usb *hif_dev)spin_lock_irqsave (&hif_dev->tx.tx_lock, flags);list_for_each_entry_safe (tx_buf, tx_buf_tmp, &hif_dev->tx.tx_buf, list) { -usb_get_urb (tx_buf->urb); -spin_unlock_irqrestore (&hif_dev->tx.tx_lock, flags); -usb_kill_urb (tx_buf->urb);list_del (&tx_buf->list);usb_free_urb (tx_buf->urb);kfree (tx_buf->buf);kfree (tx_buf); -spin_lock_irqsave (&hif_dev->tx.tx_lock, flags); }spin_unlock_irqrestore (&hif_dev->tx.tx_lock, flags);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 142/731 wifi: ath9k: hif_usb: Fix use-after-free in ath9k_hif_usb_reg_in_cb()
In reply to Greg Kroah-HartmanFrom: Fedor Pchelkin <[email protected]>
[ Upstream commit dd95f2239fc846795fc926787c3ae0ca701c9840 ]
It is possible that skb is freed in ath9k_htc_rx_msg(), then usb_submit_urb() fails and we try to free skb again. It causes use-after-free bug. Moreover, if alloc_skb() fails, urb->context becomes NULL but rx_buf is not freed and there can be a memory leak.
The patch removes unnecessary nskb and makes skb processing more clear: it is supposed that ath9k_htc_rx_msg() either frees old skb or passes its managing to another callback function.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- drivers/net/wireless/ath/ath9k/hif_usb.c | 28 +++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-)
drivers/net/wireless/ath/ath9k/hif_usb.c +15 -13
@@ -709,14 +709,13 @@ static void ath9k_hif_usb_reg_in_cb(struct urb *urb)struct rx_buf *rx_buf = (struct rx_buf *)urb->context;struct hif_device_usb *hif_dev = rx_buf->hif_dev;struct sk_buff *skb = rx_buf->skb; -struct sk_buff *nskb;int ret;if (!skb)return ;if (!hif_dev) - goto free; + goto free_skb;switch (urb->status) {case 0 :
@@ -725,7 +724,7 @@ static void ath9k_hif_usb_reg_in_cb(struct urb *urb)case -ECONNRESET :case -ENODEV :case -ESHUTDOWN : - goto free; + goto free_skb;default :skb_reset_tail_pointer (skb);skb_trim (skb,0 );
@@ -736,25 +735,27 @@ static void ath9k_hif_usb_reg_in_cb(struct urb *urb)if (likely (urb->actual_length !=0 )) {skb_put (skb, urb->actual_length); -/* Process the command first */ +/* +* Process the command first. +* skb is either freed here or passed to be +* managed to another callback function. +*/ ath9k_htc_rx_msg (hif_dev->htc_handle, skb, skb->len,USB_REG_IN_PIPE ); - - nskb =alloc_skb (MAX_REG_IN_BUF_SIZE ,GFP_ATOMIC ); -if (!nskb) { + skb =alloc_skb (MAX_REG_IN_BUF_SIZE ,GFP_ATOMIC ); +if (!skb) {dev_err (&hif_dev->udev->dev,"ath9k_htc: REG_IN memory allocation failure\n" ); - urb->context =NULL ; -return ; + goto free_rx_buf; } - rx_buf->skb = nskb; + rx_buf->skb = skb;usb_fill_int_urb (urb, hif_dev->udev,usb_rcvintpipe (hif_dev->udev,USB_REG_IN_PIPE ), - nskb->data,MAX_REG_IN_BUF_SIZE , + skb->data,MAX_REG_IN_BUF_SIZE , ath9k_hif_usb_reg_in_cb, rx_buf,1 ); }
@@ -763,12 +764,13 @@ static void ath9k_hif_usb_reg_in_cb(struct urb *urb) ret =usb_submit_urb (urb,GFP_ATOMIC );if (ret) {usb_unanchor_urb (urb); - goto free; + goto free_skb; }return ; -free: +free_skb:kfree_skb (skb); +free_rx_buf:kfree (rx_buf); urb->context =NULL ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 143/731 wifi: rtl8xxxu: Fix reading the vendor of combo chips
In reply to Greg Kroah-HartmanFrom: Bitterblue Smith <[email protected]>
[ Upstream commit 6f103aeb5e985ac08f3a4a049a2c17294f40cff9 ]
The wifi + bluetooth combo chips (RTL8723AU and RTL8723BU) read the chip vendor from the wrong register because the val32 variable gets overwritten. Add one more variable to avoid this.
This had no real effect on RTL8723BU. It may have had an effect on RTL8723AU.
--- .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +8 -8
@@ -1607,18 +1607,18 @@ static void rtl8xxxu_print_chipinfo(struct rtl8xxxu_priv *priv)static int rtl8xxxu_identify_chip (struct rtl8xxxu_priv *priv) {struct device *dev = &priv->udev->dev; -u32 val32, bonding; +u32 val32, bonding, sys_cfg;u16 val16; - val32 =rtl8xxxu_read32 (priv,REG_SYS_CFG ); - priv->chip_cut = (val32 &SYS_CFG_CHIP_VERSION_MASK ) >> + sys_cfg =rtl8xxxu_read32 (priv,REG_SYS_CFG ); + priv->chip_cut = (sys_cfg &SYS_CFG_CHIP_VERSION_MASK ) >>SYS_CFG_CHIP_VERSION_SHIFT ; -if (val32 &SYS_CFG_TRP_VAUX_EN ) { +if (sys_cfg &SYS_CFG_TRP_VAUX_EN ) {dev_info (dev,"Unsupported test chip\n" );return -ENOTSUPP ; } -if (val32 &SYS_CFG_BT_FUNC ) { +if (sys_cfg &SYS_CFG_BT_FUNC ) {if (priv->chip_cut >=3 ) {sprintf (priv->chip_name,"8723BU" ); priv->rtl_chip =RTL8723B ;
@@ -1640,7 +1640,7 @@ static int rtl8xxxu_identify_chip(struct rtl8xxxu_priv *priv)if (val32 &MULTI_GPS_FUNC_EN ) priv->has_gps =1 ; priv->is_multi_func =1 ; - }else if (val32 &SYS_CFG_TYPE_ID ) { + }else if (sys_cfg &SYS_CFG_TYPE_ID ) { bonding =rtl8xxxu_read32 (priv,REG_HPON_FSM ); bonding &=HPON_FSM_BONDING_MASK ; if (priv->fops->tx_desc_size ==
@@ -1688,7 +1688,7 @@ static int rtl8xxxu_identify_chip(struct rtl8xxxu_priv *priv)case RTL8188E :case RTL8192E :case RTL8723B : -switch (val32 &SYS_CFG_VENDOR_EXT_MASK ) { +switch (sys_cfg &SYS_CFG_VENDOR_EXT_MASK ) {case SYS_CFG_VENDOR_ID_TSMC :sprintf (priv->chip_vendor,"TSMC" );break ;
@@ -1705,7 +1705,7 @@ static int rtl8xxxu_identify_chip(struct rtl8xxxu_priv *priv) }break ;default : -if (val32 &SYS_CFG_VENDOR_ID ) { +if (sys_cfg &SYS_CFG_VENDOR_ID ) {sprintf (priv->chip_vendor,"UMC" ); priv->vendor_umc =1 ; }else {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 144/731 drm/bridge: adv7533: remove dynamic lane switching from adv7533 bridge
In reply to Greg Kroah-HartmanFrom: Abhinav Kumar <[email protected]>
[ Upstream commit 9a0cdcd6649b76f0b7ceec0e55b0a718321e34d3 ]
adv7533 bridge tries to dynamically switch lanes based on the mode by detaching and attaching the mipi dsi device.
This approach is incorrect because this method of dynamic switch of detaching and attaching the mipi dsi device also results in removing and adding the component which is not necessary.
This approach is also prone to deadlocks. So for example, on the db410c whenever this path is executed with lockdep enabled, this results in a deadlock due to below ordering of locks.
-> #1 (crtc_ww_class_acquire){+.+.}-{0:0}:
lock_acquire+0x6c/0x90
drm_modeset_acquire_init+0xf4/0x150
drmm_mode_config_init+0x220/0x770
msm_drm_bind+0x13c/0x654
try_to_bring_up_aggregate_device+0x164/0x1d0
__component_add+0xa8/0x174
component_add+0x18/0x2c
dsi_dev_attach+0x24/0x30
dsi_host_attach+0x98/0x14c
devm_mipi_dsi_attach+0x38/0xb0
adv7533_attach_dsi+0x8c/0x110
adv7511_probe+0x5a0/0x930
i2c_device_probe+0x30c/0x350
really_probe.part.0+0x9c/0x2b0
__driver_probe_device+0x98/0x144
driver_probe_device+0xac/0x14c
__device_attach_driver+0xbc/0x124
bus_for_each_drv+0x78/0xd0
__device_attach+0xa8/0x1c0
device_initial_probe+0x18/0x24
bus_probe_device+0xa0/0xac
deferred_probe_work_func+0x90/0xd0
process_one_work+0x28c/0x6b0
worker_thread+0x240/0x444
kthread+0x110/0x114
ret_from_fork+0x10/0x20-> #0 (component_mutex){+.+.}-{3:3}:
__lock_acquire+0x1280/0x20ac
lock_acquire.part.0+0xe0/0x230
lock_acquire+0x6c/0x90
__mutex_lock+0x84/0x400
mutex_lock_nested+0x3c/0x70
component_del+0x34/0x170
dsi_dev_detach+0x24/0x30
dsi_host_detach+0x20/0x64
mipi_dsi_detach+0x2c/0x40
adv7533_mode_set+0x64/0x90
adv7511_bridge_mode_set+0x210/0x214
drm_bridge_chain_mode_set+0x5c/0x84
crtc_set_mode+0x18c/0x1dc
drm_atomic_helper_commit_modeset_disables+0x40/0x50
msm_atomic_commit_tail+0x1d0/0x6e0
commit_tail+0xa4/0x180
drm_atomic_helper_commit+0x178/0x3b0
drm_atomic_commit+0xa4/0xe0
drm_client_modeset_commit_atomic+0x228/0x284
drm_client_modeset_commit_locked+0x64/0x1d0
drm_client_modeset_commit+0x34/0x60
drm_fb_helper_lastclose+0x74/0xcc
drm_lastclose+0x3c/0x80
drm_release+0xfc/0x114
__fput+0x70/0x224
____fput+0x14/0x20
task_work_run+0x88/0x1a0
do_exit+0x350/0xa50
do_group_exit+0x38/0xa4
__wake_up_parent+0x0/0x34
invoke_syscall+0x48/0x114
el0_svc_common.constprop.0+0x60/0x11c
do_el0_svc+0x30/0xc0
el0_svc+0x58/0x100
el0t_64_sync_handler+0x1b0/0x1bc
el0t_64_sync+0x18c/0x190Due to above reasons, remove the dynamic lane switching code from adv7533 bridge chip and filter out the modes which would need different number of lanes as compared to the initialization time using the mode_valid callback.
This can be potentially re-introduced by using the pre_enable() callback but this needs to be evaluated first whether such an approach will work so this will be done with a separate change.
changes since RFC:
- Fix commit text and add TODO comment
changes in v2:
- Fix checkpatch formatting errors
--- drivers/gpu/drm/bridge/adv7511/adv7511.h | 3 ++- drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 18 ++++++++++---- drivers/gpu/drm/bridge/adv7511/adv7533.c | 25 ++++++++++---------- 3 files changed, 29 insertions(+), 17 deletions(-)
drivers/gpu/drm/bridge/adv7511/adv7511.h +2 -1
@@ -395,7 +395,8 @@ static inline int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511)void adv7533_dsi_power_on (struct adv7511 *adv);void adv7533_dsi_power_off (struct adv7511 *adv); -void adv7533_mode_set (struct adv7511 *adv,const struct drm_display_mode *mode); +enum drm_mode_status adv7533_mode_valid (struct adv7511 *adv, +const struct drm_display_mode *mode);int adv7533_patch_registers (struct adv7511 *adv);int adv7533_patch_cec_registers (struct adv7511 *adv);int adv7533_attach_dsi (struct adv7511 *adv);
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +14 -4
@@ -697,7 +697,7 @@ adv7511_detect(struct adv7511 *adv7511, struct drm_connector *connector) }static enum drm_mode_status adv7511_mode_valid (struct adv7511 *adv7511, -struct drm_display_mode *mode) +const struct drm_display_mode *mode) {if (mode->clock >165000 )return MODE_CLOCK_HIGH ;
@@ -791,9 +791,6 @@ static void adv7511_mode_set(struct adv7511 *adv7511,regmap_update_bits (adv7511->regmap,0x17 ,0x60 , (vsync_polarity <<6 ) | (hsync_polarity <<5 )); -if (adv7511->type ==ADV7533 || adv7511->type ==ADV7535 ) -adv7533_mode_set (adv7511, adj_mode); -drm_mode_copy (&adv7511->curr_mode, adj_mode);/*
@@ -913,6 +910,18 @@ static void adv7511_bridge_mode_set(struct drm_bridge *bridge,adv7511_mode_set (adv, mode, adj_mode); } +static enum drm_mode_status adv7511_bridge_mode_valid (struct drm_bridge *bridge, +const struct drm_display_info *info, +const struct drm_display_mode *mode) +{ +struct adv7511 *adv =bridge_to_adv7511 (bridge); + +if (adv->type ==ADV7533 || adv->type ==ADV7535 ) +return adv7533_mode_valid (adv, mode); +else +return adv7511_mode_valid (adv, mode); +} +static int adv7511_bridge_attach (struct drm_bridge *bridge,enum drm_bridge_attach_flags flags) {
@@ -963,6 +972,7 @@ static const struct drm_bridge_funcs adv7511_bridge_funcs = { .enable = adv7511_bridge_enable, .disable = adv7511_bridge_disable, .mode_set = adv7511_bridge_mode_set, + .mode_valid = adv7511_bridge_mode_valid, .attach = adv7511_bridge_attach, .detect = adv7511_bridge_detect, .get_edid = adv7511_bridge_get_edid,
drivers/gpu/drm/bridge/adv7511/adv7533.c +13 -12
@@ -100,26 +100,27 @@ void adv7533_dsi_power_off(struct adv7511 *adv)regmap_write (adv->regmap_cec,0x27 ,0x0b ); } -void adv7533_mode_set (struct adv7511 *adv,const struct drm_display_mode *mode) +enum drm_mode_status adv7533_mode_valid (struct adv7511 *adv, +const struct drm_display_mode *mode) { +int lanes;struct mipi_dsi_device *dsi = adv->dsi; -int lanes, ret; - -if (adv->num_dsi_lanes !=4 ) -return ;if (mode->clock >80000 ) lanes =4 ;else lanes =3 ; -if (lanes != dsi->lanes) { -mipi_dsi_detach (dsi); - dsi->lanes = lanes; - ret =mipi_dsi_attach (dsi); -if (ret) -dev_err (&dsi->dev,"failed to change host lanes\n" ); - } +/* +* TODO: add support for dynamic switching of lanes +* by using the bridge pre_enable() op . Till then filter +* out the modes which shall need different number of lanes +* than what was configured in the device tree. +*/ +if (lanes != dsi->lanes) +return MODE_BAD ; + +return MODE_OK ; }int adv7533_patch_registers (struct adv7511 *adv)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 145/731 libbpf: Fix use-after-free in btf_dump_name_dups
In reply to Greg Kroah-HartmanFrom: Xu Kuohai <[email protected]>
[ Upstream commit 93c660ca40b5d2f7c1b1626e955a8e9fa30e0749 ]
ASAN reports an use-after-free in btf_dump_name_dups:
ERROR: AddressSanitizer: heap-use-after-free on address 0xffff927006db at pc 0xaaaab5dfb618 bp 0xffffdd89b890 sp 0xffffdd89b928 READ of size 2 at 0xffff927006db thread T0
#0 0xaaaab5dfb614 in __interceptor_strcmp.part.0 (test_progs+0x21b614)
#1 0xaaaab635f144 in str_equal_fn tools/lib/bpf/btf_dump.c:127
#2 0xaaaab635e3e0 in hashmap_find_entry tools/lib/bpf/hashmap.c:143
#3 0xaaaab635e72c in hashmap__find tools/lib/bpf/hashmap.c:212
#4 0xaaaab6362258 in btf_dump_name_dups tools/lib/bpf/btf_dump.c:1525
#5 0xaaaab636240c in btf_dump_resolve_name tools/lib/bpf/btf_dump.c:1552
#6 0xaaaab6362598 in btf_dump_type_name tools/lib/bpf/btf_dump.c:1567
#7 0xaaaab6360b48 in btf_dump_emit_struct_def tools/lib/bpf/btf_dump.c:912
#8 0xaaaab6360630 in btf_dump_emit_type tools/lib/bpf/btf_dump.c:798
#9 0xaaaab635f720 in btf_dump__dump_type tools/lib/bpf/btf_dump.c:282
#10 0xaaaab608523c in test_btf_dump_incremental tools/testing/selftests/bpf/prog_tests/btf_dump.c:236
#11 0xaaaab6097530 in test_btf_dump tools/testing/selftests/bpf/prog_tests/btf_dump.c:875
#12 0xaaaab6314ed0 in run_one_test tools/testing/selftests/bpf/test_progs.c:1062
#13 0xaaaab631a0a8 in main tools/testing/selftests/bpf/test_progs.c:1697
#14 0xffff9676d214 in __libc_start_main ../csu/libc-start.c:308
#15 0xaaaab5d65990 (test_progs+0x185990)0xffff927006db is located 11 bytes inside of 16-byte region [0xffff927006d0,0xffff927006e0) freed by thread T0 here:
#0 0xaaaab5e2c7c4 in realloc (test_progs+0x24c7c4)
#1 0xaaaab634f4a0 in libbpf_reallocarray tools/lib/bpf/libbpf_internal.h:191
#2 0xaaaab634f840 in libbpf_add_mem tools/lib/bpf/btf.c:163
#3 0xaaaab636643c in strset_add_str_mem tools/lib/bpf/strset.c:106
#4 0xaaaab6366560 in strset__add_str tools/lib/bpf/strset.c:157
#5 0xaaaab6352d70 in btf__add_str tools/lib/bpf/btf.c:1519
#6 0xaaaab6353e10 in btf__add_field tools/lib/bpf/btf.c:2032
#7 0xaaaab6084fcc in test_btf_dump_incremental tools/testing/selftests/bpf/prog_tests/btf_dump.c:232
#8 0xaaaab6097530 in test_btf_dump tools/testing/selftests/bpf/prog_tests/btf_dump.c:875
#9 0xaaaab6314ed0 in run_one_test tools/testing/selftests/bpf/test_progs.c:1062
#10 0xaaaab631a0a8 in main tools/testing/selftests/bpf/test_progs.c:1697
#11 0xffff9676d214 in __libc_start_main ../csu/libc-start.c:308
#12 0xaaaab5d65990 (test_progs+0x185990)previously allocated by thread T0 here:
#0 0xaaaab5e2c7c4 in realloc (test_progs+0x24c7c4)
#1 0xaaaab634f4a0 in libbpf_reallocarray tools/lib/bpf/libbpf_internal.h:191
#2 0xaaaab634f840 in libbpf_add_mem tools/lib/bpf/btf.c:163
#3 0xaaaab636643c in strset_add_str_mem tools/lib/bpf/strset.c:106
#4 0xaaaab6366560 in strset__add_str tools/lib/bpf/strset.c:157
#5 0xaaaab6352d70 in btf__add_str tools/lib/bpf/btf.c:1519
#6 0xaaaab6353ff0 in btf_add_enum_common tools/lib/bpf/btf.c:2070
#7 0xaaaab6354080 in btf__add_enum tools/lib/bpf/btf.c:2102
#8 0xaaaab6082f50 in test_btf_dump_incremental tools/testing/selftests/bpf/prog_tests/btf_dump.c:162
#9 0xaaaab6097530 in test_btf_dump tools/testing/selftests/bpf/prog_tests/btf_dump.c:875
#10 0xaaaab6314ed0 in run_one_test tools/testing/selftests/bpf/test_progs.c:1062
#11 0xaaaab631a0a8 in main tools/testing/selftests/bpf/test_progs.c:1697
#12 0xffff9676d214 in __libc_start_main ../csu/libc-start.c:308
#13 0xaaaab5d65990 (test_progs+0x185990)The reason is that the key stored in hash table name_map is a string address, and the string memory is allocated by realloc() function, when the memory is resized by realloc() later, the old memory may be freed, so the address stored in name_map references to a freed memory, causing use-after-free.
Fix it by storing duplicated string address in name_map.
--- tools/lib/bpf/btf_dump.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
tools/lib/bpf/btf_dump.c +26 -3
@@ -215,6 +215,17 @@ static int btf_dump_resize(struct btf_dump *d)return 0 ; } +static void btf_dump_free_names (struct hashmap *map) +{ +size_t bkt; +struct hashmap_entry *cur; + +hashmap__for_each_entry (map, cur, bkt) +free ((void *)cur->key); + +hashmap__free (map); +} +void btf_dump__free (struct btf_dump *d) {int i;
@@ -233,8 +244,8 @@ void btf_dump__free(struct btf_dump *d)free (d->cached_names);free (d->emit_queue);free (d->decl_stack); -hashmap__free (d->type_names); -hashmap__free (d->ident_names); +btf_dump_free_names (d->type_names); +btf_dump_free_names (d->ident_names);free (d); }
@@ -1457,11 +1468,23 @@ static void btf_dump_emit_type_cast(struct btf_dump *d, __u32 id,static size_t btf_dump_name_dups (struct btf_dump *d,struct hashmap *name_map,const char *orig_name) { +char *old_name, *new_name;size_t dup_cnt =0 ; +int err; + + new_name =strdup (orig_name); +if (!new_name) +return 1 ;hashmap__find (name_map, orig_name, (void **)&dup_cnt); dup_cnt++; -hashmap__set (name_map, orig_name, (void *)dup_cnt,NULL ,NULL ); + + err =hashmap__set (name_map, new_name, (void *)dup_cnt, + (const void **)&old_name,NULL ); +if (err) +free (new_name); + +free (old_name);return dup_cnt; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 146/731 libbpf: Fix null-pointer dereference in find_prog_by_sec_insn()
In reply to Greg Kroah-HartmanFrom: Shung-Hsi Yu <[email protected]>
[ Upstream commit d0d382f95a9270dcf803539d6781d6bd67e3f5b2 ]
When there are no program sections, obj->programs is left unallocated, and find_prog_by_sec_insn()'s search lands on &obj->programs[0] == NULL, and will cause null-pointer dereference in the following access to prog->sec_idx.
Guard the search with obj->nr_programs similar to what's being done in __bpf_program__iter() to prevent null-pointer access from happening.
--- tools/lib/bpf/libbpf.c | 3 +++ 1 file changed, 3 insertions(+)
tools/lib/bpf/libbpf.c +3 -0
@@ -3763,6 +3763,9 @@ static struct bpf_program *find_prog_by_sec_insn(const struct bpf_object *obj,int l =0 , r = obj->nr_programs -1 , m;struct bpf_program *prog; +if (!obj->nr_programs) +return NULL ; +while (l < r) { m = l + (r - l +1 ) /2 ; prog = &obj->programs[m];
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 147/731 ata: libata: move ata_{port,link,dev}_dbg to standard pr_XXX() macros
In reply to Greg Kroah-HartmanFrom: Hannes Reinecke <[email protected]>
[ Upstream commit 742bef476ca5352b16063161fb73a56629a6d995 ]
Use standard pr_{debug,info,notice,warn,err} macros instead of the hand-crafted printk helpers.
Stable-dep-of: 7390896b3484 ("ata: libata: fix NCQ autosense logic")
--- drivers/ata/libata-acpi.c | 48 +++++++++++++------------ drivers/ata/libata-core.c | 61 ------------------------------- drivers/ata/pata_ixp4xx_cf.c | 6 ++-- include/linux/libata.h | 69 ++++++++++++++++++++---------------- 4 files changed, 67 insertions(+), 117 deletions(-)
drivers/ata/libata-acpi.c +26 -22
@@ -650,9 +650,7 @@ static int ata_acpi_run_tf(struct ata_device *dev,struct ata_taskfile *pptf =NULL ;struct ata_taskfile tf, ptf, rtf;unsigned int err_mask; -const char *level;const char *descr; -char msg[60 ];int rc; if ((gtf->tf[0] == 0) && (gtf->tf[1] == 0) && (gtf->tf[2] == 0)
@@ -666,6 +664,10 @@ static int ata_acpi_run_tf(struct ata_device *dev, pptf = &ptf; } + descr =ata_get_cmd_descript (tf.command); +if (!descr) + descr ="unknown" ; +if (!ata_acpi_filter_tf (dev, &tf, pptf)) { rtf = tf; err_mask = ata_exec_internal(dev, &rtf, NULL,
@@ -673,40 +675,42 @@ static int ata_acpi_run_tf(struct ata_device *dev,switch (err_mask) {case 0 : - level =KERN_DEBUG ; -snprintf (msg,sizeof (msg),"succeeded" ); +ata_dev_dbg (dev, +"ACPI cmd %02x/%02x:%02x:%02x:%02x:%02x:%02x" +"(%s) succeeded\n" , + tf.command, tf.feature, tf.nsect, tf.lbal, + tf.lbam, tf.lbah, tf.device, descr); rc =1 ;break ;case AC_ERR_DEV : - level =KERN_INFO ; -snprintf (msg,sizeof (msg), -"rejected by device (Stat=0x%02x Err=0x%02x)" , - rtf.command, rtf.feature); +ata_dev_info (dev, +"ACPI cmd %02x/%02x:%02x:%02x:%02x:%02x:%02x" +"(%s) rejected by device (Stat=0x%02x Err=0x%02x)" , + tf.command, tf.feature, tf.nsect, tf.lbal, + tf.lbam, tf.lbah, tf.device, descr, + rtf.command, rtf.feature); rc =0 ;break ;default : - level =KERN_ERR ; -snprintf (msg,sizeof (msg), -"failed (Emask=0x%x Stat=0x%02x Err=0x%02x)" , - err_mask, rtf.command, rtf.feature); +ata_dev_err (dev, +"ACPI cmd %02x/%02x:%02x:%02x:%02x:%02x:%02x" +"(%s) failed (Emask=0x%x Stat=0x%02x Err=0x%02x)" , + tf.command, tf.feature, tf.nsect, tf.lbal, + tf.lbam, tf.lbah, tf.device, descr, + err_mask, rtf.command, rtf.feature); rc = -EIO ;break ; } }else { - level =KERN_INFO ; -snprintf (msg,sizeof (msg),"filtered out" ); +ata_dev_info (dev, +"ACPI cmd %02x/%02x:%02x:%02x:%02x:%02x:%02x" +"(%s) filtered out\n" , + tf.command, tf.feature, tf.nsect, tf.lbal, + tf.lbam, tf.lbah, tf.device, descr); rc =0 ; } - descr =ata_get_cmd_descript (tf.command); - -ata_dev_printk (dev, level, -"ACPI cmd %02x/%02x:%02x:%02x:%02x:%02x:%02x (%s) %s\n" , - tf.command, tf.feature, tf.nsect, tf.lbal, - tf.lbam, tf.lbah, tf.device, - (descr ? descr :"unknown" ), msg); -return rc; }
drivers/ata/libata-core.c +0 -61
67 lines not on this page · raw message
drivers/ata/pata_ixp4xx_cf.c +3 -3
@@ -114,7 +114,7 @@ static void ixp4xx_set_piomode(struct ata_port *ap, struct ata_device *adev) {struct ixp4xx_pata *ixpp = ap->host->private_data; -ata_dev_printk (adev,KERN_INFO ,"configured for PIO%d 8bit\n" , +ata_dev_info (adev,"configured for PIO%d 8bit\n" , adev->pio_mode -XFER_PIO_0 );ixp4xx_set_8bit_timing (ixpp, adev->pio_mode); }
@@ -132,8 +132,8 @@ static unsigned int ixp4xx_mmio_data_xfer(struct ata_queued_cmd *qc,struct ixp4xx_pata *ixpp = ap->host->private_data;unsigned long flags; -ata_dev_printk (adev,KERN_DEBUG ,"%s %d bytes\n" , (rw ==READ ) ?"READ" :"WRITE" , - buflen); +ata_dev_dbg (adev,"%s %d bytes\n" , (rw ==READ ) ?"READ" :"WRITE" , + buflen);spin_lock_irqsave (ap->lock, flags);/* set the expansion bus in 16bit mode and restore
include/linux/libata.h +38 -31
100 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 148/731 ata: add/use ata_taskfile::{error|status} fields
In reply to Greg Kroah-HartmanFrom: Sergey Shtylyov <[email protected]>
[ Upstream commit efcef265fd83d9a68a68926abecb3e1dd3e260a8 ]
Add the explicit error and status register fields to 'struct ata_taskfile' using the anonymous *union*s ('struct ide_taskfile' had that for ages!) and update the libata taskfile code accordingly. There should be no object code changes resulting from that...
Stable-dep-of: 7390896b3484 ("ata: libata: fix NCQ autosense logic")
--- drivers/ata/acard-ahci.c | 2 +- drivers/ata/ahci.c | 4 ++-- drivers/ata/ahci_qoriq.c | 2 +- drivers/ata/ahci_xgene.c | 2 +- drivers/ata/libahci.c | 4 ++-- drivers/ata/libata-acpi.c | 8 +++---- drivers/ata/libata-core.c | 12 +++++----- drivers/ata/libata-eh.c | 42 +++++++++++++++++------------------ drivers/ata/libata-sata.c | 10 ++++----- drivers/ata/libata-scsi.c | 22 +++++++++--------- drivers/ata/libata-sff.c | 6 ++--- drivers/ata/pata_ep93xx.c | 4 ++-- drivers/ata/pata_ns87415.c | 4 ++-- drivers/ata/pata_octeon_cf.c | 4 ++-- drivers/ata/pata_samsung_cf.c | 2 +- drivers/ata/sata_highbank.c | 2 +- drivers/ata/sata_inic162x.c | 10 ++++----- drivers/ata/sata_rcar.c | 4 ++-- drivers/ata/sata_svw.c | 10 ++++----- drivers/ata/sata_vsc.c | 10 ++++----- include/linux/libata.h | 10 +++++++-- 21 files changed, 90 insertions(+), 84 deletions(-)
drivers/ata/acard-ahci.c +1 -1
@@ -267,7 +267,7 @@ static bool acard_ahci_qc_fill_rtf(struct ata_queued_cmd *qc)if (qc->tf.protocol ==ATA_PROT_PIO && qc->dma_dir ==DMA_FROM_DEVICE && !(qc->flags &ATA_QCFLAG_FAILED )) {ata_tf_from_fis (rx_fis +RX_FIS_PIO_SETUP , &qc->result_tf); - qc->result_tf.command = (rx_fis +RX_FIS_PIO_SETUP )[15 ]; + qc->result_tf.status = (rx_fis +RX_FIS_PIO_SETUP )[15 ]; }else ata_tf_from_fis (rx_fis +RX_FIS_D2H_REG , &qc->result_tf);
drivers/ata/ahci.c +2 -2
@@ -735,7 +735,7 @@ static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,/* clear D2H reception area to properly wait for D2H FIS */ ata_tf_init (link->device, &tf); - tf.command =ATA_BUSY ; + tf.status =ATA_BUSY ;ata_tf_to_fis (&tf,0 ,0 , d2h_fis); rc = sata_link_hardreset(link, sata_ehc_deb_timing(&link->eh_context),
@@ -806,7 +806,7 @@ static int ahci_avn_hardreset(struct ata_link *link, unsigned int *class,/* clear D2H reception area to properly wait for D2H FIS */ ata_tf_init (link->device, &tf); - tf.command =ATA_BUSY ; + tf.status =ATA_BUSY ;ata_tf_to_fis (&tf,0 ,0 , d2h_fis); rc = sata_link_hardreset(link, timing, deadline, &online,
drivers/ata/ahci_qoriq.c +1 -1
@@ -125,7 +125,7 @@ static int ahci_qoriq_hardreset(struct ata_link *link, unsigned int *class,/* clear D2H reception area to properly wait for D2H FIS */ ata_tf_init (link->device, &tf); - tf.command =ATA_BUSY ; + tf.status =ATA_BUSY ;ata_tf_to_fis (&tf,0 ,0 , d2h_fis); rc = sata_link_hardreset(link, timing, deadline, &online,
drivers/ata/ahci_xgene.c +1 -1
@@ -365,7 +365,7 @@ static int xgene_ahci_do_hardreset(struct ata_link *link, do { /* clear D2H reception area to properly wait for D2H FIS */ ata_tf_init(link->device, &tf); - tf.command = ATA_BUSY; + tf.status = ATA_BUSY; ata_tf_to_fis(&tf, 0, 0, d2h_fis); rc = sata_link_hardreset(link, timing, deadline, online, ahci_check_ready);
drivers/ata/libahci.c +2 -2
@@ -1552,7 +1552,7 @@ int ahci_do_hardreset(struct ata_link *link, unsigned int *class,/* clear D2H reception area to properly wait for D2H FIS */ ata_tf_init (link->device, &tf); - tf.command =ATA_BUSY ; + tf.status =ATA_BUSY ;ata_tf_to_fis (&tf,0 ,0 , d2h_fis); rc = sata_link_hardreset(link, timing, deadline, online,
@@ -2038,7 +2038,7 @@ static bool ahci_qc_fill_rtf(struct ata_queued_cmd *qc)if (qc->tf.protocol ==ATA_PROT_PIO && qc->dma_dir ==DMA_FROM_DEVICE && !(qc->flags &ATA_QCFLAG_FAILED )) {ata_tf_from_fis (rx_fis +RX_FIS_PIO_SETUP , &qc->result_tf); - qc->result_tf.command = (rx_fis +RX_FIS_PIO_SETUP )[15 ]; + qc->result_tf.status = (rx_fis +RX_FIS_PIO_SETUP )[15 ]; }else ata_tf_from_fis (rx_fis +RX_FIS_D2H_REG , &qc->result_tf);
drivers/ata/libata-acpi.c +4 -4
@@ -554,13 +554,13 @@ static void ata_acpi_gtf_to_tf(struct ata_device *dev, tf->flags |=ATA_TFLAG_ISADDR |ATA_TFLAG_DEVICE ; tf->protocol =ATA_PROT_NODATA ; - tf->feature = gtf->tf[0 ];/* 0x1f1 */ + tf->error = gtf->tf[0 ];/* 0x1f1 */ tf->nsect = gtf->tf[1 ];/* 0x1f2 */ tf->lbal = gtf->tf[2 ];/* 0x1f3 */ tf->lbam = gtf->tf[3 ];/* 0x1f4 */ tf->lbah = gtf->tf[4 ];/* 0x1f5 */ tf->device = gtf->tf[5 ];/* 0x1f6 */ - tf->command = gtf->tf[6 ];/* 0x1f7 */ + tf->status = gtf->tf[6 ];/* 0x1f7 */ } static int ata_acpi_filter_tf(struct ata_device *dev,
@@ -689,7 +689,7 @@ static int ata_acpi_run_tf(struct ata_device *dev,"(%s) rejected by device (Stat=0x%02x Err=0x%02x)" , tf.command, tf.feature, tf.nsect, tf.lbal, tf.lbam, tf.lbah, tf.device, descr, - rtf.command, rtf.feature); + rtf.status, rtf.error); rc =0 ;break ;
@@ -699,7 +699,7 @@ static int ata_acpi_run_tf(struct ata_device *dev,"(%s) failed (Emask=0x%x Stat=0x%02x Err=0x%02x)" , tf.command, tf.feature, tf.nsect, tf.lbal, tf.lbam, tf.lbah, tf.device, descr, - err_mask, rtf.command, rtf.feature); + err_mask, rtf.status, rtf.error); rc = -EIO ;break ; }
drivers/ata/libata-core.c +6 -6
@@ -1185,7 +1185,7 @@ static int ata_read_native_max_address(struct ata_device *dev, u64 *max_sectors)ata_dev_warn (dev,"failed to read native max address (err_mask=0x%x)\n" , err_mask); -if (err_mask ==AC_ERR_DEV && (tf.feature &ATA_ABORTED )) +if (err_mask ==AC_ERR_DEV && (tf.error &ATA_ABORTED ))return -EACCES ;return -EIO ; }
@@ -1249,7 +1249,7 @@ static int ata_set_max_sectors(struct ata_device *dev, u64 new_sectors)"failed to set max address (err_mask=0x%x)\n" , err_mask);if (err_mask ==AC_ERR_DEV && - (tf.feature & (ATA_ABORTED |ATA_IDNF ))) + (tf.error & (ATA_ABORTED |ATA_IDNF )))return -EACCES ;return -EIO ; }
@@ -1616,7 +1616,7 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,/* perform minimal error analysis */ if (qc->flags &ATA_QCFLAG_FAILED ) { -if (qc->result_tf.command & (ATA_ERR |ATA_DF )) +if (qc->result_tf.status & (ATA_ERR |ATA_DF )) qc->err_mask |=AC_ERR_DEV ;if (!qc->err_mask)
@@ -1625,7 +1625,7 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,if (qc->err_mask & ~AC_ERR_OTHER ) qc->err_mask &= ~AC_ERR_OTHER ; }else if (qc->tf.command ==ATA_CMD_REQ_SENSE_DATA ) { - qc->result_tf.command |=ATA_SENSE ; + qc->result_tf.status |=ATA_SENSE ; }/* finish up */
@@ -1848,7 +1848,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,return 0 ; } -if ((err_mask ==AC_ERR_DEV ) && (tf.feature &ATA_ABORTED )) { +if ((err_mask ==AC_ERR_DEV ) && (tf.error &ATA_ABORTED )) {/* Device or controller might have reported * the wrong device class. Give a shot at the * other IDENTIFY if the current one is
@@ -4371,7 +4371,7 @@ static unsigned int ata_dev_init_params(struct ata_device *dev,/* A clean abort indicates an original or just out of spec drive and we should continue as we issue the setup based on the drive reported working geometry */ -if (err_mask ==AC_ERR_DEV && (tf.feature &ATA_ABORTED )) +if (err_mask ==AC_ERR_DEV && (tf.error &ATA_ABORTED )) err_mask =0 ;DPRINTK ("EXIT, err_mask=%x\n" , err_mask);
drivers/ata/libata-eh.c +21 -21
89 lines not on this page · raw message
drivers/ata/libata-sata.c +5 -5
@@ -191,8 +191,8 @@ EXPORT_SYMBOL_GPL(ata_tf_to_fis);void ata_tf_from_fis (const u8 *fis,struct ata_taskfile *tf) { - tf->command = fis[2 ];/* status */ - tf->feature = fis[3 ];/* error */ + tf->status = fis[2 ]; + tf->error = fis[3 ]; tf->lbal = fis[4 ]; tf->lbam = fis[5 ];
@@ -1402,8 +1402,8 @@ static int ata_eh_read_log_10h(struct ata_device *dev, *tag = buf[0 ] &0x1f ; - tf->command = buf[2 ]; - tf->feature = buf[3 ]; + tf->status = buf[2 ]; + tf->error = buf[3 ]; tf->lbal = buf[4 ]; tf->lbam = buf[5 ]; tf->lbah = buf[6 ];
@@ -1478,7 +1478,7 @@ void ata_eh_analyze_ncq_error(struct ata_link *link) qc->result_tf.flags =ATA_TFLAG_ISADDR |ATA_TFLAG_LBA |ATA_TFLAG_LBA48 ; qc->err_mask |=AC_ERR_DEV |AC_ERR_NCQ ;if (dev->class ==ATA_DEV_ZAC && - ((qc->result_tf.command &ATA_SENSE ) || qc->result_tf.auxiliary)) { + ((qc->result_tf.status &ATA_SENSE ) || qc->result_tf.auxiliary)) {char sense_key, asc, ascq; sense_key = (qc->result_tf.auxiliary >>16 ) &0xff ;
drivers/ata/libata-scsi.c +11 -11
@@ -671,7 +671,7 @@ static void ata_qc_set_pc_nbytes(struct ata_queued_cmd *qc)*/ static void ata_dump_status (unsigned id,struct ata_taskfile *tf) { -u8 stat = tf->command, err = tf->feature; +u8 stat = tf->status, err = tf->error;pr_warn ("ata%u: status=0x%02x { " , id, stat);if (stat &ATA_BUSY ) {
@@ -867,8 +867,8 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc)* onto sense key, asc & ascq. */ if (qc->err_mask || - tf->command & (ATA_BUSY |ATA_DF |ATA_ERR |ATA_DRQ )) { -ata_to_sense_error (qc->ap->print_id, tf->command, tf->feature, + tf->status & (ATA_BUSY |ATA_DF |ATA_ERR |ATA_DRQ )) { +ata_to_sense_error (qc->ap->print_id, tf->status, tf->error, &sense_key, &asc, &ascq, verbose);ata_scsi_set_sense (qc->dev, cmd, sense_key, asc, ascq); }else {
@@ -897,13 +897,13 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc)* Copy registers into sense buffer. */ desc[2 ] =0x00 ; - desc[3 ] = tf->feature;/* == error reg */ + desc[3 ] = tf->error; desc[5 ] = tf->nsect; desc[7 ] = tf->lbal; desc[9 ] = tf->lbam; desc[11 ] = tf->lbah; desc[12 ] = tf->device; - desc[13 ] = tf->command;/* == status reg */ + desc[13 ] = tf->status;/* * Fill in Extend bit, and the high order bytes
@@ -918,8 +918,8 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) } }else {/* Fixed sense format */ - desc[0 ] = tf->feature; - desc[1 ] = tf->command;/* status */ + desc[0 ] = tf->error; + desc[1 ] = tf->status; desc[2 ] = tf->device; desc[3 ] = tf->nsect; desc[7 ] =0 ;
@@ -968,14 +968,14 @@ static void ata_gen_ata_sense(struct ata_queued_cmd *qc)* onto sense key, asc & ascq. */ if (qc->err_mask || - tf->command & (ATA_BUSY |ATA_DF |ATA_ERR |ATA_DRQ )) { -ata_to_sense_error (qc->ap->print_id, tf->command, tf->feature, + tf->status & (ATA_BUSY |ATA_DF |ATA_ERR |ATA_DRQ )) { +ata_to_sense_error (qc->ap->print_id, tf->status, tf->error, &sense_key, &asc, &ascq, verbose);ata_scsi_set_sense (dev, cmd, sense_key, asc, ascq); }else {/* Could not decode error */ ata_dev_warn (dev,"could not decode error status 0x%x err_mask 0x%x\n" , - tf->command, qc->err_mask); + tf->status, qc->err_mask);ata_scsi_set_sense (dev, cmd,ABORTED_COMMAND ,0 ,0 );return ; }
@@ -2490,7 +2490,7 @@ static void atapi_request_sense(struct ata_queued_cmd *qc)/* fill these in, for the case where they are -not- overwritten */ cmd->sense_buffer[0 ] =0x70 ; - cmd->sense_buffer[2 ] = qc->tf.feature >>4 ; + cmd->sense_buffer[2 ] = qc->tf.error >>4 ;ata_qc_reinit (qc);
drivers/ata/libata-sff.c +3 -3
@@ -457,8 +457,8 @@ void ata_sff_tf_read(struct ata_port *ap, struct ata_taskfile *tf) {struct ata_ioports *ioaddr = &ap->ioaddr; - tf->command =ata_sff_check_status (ap); - tf->feature =ioread8 (ioaddr->error_addr); + tf->status =ata_sff_check_status (ap); + tf->error =ioread8 (ioaddr->error_addr); tf->nsect =ioread8 (ioaddr->nsect_addr); tf->lbal =ioread8 (ioaddr->lbal_addr); tf->lbam =ioread8 (ioaddr->lbam_addr);
@@ -1837,7 +1837,7 @@ unsigned int ata_sff_dev_classify(struct ata_device *dev, int present,memset (&tf,0 ,sizeof (tf)); ap->ops->sff_tf_read (ap, &tf); - err = tf.feature; + err = tf.error;if (r_err) *r_err = err;
drivers/ata/pata_ep93xx.c +2 -2
@@ -416,8 +416,8 @@ static void ep93xx_pata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) {struct ep93xx_pata_data *drv_data = ap->host->private_data; - tf->command =ep93xx_pata_check_status (ap); - tf->feature =ep93xx_pata_read_reg (drv_data,IDECTRL_ADDR_FEATURE ); + tf->status =ep93xx_pata_check_status (ap); + tf->error =ep93xx_pata_read_reg (drv_data,IDECTRL_ADDR_FEATURE ); tf->nsect =ep93xx_pata_read_reg (drv_data,IDECTRL_ADDR_NSECT ); tf->lbal =ep93xx_pata_read_reg (drv_data,IDECTRL_ADDR_LBAL ); tf->lbam =ep93xx_pata_read_reg (drv_data,IDECTRL_ADDR_LBAM );
drivers/ata/pata_ns87415.c +2 -2
@@ -264,8 +264,8 @@ void ns87560_tf_read(struct ata_port *ap, struct ata_taskfile *tf) {struct ata_ioports *ioaddr = &ap->ioaddr; - tf->command =ns87560_check_status (ap); - tf->feature =ioread8 (ioaddr->error_addr); + tf->status =ns87560_check_status (ap); + tf->error =ioread8 (ioaddr->error_addr); tf->nsect =ioread8 (ioaddr->nsect_addr); tf->lbal =ioread8 (ioaddr->lbal_addr); tf->lbam =ioread8 (ioaddr->lbam_addr);
drivers/ata/pata_octeon_cf.c +2 -2
@@ -386,7 +386,7 @@ static void octeon_cf_tf_read16(struct ata_port *ap, struct ata_taskfile *tf)void __iomem *base = ap->ioaddr.data_addr; blob =__raw_readw (base +0xc ); - tf->feature = blob >>8 ; + tf->error = blob >>8 ; blob =__raw_readw (base +2 ); tf->nsect = blob &0xff ;
@@ -398,7 +398,7 @@ static void octeon_cf_tf_read16(struct ata_port *ap, struct ata_taskfile *tf) blob =__raw_readw (base +6 ); tf->device = blob &0xff ; - tf->command = blob >>8 ; + tf->status = blob >>8 ;if (tf->flags &ATA_TFLAG_LBA48 ) {if (likely (ap->ioaddr.ctl_addr)) {
drivers/ata/pata_samsung_cf.c +1 -1
@@ -213,7 +213,7 @@ static void pata_s3c_tf_read(struct ata_port *ap, struct ata_taskfile *tf) {struct ata_ioports *ioaddr = &ap->ioaddr; - tf->feature =ata_inb (ap->host, ioaddr->error_addr); + tf->error =ata_inb (ap->host, ioaddr->error_addr); tf->nsect =ata_inb (ap->host, ioaddr->nsect_addr); tf->lbal =ata_inb (ap->host, ioaddr->lbal_addr); tf->lbam =ata_inb (ap->host, ioaddr->lbam_addr);
drivers/ata/sata_highbank.c +1 -1
@@ -400,7 +400,7 @@ static int ahci_highbank_hardreset(struct ata_link *link, unsigned int *class,/* clear D2H reception area to properly wait for D2H FIS */ ata_tf_init (link->device, &tf); - tf.command =ATA_BUSY ; + tf.status =ATA_BUSY ;ata_tf_to_fis (&tf,0 ,0 , d2h_fis); do {
drivers/ata/sata_inic162x.c +5 -5
@@ -559,13 +559,13 @@ static void inic_tf_read(struct ata_port *ap, struct ata_taskfile *tf) {void __iomem *port_base =inic_port_base (ap); - tf->feature =readb (port_base +PORT_TF_FEATURE ); + tf->error =readb (port_base +PORT_TF_FEATURE ); tf->nsect =readb (port_base +PORT_TF_NSECT ); tf->lbal =readb (port_base +PORT_TF_LBAL ); tf->lbam =readb (port_base +PORT_TF_LBAM ); tf->lbah =readb (port_base +PORT_TF_LBAH ); tf->device =readb (port_base +PORT_TF_DEVICE ); - tf->command =readb (port_base +PORT_TF_COMMAND ); + tf->status =readb (port_base +PORT_TF_COMMAND ); }static bool inic_qc_fill_rtf (struct ata_queued_cmd *qc)
@@ -582,11 +582,11 @@ static bool inic_qc_fill_rtf(struct ata_queued_cmd *qc)*/ inic_tf_read (qc->ap, &tf); -if (!(tf.command &ATA_ERR )) +if (!(tf.status &ATA_ERR ))return false; - rtf->command = tf.command; - rtf->feature = tf.feature; + rtf->status = tf.status; + rtf->error = tf.error;return true; }
drivers/ata/sata_rcar.c +2 -2
@@ -417,8 +417,8 @@ static void sata_rcar_tf_read(struct ata_port *ap, struct ata_taskfile *tf) {struct ata_ioports *ioaddr = &ap->ioaddr; - tf->command =sata_rcar_check_status (ap); - tf->feature =ioread32 (ioaddr->error_addr); + tf->status =sata_rcar_check_status (ap); + tf->error =ioread32 (ioaddr->error_addr); tf->nsect =ioread32 (ioaddr->nsect_addr); tf->lbal =ioread32 (ioaddr->lbal_addr); tf->lbam =ioread32 (ioaddr->lbam_addr);
drivers/ata/sata_svw.c +5 -5
@@ -194,24 +194,24 @@ static void k2_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)static void k2_sata_tf_read (struct ata_port *ap,struct ata_taskfile *tf) {struct ata_ioports *ioaddr = &ap->ioaddr; -u16 nsect, lbal, lbam, lbah, feature; +u16 nsect, lbal, lbam, lbah, error; - tf->command =k2_stat_check_status (ap); + tf->status =k2_stat_check_status (ap); tf->device =readw (ioaddr->device_addr); - feature =readw (ioaddr->error_addr); + error =readw (ioaddr->error_addr); nsect =readw (ioaddr->nsect_addr); lbal =readw (ioaddr->lbal_addr); lbam =readw (ioaddr->lbam_addr); lbah =readw (ioaddr->lbah_addr); - tf->feature = feature; + tf->error = error; tf->nsect = nsect; tf->lbal = lbal; tf->lbam = lbam; tf->lbah = lbah;if (tf->flags &ATA_TFLAG_LBA48 ) { - tf->hob_feature = feature >>8 ; + tf->hob_feature = error >>8 ; tf->hob_nsect = nsect >>8 ; tf->hob_lbal = lbal >>8 ; tf->hob_lbam = lbam >>8 ;
drivers/ata/sata_vsc.c +5 -5
@@ -183,24 +183,24 @@ static void vsc_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)static void vsc_sata_tf_read (struct ata_port *ap,struct ata_taskfile *tf) {struct ata_ioports *ioaddr = &ap->ioaddr; -u16 nsect, lbal, lbam, lbah, feature; +u16 nsect, lbal, lbam, lbah, error; - tf->command =ata_sff_check_status (ap); + tf->status =ata_sff_check_status (ap); tf->device =readw (ioaddr->device_addr); - feature =readw (ioaddr->error_addr); + error =readw (ioaddr->error_addr); nsect =readw (ioaddr->nsect_addr); lbal =readw (ioaddr->lbal_addr); lbam =readw (ioaddr->lbam_addr); lbah =readw (ioaddr->lbah_addr); - tf->feature = feature; + tf->error = error; tf->nsect = nsect; tf->lbal = lbal; tf->lbam = lbam; tf->lbah = lbah;if (tf->flags &ATA_TFLAG_LBA48 ) { - tf->hob_feature = feature >>8 ; + tf->hob_feature = error >>8 ; tf->hob_nsect = nsect >>8 ; tf->hob_lbal = lbal >>8 ; tf->hob_lbam = lbam >>8 ;
include/linux/libata.h +8 -2
@@ -565,7 +565,10 @@ struct ata_taskfile {u8 hob_lbam;u8 hob_lbah; -u8 feature; +union { +u8 error; +u8 feature; + };u8 nsect;u8 lbal;u8 lbam;
@@ -573,7 +576,10 @@ struct ata_taskfile {u8 device; -u8 command;/* IO operation */ +union { +u8 status; +u8 command; + };u32 auxiliary;/* auxiliary field */ /* from SATA 3.1 and */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 149/731 ata: libata: fix NCQ autosense logic
In reply to Greg Kroah-HartmanFrom: Niklas Cassel <[email protected]>
[ Upstream commit 7390896b3484d44cbdb8bc4859964314ac66d3c9 ]
Currently, the logic if we should call ata_scsi_set_sense() (and set flag ATA_QCFLAG_SENSE_VALID to indicate that we have successfully added sense data to the struct ata_queued_cmd) looks like this:
if (dev->class == ATA_DEV_ZAC &&
((qc->result_tf.status & ATA_SENSE) || qc->result_tf.auxiliary))
The problem with this is that a drive can support the NCQ command error log without supporting NCQ autosense.
On such a drive, if the failing command has sense data, the status field in the NCQ command error log will have the ATA_SENSE bit set.
It is just that this sense data is not included in the NCQ command error log when NCQ autosense is not supported. Instead the sense data has to be fetched using the REQUEST SENSE DATA EXT command.
Therefore, we should only add the sense data if the drive supports NCQ autosense AND the ATA_SENSE bit is set in the status field.
Fix this, and at the same time, remove the duplicated ATA_DEV_ZAC check. The struct ata_taskfile supplied to ata_eh_read_log_10h() is memset:ed before calling the function, so simply checking if qc->result_tf.auxiliary is set is sufficient to tell us that the log actually contained sense data.
--- drivers/ata/libata-sata.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/ata/libata-sata.c +8 -3
@@ -1413,7 +1413,8 @@ static int ata_eh_read_log_10h(struct ata_device *dev, tf->hob_lbah = buf[10 ]; tf->nsect = buf[12 ]; tf->hob_nsect = buf[13 ]; -if (dev->class ==ATA_DEV_ZAC &&ata_id_has_ncq_autosense (dev->id)) +if (dev->class ==ATA_DEV_ZAC &&ata_id_has_ncq_autosense (dev->id) && + (tf->status &ATA_SENSE )) tf->auxiliary = buf[14 ] <<16 | buf[15 ] <<8 | buf[16 ];return 0 ;
@@ -1477,8 +1478,12 @@ void ata_eh_analyze_ncq_error(struct ata_link *link)memcpy (&qc->result_tf, &tf,sizeof (tf)); qc->result_tf.flags =ATA_TFLAG_ISADDR |ATA_TFLAG_LBA |ATA_TFLAG_LBA48 ; qc->err_mask |=AC_ERR_DEV |AC_ERR_NCQ ; -if (dev->class ==ATA_DEV_ZAC && - ((qc->result_tf.status &ATA_SENSE ) || qc->result_tf.auxiliary)) { + +/* +* If the device supports NCQ autosense, ata_eh_read_log_10h() will have +* stored the sense data in qc->result_tf.auxiliary. +*/ +if (qc->result_tf.auxiliary) {char sense_key, asc, ascq; sense_key = (qc->result_tf.auxiliary >>16 ) &0xff ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 150/731 ipmi: kcs: Poll OBF briefly to reduce OBE latency
In reply to Greg Kroah-HartmanFrom: Andrew Jeffery <[email protected]>
[ Upstream commit f90bc0f97f2b65af233a37b2e32fc81871a1e3cf ]
The ASPEED KCS devices don't provide a BMC-side interrupt for the host reading the output data register (ODR). The act of the host reading ODR clears the output buffer full (OBF) flag in the status register (STR), informing the BMC it can transmit a subsequent byte.
On the BMC side the KCS client must enable the OBE event *and* perform a subsequent read of STR anyway to avoid races - the polling provides a window for the host to read ODR if data was freshly written while minimising BMC-side latency.
Message-Id: <[email protected]>
--- drivers/char/ipmi/kcs_bmc_aspeed.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
drivers/char/ipmi/kcs_bmc_aspeed.c +21 -3
@@ -404,13 +404,31 @@ static void aspeed_kcs_check_obe(struct timer_list *timer)static void aspeed_kcs_irq_mask_update (struct kcs_bmc_device *kcs_bmc,u8 mask,u8 state) {struct aspeed_kcs_bmc *priv =to_aspeed_kcs_bmc (kcs_bmc); +int rc; +u8 str;/* We don't have an OBE IRQ, emulate it */ if (mask &KCS_BMC_EVENT_TYPE_OBE ) { -if (KCS_BMC_EVENT_TYPE_OBE & state) -mod_timer (&priv->obe.timer, jiffies +OBE_POLL_PERIOD ); -else +if (KCS_BMC_EVENT_TYPE_OBE & state) { +/* +* Given we don't have an OBE IRQ, delay by polling briefly to see if we can +* observe such an event before returning to the caller. This is not +* incorrect because OBF may have already become clear before enabling the +* IRQ if we had one, under which circumstance no event will be propagated +* anyway. +* +* The onus is on the client to perform a race-free check that it hasn't +* missed the event. +*/ + rc =read_poll_timeout_atomic (aspeed_kcs_inb, str, + !(str &KCS_BMC_STR_OBF ),1 ,100 , false, + &priv->kcs_bmc, priv->kcs_bmc.ioreg.str); +/* Time for the slow path? */ +if (rc == -ETIMEDOUT ) +mod_timer (&priv->obe.timer, jiffies +OBE_POLL_PERIOD ); + }else {del_timer (&priv->obe.timer); + } }if (mask &KCS_BMC_EVENT_TYPE_IBF ) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 151/731 drm/amdgpu/powerplay/psm: Fix memory leak in power state init
In reply to Greg Kroah-HartmanFrom: Rafael Mendonca <[email protected]>
[ Upstream commit 8f8033d5663b18e6efb33feb61f2287a04605ab5 ]
Commit 902bc65de0b3 ("drm/amdgpu/powerplay/psm: return an error in power state init") made the power state init function return early in case of failure to get an entry from the powerplay table, but it missed to clean up the allocated memory for the current power state before returning.
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c +2 -0
@@ -75,8 +75,10 @@ int psm_init_power_state_table(struct pp_hwmgr *hwmgr)for (i =0 ; i < table_entries; i++) { result = hwmgr->hwmgr_func->get_pp_table_entry (hwmgr, i, state);if (result) { +kfree (hwmgr->current_ps);kfree (hwmgr->request_ps);kfree (hwmgr->ps); + hwmgr->current_ps =NULL ; hwmgr->request_ps =NULL ; hwmgr->ps =NULL ;return -EINVAL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 152/731 powerpc: dts: t208x: Mark MAC1 and MAC2 as 10G
In reply to Greg Kroah-HartmanFrom: Sean Anderson <[email protected]>
[ Upstream commit 36926a7d70c2d462fca1ed85bfee000d17fd8662 ]
On the T208X SoCs, MAC1 and MAC2 support XGMII. Add some new MAC dtsi fragments, and mark the QMAN ports as 10G.
--- .../boot/dts/fsl/qoriq-fman3-0-10g-2.dtsi | 44 +++++++++++++++++++ .../boot/dts/fsl/qoriq-fman3-0-10g-3.dtsi | 44 +++++++++++++++++++ arch/powerpc/boot/dts/fsl/t2081si-post.dtsi | 4 +- 3 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-2.dtsi create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-3.dtsi
arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-2.dtsi new file +44 -0
@@ -0,0 +1,44 @@ +// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-or-later +/* + * QorIQ FMan v3 10g port #2 device tree stub [ controller @ offset 0x400000 ] + * + * Copyright 2022 Sean Anderson <[email protected]> + * Copyright 2012 - 2015 Freescale Semiconductor Inc. + */ + +fman@400000 { + fman0_rx_0x08: port@88000 { + cell-index = <0x8>; + compatible = "fsl,fman-v3-port-rx"; + reg = <0x88000 0x1000>; + fsl,fman-10g-port; + }; + + fman0_tx_0x28: port@a8000 { + cell-index = <0x28>; + compatible = "fsl,fman-v3-port-tx"; + reg = <0xa8000 0x1000>; + fsl,fman-10g-port; + }; + + ethernet@e0000 { + cell-index = <0>; + compatible = "fsl,fman-memac"; + reg = <0xe0000 0x1000>; + fsl,fman-ports = <&fman0_rx_0x08 &fman0_tx_0x28>; + ptp-timer = <&ptp_timer0>; + pcsphy-handle = <&pcsphy0>; + }; + + mdio@e1000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; + reg = <0xe1000 0x1000>; + fsl,erratum-a011043; /* must ignore read errors */ + + pcsphy0: ethernet-phy@0 { + reg = <0x0>; + }; + }; +};
arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-3.dtsi new file +44 -0
44 lines not on this page · raw message
arch/powerpc/boot/dts/fsl/t2081si-post.dtsi +2 -2
@@ -609,8 +609,8 @@ usb1: usb@211000 { /include/ "qoriq-bman1.dtsi" /include/ "qoriq-fman3-0.dtsi" -/include/ "qoriq-fman3-0-1g-0.dtsi" -/include/ "qoriq-fman3-0-1g-1.dtsi" +/include/ "qoriq-fman3-0-10g-2.dtsi" +/include/ "qoriq-fman3-0-10g-3.dtsi" /include/ "qoriq-fman3-0-1g-2.dtsi" /include/ "qoriq-fman3-0-1g-3.dtsi" /include/ "qoriq-fman3-0-1g-4.dtsi"
Signature · 1 line
2.35.1
Re: [PATCH 5.15 152/731] powerpc: dts: t208x: Mark MAC1 and MAC2 as 10G
Hi Greg,
Quoted 11 lines · Greg Kroah-Hartman
From: Sean Anderson <[email protected]>
[ Upstream commit
36926a7d70c2d462fca1ed85bfee000d17fd8662]On the T208X SoCs, MAC1 and MAC2 support XGMII. Add some new MAC dtsi fragments, and mark the QMAN ports as 10G.
Fixes da414bb923d9 ("powerpc/mpc85xx: Add FSL QorIQ DPAA FMan support to the SoC device tree(s)")Signed-off-by Sean Anderson <[email protected]>Signed-off-by David S. Miller <[email protected]>Signed-off-by Sasha Levin <[email protected]>
This shouldn't be backported without [1].
That said, this fix isn't necessary for kernels which don't use phylink for this ethernet driver.
--Sean
[1] https://lore.kernel.org/netdev/[email protected]/
Quoted 123 lines
--- .../boot/dts/fsl/qoriq-fman3-0-10g-2.dtsi | 44 +++++++++++++++++++ .../boot/dts/fsl/qoriq-fman3-0-10g-3.dtsi | 44 +++++++++++++++++++ arch/powerpc/boot/dts/fsl/t2081si-post.dtsi | 4 +- 3 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-2.dtsi create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-3.dtsiarch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-2.dtsi new file +44
-0@@ -0,0 +1,44 @@ +// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-or-later +/* + * QorIQ FMan v3 10g port #2 device tree stub [ controller @ offset 0x400000 ] + * + * Copyright 2022 Sean Anderson <[email protected]> + * Copyright 2012 - 2015 Freescale Semiconductor Inc. + */ + +fman@400000 { + fman0_rx_0x08: port@88000 { + cell-index = <0x8>; + compatible = "fsl,fman-v3-port-rx"; + reg = <0x88000 0x1000>; + fsl,fman-10g-port; + }; + + fman0_tx_0x28: port@a8000 { + cell-index = <0x28>; + compatible = "fsl,fman-v3-port-tx"; + reg = <0xa8000 0x1000>; + fsl,fman-10g-port; + }; + + ethernet@e0000 { + cell-index = <0>; + compatible = "fsl,fman-memac"; + reg = <0xe0000 0x1000>; + fsl,fman-ports = <&fman0_rx_0x08 &fman0_tx_0x28>; + ptp-timer = <&ptp_timer0>; + pcsphy-handle = <&pcsphy0>; + }; + + mdio@e1000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; + reg = <0xe1000 0x1000>; + fsl,erratum-a011043; /* must ignore read errors */ + + pcsphy0: ethernet-phy@0 { + reg = <0x0>; + }; + }; +};arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-3.dtsi new file +44
-0@@ -0,0 +1,44 @@ +// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-or-later +/* + * QorIQ FMan v3 10g port #3 device tree stub [ controller @ offset 0x400000 ] + * + * Copyright 2022 Sean Anderson <[email protected]> + * Copyright 2012 - 2015 Freescale Semiconductor Inc. + */ + +fman@400000 { + fman0_rx_0x09: port@89000 { + cell-index = <0x9>; + compatible = "fsl,fman-v3-port-rx"; + reg = <0x89000 0x1000>; + fsl,fman-10g-port; + }; + + fman0_tx_0x29: port@a9000 { + cell-index = <0x29>; + compatible = "fsl,fman-v3-port-tx"; + reg = <0xa9000 0x1000>; + fsl,fman-10g-port; + }; + + ethernet@e2000 { + cell-index = <1>; + compatible = "fsl,fman-memac"; + reg = <0xe2000 0x1000>; + fsl,fman-ports = <&fman0_rx_0x09 &fman0_tx_0x29>; + ptp-timer = <&ptp_timer0>; + pcsphy-handle = <&pcsphy1>; + }; + + mdio@e3000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; + reg = <0xe3000 0x1000>; + fsl,erratum-a011043; /* must ignore read errors */ + + pcsphy1: ethernet-phy@0 { + reg = <0x0>; + }; + }; +};arch/powerpc/boot/dts/fsl/t2081si-post.dtsi +2
-2@@ -609,8 +609,8 @@ usb1: usb@211000 { /include/ "qoriq-bman1.dtsi" /include/ "qoriq-fman3-0.dtsi" -/include/ "qoriq-fman3-0-1g-0.dtsi" -/include/ "qoriq-fman3-0-1g-1.dtsi" +/include/ "qoriq-fman3-0-10g-2.dtsi" +/include/ "qoriq-fman3-0-10g-3.dtsi" /include/ "qoriq-fman3-0-1g-2.dtsi" /include/ "qoriq-fman3-0-1g-3.dtsi" /include/ "qoriq-fman3-0-1g-4.dtsi"
Greg Kroah-Hartman
maintainerRe: [PATCH 5.15 152/731] powerpc: dts: t208x: Mark MAC1 and MAC2 as 10G
Quoted 10 lines · Sean Anderson
Hi Greg,
Quoted 7 lines · Greg Kroah-Hartman
From: Sean Anderson <[email protected]>
[ Upstream commit
36926a7d70c2d462fca1ed85bfee000d17fd8662]On the T208X SoCs, MAC1 and MAC2 support XGMII. Add some new MAC dtsi fragments, and mark the QMAN ports as 10G.
Quoted 6 lines
Quoted 4 lines
Fixes da414bb923d9 ("powerpc/mpc85xx: Add FSL QorIQ DPAA FMan support to the SoC device tree(s)")Signed-off-by Sean Anderson <[email protected]>Signed-off-by David S. Miller <[email protected]>Signed-off-by Sasha Levin <[email protected]>This shouldn't be backported without [1].
Thanks, I'll drop this from everywhere.
greg k-h
Greg Kroah-Hartman
maintainerPATCH 153/731 media: v4l2-ctrls: Fix off-by-one error in integer menu control check
In reply to Greg Kroah-HartmanFrom: Laurent Pinchart <[email protected]>
[ Upstream commit b6bcdf763db1f5ea602bf876cfe91debfb3c7773 ]
The V4L2 API defines the maximum value for an integer menu control as the number of elements minus one. The v4l2_ctrl_new_std_menu() validates this constraint with an off-by-one error. Fix it.
--- drivers/media/v4l2-core/v4l2-ctrls-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-ctrls-core.c +1 -1
@@ -1456,7 +1456,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,else if (type ==V4L2_CTRL_TYPE_INTEGER_MENU ) qmenu_int =v4l2_ctrl_get_int_menu (id, &qmenu_int_len); -if ((!qmenu && !qmenu_int) || (qmenu_int && max > qmenu_int_len)) { +if ((!qmenu && !qmenu_int) || (qmenu_int && max >= qmenu_int_len)) {handler_set_err (hdl, -EINVAL );return NULL ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 154/731 media: coda: jpeg: Add check for kmalloc
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit f30ce3d3760b22ee33c8d9c2e223764ad30bdc5f ]
As kmalloc can return NULL pointer, it should be better to check the return value and return error, same as coda_jpeg_decode_header.
--- drivers/media/platform/coda/coda-jpeg.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/media/platform/coda/coda-jpeg.c +8 -2
@@ -1052,10 +1052,16 @@ static int coda9_jpeg_start_encoding(struct coda_ctx *ctx)v4l2_err (&dev->v4l2_dev,"error loading Huffman tables\n" );return ret; } -if (!ctx->params.jpeg_qmat_tab[0 ]) +if (!ctx->params.jpeg_qmat_tab[0 ]) { ctx->params.jpeg_qmat_tab[0 ] =kmalloc (64 ,GFP_KERNEL ); -if (!ctx->params.jpeg_qmat_tab[1 ]) +if (!ctx->params.jpeg_qmat_tab[0 ]) +return -ENOMEM ; + } +if (!ctx->params.jpeg_qmat_tab[1 ]) { ctx->params.jpeg_qmat_tab[1 ] =kmalloc (64 ,GFP_KERNEL ); +if (!ctx->params.jpeg_qmat_tab[1 ]) +return -ENOMEM ; + }coda_set_jpeg_compression_quality (ctx, ctx->params.jpeg_quality);return 0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 155/731 media: adv748x: afe: Select input port when initializing AFE
In reply to Greg Kroah-HartmanFrom: Niklas Söderlund <[email protected]>
[ Upstream commit 23ddb85dafefdace1ad79d1a30b0a4e7c4b5cd8d ]
When moving the input selection to adv748x_reset() it was missed that during probe the device is reset _before_ the initialization and parsing of DT by the AFE subdevice. This can lead to the wrong input port (in case it's not port 0) being selected until the device is reset for the first time.
Fix this by restoring the call to adv748x_afe_s_input() in the AFE initialization while also keeping it in the adv748x_reset().
--- drivers/media/i2c/adv748x/adv748x-afe.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/i2c/adv748x/adv748x-afe.c +4 -0
@@ -521,6 +521,10 @@ int adv748x_afe_init(struct adv748x_afe *afe) } } +adv748x_afe_s_input (afe, afe->input); + +adv_dbg (state,"AFE Default input set to %d\n" , afe->input); +/* Entity pads and sinks are 0-indexed to match the pads */ for (i =ADV748X_AFE_SINK_AIN0 ; i <=ADV748X_AFE_SINK_AIN7 ; i++) afe->pads[i].flags =MEDIA_PAD_FL_SINK ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 156/731 media: i2c: ad5820: Fix error path
In reply to Greg Kroah-HartmanFrom: Ricardo Ribalda <[email protected]>
[ Upstream commit 9fce241660f37d9e95e93c0ae6fba8cfefa5797b ]
Error path seems to be swaped. Fix the order and provide some meaningful names.
--- drivers/media/i2c/ad5820.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/media/i2c/ad5820.c +5 -5
@@ -327,18 +327,18 @@ static int ad5820_probe(struct i2c_client *client, ret =media_entity_pads_init (&coil->subdev.entity,0 ,NULL );if (ret <0 ) - goto cleanup2; + goto clean_mutex; ret =v4l2_async_register_subdev (&coil->subdev);if (ret <0 ) - goto cleanup; + goto clean_entity;return ret; -cleanup2: -mutex_destroy (&coil->power_lock); -cleanup: +clean_entity:media_entity_cleanup (&coil->subdev.entity); +clean_mutex: +mutex_destroy (&coil->power_lock);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 157/731 venus: pm_helpers: Fix error check in vcodec_domains_get()
In reply to Greg Kroah-HartmanFrom: Tang Bin <[email protected]>
[ Upstream commit 0f6e8d8c94a82e85e1b9b62a7671990740dc6f70 ]
In the function vcodec_domains_get(), dev_pm_domain_attach_by_name() may return NULL in some cases, so IS_ERR() doesn't meet the requirements. Thus fix it.
--- drivers/media/platform/qcom/venus/pm_helpers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/venus/pm_helpers.c +2 -2
@@ -869,8 +869,8 @@ static int vcodec_domains_get(struct venus_core *core)for (i =0 ; i < res->vcodec_pmdomains_num; i++) { pd =dev_pm_domain_attach_by_name (dev, res->vcodec_pmdomains[i]); -if (IS_ERR (pd)) -return PTR_ERR (pd); +if (IS_ERR_OR_NULL (pd)) +return PTR_ERR (pd) ? : -ENODATA ; core->pmdomains[i] = pd; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 158/731 soreuseport: Fix socket selection for SO_INCOMING_CPU.
In reply to Greg Kroah-HartmanFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit b261eda84ec136240a9ca753389853a3a1bccca2 ]
Kazuho Oku reported that setsockopt(SO_INCOMING_CPU) does not work with setsockopt(SO_REUSEPORT) since v4.6.
With the combination of SO_REUSEPORT and SO_INCOMING_CPU, we could build a highly efficient server application.
setsockopt(SO_INCOMING_CPU) associates a CPU with a TCP listener or UDP socket, and then incoming packets processed on the CPU will likely be distributed to the socket. Technically, a socket could even receive packets handled on another CPU if no sockets in the reuseport group have the same CPU receiving the flow.
The logic exists in compute_score() so that a socket will get a higher score if it has the same CPU with the flow. However, the score gets ignored after the blamed two commits, which introduced a faster socket selection algorithm for SO_REUSEPORT.
This patch introduces a counter of sockets with SO_INCOMING_CPU in a reuseport group to check if we should iterate all sockets to find a proper one. We increment the counter when
* calling listen() if the socket has SO_INCOMING_CPU and SO_REUSEPORT
* enabling SO_INCOMING_CPU if the socket is in a reuseport group
Also, we decrement it when
* detaching a socket out of the group to apply SO_INCOMING_CPU to migrated TCP requests
* disabling SO_INCOMING_CPU if the socket is in a reuseport group
When the counter reaches 0, we can get back to the O(1) selection algorithm.
The overall changes are negligible for the non-SO_INCOMING_CPU case, and the only notable thing is that we have to update sk_incomnig_cpu under reuseport_lock. Otherwise, the race prevents transitioning to the O(n) algorithm and results in the wrong socket selection.
cpu1 (setsockopt) cpu2 (listen)
+-----------------+ +-------------+
lock_sock(sk1) lock_sock(sk2)
reuseport_update_incoming_cpu(sk1, val)
.
| /* set CPU as 0 */ |- WRITE_ONCE(sk1->incoming_cpu, val) | | spin_lock_bh(&reuseport_lock) | reuseport_grow(sk2, reuse) | . | |- more_socks_size = reuse->max_socks * 2U; | |- if (more_socks_size > U16_MAX && | | reuse->num_closed_socks) | | . | | |- RCU_INIT_POINTER(sk1->sk_reuseport_cb, NULL); | | `- __reuseport_detach_closed_sock(sk1, reuse) | | . | | `- reuseport_put_incoming_cpu(sk1, reuse) | | . | | | /* Read shutdown()ed sk1's sk_incoming_cpu | | | * without lock_sock(). | | | */ | | `- if (sk1->sk_incoming_cpu >= 0) | | . | | | /* decrement not-yet-incremented | | | * count, which is never incremented. | | | */ | | `- __reuseport_put_incoming_cpu(reuse); | | | `- spin_lock_bh(&reuseport_lock) | |- spin_lock_bh(&reuseport_lock) | |- reuse = rcu_dereference_protected(sk1->sk_reuseport_cb, ...) |- if (!reuse) | . | | /* Cannot increment reuse->incoming_cpu. */ | `- goto out; |
`- spin_unlock_bh(&reuseport_lock)
--- include/net/sock_reuseport.h | 2 + net/core/sock.c | 2 +- net/core/sock_reuseport.c | 94 ++++++++++++++++++++++++++++++++++-- 3 files changed, 92 insertions(+), 6 deletions(-)
include/net/sock_reuseport.h +2 -0
@@ -16,6 +16,7 @@ struct sock_reuseport {u16 max_socks;/* length of socks */ u16 num_socks;/* elements in socks */ u16 num_closed_socks;/* closed elements in socks */ +u16 incoming_cpu;/* The last synq overflow event timestamp of this * reuse->socks[] group. */
@@ -58,5 +59,6 @@ static inline bool reuseport_has_conns(struct sock *sk) }void reuseport_has_conns_set (struct sock *sk); +void reuseport_update_incoming_cpu (struct sock *sk,int val);#endif /* _SOCK_REUSEPORT_H */
net/core/sock.c +1 -1
@@ -1302,7 +1302,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname,break ; }case SO_INCOMING_CPU : -WRITE_ONCE (sk->sk_incoming_cpu, val); +reuseport_update_incoming_cpu (sk, val);break ;case SO_CNX_ADVICE :
net/core/sock_reuseport.c +89 -5
149 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 159/731 media: exynos4-is: dont rely on the v4l2_async_subdev internals
In reply to Greg Kroah-HartmanFrom: Marek Szyprowski <[email protected]>
[ Upstream commit f98a5c2e1c4396488c27274ba82afc11725a4bcc ]
Commit 1f391df44607 ("media: v4l2-async: Use endpoints in __v4l2_async_nf_add_fwnode_remote()") changed the data that is stored in the v4l2_async_subdev internals from the fwnode pointer to the parent device to the fwnode pointer to the matched endpoint. This broke the sensor matching code, which relied on the particular fwnode data in the v4l2_async_subdev internals. Fix this by simply matching the v4l2_async_subdev pointer, which is already available there.
--- drivers/media/platform/exynos4-is/media-dev.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/media/platform/exynos4-is/media-dev.c +1 -3
@@ -1380,9 +1380,7 @@ static int subdev_notifier_bound(struct v4l2_async_notifier *notifier,/* Find platform data for this sensor subdev */ for (i =0 ; i <ARRAY_SIZE (fmd->sensor); i++) -if (fmd->sensor[i].asd && - fmd->sensor[i].asd->match.fwnode == -of_fwnode_handle (subdev->dev->of_node)) +if (fmd->sensor[i].asd == asd) si = &fmd->sensor[i];if (si ==NULL )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 160/731 libbpf: Btf dedup identical struct test needs check for nested structs/arrays
In reply to Greg Kroah-HartmanFrom: Alan Maguire <[email protected]>
[ Upstream commit f3c51fe02c55bd944662714e5b91b96dc271ad9f ]
When examining module BTF, it is common to see core kernel structures such as sk_buff, net_device duplicated in the module. After adding debug messaging to BTF it turned out that much of the problem was down to the identical struct test failing during deduplication; sometimes the compiler adds identical structs. However
it turns out sometimes that type ids of identical struct members can also differ, even when the containing structs are still identical.
To take an example, for struct sk_buff, debug messaging revealed that the identical struct matching was failing for the anon struct "headers"; specifically for the first field:
__u8 __pkt_type_offset[0]; /* 128 0 */
Looking at the code in BTF deduplication, we have code that guards against the possibility of identical struct definitions, down to type ids, and identical array definitions. However in this case we have a struct which is being defined twice but does not have identical type ids since each duplicate struct has separate type
ids for the above array member. A similar problem (though not
observed) could occur for struct-in-struct.
The solution is to make the "identical struct" test check members not just for matching ids, but to also check if they in turn are identical structs or arrays.
The results of doing this are quite dramatic (for some modules at least); I see the number of type ids drop from around 10000 to just over 1000 in one module for example.
For testing use latest pahole or apply [1], otherwise dedups can fail for the reasons described there.
Also fix return type of btf_dedup_identical_arrays() as suggested by Andrii to match boolean return type used elsewhere.
[1] https://lore.kernel.org/bpf/1666364523-9648-1-git-send-email-alan.maguire
--- tools/lib/bpf/btf.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
tools/lib/bpf/btf.c +5 -3
@@ -3718,14 +3718,14 @@ static inline __u16 btf_fwd_kind(struct btf_type *t) }/* Check if given two types are identical ARRAY definitions */ -static int btf_dedup_identical_arrays (struct btf_dedup *d,__u32 id1,__u32 id2) +static bool btf_dedup_identical_arrays (struct btf_dedup *d,__u32 id1,__u32 id2) {struct btf_type *t1, *t2; t1 =btf_type_by_id (d->btf, id1); t2 =btf_type_by_id (d->btf, id2);if (!btf_is_array (t1) || !btf_is_array (t2)) -return 0 ; +return false;return btf_equal_array (t1, t2); }
@@ -3749,7 +3749,9 @@ static bool btf_dedup_identical_structs(struct btf_dedup *d, __u32 id1, __u32 id m1 =btf_members (t1); m2 =btf_members (t2);for (i =0 , n =btf_vlen (t1); i < n; i++, m1++, m2++) { -if (m1->type != m2->type) +if (m1->type != m2->type && + !btf_dedup_identical_arrays (d, m1->type, m2->type) && + !btf_dedup_identical_structs (d, m1->type, m2->type))return false; }return true;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 161/731 can: kvaser_usb: do not increase tx statistics when sending error message frames
In reply to Greg Kroah-HartmanFrom: Vincent Mailhol <[email protected]>
[ Upstream commit 0b0ce2c67795672115ac6ca28351a78799cd114b ]
The CAN error message frames (i.e. error skb) are an interface specific to socket CAN. The payload of the CAN error message frames does not correspond to any actual data sent on the wire. Only an error flag and a delimiter are transmitted when an error occurs (c.f. ISO 11898-1 section 10.4.4.2 "Error flag").
For this reason, it makes no sense to increment the tx_packets and tx_bytes fields of struct net_device_stats when sending an error message frame because no actual payload will be transmitted on the wire.
N.B. Sending error message frames is a very specific feature which, at the moment, is only supported by the Kvaser Hydra hardware. Please refer to [1] for more details on the topic.
Stable-dep-of: 35364f5b41a4 ("can: kvaser_usb: kvaser_usb_leaf: Get capabilities from device")
--- drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c +6 -1
@@ -295,6 +295,7 @@ struct kvaser_cmd {#define KVASER_USB_HYDRA_CF_FLAG_OVERRUN BIT(1)#define KVASER_USB_HYDRA_CF_FLAG_REMOTE_FRAME BIT(4)#define KVASER_USB_HYDRA_CF_FLAG_EXTENDED_ID BIT(5) +#define KVASER_USB_HYDRA_CF_FLAG_TX_ACK BIT(6)/* CAN frame flags. Used in ext_rx_can and ext_tx_can */ #define KVASER_USB_HYDRA_CF_FLAG_OSM_NACK BIT(12)#define KVASER_USB_HYDRA_CF_FLAG_ABL BIT(13)
@@ -1125,6 +1126,7 @@ static void kvaser_usb_hydra_tx_acknowledge(const struct kvaser_usb *dev,struct kvaser_usb_net_priv *priv;unsigned long irq_flags;bool one_shot_fail = false; +bool is_err_frame = false;u16 transid =kvaser_usb_hydra_get_cmd_transid (cmd); priv =kvaser_usb_hydra_net_priv_from_cmd (dev, cmd);
@@ -1143,10 +1145,13 @@ static void kvaser_usb_hydra_tx_acknowledge(const struct kvaser_usb *dev,kvaser_usb_hydra_one_shot_fail (priv, cmd_ext); one_shot_fail = true; } + + is_err_frame = flags &KVASER_USB_HYDRA_CF_FLAG_TX_ACK && + flags &KVASER_USB_HYDRA_CF_FLAG_ERROR_FRAME ; } context = &priv->tx_contexts[transid % dev->max_tx_urbs]; -if (!one_shot_fail) { +if (!one_shot_fail && !is_err_frame) {struct net_device_stats *stats = &priv->netdev->stats; stats->tx_packets++;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 162/731 can: kvaser_usb: kvaser_usb_leaf: Get capabilities from device
In reply to Greg Kroah-HartmanFrom: Jimmy Assarsson <[email protected]>
[ Upstream commit 35364f5b41a4917fe94a3f393d149b63ec583297 ]
Use the CMD_GET_CAPABILITIES_REQ command to query the device for certain capabilities. We are only interested in LISTENONLY mode and wither the device reports CAN error counters.
--- .../net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 144 +++++++++++++++++- 1 file changed, 143 insertions(+), 1 deletion(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +143 -1
@@ -73,6 +73,8 @@#define CMD_TX_ACKNOWLEDGE 50#define CMD_CAN_ERROR_EVENT 51#define CMD_FLUSH_QUEUE_REPLY 68 +#define CMD_GET_CAPABILITIES_REQ 95 +#define CMD_GET_CAPABILITIES_RESP 96#define CMD_LEAF_LOG_MESSAGE 106
@@ -82,6 +84,8 @@#define KVASER_USB_LEAF_SWOPTION_FREQ_32_MHZ_CLK BIT(5)#define KVASER_USB_LEAF_SWOPTION_FREQ_24_MHZ_CLK BIT(6) +#define KVASER_USB_LEAF_SWOPTION_EXT_CAP BIT(12) +/* error factors */ #define M16C_EF_ACKE BIT(0)#define M16C_EF_CRCE BIT(1)
@@ -277,6 +281,28 @@ struct leaf_cmd_log_message {u8 data[8 ]; } __packed; +/* Sub commands for cap_req and cap_res */ +#define KVASER_USB_LEAF_CAP_CMD_LISTEN_MODE 0x02 +#define KVASER_USB_LEAF_CAP_CMD_ERR_REPORT 0x05 +struct kvaser_cmd_cap_req { +__le16 padding0; +__le16 cap_cmd; +__le16 padding1; +__le16 channel; +} __packed; + +/* Status codes for cap_res */ +#define KVASER_USB_LEAF_CAP_STAT_OK 0x00 +#define KVASER_USB_LEAF_CAP_STAT_NOT_IMPL 0x01 +#define KVASER_USB_LEAF_CAP_STAT_UNAVAIL 0x02 +struct kvaser_cmd_cap_res { +__le16 padding; +__le16 cap_cmd; +__le16 status; +__le32 mask; +__le32 value; +} __packed; +struct kvaser_cmd {u8 len;u8 id;
@@ -294,6 +320,8 @@ struct kvaser_cmd {struct leaf_cmd_chip_state_event chip_state_event;struct leaf_cmd_error_event error_event;struct leaf_cmd_log_message log_message; +struct kvaser_cmd_cap_req cap_req; +struct kvaser_cmd_cap_res cap_res; }__packed leaf;union {
@@ -323,6 +351,7 @@ static const u8 kvaser_usb_leaf_cmd_sizes_leaf[] = { [CMD_LEAF_LOG_MESSAGE] = kvaser_fsize(u.leaf.log_message), [CMD_CHIP_STATE_EVENT] = kvaser_fsize(u.leaf.chip_state_event), [CMD_CAN_ERROR_EVENT] = kvaser_fsize(u.leaf.error_event), + [CMD_GET_CAPABILITIES_RESP] = kvaser_fsize(u.leaf.cap_res),/* ignored events: */ [CMD_FLUSH_QUEUE_REPLY] = CMD_SIZE_ANY, };
@@ -607,6 +636,9 @@ static void kvaser_usb_leaf_get_software_info_leaf(struct kvaser_usb *dev, dev->fw_version =le32_to_cpu (softinfo->fw_version); dev->max_tx_urbs =le16_to_cpu (softinfo->max_outstanding_tx); +if (sw_options &KVASER_USB_LEAF_SWOPTION_EXT_CAP ) + dev->card_data.capabilities |=KVASER_USB_CAP_EXT_CAP ; +if (dev->driver_info->quirks &KVASER_USB_QUIRK_IGNORE_CLK_FREQ ) {/* Firmware expects bittiming parameters calculated for 16MHz * clock, regardless of the actual clock
@@ -694,6 +726,116 @@ static int kvaser_usb_leaf_get_card_info(struct kvaser_usb *dev)return 0 ; } +static int kvaser_usb_leaf_get_single_capability (struct kvaser_usb *dev, +u16 cap_cmd_req,u16 *status) +{ +struct kvaser_usb_dev_card_data *card_data = &dev->card_data; +struct kvaser_cmd *cmd; +u32 value =0 ; +u32 mask =0 ; +u16 cap_cmd_res; +int err; +int i; + + cmd =kzalloc (sizeof (*cmd),GFP_KERNEL ); +if (!cmd) +return -ENOMEM ; + + cmd->id =CMD_GET_CAPABILITIES_REQ ; + cmd->u.leaf.cap_req.cap_cmd =cpu_to_le16 (cap_cmd_req); + cmd->len =CMD_HEADER_LEN +sizeof (struct kvaser_cmd_cap_req ); + + err =kvaser_usb_send_cmd (dev, cmd, cmd->len); +if (err) + goto end; + + err =kvaser_usb_leaf_wait_cmd (dev,CMD_GET_CAPABILITIES_RESP , cmd); +if (err) + goto end; + + *status =le16_to_cpu (cmd->u.leaf.cap_res.status); + +if (*status !=KVASER_USB_LEAF_CAP_STAT_OK ) + goto end; + + cap_cmd_res =le16_to_cpu (cmd->u.leaf.cap_res.cap_cmd); +switch (cap_cmd_res) { +case KVASER_USB_LEAF_CAP_CMD_LISTEN_MODE : +case KVASER_USB_LEAF_CAP_CMD_ERR_REPORT : + value =le32_to_cpu (cmd->u.leaf.cap_res.value); + mask =le32_to_cpu (cmd->u.leaf.cap_res.mask); +break ; +default : +dev_warn (&dev->intf->dev,"Unknown capability command %u\n" , + cap_cmd_res); +break ; + } + +for (i =0 ; i < dev->nchannels; i++) { +if (BIT (i) & (value & mask)) { +switch (cap_cmd_res) { +case KVASER_USB_LEAF_CAP_CMD_LISTEN_MODE : + card_data->ctrlmode_supported |= +CAN_CTRLMODE_LISTENONLY ; +break ; +case KVASER_USB_LEAF_CAP_CMD_ERR_REPORT : + card_data->capabilities |= +KVASER_USB_CAP_BERR_CAP ; +break ; + } + } + } + +end: +kfree (cmd); + +return err; +} + +static int kvaser_usb_leaf_get_capabilities_leaf (struct kvaser_usb *dev) +{ +int err; +u16 status; + +if (!(dev->card_data.capabilities &KVASER_USB_CAP_EXT_CAP )) { +dev_info (&dev->intf->dev, +"No extended capability support. Upgrade device firmware.\n" ); +return 0 ; + } + + err =kvaser_usb_leaf_get_single_capability (dev, +KVASER_USB_LEAF_CAP_CMD_LISTEN_MODE , + &status); +if (err) +return err; +if (status) +dev_info (&dev->intf->dev, +"KVASER_USB_LEAF_CAP_CMD_LISTEN_MODE failed %u\n" , + status); + + err =kvaser_usb_leaf_get_single_capability (dev, +KVASER_USB_LEAF_CAP_CMD_ERR_REPORT , + &status); +if (err) +return err; +if (status) +dev_info (&dev->intf->dev, +"KVASER_USB_LEAF_CAP_CMD_ERR_REPORT failed %u\n" , + status); + +return 0 ; +} + +static int kvaser_usb_leaf_get_capabilities (struct kvaser_usb *dev) +{ +int err =0 ; + +if (dev->driver_info->family ==KVASER_LEAF ) + err =kvaser_usb_leaf_get_capabilities_leaf (dev); + +return err; +} +static void kvaser_usb_leaf_tx_acknowledge (const struct kvaser_usb *dev,const struct kvaser_cmd *cmd) {
@@ -1490,7 +1632,7 @@ const struct kvaser_usb_dev_ops kvaser_usb_leaf_dev_ops = { .dev_get_software_info = kvaser_usb_leaf_get_software_info, .dev_get_software_details = NULL, .dev_get_card_info = kvaser_usb_leaf_get_card_info, - .dev_get_capabilities = NULL, + .dev_get_capabilities = kvaser_usb_leaf_get_capabilities, .dev_set_opt_mode = kvaser_usb_leaf_set_opt_mode, .dev_start_chip = kvaser_usb_leaf_start_chip, .dev_stop_chip = kvaser_usb_leaf_stop_chip,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 163/731 can: kvaser_usb: kvaser_usb_leaf: Rename {leaf,usbcan}_cmd_error_event to {leaf,usbcan}_cmd_can_error_event
In reply to Greg Kroah-HartmanFrom: Jimmy Assarsson <[email protected]>
[ Upstream commit 7ea56128dbf904a3359bcf9289cccdfa3c85c7e8 ]
Prepare for handling CMD_ERROR_EVENT. Rename struct {leaf,usbcan}_cmd_error_event to {leaf,usbcan}_cmd_can_error_event.
--- .../net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +19 -19
@@ -233,7 +233,7 @@ struct kvaser_cmd_tx_acknowledge_header {u8 tid; } __packed; -struct leaf_cmd_error_event { +struct leaf_cmd_can_error_event {u8 tid;u8 flags;__le16 time[3 ];
@@ -245,7 +245,7 @@ struct leaf_cmd_error_event {u8 error_factor; } __packed; -struct usbcan_cmd_error_event { +struct usbcan_cmd_can_error_event {u8 tid;u8 padding;u8 tx_errors_count_ch0;
@@ -318,7 +318,7 @@ struct kvaser_cmd {struct leaf_cmd_softinfo softinfo;struct leaf_cmd_rx_can rx_can;struct leaf_cmd_chip_state_event chip_state_event; -struct leaf_cmd_error_event error_event; +struct leaf_cmd_can_error_event can_error_event;struct leaf_cmd_log_message log_message;struct kvaser_cmd_cap_req cap_req;struct kvaser_cmd_cap_res cap_res;
@@ -328,7 +328,7 @@ struct kvaser_cmd {struct usbcan_cmd_softinfo softinfo;struct usbcan_cmd_rx_can rx_can;struct usbcan_cmd_chip_state_event chip_state_event; -struct usbcan_cmd_error_event error_event; +struct usbcan_cmd_can_error_event can_error_event; }__packed usbcan;struct kvaser_cmd_tx_can tx_can;
@@ -350,7 +350,7 @@ static const u8 kvaser_usb_leaf_cmd_sizes_leaf[] = { [CMD_RX_EXT_MESSAGE] = kvaser_fsize(u.leaf.rx_can), [CMD_LEAF_LOG_MESSAGE] = kvaser_fsize(u.leaf.log_message), [CMD_CHIP_STATE_EVENT] = kvaser_fsize(u.leaf.chip_state_event), - [CMD_CAN_ERROR_EVENT] = kvaser_fsize(u.leaf.error_event), + [CMD_CAN_ERROR_EVENT] = kvaser_fsize(u.leaf.can_error_event), [CMD_GET_CAPABILITIES_RESP] = kvaser_fsize(u.leaf.cap_res),/* ignored events: */ [CMD_FLUSH_QUEUE_REPLY] = CMD_SIZE_ANY,
@@ -365,7 +365,7 @@ static const u8 kvaser_usb_leaf_cmd_sizes_usbcan[] = { [CMD_RX_STD_MESSAGE] = kvaser_fsize(u.usbcan.rx_can), [CMD_RX_EXT_MESSAGE] = kvaser_fsize(u.usbcan.rx_can), [CMD_CHIP_STATE_EVENT] = kvaser_fsize(u.usbcan.chip_state_event), - [CMD_CAN_ERROR_EVENT] = kvaser_fsize(u.usbcan.error_event), + [CMD_CAN_ERROR_EVENT] = kvaser_fsize(u.usbcan.can_error_event),/* ignored events: */ [CMD_USBCAN_CLOCK_OVERFLOW_EVENT] = CMD_SIZE_ANY, };
@@ -1137,11 +1137,11 @@ static void kvaser_usb_leaf_usbcan_rx_error(const struct kvaser_usb *dev,case CMD_CAN_ERROR_EVENT : es.channel =0 ; - es.status = cmd->u.usbcan.error_event.status_ch0; - es.txerr = cmd->u.usbcan.error_event.tx_errors_count_ch0; - es.rxerr = cmd->u.usbcan.error_event.rx_errors_count_ch0; + es.status = cmd->u.usbcan.can_error_event.status_ch0; + es.txerr = cmd->u.usbcan.can_error_event.tx_errors_count_ch0; + es.rxerr = cmd->u.usbcan.can_error_event.rx_errors_count_ch0; es.usbcan.other_ch_status = - cmd->u.usbcan.error_event.status_ch1; + cmd->u.usbcan.can_error_event.status_ch1;kvaser_usb_leaf_usbcan_conditionally_rx_error (dev, &es);/* The USBCAN firmware supports up to 2 channels.
@@ -1149,13 +1149,13 @@ static void kvaser_usb_leaf_usbcan_rx_error(const struct kvaser_usb *dev,*/ if (dev->nchannels ==MAX_USBCAN_NET_DEVICES ) { es.channel =1 ; - es.status = cmd->u.usbcan.error_event.status_ch1; + es.status = cmd->u.usbcan.can_error_event.status_ch1; es.txerr = - cmd->u.usbcan.error_event.tx_errors_count_ch1; + cmd->u.usbcan.can_error_event.tx_errors_count_ch1; es.rxerr = - cmd->u.usbcan.error_event.rx_errors_count_ch1; + cmd->u.usbcan.can_error_event.rx_errors_count_ch1; es.usbcan.other_ch_status = - cmd->u.usbcan.error_event.status_ch0; + cmd->u.usbcan.can_error_event.status_ch0;kvaser_usb_leaf_usbcan_conditionally_rx_error (dev, &es); }break ;
@@ -1172,11 +1172,11 @@ static void kvaser_usb_leaf_leaf_rx_error(const struct kvaser_usb *dev,switch (cmd->id) {case CMD_CAN_ERROR_EVENT : - es.channel = cmd->u.leaf.error_event.channel; - es.status = cmd->u.leaf.error_event.status; - es.txerr = cmd->u.leaf.error_event.tx_errors_count; - es.rxerr = cmd->u.leaf.error_event.rx_errors_count; - es.leaf.error_factor = cmd->u.leaf.error_event.error_factor; + es.channel = cmd->u.leaf.can_error_event.channel; + es.status = cmd->u.leaf.can_error_event.status; + es.txerr = cmd->u.leaf.can_error_event.tx_errors_count; + es.rxerr = cmd->u.leaf.can_error_event.rx_errors_count; + es.leaf.error_factor = cmd->u.leaf.can_error_event.error_factor;break ;case CMD_LEAF_LOG_MESSAGE : es.channel = cmd->u.leaf.log_message.channel;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 164/731 can: kvaser_usb: kvaser_usb_leaf: Handle CMD_ERROR_EVENT
In reply to Greg Kroah-HartmanFrom: Jimmy Assarsson <[email protected]>
[ Upstream commit b24cb2d169e0c9dce664a959e1f2aa9781285dc9 ]
The device will send an error event command, to indicate certain errors. This indicates a misbehaving driver, and should never occur.
--- .../net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+)
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +99 -0
@@ -69,6 +69,7 @@#define CMD_GET_CARD_INFO_REPLY 35#define CMD_GET_SOFTWARE_INFO 38#define CMD_GET_SOFTWARE_INFO_REPLY 39 +#define CMD_ERROR_EVENT 45#define CMD_FLUSH_QUEUE 48#define CMD_TX_ACKNOWLEDGE 50#define CMD_CAN_ERROR_EVENT 51
@@ -257,6 +258,28 @@ struct usbcan_cmd_can_error_event {__le16 time; } __packed; +/* CMD_ERROR_EVENT error codes */ +#define KVASER_USB_LEAF_ERROR_EVENT_TX_QUEUE_FULL 0x8 +#define KVASER_USB_LEAF_ERROR_EVENT_PARAM 0x9 + +struct leaf_cmd_error_event { +u8 tid; +u8 error_code; +__le16 timestamp[3 ]; +__le16 padding; +__le16 info1; +__le16 info2; +} __packed; + +struct usbcan_cmd_error_event { +u8 tid; +u8 error_code; +__le16 info1; +__le16 info2; +__le16 timestamp; +__le16 padding; +} __packed; +struct kvaser_cmd_ctrl_mode {u8 tid;u8 channel;
@@ -320,6 +343,7 @@ struct kvaser_cmd {struct leaf_cmd_chip_state_event chip_state_event;struct leaf_cmd_can_error_event can_error_event;struct leaf_cmd_log_message log_message; +struct leaf_cmd_error_event error_event;struct kvaser_cmd_cap_req cap_req;struct kvaser_cmd_cap_res cap_res; }__packed leaf;
@@ -329,6 +353,7 @@ struct kvaser_cmd {struct usbcan_cmd_rx_can rx_can;struct usbcan_cmd_chip_state_event chip_state_event;struct usbcan_cmd_can_error_event can_error_event; +struct usbcan_cmd_error_event error_event; }__packed usbcan;struct kvaser_cmd_tx_can tx_can;
@@ -352,6 +377,7 @@ static const u8 kvaser_usb_leaf_cmd_sizes_leaf[] = { [CMD_CHIP_STATE_EVENT] = kvaser_fsize(u.leaf.chip_state_event), [CMD_CAN_ERROR_EVENT] = kvaser_fsize(u.leaf.can_error_event), [CMD_GET_CAPABILITIES_RESP] = kvaser_fsize(u.leaf.cap_res), + [CMD_ERROR_EVENT] = kvaser_fsize(u.leaf.error_event),/* ignored events: */ [CMD_FLUSH_QUEUE_REPLY] = CMD_SIZE_ANY, };
@@ -366,6 +392,7 @@ static const u8 kvaser_usb_leaf_cmd_sizes_usbcan[] = { [CMD_RX_EXT_MESSAGE] = kvaser_fsize(u.usbcan.rx_can), [CMD_CHIP_STATE_EVENT] = kvaser_fsize(u.usbcan.chip_state_event), [CMD_CAN_ERROR_EVENT] = kvaser_fsize(u.usbcan.can_error_event), + [CMD_ERROR_EVENT] = kvaser_fsize(u.usbcan.error_event),/* ignored events: */ [CMD_USBCAN_CLOCK_OVERFLOW_EVENT] = CMD_SIZE_ANY, };
@@ -1308,6 +1335,74 @@ static void kvaser_usb_leaf_rx_can_msg(const struct kvaser_usb *dev,netif_rx (skb); } +static void kvaser_usb_leaf_error_event_parameter (const struct kvaser_usb *dev, +const struct kvaser_cmd *cmd) +{ +u16 info1 =0 ; + +switch (dev->driver_info->family) { +case KVASER_LEAF : + info1 =le16_to_cpu (cmd->u.leaf.error_event.info1); +break ; +case KVASER_USBCAN : + info1 =le16_to_cpu (cmd->u.usbcan.error_event.info1); +break ; + } + +/* info1 will contain the offending cmd_no */ +switch (info1) { +case CMD_SET_CTRL_MODE : +dev_warn (&dev->intf->dev, +"CMD_SET_CTRL_MODE error in parameter\n" ); +break ; + +case CMD_SET_BUS_PARAMS : +dev_warn (&dev->intf->dev, +"CMD_SET_BUS_PARAMS error in parameter\n" ); +break ; + +default : +dev_warn (&dev->intf->dev, +"Unhandled parameter error event cmd_no (%u)\n" , + info1); +break ; + } +} + +static void kvaser_usb_leaf_error_event (const struct kvaser_usb *dev, +const struct kvaser_cmd *cmd) +{ +u8 error_code =0 ; + +switch (dev->driver_info->family) { +case KVASER_LEAF : + error_code = cmd->u.leaf.error_event.error_code; +break ; +case KVASER_USBCAN : + error_code = cmd->u.usbcan.error_event.error_code; +break ; + } + +switch (error_code) { +case KVASER_USB_LEAF_ERROR_EVENT_TX_QUEUE_FULL : +/* Received additional CAN message, when firmware TX queue is +* already full. Something is wrong with the driver. +* This should never happen! +*/ +dev_err (&dev->intf->dev, +"Received error event TX_QUEUE_FULL\n" ); +break ; +case KVASER_USB_LEAF_ERROR_EVENT_PARAM : +kvaser_usb_leaf_error_event_parameter (dev, cmd); +break ; + +default : +dev_warn (&dev->intf->dev, +"Unhandled error event (%d)\n" , error_code); +break ; + } +} +static void kvaser_usb_leaf_start_chip_reply (const struct kvaser_usb *dev,const struct kvaser_cmd *cmd) {
@@ -1386,6 +1481,10 @@ static void kvaser_usb_leaf_handle_command(const struct kvaser_usb *dev,kvaser_usb_leaf_tx_acknowledge (dev, cmd);break ; +case CMD_ERROR_EVENT : +kvaser_usb_leaf_error_event (dev, cmd); +break ; +/* Ignored commands */ case CMD_USBCAN_CLOCK_OVERFLOW_EVENT :if (dev->driver_info->family !=KVASER_USBCAN )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 165/731 can: kvaser_usb_leaf: Set Warning state even without bus errors
In reply to Greg Kroah-HartmanFrom: Anssi Hannula <[email protected]>
[ Upstream commit df1b7af2761b935f63b4a53e789d41ed859edf61 ]
kvaser_usb_leaf_rx_error_update_can_state() sets error state according to error counters when the hardware does not indicate a specific state directly.
However, this is currently gated behind a check for M16C_STATE_BUS_ERROR which does not always seem to be set when error counters are increasing, and may not be set when error counters are decreasing.
This causes the CAN_STATE_ERROR_WARNING state to not be set in some cases even when appropriate.
Change the code to set error state from counters even without M16C_STATE_BUS_ERROR.
The Error-Passive case seems superfluous as it is already set via M16C_STATE_BUS_PASSIVE flag above, but it is kept for now.
Tested with 0bfd:0124 Kvaser Mini PCI Express 2xHS FW 4.18.778.
--- .../net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +8 -12
@@ -965,20 +965,16 @@ kvaser_usb_leaf_rx_error_update_can_state(struct kvaser_usb_net_priv *priv, new_state =CAN_STATE_BUS_OFF ; }else if (es->status &M16C_STATE_BUS_PASSIVE ) { new_state =CAN_STATE_ERROR_PASSIVE ; - }else if (es->status &M16C_STATE_BUS_ERROR ) { + }else if ((es->status &M16C_STATE_BUS_ERROR ) && + cur_state >=CAN_STATE_BUS_OFF ) {/* Guard against spurious error events after a busoff */ -if (cur_state <CAN_STATE_BUS_OFF ) { -if (es->txerr >=128 || es->rxerr >=128 ) - new_state =CAN_STATE_ERROR_PASSIVE ; -else if (es->txerr >=96 || es->rxerr >=96 ) - new_state =CAN_STATE_ERROR_WARNING ; -else if (cur_state >CAN_STATE_ERROR_ACTIVE ) - new_state =CAN_STATE_ERROR_ACTIVE ; - } - } - -if (!es->status) + }else if (es->txerr >=128 || es->rxerr >=128 ) { + new_state =CAN_STATE_ERROR_PASSIVE ; + }else if (es->txerr >=96 || es->rxerr >=96 ) { + new_state =CAN_STATE_ERROR_WARNING ; + }else { new_state =CAN_STATE_ERROR_ACTIVE ; + }if (new_state != cur_state) { tx_state = (es->txerr >= es->rxerr) ? new_state :0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 166/731 can: kvaser_usb: make use of units.h in assignment of frequency
In reply to Greg Kroah-HartmanFrom: Jimmy Assarsson <[email protected]>
[ Upstream commit b8f91799687eeb6ffe73b66420db46d8c0292295 ]
Use the MEGA define plus the comment /* Hz */ when assigning frequencies.
Stable-dep-of: 8d21f5927ae6 ("can: kvaser_usb_leaf: Fix improved state not being reported")
--- drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 7 ++++--- drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c +4 -3
@@ -22,6 +22,7 @@#include <linux/spinlock.h> #include <linux/string.h> #include <linux/types.h> +#include <linux/units.h> #include <linux/usb.h> #include <linux/can.h>
@@ -2049,7 +2050,7 @@ const struct kvaser_usb_dev_ops kvaser_usb_hydra_dev_ops = {static const struct kvaser_usb_dev_cfg kvaser_usb_hydra_dev_cfg_kcan = { .clock = { - .freq =80000000 , + .freq =80 *MEGA /* Hz */ , }, .timestamp_freq =80 , .bittiming_const = &kvaser_usb_hydra_kcan_bittiming_c,
@@ -2058,7 +2059,7 @@ static const struct kvaser_usb_dev_cfg kvaser_usb_hydra_dev_cfg_kcan = {static const struct kvaser_usb_dev_cfg kvaser_usb_hydra_dev_cfg_flexc = { .clock = { - .freq =24000000 , + .freq =24 *MEGA /* Hz */ , }, .timestamp_freq =1 , .bittiming_const = &kvaser_usb_flexc_bittiming_const,
@@ -2066,7 +2067,7 @@ static const struct kvaser_usb_dev_cfg kvaser_usb_hydra_dev_cfg_flexc = {static const struct kvaser_usb_dev_cfg kvaser_usb_hydra_dev_cfg_rt = { .clock = { - .freq =80000000 , + .freq =80 *MEGA /* Hz */ , }, .timestamp_freq =24 , .bittiming_const = &kvaser_usb_hydra_rt_bittiming_c,
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +5 -4
@@ -19,6 +19,7 @@#include <linux/spinlock.h> #include <linux/string.h> #include <linux/types.h> +#include <linux/units.h> #include <linux/usb.h> #include <linux/can.h>
@@ -446,7 +447,7 @@ static const struct can_bittiming_const kvaser_usb_leaf_m32c_bittiming_const = {static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_usbcan_dev_cfg = { .clock = { - .freq =8000000 , + .freq =8 *MEGA /* Hz */ , }, .timestamp_freq =1 , .bittiming_const = &kvaser_usb_leaf_m16c_bittiming_const,
@@ -454,7 +455,7 @@ static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_usbcan_dev_cfg = {static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_m32c_dev_cfg = { .clock = { - .freq =16000000 , + .freq =16 *MEGA /* Hz */ , }, .timestamp_freq =1 , .bittiming_const = &kvaser_usb_leaf_m32c_bittiming_const,
@@ -470,7 +471,7 @@ static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_imx_dev_cfg_16mhz = {static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_imx_dev_cfg_24mhz = { .clock = { - .freq =24000000 , + .freq =24 *MEGA /* Hz */ , }, .timestamp_freq =1 , .bittiming_const = &kvaser_usb_flexc_bittiming_const,
@@ -478,7 +479,7 @@ static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_imx_dev_cfg_24mhz = {static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_imx_dev_cfg_32mhz = { .clock = { - .freq =32000000 , + .freq =32 *MEGA /* Hz */ , }, .timestamp_freq =1 , .bittiming_const = &kvaser_usb_flexc_bittiming_const,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 167/731 can: kvaser_usb_leaf: Fix improved state not being reported
In reply to Greg Kroah-HartmanFrom: Anssi Hannula <[email protected]>
[ Upstream commit 8d21f5927ae604881f98587fabf6753f88730968 ]
The tested 0bfd:0017 Kvaser Memorator Professional HS/HS FW 2.0.50 and 0bfd:0124 Kvaser Mini PCI Express 2xHS FW 4.18.778 do not seem to send any unsolicited events when error counters decrease or when the device transitions from ERROR_PASSIVE to ERROR_ACTIVE (or WARNING).
This causes the interface to e.g. indefinitely stay in the ERROR_PASSIVE state.
Fix that by asking for chip state (inc. counters) event every 0.5 secs when error counters are non-zero.
Since there are non-error-counter devices, also always poll in ERROR_PASSIVE even if the counters show zero.
--- drivers/net/can/usb/kvaser_usb/kvaser_usb.h | 7 +++ .../net/can/usb/kvaser_usb/kvaser_usb_core.c | 19 +++++- .../net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 58 +++++++++++++++++++ 3 files changed, 81 insertions(+), 3 deletions(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb.h +7 -0
@@ -104,6 +104,9 @@ struct kvaser_usb_net_priv {struct can_priv can;struct can_berr_counter bec; +/* subdriver-specific data */ +void *sub_priv; +struct kvaser_usb *dev;struct net_device *netdev;int channel;
@@ -125,6 +128,8 @@ struct kvaser_usb_net_priv {* * @dev_setup_endpoints: setup USB in and out endpoints * @dev_init_card: initialize card +* @dev_init_channel: initialize channel +* @dev_remove_channel: uninitialize channel * @dev_get_software_info: get software info * @dev_get_software_details: get software details * @dev_get_card_info: get card info
@@ -146,6 +151,8 @@ struct kvaser_usb_dev_ops { struct can_berr_counter *bec);int (*dev_setup_endpoints)(struct kvaser_usb *dev);int (*dev_init_card)(struct kvaser_usb *dev); +int (*dev_init_channel)(struct kvaser_usb_net_priv *priv); +void (*dev_remove_channel)(struct kvaser_usb_net_priv *priv);int (*dev_get_software_info)(struct kvaser_usb *dev);int (*dev_get_software_details)(struct kvaser_usb *dev);int (*dev_get_card_info)(struct kvaser_usb *dev);
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +16 -3
@@ -672,6 +672,7 @@ static const struct net_device_ops kvaser_usb_netdev_ops = {static void kvaser_usb_remove_interfaces (struct kvaser_usb *dev) { +const struct kvaser_usb_dev_ops *ops = dev->driver_info->ops;int i;for (i =0 ; i < dev->nchannels; i++) {
@@ -687,6 +688,9 @@ static void kvaser_usb_remove_interfaces(struct kvaser_usb *dev)if (!dev->nets[i])continue ; +if (ops->dev_remove_channel) + ops->dev_remove_channel (dev->nets[i]); +free_candev (dev->nets[i]->netdev); } }
@@ -754,17 +758,26 @@ static int kvaser_usb_init_one(struct kvaser_usb *dev, int channel) dev->nets[channel] = priv; +if (ops->dev_init_channel) { + err = ops->dev_init_channel (priv); +if (err) + goto err; + } + err =register_candev (netdev);if (err) {dev_err (&dev->intf->dev,"Failed to register CAN device\n" ); -free_candev (netdev); - dev->nets[channel] =NULL ; -return err; + goto err; }netdev_dbg (netdev,"device registered\n" );return 0 ; + +err: +free_candev (netdev); + dev->nets[channel] =NULL ; +return err; } static int kvaser_usb_probe(struct usb_interface *intf,
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +58 -0
122 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 168/731 can: kvaser_usb_leaf: Fix wrong CAN state after stopping
In reply to Greg Kroah-HartmanFrom: Anssi Hannula <[email protected]>
[ Upstream commit a11249acf802341294557895d8e5f6aef080253f ]
0bfd:0124 Kvaser Mini PCI Express 2xHS FW 4.18.778 sends a CMD_CHIP_STATE_EVENT indicating bus-off after stopping the device, causing a stopped device to appear as CAN_STATE_BUS_OFF instead of CAN_STATE_STOPPED.
Fix that by not handling error events on stopped devices.
--- drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +4 -0
@@ -1050,6 +1050,10 @@ static void kvaser_usb_leaf_rx_error(const struct kvaser_usb *dev, leaf = priv->sub_priv; stats = &priv->netdev->stats; +/* Ignore e.g. state change to bus-off reported just after stopping */ +if (!netif_running (priv->netdev)) +return ; +/* Update all of the CAN interface's state and error counters before * trying any memory allocation that can actually fail with -ENOMEM. *
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 169/731 can: kvaser_usb_leaf: Fix bogus restart events
In reply to Greg Kroah-HartmanFrom: Anssi Hannula <[email protected]>
[ Upstream commit 90904d326269a38fe5dd895fb2db7c03199654c4 ]
When auto-restart is enabled, the kvaser_usb_leaf driver considers transition from any state >= CAN_STATE_BUS_OFF as a bus-off recovery event (restart).
However, these events may occur at interface startup time before kvaser_usb_open() has set the state to CAN_STATE_ERROR_ACTIVE, causing restarts counter to increase and CAN_ERR_RESTARTED to be sent despite no actual restart having occurred.
Fix that by making the auto-restart condition checks more strict so that they only trigger when the interface was actually in the BUS_OFF state.
--- drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +3 -3
@@ -900,7 +900,7 @@ static void kvaser_usb_leaf_tx_acknowledge(const struct kvaser_usb *dev, context = &priv->tx_contexts[tid % dev->max_tx_urbs];/* Sometimes the state change doesn't come after a bus-off event */ -if (priv->can.restart_ms && priv->can.state >=CAN_STATE_BUS_OFF ) { +if (priv->can.restart_ms && priv->can.state ==CAN_STATE_BUS_OFF ) {struct sk_buff *skb;struct can_frame *cf;
@@ -1003,7 +1003,7 @@ kvaser_usb_leaf_rx_error_update_can_state(struct kvaser_usb_net_priv *priv, }if (priv->can.restart_ms && - cur_state >=CAN_STATE_BUS_OFF && + cur_state ==CAN_STATE_BUS_OFF && new_state <CAN_STATE_BUS_OFF ) priv->can.can_stats.restarts++;
@@ -1093,7 +1093,7 @@ static void kvaser_usb_leaf_rx_error(const struct kvaser_usb *dev, }if (priv->can.restart_ms && - old_state >=CAN_STATE_BUS_OFF && + old_state ==CAN_STATE_BUS_OFF && new_state <CAN_STATE_BUS_OFF ) { cf->can_id |=CAN_ERR_RESTARTED ;netif_carrier_on (priv->netdev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 170/731 can: kvaser_usb: Add struct kvaser_usb_busparams
In reply to Greg Kroah-HartmanFrom: Jimmy Assarsson <[email protected]>
[ Upstream commit 00e5786177649c1e3110f9454fdd34e336597265 ]
Add struct kvaser_usb_busparams containing the busparameters used in CMD_{SET,GET}_BUSPARAMS* commands.
Stable-dep-of: 39d3df6b0ea8 ("can: kvaser_usb: Compare requested bittiming parameters with actual parameters in do_set_{,data}_bittiming")
--- drivers/net/can/usb/kvaser_usb/kvaser_usb.h | 8 +++++ .../net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 32 +++++++------------ .../net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 18 ++++------- 3 files changed, 27 insertions(+), 31 deletions(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb.h +8 -0
@@ -76,6 +76,14 @@ struct kvaser_usb_tx_urb_context {int dlc; }; +struct kvaser_usb_busparams { +__le32 bitrate; +u8 tseg1; +u8 tseg2; +u8 sjw; +u8 nsamples; +} __packed; +struct kvaser_usb {struct usb_device *udev;struct usb_interface *intf;
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c +12 -20
@@ -196,17 +196,9 @@ struct kvaser_cmd_chip_state_event {#define KVASER_USB_HYDRA_BUS_MODE_CANFD_ISO 0x01#define KVASER_USB_HYDRA_BUS_MODE_NONISO 0x02struct kvaser_cmd_set_busparams { -__le32 bitrate; -u8 tseg1; -u8 tseg2; -u8 sjw; -u8 nsamples; +struct kvaser_usb_busparams busparams_arb;u8 reserved0[4 ]; -__le32 bitrate_d; -u8 tseg1_d; -u8 tseg2_d; -u8 sjw_d; -u8 nsamples_d; +struct kvaser_usb_busparams busparams_data;u8 canfd_mode;u8 reserved1[7 ]; } __packed;
@@ -1542,11 +1534,11 @@ static int kvaser_usb_hydra_set_bittiming(struct net_device *netdev)return -ENOMEM ; cmd->header.cmd_no =CMD_SET_BUSPARAMS_REQ ; - cmd->set_busparams_req.bitrate =cpu_to_le32 (bt->bitrate); - cmd->set_busparams_req.sjw = (u8 )sjw; - cmd->set_busparams_req.tseg1 = (u8 )tseg1; - cmd->set_busparams_req.tseg2 = (u8 )tseg2; - cmd->set_busparams_req.nsamples =1 ; + cmd->set_busparams_req.busparams_arb.bitrate =cpu_to_le32 (bt->bitrate); + cmd->set_busparams_req.busparams_arb.sjw = (u8 )sjw; + cmd->set_busparams_req.busparams_arb.tseg1 = (u8 )tseg1; + cmd->set_busparams_req.busparams_arb.tseg2 = (u8 )tseg2; + cmd->set_busparams_req.busparams_arb.nsamples =1 ;kvaser_usb_hydra_set_cmd_dest_he (cmd, dev->card_data.hydra.channel_to_he[priv->channel]);
@@ -1576,11 +1568,11 @@ static int kvaser_usb_hydra_set_data_bittiming(struct net_device *netdev)return -ENOMEM ; cmd->header.cmd_no =CMD_SET_BUSPARAMS_FD_REQ ; - cmd->set_busparams_req.bitrate_d =cpu_to_le32 (dbt->bitrate); - cmd->set_busparams_req.sjw_d = (u8 )sjw; - cmd->set_busparams_req.tseg1_d = (u8 )tseg1; - cmd->set_busparams_req.tseg2_d = (u8 )tseg2; - cmd->set_busparams_req.nsamples_d =1 ; + cmd->set_busparams_req.busparams_data.bitrate =cpu_to_le32 (dbt->bitrate); + cmd->set_busparams_req.busparams_data.sjw = (u8 )sjw; + cmd->set_busparams_req.busparams_data.tseg1 = (u8 )tseg1; + cmd->set_busparams_req.busparams_data.tseg2 = (u8 )tseg2; + cmd->set_busparams_req.busparams_data.nsamples =1 ;if (priv->can.ctrlmode &CAN_CTRLMODE_FD ) {if (priv->can.ctrlmode &CAN_CTRLMODE_FD_NON_ISO )
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +7 -11
@@ -164,11 +164,7 @@ struct usbcan_cmd_softinfo {struct kvaser_cmd_busparams {u8 tid;u8 channel; -__le32 bitrate; -u8 tseg1; -u8 tseg2; -u8 sjw; -u8 no_samp; +struct kvaser_usb_busparams busparams; } __packed;struct kvaser_cmd_tx_can {
@@ -1704,15 +1700,15 @@ static int kvaser_usb_leaf_set_bittiming(struct net_device *netdev) cmd->len =CMD_HEADER_LEN +sizeof (struct kvaser_cmd_busparams ); cmd->u.busparams.channel = priv->channel; cmd->u.busparams.tid =0xff ; - cmd->u.busparams.bitrate =cpu_to_le32 (bt->bitrate); - cmd->u.busparams.sjw = bt->sjw; - cmd->u.busparams.tseg1 = bt->prop_seg + bt->phase_seg1; - cmd->u.busparams.tseg2 = bt->phase_seg2; + cmd->u.busparams.busparams.bitrate =cpu_to_le32 (bt->bitrate); + cmd->u.busparams.busparams.sjw = bt->sjw; + cmd->u.busparams.busparams.tseg1 = bt->prop_seg + bt->phase_seg1; + cmd->u.busparams.busparams.tseg2 = bt->phase_seg2;if (priv->can.ctrlmode &CAN_CTRLMODE_3_SAMPLES ) - cmd->u.busparams.no_samp =3 ; + cmd->u.busparams.busparams.nsamples =3 ;else - cmd->u.busparams.no_samp =1 ; + cmd->u.busparams.busparams.nsamples =1 ; rc =kvaser_usb_send_cmd (dev, cmd, cmd->len);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 171/731 can: kvaser_usb: Compare requested bittiming parameters with actual parameters in do_set_{,data}_bittiming
In reply to Greg Kroah-HartmanFrom: Jimmy Assarsson <[email protected]>
[ Upstream commit 39d3df6b0ea80f9b515c632ca07b39b1c156edee ]
The device will respond with a CMD_ERROR_EVENT command, with error_code KVASER_USB_{LEAF,HYDRA}_ERROR_EVENT_PARAM, if the CMD_SET_BUSPARAMS_REQ contains invalid bittiming parameters.
However, this command does not contain any channel reference.
To check if the CMD_SET_BUSPARAMS_REQ was successful, redback and compare the requested bittiming parameters with the device reported parameters.
--- drivers/net/can/usb/kvaser_usb/kvaser_usb.h | 15 +- .../net/can/usb/kvaser_usb/kvaser_usb_core.c | 96 ++++++++++- .../net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 150 +++++++++++++++--- .../net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 64 ++++++-- 4 files changed, 284 insertions(+), 41 deletions(-)
drivers/net/can/usb/kvaser_usb/kvaser_usb.h +12 -3
@@ -119,9 +119,12 @@ struct kvaser_usb_net_priv {struct net_device *netdev;int channel; -struct completion start_comp, stop_comp, flush_comp; +struct completion start_comp, stop_comp, flush_comp, + get_busparams_comp;struct usb_anchor tx_submitted; +struct kvaser_usb_busparams busparams_nominal, busparams_data; +spinlock_t tx_contexts_lock;/* lock for active_tx_contexts */ int active_tx_contexts;struct kvaser_usb_tx_urb_context tx_contexts[];
@@ -131,7 +134,9 @@ struct kvaser_usb_net_priv {* struct kvaser_usb_dev_ops - Device specific functions * @dev_set_mode: used for can.do_set_mode * @dev_set_bittiming: used for can.do_set_bittiming +* @dev_get_busparams: readback arbitration busparams * @dev_set_data_bittiming: used for can.do_set_data_bittiming +* @dev_get_data_busparams: readback data busparams * @dev_get_berr_counter: used for can.do_get_berr_counter * * @dev_setup_endpoints: setup USB in and out endpoints
@@ -153,8 +158,12 @@ struct kvaser_usb_net_priv {*/ struct kvaser_usb_dev_ops {int (*dev_set_mode)(struct net_device *netdev,enum can_mode mode); -int (*dev_set_bittiming)(struct net_device *netdev); -int (*dev_set_data_bittiming)(struct net_device *netdev); +int (*dev_set_bittiming)(const struct net_device *netdev, +const struct kvaser_usb_busparams *busparams); +int (*dev_get_busparams)(struct kvaser_usb_net_priv *priv); +int (*dev_set_data_bittiming)(const struct net_device *netdev, +const struct kvaser_usb_busparams *busparams); +int (*dev_get_data_busparams)(struct kvaser_usb_net_priv *priv);int (*dev_get_berr_counter)(const struct net_device *netdev,struct can_berr_counter *bec);int (*dev_setup_endpoints)(struct kvaser_usb *dev);
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +90 -6
126 lines not on this page · raw message
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c +129 -21
240 lines not on this page · raw message
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c +53 -11
115 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 172/731 drm/rockchip: lvds: fix PM usage counter unbalance in poweron
In reply to Greg Kroah-HartmanFrom: Zhang Qilong <[email protected]>
[ Upstream commit 4dba27f1a14592ac4cf71c3bc1cc1fd05dea8015 ]
pm_runtime_get_sync will increment pm usage counter even it failed. Forgetting to putting operation will result in reference leak here. We fix it by replacing it with the newest pm_runtime_resume_and_get to keep usage counter balanced.
--- drivers/gpu/drm/rockchip/rockchip_lvds.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/rockchip/rockchip_lvds.c +7 -3
@@ -145,7 +145,7 @@ static int rk3288_lvds_poweron(struct rockchip_lvds *lvds)DRM_DEV_ERROR (lvds->dev,"failed to enable lvds pclk %d\n" , ret);return ret; } - ret =pm_runtime_get_sync (lvds->dev); + ret =pm_runtime_resume_and_get (lvds->dev);if (ret <0 ) {DRM_DEV_ERROR (lvds->dev,"failed to get pm runtime: %d\n" , ret);clk_disable (lvds->pclk);
@@ -329,16 +329,20 @@ static int px30_lvds_poweron(struct rockchip_lvds *lvds) {int ret; - ret =pm_runtime_get_sync (lvds->dev); + ret =pm_runtime_resume_and_get (lvds->dev);if (ret <0 ) {DRM_DEV_ERROR (lvds->dev,"failed to get pm runtime: %d\n" , ret);return ret; }/* Enable LVDS mode */ -return regmap_update_bits (lvds->grf,PX30_LVDS_GRF_PD_VO_CON1 , + ret =regmap_update_bits (lvds->grf,PX30_LVDS_GRF_PD_VO_CON1 ,PX30_LVDS_MODE_EN (1 ) |PX30_LVDS_P2S_EN (1 ),PX30_LVDS_MODE_EN (1 ) |PX30_LVDS_P2S_EN (1 )); +if (ret) +pm_runtime_put (lvds->dev); + +return ret; }static void px30_lvds_poweroff (struct rockchip_lvds *lvds)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 173/731 clk: renesas: r9a06g032: Repair grave increment error
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
[ Upstream commit 02693e11611e082e3c4d8653e8af028e43d31164 ]
If condition (clkspec.np != pd->dev.of_node) is true, then the driver ends up in an endless loop, forever, locking up the machine.
--- drivers/clk/renesas/r9a06g032-clocks.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/clk/renesas/r9a06g032-clocks.c +1 -2
@@ -386,7 +386,7 @@ static int r9a06g032_attach_dev(struct generic_pm_domain *pd,int error;int index; -while (!of_parse_phandle_with_args (np,"clocks" ,"#clock-cells" , i, +while (!of_parse_phandle_with_args (np,"clocks" ,"#clock-cells" , i++, &clkspec)) {if (clkspec.np != pd->dev.of_node)continue ;
@@ -399,7 +399,6 @@ static int r9a06g032_attach_dev(struct generic_pm_domain *pd,if (error)return error; } - i++; }return 0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 174/731 spi: Update reference to struct spi_controller
In reply to Greg Kroah-HartmanFrom: Jonathan Neuschäfer <[email protected]>
[ Upstream commit bf585ccee22faf469d82727cf375868105b362f7 ]
struct spi_master has been renamed to struct spi_controller. Update the reference in spi.rst to make it clickable again.
--- Documentation/driver-api/spi.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/driver-api/spi.rst +2 -2
@@ -25,8 +25,8 @@ hardware, which may be as simple as a set of GPIO pins or as complex as a pair of FIFOs connected to dual DMA engines on the other side of the SPI shift register (maximizing throughput). Such drivers bridge between whatever bus they sit on (often the platform bus) and SPI, and expose -the SPI side of their device as a :c:type:`struct spi_master -<spi_master>`. SPI devices are children of that master, +the SPI side of their device as a :c:type:`struct spi_controller +<spi_controller>`. SPI devices are children of that master, represented as a :c:type:`struct spi_device <spi_device>` and manufactured from :c:type:`struct spi_board_info <spi_board_info>` descriptors which are usually provided by
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 175/731 drm/panel/panel-sitronix-st7701: Remove panel on DSI attach failure
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
[ Upstream commit c62102165dd79284d42383d2f7ed17301bd8e629 ]
In case mipi_dsi_attach() fails, call drm_panel_remove() to avoid memory leak.
--- drivers/gpu/drm/panel/panel-sitronix-st7701.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/panel/panel-sitronix-st7701.c +9 -1
@@ -384,7 +384,15 @@ static int st7701_dsi_probe(struct mipi_dsi_device *dsi) st7701->dsi = dsi; st7701->desc = desc; -return mipi_dsi_attach (dsi); + ret =mipi_dsi_attach (dsi); +if (ret) + goto err_attach; + +return 0 ; + +err_attach: +drm_panel_remove (&st7701->panel); +return ret; }static int st7701_dsi_remove (struct mipi_dsi_device *dsi)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 176/731 ima: Handle -ESTALE returned by ima_filter_rule_match()
In reply to Greg Kroah-HartmanFrom: GUO Zihua <[email protected]>
[ Upstream commit c7423dbdbc9ecef7fff5239d144cad4b9887f4de ]
IMA relies on the blocking LSM policy notifier callback to update the LSM based IMA policy rules.
When SELinux update its policies, IMA would be notified and starts updating all its lsm rules one-by-one. During this time, -ESTALE would be returned by ima_filter_rule_match() if it is called with a LSM rule that has not yet been updated. In ima_match_rules(), -ESTALE is not handled, and the LSM rule is considered a match, causing extra files to be measured by IMA.
Fix it by re-initializing a temporary rule if -ESTALE is returned by ima_filter_rule_match(). The origin rule in the rule list would be updated by the LSM policy notifier callback.
--- security/integrity/ima/ima_policy.c | 41 ++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 9 deletions(-)
security/integrity/ima/ima_policy.c +32 -9
@@ -542,6 +542,9 @@ static bool ima_match_rules(struct ima_rule_entry *rule, const char *func_data) {int i; +bool result = false; +struct ima_rule_entry *lsm_rule = rule; +bool rule_reinitialized = false;if ((rule->flags &IMA_FUNC ) && (rule->func != func && func !=POST_SETATTR ))
@@ -590,35 +593,55 @@ static bool ima_match_rules(struct ima_rule_entry *rule,int rc =0 ;u32 osid; -if (!rule->lsm[i].rule) { -if (!rule->lsm[i].args_p) +if (!lsm_rule->lsm[i].rule) { +if (!lsm_rule->lsm[i].args_p)continue ;else return false; } + +retry:switch (i) {case LSM_OBJ_USER :case LSM_OBJ_ROLE :case LSM_OBJ_TYPE :security_inode_getsecid (inode, &osid); - rc =ima_filter_rule_match (osid, rule->lsm[i].type, + rc =ima_filter_rule_match (osid, lsm_rule->lsm[i].type, Audit_equal, - rule->lsm[i].rule); + lsm_rule->lsm[i].rule);break ;case LSM_SUBJ_USER :case LSM_SUBJ_ROLE :case LSM_SUBJ_TYPE : - rc =ima_filter_rule_match (secid, rule->lsm[i].type, + rc =ima_filter_rule_match (secid, lsm_rule->lsm[i].type, Audit_equal, - rule->lsm[i].rule); + lsm_rule->lsm[i].rule);break ;default :break ; } -if (!rc) -return false; + +if (rc == -ESTALE && !rule_reinitialized) { + lsm_rule =ima_lsm_copy_rule (rule); +if (lsm_rule) { + rule_reinitialized = true; + goto retry; + } + } +if (!rc) { + result = false; + goto out; + } } -return true; + result = true; + +out: +if (rule_reinitialized) { +for (i =0 ; i <MAX_LSM_RULES ; i++) +ima_filter_rule_free (lsm_rule->lsm[i].rule); +kfree (lsm_rule); + } +return result; }/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 177/731 drm/msm/hdmi: drop unused GPIO support
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit 68e674b13b17ed41aac2763d12ece6deaae8df58 ]
The HDMI driver has code to configure extra GPIOs, which predates pinctrl support. Nowadays all platforms should use pinctrl instead. Neither of upstreamed Qualcomm platforms uses these properties, so it's safe to drop them.
Patchwork: https://patchwork.freedesktop.org/patch/488858/
Stable-dep-of: b964444b2b64 ("drm/msm/hdmi: use devres helper for runtime PM management")
--- drivers/gpu/drm/msm/hdmi/hdmi.c | 66 +++++++---------------------- drivers/gpu/drm/msm/hdmi/hdmi.h | 13 +----- drivers/gpu/drm/msm/hdmi/hdmi_hpd.c | 62 ++------------------------- 3 files changed, 21 insertions(+), 120 deletions(-)
drivers/gpu/drm/msm/hdmi/hdmi.c +15 -51
@@ -247,6 +247,20 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev) hdmi->pwr_clks[i] = clk; } + hdmi->hpd_gpiod =devm_gpiod_get_optional (&pdev->dev,"hpd" ,GPIOD_IN ); +/* This will catch e.g. -EPROBE_DEFER */ +if (IS_ERR (hdmi->hpd_gpiod)) { + ret =PTR_ERR (hdmi->hpd_gpiod); +DRM_DEV_ERROR (&pdev->dev,"failed to get hpd gpio: (%d)\n" , ret); + goto fail; + } + +if (!hdmi->hpd_gpiod) +DBG ("failed to get HPD gpio" ); + +if (hdmi->hpd_gpiod) +gpiod_set_consumer_name (hdmi->hpd_gpiod,"HDMI_HPD" ); +pm_runtime_enable (&pdev->dev); hdmi->workq =alloc_ordered_workqueue ("msm_hdmi" ,0 );
@@ -429,20 +443,6 @@ static struct hdmi_platform_config hdmi_tx_8996_config = { .hpd_freq = hpd_clk_freq_8x74, }; -static const struct { -const char *name; -const bool output; -const int value; -const char *label; -} msm_hdmi_gpio_pdata[] = { - {"qcom,hdmi-tx-ddc-clk" , true,1 ,"HDMI_DDC_CLK" }, - {"qcom,hdmi-tx-ddc-data" , true,1 ,"HDMI_DDC_DATA" }, - {"qcom,hdmi-tx-hpd" , false,1 ,"HDMI_HPD" }, - {"qcom,hdmi-tx-mux-en" , true,1 ,"HDMI_MUX_EN" }, - {"qcom,hdmi-tx-mux-sel" , true,0 ,"HDMI_MUX_SEL" }, - {"qcom,hdmi-tx-mux-lpm" , true,1 ,"HDMI_MUX_LPM" }, -}; -/* * HDMI audio codec callbacks */
@@ -555,7 +555,7 @@ static int msm_hdmi_bind(struct device *dev, struct device *master, void *data)struct hdmi_platform_config *hdmi_cfg;struct hdmi *hdmi;struct device_node *of_node = dev->of_node; -int i, err; +int err; hdmi_cfg = (struct hdmi_platform_config *)of_device_get_match_data (dev);
@@ -567,42 +567,6 @@ static int msm_hdmi_bind(struct device *dev, struct device *master, void *data) hdmi_cfg->mmio_name ="core_physical" ; hdmi_cfg->qfprom_mmio_name ="qfprom_physical" ; -for (i =0 ; i <HDMI_MAX_NUM_GPIO ; i++) { -const char *name = msm_hdmi_gpio_pdata[i].name; -struct gpio_desc *gpiod; - -/* -* We are fetching the GPIO lines "as is" since the connector -* code is enabling and disabling the lines. Until that point -* the power-on default value will be kept. -*/ - gpiod =devm_gpiod_get_optional (dev, name,GPIOD_ASIS ); -/* This will catch e.g. -PROBE_DEFER */ -if (IS_ERR (gpiod)) -return PTR_ERR (gpiod); -if (!gpiod) { -/* Try a second time, stripping down the name */ -char name3[32 ]; - -/* -* Try again after stripping out the "qcom,hdmi-tx" -* prefix. This is mainly to match "hpd-gpios" used -* in the upstream bindings. -*/ -if (sscanf (name,"qcom,hdmi-tx-%s" , name3)) - gpiod =devm_gpiod_get_optional (dev, name3,GPIOD_ASIS ); -if (IS_ERR (gpiod)) -return PTR_ERR (gpiod); -if (!gpiod) -DBG ("failed to get gpio: %s" , name); - } - hdmi_cfg->gpios[i].gpiod = gpiod; -if (gpiod) -gpiod_set_consumer_name (gpiod, msm_hdmi_gpio_pdata[i].label); - hdmi_cfg->gpios[i].output = msm_hdmi_gpio_pdata[i].output; - hdmi_cfg->gpios[i].value = msm_hdmi_gpio_pdata[i].value; - } - dev->platform_data = hdmi_cfg; hdmi =msm_hdmi_init (to_platform_device (dev));
drivers/gpu/drm/msm/hdmi/hdmi.h +2 -11
@@ -19,17 +19,9 @@#include "msm_drv.h" #include "hdmi.xml.h" -#define HDMI_MAX_NUM_GPIO 6 -struct hdmi_phy ;struct hdmi_platform_config ; -struct hdmi_gpio_data { -struct gpio_desc *gpiod; -bool output; -int value; -}; -struct hdmi_audio {bool enabled;struct hdmi_audio_infoframe infoframe;
@@ -61,6 +53,8 @@ struct hdmi {struct clk **hpd_clks;struct clk **pwr_clks; +struct gpio_desc *hpd_gpiod; +struct hdmi_phy *phy;struct device *phy_dev;
@@ -109,9 +103,6 @@ struct hdmi_platform_config {/* clks that need to be on for screen pwr (ie pixel clk): */ const char **pwr_clk_names;int pwr_clk_cnt; - -/* gpio's: */ -struct hdmi_gpio_data gpios[HDMI_MAX_NUM_GPIO ]; };struct hdmi_bridge {
drivers/gpu/drm/msm/hdmi/hdmi_hpd.c +4 -58
98 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 178/731 drm/msm/hdmi: use devres helper for runtime PM management
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit b964444b2b64ce182495731d830499d1c588ccf6 ]
Use devm_pm_runtime_enable() to enable runtime PM. This way its effect will be reverted on device unbind/destruction.
Patchwork: https://patchwork.freedesktop.org/patch/499647/
--- drivers/gpu/drm/msm/hdmi/hdmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/hdmi/hdmi.c +1 -1
@@ -261,7 +261,7 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev)if (hdmi->hpd_gpiod)gpiod_set_consumer_name (hdmi->hpd_gpiod,"HDMI_HPD" ); -pm_runtime_enable (&pdev->dev); +devm_pm_runtime_enable (&pdev->dev); hdmi->workq =alloc_ordered_workqueue ("msm_hdmi" ,0 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 179/731 bpf: Fix slot type check in check_stack_write_var_off
In reply to Greg Kroah-HartmanFrom: Kumar Kartikeya Dwivedi <[email protected]>
[ Upstream commit f5e477a861e4a20d8a1c5f7a245f3a3c3c376b03 ]
For the case where allow_ptr_leaks is false, code is checking whether slot type is STACK_INVALID and STACK_SPILL and rejecting other cases. This is a consequence of incorrectly checking for register type instead of the slot type (NOT_INIT and SCALAR_VALUE respectively). Fix the check.
--- kernel/bpf/verifier.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
kernel/bpf/verifier.c +11 -8
@@ -2772,14 +2772,17 @@ static int check_stack_write_var_off(struct bpf_verifier_env *env, spi = slot /BPF_REG_SIZE ; stype = &state->stack[spi].slot_type[slot %BPF_REG_SIZE ]; -if (!env->allow_ptr_leaks - && *stype !=NOT_INIT - && *stype !=SCALAR_VALUE ) { -/* Reject the write if there's are spilled pointers in -* range. If we didn't reject here, the ptr status -* would be erased below (even though not all slots are -* actually overwritten), possibly opening the door to -* leaks. +if (!env->allow_ptr_leaks && *stype !=STACK_MISC && *stype !=STACK_ZERO ) { +/* Reject the write if range we may write to has not +* been initialized beforehand. If we didn't reject +* here, the ptr status would be erased below (even +* though not all slots are actually overwritten), +* possibly opening the door to leaks. +* +* We do however catch STACK_INVALID case below, and +* only allow reading possibly uninitialized memory +* later for CAP_PERFMON, as the write may not happen to +* that slot. */ verbose (env,"spilled ptr in range of var-offset stack write; insn %d, ptr off: %d" , insn_idx, i);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 180/731 media: vivid: fix compose size exceed boundary
In reply to Greg Kroah-HartmanFrom: Liu Shixin <[email protected]>
[ Upstream commit 94a7ad9283464b75b12516c5512541d467cefcf8 ]
syzkaller found a bug:
BUG: unable to handle page fault for address: ffffc9000a3b1000 #PF: supervisor write access in kernel mode #PF: error_code(0x0002) - not-present page PGD 100000067 P4D 100000067 PUD 10015f067 PMD 1121ca067 PTE 0 Oops: 0002 [#1] PREEMPT SMP CPU: 0 PID: 23489 Comm: vivid-000-vid-c Not tainted 6.1.0-rc1+ #512 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 RIP: 0010:memcpy_erms+0x6/0x10 [...] Call Trace: <TASK> ? tpg_fill_plane_buffer+0x856/0x15b0 vivid_fillbuff+0x8ac/0x1110 vivid_thread_vid_cap_tick+0x361/0xc90 vivid_thread_vid_cap+0x21a/0x3a0 kthread+0x143/0x180 ret_from_fork+0x1f/0x30 </TASK>
This is because we forget to check boundary after adjust compose->height int V4L2_SEL_TGT_CROP case. Add v4l2_rect_map_inside() to fix this problem for this case.
--- drivers/media/test-drivers/vivid/vivid-vid-cap.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/test-drivers/vivid/vivid-vid-cap.c +1 -0
@@ -961,6 +961,7 @@ int vivid_vid_cap_s_selection(struct file *file, void *fh, struct v4l2_selectionif (dev->has_compose_cap) {v4l2_rect_set_min_size (compose, &min_rect);v4l2_rect_set_max_size (compose, &max_rect); +v4l2_rect_map_inside (compose, &fmt); } dev->fmt_cap_rect = fmt;tpg_s_buf_height (&dev->tpg, fmt.height);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 181/731 media: platform: exynos4-is: fix return value check in fimc_md_probe()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit e38e42c078da4af962d322b97e726dcb2f184e3f ]
devm_pinctrl_get() may return ERR_PTR(-EPROBE_DEFER), add a minus sign to fix it.
--- drivers/media/platform/exynos4-is/media-dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/exynos4-is/media-dev.c +1 -1
@@ -1472,7 +1472,7 @@ static int fimc_md_probe(struct platform_device *pdev) pinctrl =devm_pinctrl_get (dev);if (IS_ERR (pinctrl)) { ret =PTR_ERR (pinctrl); -if (ret !=EPROBE_DEFER ) +if (ret != -EPROBE_DEFER )dev_err (dev,"Failed to get pinctrl: %d\n" , ret); goto err_clk; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 182/731 bpf: propagate precision in ALU/ALU64 operations
In reply to Greg Kroah-HartmanFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit a3b666bfa9c9edc05bca62a87abafe0936bd7f97 ]
When processing ALU/ALU64 operations (apart from BPF_MOV, which is handled correctly already; and BPF_NEG and BPF_END are special and don't have source register), if destination register is already marked precise, this causes problem with potentially missing precision tracking for the source register. E.g., when we have r1 >>= r5 and r1 is marked precise, but r5 isn't, this will lead to r5 staying as imprecise. This is due to the precision backtracking logic stopping early when it sees r1 is already marked precise. If r1 wasn't precise, we'd keep backtracking and would add r5 to the set of registers that need to be marked precise. So there is a discrepancy here which can lead to invalid and incompatible states matched due to lack of precision marking on r5. If r1 wasn't precise, precision backtracking would correctly mark both r1 and r5 as precise.
This is simple to fix, though. During the forward instruction simulation pass, for arithmetic operations of scalar <op>= scalar form (where <op> is ALU or ALU64 operations), if destination register is already precise, mark source register as precise. This applies only when both involved registers are SCALARs. ptr += scalar and scalar += ptr cases are already handled correctly.
This does have (negative) effect on some selftest programs and few Cilium programs. ~/baseline-tmp-results.csv are veristat results with this patch, while ~/baseline-results.csv is without it. See post scriptum for instructions on how to make Cilium programs testable with veristat. Correctness has a price.
$ ./veristat -C -e file,prog,insns,states ~/baseline-results.csv ~/baseline-tmp-results.csv | grep -v '+0' File Program Total insns (A) Total insns (B) Total insns (DIFF) Total states (A) Total states (B) Total states (DIFF) ----------------------- -------------------- --------------- --------------- ------------------ ---------------- ---------------- ------------------- bpf_cubic.bpf.linked1.o bpf_cubic_cong_avoid 997 1700 +703 (+70.51%) 62 90 +28 (+45.16%) test_l4lb.bpf.linked1.o balancer_ingress 4559 5469 +910 (+19.96%) 118 126 +8 (+6.78%) ----------------------- -------------------- --------------- --------------- ------------------ ---------------- ---------------- -------------------
$ ./veristat -C -e file,prog,verdict,insns,states ~/baseline-results-cilium.csv ~/baseline-tmp-results-cilium.csv | grep -v '+0' File Program Total insns (A) Total insns (B) Total insns (DIFF) Total states (A) Total states (B) Total states (DIFF) ------------- ------------------------------ --------------- --------------- ------------------ ---------------- ---------------- ------------------- bpf_host.o tail_nodeport_nat_ingress_ipv6 4448 5261 +813 (+18.28%) 234 247 +13 (+5.56%) bpf_host.o tail_nodeport_nat_ipv6_egress 3396 3446 +50 (+1.47%) 201 203 +2 (+1.00%) bpf_lxc.o tail_nodeport_nat_ingress_ipv6 4448 5261 +813 (+18.28%) 234 247 +13 (+5.56%) bpf_overlay.o tail_nodeport_nat_ingress_ipv6 4448 5261 +813 (+18.28%) 234 247 +13 (+5.56%) bpf_xdp.o tail_lb_ipv4 71736 73442 +1706 (+2.38%) 4295 4370 +75 (+1.75%) ------------- ------------------------------ --------------- --------------- ------------------ ---------------- ---------------- -------------------
P.S. To make Cilium ([0]) programs libbpf-compatible and thus veristat-loadable, apply changes from topmost commit in [1], which does minimal changes to Cilium source code, mostly around SEC() annotations and BPF map definitions.
[0] https://github.com/cilium/cilium/
[1] https://github.com/anakryiko/cilium/commits/libbpf-friendliness
--- kernel/bpf/verifier.c | 5 +++++ 1 file changed, 5 insertions(+)
kernel/bpf/verifier.c +5 -0
@@ -7998,6 +7998,11 @@ static int adjust_reg_min_max_vals(struct bpf_verifier_env *env,return err;return adjust_ptr_min_max_vals (env, insn, dst_reg, src_reg); + }else if (dst_reg->precise) { +/* if dst_reg is precise, src_reg should be precise as well */ + err =mark_chain_precision (env, insn->src_reg); +if (err) +return err; } }else {/* Pretend the src is a reg with a known value, since we only
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 183/731 bpf: Check the other end of slot_type for STACK_SPILL
In reply to Greg Kroah-HartmanFrom: Martin KaFai Lau <[email protected]>
[ Upstream commit 27113c59b6d0a587b29ae72d4ff3f832f58b0651 ]
Every 8 bytes of the stack is tracked by a bpf_stack_state. Within each bpf_stack_state, there is a 'u8 slot_type[8]' to track the type of each byte. Verifier tests slot_type[0] == STACK_SPILL to decide if the spilled reg state is saved. Verifier currently only saves the reg state if the whole 8 bytes are spilled to the stack, so checking the slot_type[7] is the same as checking slot_type[0].
The later patch will allow verifier to save the bounded scalar reg also for <8 bytes spill. There is a llvm patch [1] to ensure the <8 bytes spill will be 8-byte aligned, so checking slot_type[7] instead of slot_type[0] is required.
While at it, this patch refactors the slot_type[0] == STACK_SPILL test into a new function is_spilled_reg() and change the slot_type[0] check to slot_type[7] check in there also.
[1] https://reviews.llvm.org/D109073
Stable-dep-of: 529409ea92d5 ("bpf: propagate precision across all frames, not just the last one")
--- kernel/bpf/verifier.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-)
kernel/bpf/verifier.c +19 -11
@@ -606,6 +606,14 @@ static const char *kernel_type_name(const struct btf* btf, u32 id)return btf_name_by_offset (btf,btf_type_by_id (btf, id)->name_off); } +/* The reg state of a pointer or a bounded scalar was saved when +* it was spilled to the stack. +*/ +static bool is_spilled_reg (const struct bpf_stack_state *stack) +{ +return stack->slot_type[BPF_REG_SIZE -1 ] ==STACK_SPILL ; +} +static void print_verifier_state (struct bpf_verifier_env *env,const struct bpf_func_state *state) {
@@ -709,7 +717,7 @@ static void print_verifier_state(struct bpf_verifier_env *env,continue ;verbose (env," fp%d" , (-i -1 ) *BPF_REG_SIZE );print_liveness (env, state->stack[i].spilled_ptr.live); -if (state->stack[i].slot_type[0 ] ==STACK_SPILL ) { +if (is_spilled_reg (&state->stack[i])) { reg = &state->stack[i].spilled_ptr; t = reg->type;verbose (env,"=%s" ,reg_type_str (env, t));
@@ -2351,7 +2359,7 @@ static void mark_all_scalars_precise(struct bpf_verifier_env *env, reg->precise = true; }for (j =0 ; j < func->allocated_stack /BPF_REG_SIZE ; j++) { -if (func->stack[j].slot_type[0 ] !=STACK_SPILL ) +if (!is_spilled_reg (&func->stack[j]))continue ; reg = &func->stack[j].spilled_ptr;if (reg->type !=SCALAR_VALUE )
@@ -2393,7 +2401,7 @@ static int __mark_chain_precision(struct bpf_verifier_env *env, int regno, }while (spi >=0 ) { -if (func->stack[spi].slot_type[0 ] !=STACK_SPILL ) { +if (!is_spilled_reg (&func->stack[spi])) { stack_mask =0 ;break ; }
@@ -2492,7 +2500,7 @@ static int __mark_chain_precision(struct bpf_verifier_env *env, int regno,return 0 ; } -if (func->stack[i].slot_type[0 ] !=STACK_SPILL ) { +if (!is_spilled_reg (&func->stack[i])) { stack_mask &= ~(1ull << i);continue ; }
@@ -2682,7 +2690,7 @@ static int check_stack_write_fixed_off(struct bpf_verifier_env *env,/* regular write of data into stack destroys any spilled ptr */ state->stack[spi].spilled_ptr.type =NOT_INIT ;/* Mark slots as STACK_MISC if they belonged to spilled ptr. */ -if (state->stack[spi].slot_type[0 ] ==STACK_SPILL ) +if (is_spilled_reg (&state->stack[spi]))for (i =0 ; i <BPF_REG_SIZE ; i++) state->stack[spi].slot_type[i] =STACK_MISC ;
@@ -2895,7 +2903,7 @@ static int check_stack_read_fixed_off(struct bpf_verifier_env *env, stype = reg_state->stack[spi].slot_type; reg = ®_state->stack[spi].spilled_ptr; -if (stype[0 ] ==STACK_SPILL ) { +if (is_spilled_reg (®_state->stack[spi])) {if (size !=BPF_REG_SIZE ) {if (reg->type !=SCALAR_VALUE ) {verbose_linfo (env, env->insn_idx,"; " );
@@ -4534,11 +4542,11 @@ static int check_stack_range_initialized( goto mark; } -if (state->stack[spi].slot_type[0 ] ==STACK_SPILL && +if (is_spilled_reg (&state->stack[spi]) && state->stack[spi].spilled_ptr.type ==PTR_TO_BTF_ID ) goto mark; -if (state->stack[spi].slot_type[0 ] ==STACK_SPILL && +if (is_spilled_reg (&state->stack[spi]) && (state->stack[spi].spilled_ptr.type ==SCALAR_VALUE || env->allow_ptr_leaks)) {if (clobber) {
@@ -10342,9 +10350,9 @@ static bool stacksafe(struct bpf_verifier_env *env, struct bpf_func_state *old,* return false to continue verification of this path */ return false; -if (i %BPF_REG_SIZE ) +if (i %BPF_REG_SIZE !=BPF_REG_SIZE -1 )continue ; -if (old->stack[spi].slot_type[0 ] !=STACK_SPILL ) +if (!is_spilled_reg (&old->stack[spi]))continue ;if (!regsafe (env, &old->stack[spi].spilled_ptr, &cur->stack[spi].spilled_ptr, idmap))
@@ -10551,7 +10559,7 @@ static int propagate_precision(struct bpf_verifier_env *env, }for (i =0 ; i < state->allocated_stack /BPF_REG_SIZE ; i++) { -if (state->stack[i].slot_type[0 ] !=STACK_SPILL ) +if (!is_spilled_reg (&state->stack[i]))continue ; state_reg = &state->stack[i].spilled_ptr; if (state_reg->type != SCALAR_VALUE ||
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 184/731 bpf: propagate precision across all frames, not just the last one
In reply to Greg Kroah-HartmanFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit 529409ea92d590659be487ba0839710329bd8074 ]
When equivalent completed state is found and it has additional precision restrictions, BPF verifier propagates precision to currently-being-verified state chain (i.e., including parent states) so that if some of the states in the chain are not yet completed, necessary precision restrictions are enforced.
Unfortunately, right now this happens only for the last frame (deepest active subprogram's frame), not all the frames. This can lead to incorrect matching of states due to missing precision marker. Currently this doesn't seem possible as BPF verifier forces everything to precise when validated BPF program has any subprograms. But with the next patch lifting this restriction, this becomes problematic.
In fact, without this fix, we'll start getting failure in one of the existing test_verifier test cases:
#906/p precise: cross frame pruning FAIL
Unexpected success to load!
verification time 48 usec
stack depth 0+0
processed 26 insns (limit 1000000) max_states_per_insn 3 total_states 17 peak_states 17 mark_read 8
This patch adds precision propagation across all frames.
--- kernel/bpf/verifier.c | 71 ++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 32 deletions(-)
kernel/bpf/verifier.c +39 -32
@@ -2369,7 +2369,7 @@ static void mark_all_scalars_precise(struct bpf_verifier_env *env, } } -static int __mark_chain_precision (struct bpf_verifier_env *env,int regno, +static int __mark_chain_precision (struct bpf_verifier_env *env,int frame,int regno,int spi) {struct bpf_verifier_state *st = env->cur_state;
@@ -2386,7 +2386,7 @@ static int __mark_chain_precision(struct bpf_verifier_env *env, int regno,if (!env->bpf_capable)return 0 ; - func = st->frame[st->curframe]; + func = st->frame[frame];if (regno >=0 ) { reg = &func->regs[regno];if (reg->type !=SCALAR_VALUE ) {
@@ -2467,7 +2467,7 @@ static int __mark_chain_precision(struct bpf_verifier_env *env, int regno,break ; new_marks = false; - func = st->frame[st->curframe]; + func = st->frame[frame];bitmap_from_u64 (mask, reg_mask);for_each_set_bit (i, mask,32 ) { reg = &func->regs[i];
@@ -2533,12 +2533,17 @@ static int __mark_chain_precision(struct bpf_verifier_env *env, int regno,static int mark_chain_precision (struct bpf_verifier_env *env,int regno) { -return __mark_chain_precision (env, regno,-1 ); +return __mark_chain_precision (env, env->cur_state->curframe, regno,-1 ); } -static int mark_chain_precision_stack (struct bpf_verifier_env *env,int spi) +static int mark_chain_precision_frame (struct bpf_verifier_env *env,int frame,int regno) { -return __mark_chain_precision (env,-1 , spi); +return __mark_chain_precision (env, frame, regno,-1 ); +} + +static int mark_chain_precision_stack_frame (struct bpf_verifier_env *env,int frame,int spi) +{ +return __mark_chain_precision (env, frame,-1 , spi); }static bool is_spillable_regtype (enum bpf_reg_type type)
@@ -10543,34 +10548,36 @@ static int propagate_precision(struct bpf_verifier_env *env, {struct bpf_reg_state *state_reg;struct bpf_func_state *state; -int i, err =0 ; +int i, err =0 , fr; - state = old->frame[old->curframe]; - state_reg = state->regs; -for (i =0 ; i <BPF_REG_FP ; i++, state_reg++) { -if (state_reg->type !=SCALAR_VALUE || - !state_reg->precise) -continue ; -if (env->log.level &BPF_LOG_LEVEL2 ) -verbose (env,"propagating r%d\n" , i); - err =mark_chain_precision (env, i); -if (err <0 ) -return err; - } +for (fr = old->curframe; fr >=0 ; fr--) { + state = old->frame[fr]; + state_reg = state->regs; +for (i =0 ; i <BPF_REG_FP ; i++, state_reg++) { +if (state_reg->type !=SCALAR_VALUE || + !state_reg->precise) +continue ; +if (env->log.level &BPF_LOG_LEVEL2 ) +verbose (env,"frame %d: propagating r%d\n" , i, fr); + err =mark_chain_precision_frame (env, fr, i); +if (err <0 ) +return err; + } -for (i =0 ; i < state->allocated_stack /BPF_REG_SIZE ; i++) { -if (!is_spilled_reg (&state->stack[i])) -continue ; - state_reg = &state->stack[i].spilled_ptr; -if (state_reg->type !=SCALAR_VALUE || - !state_reg->precise) -continue ; -if (env->log.level &BPF_LOG_LEVEL2 ) -verbose (env,"propagating fp%d\n" , - (-i -1 ) *BPF_REG_SIZE ); - err =mark_chain_precision_stack (env, i); -if (err <0 ) -return err; +for (i =0 ; i < state->allocated_stack /BPF_REG_SIZE ; i++) { +if (!is_spilled_reg (&state->stack[i])) +continue ; + state_reg = &state->stack[i].spilled_ptr; +if (state_reg->type !=SCALAR_VALUE || + !state_reg->precise) +continue ; +if (env->log.level &BPF_LOG_LEVEL2 ) +verbose (env,"frame %d: propagating fp%d\n" , + (-i -1 ) *BPF_REG_SIZE , fr); + err =mark_chain_precision_stack_frame (env, fr, i); +if (err <0 ) +return err; + } }return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 185/731 clk: qcom: gcc-sm8250: Use retention mode for USB GDSCs
In reply to Greg Kroah-HartmanFrom: Manivannan Sadhasivam <[email protected]>
[ Upstream commit ac1c5a03d3772b1db25e8092f771aa33f6ae2f7e ]
USB controllers on SM8250 doesn't work after coming back from suspend. This can be fixed by keeping the USB GDSCs in retention mode so that hardware can keep them ON and put into rentention mode once the parent domain goes to a low power state.
--- drivers/clk/qcom/gcc-sm8250.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/gcc-sm8250.c +2 -2
@@ -3267,7 +3267,7 @@ static struct gdsc usb30_prim_gdsc = { .pd = { .name = "usb30_prim_gdsc", }, - .pwrsts = PWRSTS_OFF_ON, + .pwrsts = PWRSTS_RET_ON, };static struct gdsc usb30_sec_gdsc = {
@@ -3275,7 +3275,7 @@ static struct gdsc usb30_sec_gdsc = { .pd = { .name = "usb30_sec_gdsc", }, - .pwrsts = PWRSTS_OFF_ON, + .pwrsts = PWRSTS_RET_ON, };static struct gdsc hlos1_vote_mmnoc_mmu_tbu_hf0_gdsc = {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 186/731 mtd: Fix device name leak when register device failed in add_mtd_device()
In reply to Greg Kroah-HartmanFrom: Zhang Xiaoxu <[email protected]>
[ Upstream commit 895d68a39481a75c680aa421546931fb11942fa6 ]
There is a kmemleak when register device failed:
unreferenced object 0xffff888101aab550 (size 8):
comm "insmod", pid 3922, jiffies 4295277753 (age 925.408s)
hex dump (first 8 bytes):
6d 74 64 30 00 88 ff ff mtd0....
backtrace:
[<00000000bde26724>] __kmalloc_node_track_caller+0x4e/0x150
[<000000003c32b416>] kvasprintf+0xb0/0x130
[<000000001f7a8f15>] kobject_set_name_vargs+0x2f/0xb0
[<000000006e781163>] dev_set_name+0xab/0xe0
[<00000000e30d0c78>] add_mtd_device+0x4bb/0x700
[<00000000f3d34de7>] mtd_device_parse_register+0x2ac/0x3f0
[<00000000c0d88488>] 0xffffffffa0238457
[<00000000b40d0922>] 0xffffffffa02a008f
[<0000000023d17b9d>] do_one_initcall+0x87/0x2a0
[<00000000770f6ca6>] do_init_module+0xdf/0x320
[<000000007b6768fe>] load_module+0x2f98/0x3330
[<00000000346bed5a>] __do_sys_finit_module+0x113/0x1b0
[<00000000674c2290>] do_syscall_64+0x35/0x80
[<000000004c6a8d97>] entry_SYSCALL_64_after_hwframe+0x46/0xb0If register device failed, should call put_device() to give up the reference.
--- drivers/mtd/mtdcore.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mtd/mtdcore.c +3 -1
@@ -671,8 +671,10 @@ int add_mtd_device(struct mtd_info *mtd)dev_set_drvdata (&mtd->dev, mtd);of_node_get (mtd_get_of_node (mtd)); error =device_register (&mtd->dev); -if (error) +if (error) { +put_device (&mtd->dev); goto fail_added; + }/* Add the nvmem provider */ error =mtd_nvmem_add (mtd);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 187/731 Input: joystick - fix Kconfig warning for JOYSTICK_ADC
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 6100a19c4fcfe154dd32f8a8ef4e8c0b1f607c75 ]
Fix a Kconfig warning for JOYSTICK_ADC by also selecting IIO_BUFFER.
WARNING: unmet direct dependencies detected for IIO_BUFFER_CB
Depends on [n]: IIO [=y] && IIO_BUFFER [=n]
Selected by [y]:
- JOYSTICK_ADC [=y] && INPUT [=y] && INPUT_JOYSTICK [=y] && IIO [=y]
--- drivers/input/joystick/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/input/joystick/Kconfig +1 -0
@@ -46,6 +46,7 @@ config JOYSTICK_A3D config JOYSTICK_ADC tristate "Simple joystick connected over ADC" depends on IIO + select IIO_BUFFER select IIO_BUFFER_CB help Say Y here if you have a simple joystick connected over ADC.
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 188/731 wifi: rsi: Fix handling of 802.3 EAPOL frames sent via control port
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
[ Upstream commit b8f6efccbb9dc0ff5dee7e20d69a4747298ee603 ]
When using wpa_supplicant v2.10, this driver is no longer able to associate with any AP and fails in the EAPOL 4-way handshake while sending the 2/4 message to the AP. The problem is not present in wpa_supplicant v2.9 or older. The problem stems from HostAP commit 144314eaa ("wpa_supplicant: Send EAPOL frames over nl80211 where available") which changes the way EAPOL frames are sent, from them being send at L2 frames to them being sent via nl80211 control port.
An EAPOL frame sent as L2 frame is passed to the WiFi driver with skb->protocol ETH_P_PAE, while EAPOL frame sent via nl80211 control port has skb->protocol set to ETH_P_802_3 . The later happens in ieee80211_tx_control_port(), where the EAPOL frame is encapsulated into 802.3 frame.
The rsi_91x driver handles ETH_P_PAE EAPOL frames as high-priority frames and sends them via highest-priority transmit queue, while the ETH_P_802_3 frames are sent as regular frames. The EAPOL 4-way handshake frames must be sent as highest-priority, otherwise the 4-way handshake times out.
Therefore, to fix this problem, inspect the skb control flags and if flag IEEE80211_TX_CTRL_PORT_CTRL_PROTO is set, assume this is an EAPOL frame and transmit the frame via high-priority queue just like other ETH_P_PAE frames.
--- drivers/net/wireless/rsi/rsi_91x_core.c | 4 +++- drivers/net/wireless/rsi/rsi_91x_hal.c | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/net/wireless/rsi/rsi_91x_core.c +3 -1
@@ -465,7 +465,9 @@ void rsi_core_xmit(struct rsi_common *common, struct sk_buff *skb) tid, 0); } } -if (skb->protocol ==cpu_to_be16 (ETH_P_PAE )) { + +if (IEEE80211_SKB_CB (skb)->control.flags & +IEEE80211_TX_CTRL_PORT_CTRL_PROTO ) { q_num =MGMT_SOFT_Q ; skb->priority = q_num; }
drivers/net/wireless/rsi/rsi_91x_hal.c +5 -1
@@ -162,12 +162,16 @@ int rsi_prepare_data_desc(struct rsi_common *common, struct sk_buff *skb)u8 header_size;u8 vap_id =0 ;u8 dword_align_bytes; +bool tx_eapol;u16 seq_num; info =IEEE80211_SKB_CB (skb); vif = info->control.vif; tx_params = (struct skb_info *)info->driver_data; + tx_eapol =IEEE80211_SKB_CB (skb)->control.flags & +IEEE80211_TX_CTRL_PORT_CTRL_PROTO ; + header_size =FRAME_DESC_SZ +sizeof (struct rsi_xtended_desc );if (header_size >skb_headroom (skb)) {rsi_dbg (ERR_ZONE ,"%s: Unable to send pkt\n" , __func__);
@@ -231,7 +235,7 @@ int rsi_prepare_data_desc(struct rsi_common *common, struct sk_buff *skb) } } -if (skb->protocol ==cpu_to_be16 (ETH_P_PAE )) { +if (tx_eapol) {rsi_dbg (INFO_ZONE ,"*** Tx EAPOL ***\n" ); data_desc->frame_info =cpu_to_le16 (RATE_INFO_ENABLE );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 189/731 media: camss: Clean up received buffers on failed start of streaming
In reply to Greg Kroah-HartmanFrom: Vladimir Zapolskiy <[email protected]>
[ Upstream commit c8f3582345e6a69da65ab588f7c4c2d1685b0e80 ]
It is required to return the received buffers, if streaming can not be started. For instance media_pipeline_start() may fail with EPIPE, if a link validation between entities is not passed, and in such a case a user gets a kernel warning:
WARNING: CPU: 1 PID: 520 at drivers/media/common/videobuf2/videobuf2-core.c:1592 vb2_start_streaming+0xec/0x160 <snip> Call trace: vb2_start_streaming+0xec/0x160 vb2_core_streamon+0x9c/0x1a0 vb2_ioctl_streamon+0x68/0xbc v4l_streamon+0x30/0x3c __video_do_ioctl+0x184/0x3e0 video_usercopy+0x37c/0x7b0 video_ioctl2+0x24/0x40 v4l2_ioctl+0x4c/0x70
The fix is to correct the error path in video_start_streaming() of camss.
--- drivers/media/platform/qcom/camss/camss-video.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/camss/camss-video.c +2 -1
@@ -493,7 +493,7 @@ static int video_start_streaming(struct vb2_queue *q, unsigned int count) ret =media_pipeline_start (&vdev->entity, &video->pipe);if (ret <0 ) -return ret; + goto flush_buffers; ret =video_check_format (video);if (ret <0 )
@@ -522,6 +522,7 @@ static int video_start_streaming(struct vb2_queue *q, unsigned int count) error:media_pipeline_stop (&vdev->entity); +flush_buffers: video->ops->flush_buffers (video,VB2_BUF_STATE_QUEUED );return ret;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 190/731 net, proc: Provide PROC_FS=n fallback for proc_create_net_single_write()
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit c3d96f690a790074b508fe183a41e36a00cd7ddd ]
Provide a CONFIG_PROC_FS=n fallback for proc_create_net_single_write().
Also provide a fallback for proc_create_net_data_write().
--- include/linux/proc_fs.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/proc_fs.h +2 -0
@@ -191,8 +191,10 @@ static inline void proc_remove(struct proc_dir_entry *de) {}static inline int remove_proc_subtree (const char *name,struct proc_dir_entry *parent) {return 0 ; }#define proc_create_net_data (name, mode, parent, ops, state_size, data) ({NULL;}) +#define proc_create_net_data_write (name, mode, parent, ops, write, state_size, data) ({NULL;})#define proc_create_net (name, mode, parent, state_size, ops) ({NULL;})#define proc_create_net_single (name, mode, parent, show, data) ({NULL;}) +#define proc_create_net_single_write (name, mode, parent, show, write, data) ({NULL;})static inline struct pid *tgid_pidfd_to_pid (const struct file *file) {
Signature · 1 line
2.35.1
Re: [PATCH 5.15 190/731] net, proc: Provide PROC_FS=n fallback for proc_create_net_single_write()
This series was applied to bpf/bpf.git (master) by Arnaldo Carvalho de Melo <[email protected]>:
Hello:
This series was applied to bpf/bpf.git (master)
by Arnaldo Carvalho de Melo <[email protected]>:
Quoted 9 lines · On Wed, 28 Dec 2022 15:34:57 +0100 you wrote:
From: David Howells <[email protected]>
[ Upstream commit
c3d96f690a790074b508fe183a41e36a00cd7ddd]Provide a
CONFIG_PROC_FS=nfallback forproc_create_net_single_write().Also provide a fallback for
proc_create_net_data_write().[...]
Here is the summary with links:
- [5.15,190/731] net, proc: Provide PROC_FS=n fallback for proc_create_net_single_write() (no matching commit)
- [5.15,514/731] perf trace: Return error if a system call doesnt exist
https://git.kernel.org/bpf/bpf/c/d4223e1776c3 - [5.15,515/731] perf trace: Use macro RAW_SYSCALL_ARGS_NUM to replace number https://git.kernel.org/bpf/bpf/c/eadcab4c7a66 - [5.15,516/731] perf trace: Handle failure when trace point folder is missed https://git.kernel.org/bpf/bpf/c/03e9a5d8eb55
- [5.15,643/731] igb: Do not free q_vector unless new one was allocated (no matching commit)
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Greg Kroah-Hartman
maintainerPATCH 191/731 rxrpc: Fix ack.bufferSize to be 0 when generating an ack
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit 8889a711f9b4dcf4dd1330fa493081beebd118c9 ]
ack.bufferSize should be set to 0 when generating an ack.
--- net/rxrpc/output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/rxrpc/output.c +1 -1
@@ -93,7 +93,7 @@ static size_t rxrpc_fill_out_ack(struct rxrpc_connection *conn, *_hard_ack = hard_ack; *_top = top; - pkt->ack.bufferSpace =htons (8 ); + pkt->ack.bufferSpace =htons (0 ); pkt->ack.maxSkew =htons (0 ); pkt->ack.firstPacket =htonl (hard_ack +1 ); pkt->ack.previousPacket =htonl (call->ackr_highest_seq);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 192/731 bfq: fix waker_bfqq inconsistency crash
In reply to Greg Kroah-HartmanFrom: Khazhismel Kumykov <[email protected]>
[ Upstream commit a1795c2ccb1e4c49220d2a0d381540024d71647c ]
This fixes crashes in bfq_add_bfqq_busy due to waker_bfqq being NULL, but woken_list_node still being hashed. This would happen when bfq_init_rq() expects a brand new allocated queue to be returned from bfq_get_bfqq_handle_split() and unconditionally updates waker_bfqq without resetting woken_list_node. Since we can always return oom_bfqq when attempting to allocate, we cannot assume waker_bfqq starts as NULL.
Avoid setting woken_bfqq for oom_bfqq entirely, as it's not useful.
Crashes would have a stacktrace like:
[160595.656560] bfq_add_bfqq_busy+0x110/0x1ec [160595.661142] bfq_add_request+0x6bc/0x980 [160595.666602] bfq_insert_request+0x8ec/0x1240 [160595.671762] bfq_insert_requests+0x58/0x9c [160595.676420] blk_mq_sched_insert_request+0x11c/0x198 [160595.682107] blk_mq_submit_bio+0x270/0x62c [160595.686759] __submit_bio_noacct_mq+0xec/0x178 [160595.691926] submit_bio+0x120/0x184 [160595.695990] ext4_mpage_readpages+0x77c/0x7c8 [160595.701026] ext4_readpage+0x60/0xb0 [160595.705158] filemap_read_page+0x54/0x114 [160595.711961] filemap_fault+0x228/0x5f4 [160595.716272] do_read_fault+0xe0/0x1f0 [160595.720487] do_fault+0x40/0x1c8
Tested by injecting random failures into bfq_get_queue, crashes go away completely.
--- block/bfq-iosched.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
block/bfq-iosched.c +7 -2
@@ -6630,6 +6630,12 @@ static struct bfq_queue *bfq_init_rq(struct request *rq) bfqq =bfq_get_bfqq_handle_split (bfqd, bic, bio, true, is_sync,NULL ); +if (unlikely (bfqq == &bfqd->oom_bfqq)) + bfqq_already_existing = true; + }else + bfqq_already_existing = true; + +if (!bfqq_already_existing) { bfqq->waker_bfqq = old_bfqq->waker_bfqq; bfqq->tentative_waker_bfqq =NULL ;
@@ -6643,8 +6649,7 @@ static struct bfq_queue *bfq_init_rq(struct request *rq)if (bfqq->waker_bfqq)hlist_add_head (&bfqq->woken_list_node, &bfqq->waker_bfqq->woken_list); - }else - bfqq_already_existing = true; + } } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 193/731 drm/radeon: Add the missed acpi_put_table() to fix memory leak
In reply to Greg Kroah-HartmanFrom: Hanjun Guo <[email protected]>
[ Upstream commit 10276a20be1115e1f76c189330da2992df980eee ]
When the radeon driver reads the bios information from ACPI table in radeon_acpi_vfct_bios(), it misses to call acpi_put_table() to release the ACPI memory after the init, so add acpi_put_table() properly to fix the memory leak.
v2: fix text formatting (Alex)
--- drivers/gpu/drm/radeon/radeon_bios.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/gpu/drm/radeon/radeon_bios.c +11 -7
@@ -612,13 +612,14 @@ static bool radeon_acpi_vfct_bios(struct radeon_device *rdev)acpi_size tbl_size;UEFI_ACPI_VFCT *vfct;unsigned offset; +bool r = false;if (!ACPI_SUCCESS (acpi_get_table ("VFCT" ,1 , &hdr)))return false; tbl_size = hdr->length;if (tbl_size <sizeof (UEFI_ACPI_VFCT )) {DRM_ERROR ("ACPI VFCT table present but broken (too short #1)\n" ); -return false; + goto out; } vfct = (UEFI_ACPI_VFCT *)hdr;
@@ -631,13 +632,13 @@ static bool radeon_acpi_vfct_bios(struct radeon_device *rdev) offset +=sizeof (VFCT_IMAGE_HEADER );if (offset > tbl_size) {DRM_ERROR ("ACPI VFCT image header truncated\n" ); -return false; + goto out; } offset += vhdr->ImageLength;if (offset > tbl_size) {DRM_ERROR ("ACPI VFCT image truncated\n" ); -return false; + goto out; } if (vhdr->ImageLength &&
@@ -649,15 +650,18 @@ static bool radeon_acpi_vfct_bios(struct radeon_device *rdev) rdev->bios =kmemdup (&vbios->VbiosContent, vhdr->ImageLength,GFP_KERNEL ); +if (rdev->bios) + r = true; -if (!rdev->bios) -return false; - return true; + goto out; } }DRM_ERROR ("ACPI VFCT table present but broken (too short #2)\n" ); -return false; + +out: +acpi_put_table (hdr); +return r; }#else static inline bool radeon_acpi_vfct_bios (struct radeon_device *rdev)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 194/731 drm/mediatek: Modify dpi power on/off sequence.
In reply to Greg Kroah-HartmanFrom: Xinlei Lee <[email protected]>
[ Upstream commit ff446c0f6290185cefafe3b376bb86063a3a9f6a ]
Modify dpi power on/off sequence so that the first gpio operation will take effect.
--- drivers/gpu/drm/mediatek/mtk_dpi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +6 -6
@@ -387,9 +387,6 @@ static void mtk_dpi_power_off(struct mtk_dpi *dpi)if (--dpi->refcount !=0 )return ; -if (dpi->pinctrl && dpi->pins_gpio) -pinctrl_select_state (dpi->pinctrl, dpi->pins_gpio); -mtk_dpi_disable (dpi);clk_disable_unprepare (dpi->pixel_clk);clk_disable_unprepare (dpi->engine_clk);
@@ -414,9 +411,6 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi) goto err_pixel; } -if (dpi->pinctrl && dpi->pins_dpi) -pinctrl_select_state (dpi->pinctrl, dpi->pins_dpi); -return 0 ; err_pixel:
@@ -630,12 +624,18 @@ static void mtk_dpi_bridge_disable(struct drm_bridge *bridge)struct mtk_dpi *dpi =bridge_to_dpi (bridge);mtk_dpi_power_off (dpi); + +if (dpi->pinctrl && dpi->pins_gpio) +pinctrl_select_state (dpi->pinctrl, dpi->pins_gpio); }static void mtk_dpi_bridge_enable (struct drm_bridge *bridge) {struct mtk_dpi *dpi =bridge_to_dpi (bridge); +if (dpi->pinctrl && dpi->pins_dpi) +pinctrl_select_state (dpi->pinctrl, dpi->pins_dpi); +mtk_dpi_power_on (dpi);mtk_dpi_set_display_mode (dpi, &dpi->mode);mtk_dpi_enable (dpi);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 195/731 ASoC: pxa: fix null-pointer dereference in filter()
In reply to Greg Kroah-HartmanFrom: Zeng Heng <[email protected]>
[ Upstream commit ec7bf231aaa1bdbcb69d23bc50c753c80fb22429 ]
kasprintf() would return NULL pointer when kmalloc() fail to allocate. Need to check the return pointer before calling strcmp().
--- sound/soc/pxa/mmp-pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/pxa/mmp-pcm.c +1 -1
@@ -98,7 +98,7 @@ static bool filter(struct dma_chan *chan, void *param) devname =kasprintf (GFP_KERNEL ,"%s.%d" , dma_data->dma_res->name, dma_data->ssp_id); -if ((strcmp (dev_name (chan->device->dev), devname) ==0 ) && +if (devname && (strcmp (dev_name (chan->device->dev), devname) ==0 ) && (chan->chan_id == dma_data->dma_res->start)) { found = true; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 196/731 libbpf: Fix uninitialized warning in btf_dump_dump_type_data
In reply to Greg Kroah-HartmanFrom: David Michael <[email protected]>
[ Upstream commit dfd0afbf151d85411b371e841f62b81ee5d1ca54 ]
GCC 11.3.0 fails to compile btf_dump.c due to the following error, which seems to originate in btf_dump_struct_data where the returned value would be uninitialized if btf_vlen returns zero.
btf_dump.c: In function ‘btf_dump_dump_type_data’:
btf_dump.c:2363:12: error: ‘err’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
2363 | if (err < 0)
| ^
--- tools/lib/bpf/btf_dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/btf_dump.c +1 -1
@@ -1915,7 +1915,7 @@ static int btf_dump_struct_data(struct btf_dump *d, {const struct btf_member *m =btf_members (t);__u16 n =btf_vlen (t); -int i, err; +int i, err =0 ;/* note that we increment depth before calling btf_dump_print() below; * this is intentional. btf_dump_data_newline() will not print a
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 197/731 nvmet: only allocate a single slab for bvecs
In reply to Greg Kroah-HartmanFrom: Christoph Hellwig <[email protected]>
[ Upstream commit fa8f9ac42350edd3ce82d0d148a60f0fa088f995 ]
There is no need to have a separate slab cache for each namespace, and having separate ones creates duplicate debugs file names as well.
--- drivers/nvme/target/core.c | 22 ++++++++++++++-------- drivers/nvme/target/io-cmd-file.c | 16 +++------------- drivers/nvme/target/nvmet.h | 3 ++- 3 files changed, 19 insertions(+), 22 deletions(-)
drivers/nvme/target/core.c +14 -8
@@ -15,6 +15,7 @@#include "nvmet.h" +struct kmem_cache *nvmet_bvec_cache;struct workqueue_struct *buffered_io_wq;struct workqueue_struct *zbd_wq;static const struct nvmet_fabrics_ops *nvmet_transports[NVMF_TRTYPE_MAX ];
@@ -1607,26 +1608,28 @@ void nvmet_subsys_put(struct nvmet_subsys *subsys)static int __init nvmet_init (void ) { -int error; +int error = -ENOMEM ; nvmet_ana_group_enabled[NVMET_DEFAULT_ANA_GRPID ] =1 ; + nvmet_bvec_cache =kmem_cache_create ("nvmet-bvec" , +NVMET_MAX_MPOOL_BVEC *sizeof (struct bio_vec ),0 , +SLAB_HWCACHE_ALIGN ,NULL ); +if (!nvmet_bvec_cache) +return -ENOMEM ; + zbd_wq =alloc_workqueue ("nvmet-zbd-wq" ,WQ_MEM_RECLAIM ,0 );if (!zbd_wq) -return -ENOMEM ; + goto out_destroy_bvec_cache; buffered_io_wq =alloc_workqueue ("nvmet-buffered-io-wq" ,WQ_MEM_RECLAIM ,0 ); -if (!buffered_io_wq) { - error = -ENOMEM ; +if (!buffered_io_wq) goto out_free_zbd_work_queue; - } nvmet_wq =alloc_workqueue ("nvmet-wq" ,WQ_MEM_RECLAIM ,0 ); -if (!nvmet_wq) { - error = -ENOMEM ; +if (!nvmet_wq) goto out_free_buffered_work_queue; - } error =nvmet_init_discovery ();if (error)
@@ -1645,6 +1648,8 @@ static int __init nvmet_init(void)destroy_workqueue (buffered_io_wq); out_free_zbd_work_queue:destroy_workqueue (zbd_wq); +out_destroy_bvec_cache: +kmem_cache_destroy (nvmet_bvec_cache);return error; }
@@ -1656,6 +1661,7 @@ static void __exit nvmet_exit(void)destroy_workqueue (nvmet_wq);destroy_workqueue (buffered_io_wq);destroy_workqueue (zbd_wq); +kmem_cache_destroy (nvmet_bvec_cache);BUILD_BUG_ON (sizeof (struct nvmf_disc_rsp_page_entry ) !=1024 );BUILD_BUG_ON (sizeof (struct nvmf_disc_rsp_page_hdr ) !=1024 );
drivers/nvme/target/io-cmd-file.c +3 -13
@@ -11,7 +11,6 @@#include <linux/fs.h> #include "nvmet.h" -#define NVMET_MAX_MPOOL_BVEC 16#define NVMET_MIN_MPOOL_OBJ 16int nvmet_file_ns_revalidate (struct nvmet_ns *ns)
@@ -33,8 +32,6 @@ void nvmet_file_ns_disable(struct nvmet_ns *ns)flush_workqueue (buffered_io_wq);mempool_destroy (ns->bvec_pool); ns->bvec_pool =NULL ; -kmem_cache_destroy (ns->bvec_cache); - ns->bvec_cache =NULL ;fput (ns->file); ns->file =NULL ; }
@@ -68,16 +65,8 @@ int nvmet_file_ns_enable(struct nvmet_ns *ns) ns->blksize_shift =min_t (u8,file_inode (ns->file)->i_blkbits,12 ); - ns->bvec_cache =kmem_cache_create ("nvmet-bvec" , -NVMET_MAX_MPOOL_BVEC *sizeof (struct bio_vec ), -0 ,SLAB_HWCACHE_ALIGN ,NULL ); -if (!ns->bvec_cache) { - ret = -ENOMEM ; - goto err; - } - ns->bvec_pool =mempool_create (NVMET_MIN_MPOOL_OBJ , mempool_alloc_slab, - mempool_free_slab, ns->bvec_cache); + mempool_free_slab, nvmet_bvec_cache);if (!ns->bvec_pool) { ret = -ENOMEM ;
@@ -86,9 +75,10 @@ int nvmet_file_ns_enable(struct nvmet_ns *ns)return ret; err: +fput (ns->file); + ns->file =NULL ; ns->size =0 ; ns->blksize_shift =0 ; -nvmet_file_ns_disable (ns);return ret; }
drivers/nvme/target/nvmet.h +2 -1
@@ -77,7 +77,6 @@ struct nvmet_ns {struct completion disable_done;mempool_t *bvec_pool; -struct kmem_cache *bvec_cache;int use_p2pmem;struct pci_dev *p2p_dev;
@@ -363,6 +362,8 @@ struct nvmet_req {u64 error_slba; }; +#define NVMET_MAX_MPOOL_BVEC 16 +extern struct kmem_cache *nvmet_bvec_cache;extern struct workqueue_struct *buffered_io_wq;extern struct workqueue_struct *zbd_wq;extern struct workqueue_struct *nvmet_wq;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 198/731 regulator: core: fix unbalanced of node refcount in regulator_dev_lookup()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit f2b41b748c19962b82709d9f23c6b2b0ce9d2f91 ]
I got the the following report:
OF: ERROR: memory leak, expected refcount 1 instead of 2, of_node_get()/of_node_put() unbalanced - destroy cset entry:
attach overlay node /i2c/pmic@62/regulators/exten
In of_get_regulator(), the node is returned from of_parse_phandle() with refcount incremented, after using it, of_node_put() need be called.
--- drivers/regulator/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/regulator/core.c +1 -0
@@ -1880,6 +1880,7 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev, node =of_get_regulator (dev, supply);if (node) { r =of_find_regulator_by_node (node); +of_node_put (node);if (r)return r;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 199/731 amdgpu/pm: prevent array underflow in vega20_odn_edit_dpm_table()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit d27252b5706e51188aed7647126e44dcf9e940c1 ]
In the PP_OD_EDIT_VDDC_CURVE case the "input_index" variable is capped at 2 but not checked for negative values so it results in an out of bounds read. This value comes from the user via sysfs.
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c +2 -1
@@ -2961,7 +2961,8 @@ static int vega20_odn_edit_dpm_table(struct pp_hwmgr *hwmgr, data->od8_settings.od8_settings_array;OverDriveTable_t *od_table = &(data->smc_state_table.overdrive_table); -int32_t input_index, input_clk, input_vol, i; +int32_t input_clk, input_vol, i; +uint32_t input_index;int od8_id;int ret;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 200/731 nvme: return err on nvme_init_non_mdts_limits fail
In reply to Greg Kroah-HartmanFrom: Joel Granados <[email protected]>
[ Upstream commit bcaf434b8f04e1ee82a8b1e1bce0de99fbff67fa ]
In nvme_init_non_mdts_limits function we were returning 0 when kzalloc failed; it now returns -ENOMEM.
--- drivers/nvme/host/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/core.c +1 -1
@@ -2874,7 +2874,7 @@ static int nvme_init_non_mdts_limits(struct nvme_ctrl *ctrl) id =kzalloc (sizeof (*id),GFP_KERNEL );if (!id) -return 0 ; +return -ENOMEM ; c.identify.opcode = nvme_admin_identify; c.identify.cns =NVME_ID_CNS_CS_CTRL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 201/731 regulator: qcom-rpmh: Fix PMR735a S3 regulator spec
In reply to Greg Kroah-HartmanFrom: Konrad Dybcio <[email protected]>
[ Upstream commit dd801b2265c81bf0c8b0b4b8f7c1e7bfed078403 ]
PMR735a has a wider range than previously defined. Fix it.
--- drivers/regulator/qcom-rpmh-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/qcom-rpmh-regulator.c +1 -1
@@ -1108,7 +1108,7 @@ static const struct rpmh_vreg_init_data pm7325_vreg_data[] = {static const struct rpmh_vreg_init_data pmr735a_vreg_data[] = {RPMH_VREG ("smps1" ,"smp%s1" , &pmic5_ftsmps520,"vdd-s1" ),RPMH_VREG ("smps2" ,"smp%s2" , &pmic5_ftsmps520,"vdd-s2" ), -RPMH_VREG ("smps3" ,"smp%s3" , &pmic5_hfsmps510,"vdd-s3" ), +RPMH_VREG ("smps3" ,"smp%s3" , &pmic5_hfsmps515,"vdd-s3" ),RPMH_VREG ("ldo1" ,"ldo%s1" , &pmic5_nldo,"vdd-l1-l2" ),RPMH_VREG ("ldo2" ,"ldo%s2" , &pmic5_nldo,"vdd-l1-l2" ),RPMH_VREG ("ldo3" ,"ldo%s3" , &pmic5_nldo,"vdd-l3" ),
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 202/731 drm/fourcc: Add packed 10bit YUV 4:2:0 format
In reply to Greg Kroah-HartmanFrom: Dave Stevenson <[email protected]>
[ Upstream commit 006ea1b5822f9019bd722ffc6242bc0880879e3d ]
Adds a format that is 3 10bit YUV 4:2:0 samples packed into a 32bit word (with 2 spare bits).
Supported on Broadcom BCM2711 chips.
Stable-dep-of: b230555f3257 ("drm/fourcc: Fix vsub/hsub for Q410 and Q401")
--- drivers/gpu/drm/drm_fourcc.c | 3 +++ include/uapi/drm/drm_fourcc.h | 11 +++++++++++ 2 files changed, 14 insertions(+)
drivers/gpu/drm/drm_fourcc.c +3 -0
@@ -266,6 +266,9 @@ const struct drm_format_info *__drm_format_info(u32 format) .num_planes = 3, .char_per_block = { 2, 2, 2 }, .block_w = { 1, 1, 1 }, .block_h = { 1, 1, 1 }, .hsub = 0, .vsub = 0, .is_yuv = true }, + { .format = DRM_FORMAT_P030, .depth = 0, .num_planes = 2, + .char_per_block = { 4, 8, 0 }, .block_w = { 3, 3, 0 }, .block_h = { 1, 1, 0 }, + .hsub = 2, .vsub = 2, .is_yuv = true}, };unsigned int i;
include/uapi/drm/drm_fourcc.h +11 -0
@@ -308,6 +308,13 @@ extern "C" {*/ #define DRM_FORMAT_P016 fourcc_code('P', '0', '1', '6')/* 2x2 subsampled Cr:Cb plane 16 bits per channel */ +/* 2 plane YCbCr420. +* 3 10 bit components and 2 padding bits packed into 4 bytes. +* index 0 = Y plane, [31:0] x:Y2:Y1:Y0 2:10:10:10 little endian +* index 1 = Cr:Cb plane, [63:0] x:Cr2:Cb2:Cr1:x:Cb1:Cr0:Cb0 [2:10:10:10:2:10:10:10] little endian +*/ +#define DRM_FORMAT_P030 fourcc_code('P', '0', '3', '0')/* 2x2 subsampled Cr:Cb plane 10 bits per channel packed */ +/* 3 plane non-subsampled (444) YCbCr * 16 bits per component, but only 10 bits are used and 6 bits are padded * index 0: Y plane, [15:0] Y:x [10:6] little endian
@@ -842,6 +849,10 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)* and UV. Some SAND-using hardware stores UV in a separate tiled * image from Y to reduce the column height, which is not supported * with these modifiers. +* +* The DRM_FORMAT_MOD_BROADCOM_SAND128_COL_HEIGHT modifier is also +* supported for DRM_FORMAT_P030 where the columns remain as 128 bytes +* wide, but as this is a 10 bpp format that translates to 96 pixels. */ #define DRM_FORMAT_MOD_BROADCOM_SAND32_COL_HEIGHT (v) \
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 203/731 drm/fourcc: Fix vsub/hsub for Q410 and Q401
In reply to Greg Kroah-HartmanFrom: Brian Starkey <[email protected]>
[ Upstream commit b230555f3257f197dd98641ef6ebaf778b52dd51 ]
These formats are not subsampled, but that means hsub and vsub should be 1, not 0.
--- drivers/gpu/drm/drm_fourcc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_fourcc.c +4 -4
@@ -260,12 +260,12 @@ const struct drm_format_info *__drm_format_info(u32 format) .vsub = 2, .is_yuv = true }, { .format = DRM_FORMAT_Q410, .depth = 0, .num_planes = 3, .char_per_block = { 2, 2, 2 }, - .block_w = { 1, 1, 1 }, .block_h = { 1, 1, 1 }, .hsub = 0, - .vsub = 0, .is_yuv = true }, + .block_w = { 1, 1, 1 }, .block_h = { 1, 1, 1 }, .hsub = 1, + .vsub = 1, .is_yuv = true }, { .format = DRM_FORMAT_Q401, .depth = 0, .num_planes = 3, .char_per_block = { 2, 2, 2 }, - .block_w = { 1, 1, 1 }, .block_h = { 1, 1, 1 }, .hsub = 0, - .vsub = 0, .is_yuv = true }, + .block_w = { 1, 1, 1 }, .block_h = { 1, 1, 1 }, .hsub = 1, + .vsub = 1, .is_yuv = true }, { .format = DRM_FORMAT_P030, .depth = 0, .num_planes = 2, .char_per_block = { 4, 8, 0 }, .block_w = { 3, 3, 0 }, .block_h = { 1, 1, 0 }, .hsub = 2, .vsub = 2, .is_yuv = true},
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 204/731 integrity: Fix memory leakage in keyring allocation error path
In reply to Greg Kroah-HartmanFrom: GUO Zihua <[email protected]>
[ Upstream commit 39419ef7af0916cc3620ecf1ed42d29659109bf3 ]
Key restriction is allocated in integrity_init_keyring(). However, if keyring allocation failed, it is not freed, causing memory leaks.
--- security/integrity/digsig.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
security/integrity/digsig.c +5 -1
@@ -122,6 +122,7 @@ int __init integrity_init_keyring(const unsigned int id) {struct key_restriction *restriction;key_perm_t perm; +int ret; perm = (KEY_POS_ALL & ~KEY_POS_SETATTR ) |KEY_USR_VIEW |KEY_USR_READ |KEY_USR_SEARCH ;
@@ -142,7 +143,10 @@ int __init integrity_init_keyring(const unsigned int id) perm |=KEY_USR_WRITE ; out: -return __integrity_init_keyring (id, perm, restriction); + ret =__integrity_init_keyring (id, perm, restriction); +if (ret) +kfree (restriction); +return ret; } static int __init integrity_add_key(const unsigned int id, const void *data,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 205/731 ima: Fix misuse of dereference of pointer in template_desc_init_fields()
In reply to Greg Kroah-HartmanFrom: Xiu Jianfeng <[email protected]>
[ Upstream commit 25369175ce84813dd99d6604e710dc2491f68523 ]
The input parameter @fields is type of struct ima_template_field ***, so when allocates array memory for @fields, the size of element should be sizeof(**field) instead of sizeof(*field).
Actually the original code would not cause any runtime error, but it's better to make it logically right.
--- security/integrity/ima/ima_template.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
security/integrity/ima/ima_template.c +2 -2
@@ -241,11 +241,11 @@ int template_desc_init_fields(const char *template_fmt, }if (fields && num_fields) { - *fields =kmalloc_array (i,sizeof (*fields),GFP_KERNEL ); + *fields =kmalloc_array (i,sizeof (**fields),GFP_KERNEL );if (*fields ==NULL )return -ENOMEM ; -memcpy (*fields, found_fields, i *sizeof (*fields)); +memcpy (*fields, found_fields, i *sizeof (**fields)); *num_fields = i; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 206/731 block: clear ->slave_dir when dropping the main slave_dir reference
In reply to Greg Kroah-HartmanFrom: Christoph Hellwig <[email protected]>
[ Upstream commit d90db3b1c8676bc88b4309c5a571333de2263b8e ]
Zero out the pointer to ->slave_dir so that the holder code doesn't incorrectly treat the object as alive when add_disk failed or after del_gendisk was called.
--- block/genhd.c | 2 ++ 1 file changed, 2 insertions(+)
block/genhd.c +2 -0
@@ -530,6 +530,7 @@ int device_add_disk(struct device *parent, struct gendisk *disk,rq_qos_exit (disk->queue); out_put_slave_dir:kobject_put (disk->slave_dir); + disk->slave_dir =NULL ; out_put_holder_dir:kobject_put (disk->part0->bd_holder_dir); out_del_integrity:
@@ -624,6 +625,7 @@ void del_gendisk(struct gendisk *disk)kobject_put (disk->part0->bd_holder_dir);kobject_put (disk->slave_dir); + disk->slave_dir =NULL ;part_stat_set_all (disk->part0,0 ); disk->part0->bd_stamp =0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 207/731 wifi: ath10k: Fix return value in ath10k_pci_init()
In reply to Greg Kroah-HartmanFrom: Xiu Jianfeng <[email protected]>
[ Upstream commit 2af7749047d8d6ad43feff69f555a13a6a6c2831 ]
This driver is attempting to register to support two different buses. if either of these is successful then ath10k_pci_init() should return 0 so that hardware attached to the successful bus can be probed and supported. only if both of these are unsuccessful should ath10k_pci_init() return an errno.
--- drivers/net/wireless/ath/ath10k/pci.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/net/wireless/ath/ath10k/pci.c +12 -8
@@ -3793,18 +3793,22 @@ static struct pci_driver ath10k_pci_driver = {static int __init ath10k_pci_init (void ) { -int ret; +int ret1, ret2; - ret =pci_register_driver (&ath10k_pci_driver); -if (ret) + ret1 =pci_register_driver (&ath10k_pci_driver); +if (ret1)printk (KERN_ERR "failed to register ath10k pci driver: %d\n" , - ret); + ret1); - ret =ath10k_ahb_init (); -if (ret) -printk (KERN_ERR "ahb init failed: %d\n" , ret); + ret2 =ath10k_ahb_init (); +if (ret2) +printk (KERN_ERR "ahb init failed: %d\n" , ret2); -return ret; +if (ret1 && ret2) +return ret1; + +/* registered to at least one bus */ +return 0 ; }module_init (ath10k_pci_init);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 208/731 drm/msm/a6xx: Fix speed-bin detection vs probe-defer
In reply to Greg Kroah-HartmanFrom: Rob Clark <[email protected]>
[ Upstream commit f6d1918794ef92b4e26b80c3d40365347b76b1fd ]
If we get an error (other than -ENOENT) we need to propagate that up the stack. Otherwise if the nvmem driver hasn't probed yet, we'll end up end up claiming that we support all the OPPs which is not likely to be true (and on some generations impossible to be true, ie. if there are conflicting OPPs).
v2: Update commit msg, gc unused label, etc
v3: Add previously missing \n's
Patchwork: https://patchwork.freedesktop.org/patch/511690/
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +5 -7
@@ -1746,7 +1746,7 @@ static u32 fuse_to_supp_hw(struct device *dev, struct adreno_rev rev, u32 fuse)if (val ==UINT_MAX ) {DRM_DEV_ERROR (dev, -"missing support for speed-bin: %u. Some OPPs may not be supported by hardware" , +"missing support for speed-bin: %u. Some OPPs may not be supported by hardware\n" , fuse);return UINT_MAX ; }
@@ -1756,7 +1756,7 @@ static u32 fuse_to_supp_hw(struct device *dev, struct adreno_rev rev, u32 fuse)static int a6xx_set_supported_hw (struct device *dev,struct adreno_rev rev) { -u32 supp_hw =UINT_MAX ; +u32 supp_hw;u32 speedbin;int ret;
@@ -1768,15 +1768,13 @@ static int a6xx_set_supported_hw(struct device *dev, struct adreno_rev rev)if (ret == -ENOENT ) {return 0 ; }else if (ret) { -DRM_DEV_ERROR (dev, -"failed to read speed-bin (%d). Some OPPs may not be supported by hardware" , - ret); - goto done; +dev_err_probe (dev, ret, +"failed to read speed-bin. Some OPPs may not be supported by hardware\n" ); +return ret; } supp_hw =fuse_to_supp_hw (dev, rev, speedbin); -done: ret =devm_pm_opp_set_supported_hw (dev, &supp_hw,1 );if (ret)return ret;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 209/731 mtd: lpddr2_nvm: Fix possible null-ptr-deref
In reply to Greg Kroah-HartmanFrom: Hui Tang <[email protected]>
[ Upstream commit 6bdd45d795adf9e73b38ced5e7f750cd199499ff ]
It will cause null-ptr-deref when resource_size(add_range) invoked, if platform_get_resource() returns NULL.
--- drivers/mtd/lpddr/lpddr2_nvm.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mtd/lpddr/lpddr2_nvm.c +2 -0
@@ -433,6 +433,8 @@ static int lpddr2_nvm_probe(struct platform_device *pdev)/* lpddr2_nvm address range */ add_range =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!add_range) +return -ENODEV ;/* Populate map_info data structure */ *map = (struct map_info ) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 210/731 Input: elants_i2c - properly handle the reset GPIO when power is off
In reply to Greg Kroah-HartmanFrom: Douglas Anderson <[email protected]>
[ Upstream commit a85fbd6498441694475716a4d5c65f9d3e073faf ]
As can be seen in elants_i2c_power_off(), we want the reset GPIO asserted when power is off. The reset GPIO is active low so we need the reset line logic low when power is off to avoid leakage.
We have a problem, though, at probe time. At probe time we haven't powered the regulators on yet but we have:
devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_LOW);
While that _looks_ right, it turns out that it's not. The GPIOD_OUT_LOW doesn't mean to init the GPIO to low. It means init the GPIO to "not asserted". Since this is an active low GPIO that inits it to be high.
Let's fix this to properly init the GPIO. Now after both probe and power off the state of the GPIO is consistent (it's "asserted" or level low).
Once we fix this, we can see that at power on time we no longer to assert the reset GPIO as the first thing. The reset GPIO is _always_ asserted before powering on. Let's fix powering on to account for this.
--- drivers/input/touchscreen/elants_i2c.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/input/touchscreen/elants_i2c.c +3 -6
@@ -1329,14 +1329,12 @@ static int elants_i2c_power_on(struct elants_data *ts)if (IS_ERR_OR_NULL (ts->reset_gpio))return 0 ; -gpiod_set_value_cansleep (ts->reset_gpio,1 ); - error =regulator_enable (ts->vcc33);if (error) {dev_err (&ts->client->dev,"failed to enable vcc33 regulator: %d\n" , error); - goto release_reset_gpio; +return error; } error =regulator_enable (ts->vccio);
@@ -1345,7 +1343,7 @@ static int elants_i2c_power_on(struct elants_data *ts)"failed to enable vccio regulator: %d\n" , error);regulator_disable (ts->vcc33); - goto release_reset_gpio; +return error; }/*
@@ -1354,7 +1352,6 @@ static int elants_i2c_power_on(struct elants_data *ts)*/ udelay (ELAN_POWERON_DELAY_USEC ); -release_reset_gpio:gpiod_set_value_cansleep (ts->reset_gpio,0 );if (error)return error;
@@ -1462,7 +1459,7 @@ static int elants_i2c_probe(struct i2c_client *client)return error; } - ts->reset_gpio =devm_gpiod_get (&client->dev,"reset" ,GPIOD_OUT_LOW ); + ts->reset_gpio =devm_gpiod_get (&client->dev,"reset" ,GPIOD_OUT_HIGH );if (IS_ERR (ts->reset_gpio)) { error =PTR_ERR (ts->reset_gpio);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 211/731 media: vidtv: Fix use-after-free in vidtv_bridge_dvb_init()
In reply to Greg Kroah-HartmanFrom: Chen Zhongjin <[email protected]>
[ Upstream commit ba8d9405935097e296bcf7a942c3a01df0edb865 ]
KASAN reports a use-after-free:
BUG: KASAN: use-after-free in dvb_dmxdev_release+0x4d5/0x5d0 [dvb_core] Call Trace: ... dvb_dmxdev_release+0x4d5/0x5d0 [dvb_core] vidtv_bridge_probe+0x7bf/0xa40 [dvb_vidtv_bridge] platform_probe+0xb6/0x170 ... Allocated by task 1238: ... dvb_register_device+0x1a7/0xa70 [dvb_core] dvb_dmxdev_init+0x2af/0x4a0 [dvb_core] vidtv_bridge_probe+0x766/0xa40 [dvb_vidtv_bridge] ... Freed by task 1238: dvb_register_device+0x6d2/0xa70 [dvb_core] dvb_dmxdev_init+0x2af/0x4a0 [dvb_core] vidtv_bridge_probe+0x766/0xa40 [dvb_vidtv_bridge] ...
It is because the error handling in vidtv_bridge_dvb_init() is wrong.
First, vidtv_bridge_dmx(dev)_init() will clean themselves when fail, but goto fail_dmx(_dev): calls release functions again, which causes use-after-free.
Also, in fail_fe, fail_tuner_probe and fail_demod_probe, j = i will cause out-of-bound when i finished its loop (i == NUM_FE). And the loop releasing is wrong, although now NUM_FE is 1 so it won't cause problem.
Fix this by correctly releasing everything.
--- .../media/test-drivers/vidtv/vidtv_bridge.c | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-)
drivers/media/test-drivers/vidtv/vidtv_bridge.c +8 -14
@@ -459,26 +459,20 @@ static int vidtv_bridge_dvb_init(struct vidtv_dvb *dvb)for (j = j -1 ; j >=0 ; --j) dvb->demux.dmx.remove_frontend (&dvb->demux.dmx, &dvb->dmx_fe[j]); -fail_dmx_dev:dvb_dmxdev_release (&dvb->dmx_dev); -fail_dmx: +fail_dmx_dev:dvb_dmx_release (&dvb->demux); +fail_dmx: +fail_demod_probe: +for (i = i -1 ; i >=0 ; --i) { +dvb_unregister_frontend (dvb->fe[i]); fail_fe: -for (j = i; j >=0 ; --j) -dvb_unregister_frontend (dvb->fe[j]); +dvb_module_release (dvb->i2c_client_tuner[i]); fail_tuner_probe: -for (j = i; j >=0 ; --j) -if (dvb->i2c_client_tuner[j]) -dvb_module_release (dvb->i2c_client_tuner[j]); - -fail_demod_probe: -for (j = i; j >=0 ; --j) -if (dvb->i2c_client_demod[j]) -dvb_module_release (dvb->i2c_client_demod[j]); - +dvb_module_release (dvb->i2c_client_demod[i]); + } fail_adapter:dvb_unregister_adapter (&dvb->adapter); - fail_i2c:i2c_del_adapter (&dvb->i2c_adapter);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 212/731 media: solo6x10: fix possible memory leak in solo_sysfs_init()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 7f5866dd96d95b74e439f6ee17b8abd8195179fb ]
If device_register() returns error in solo_sysfs_init(), the name allocated by dev_set_name() need be freed. As comment of device_register() says, it should use put_device() to give up the reference in the error path. So fix this by calling put_device(), then the name can be freed in kobject_cleanup().
--- drivers/media/pci/solo6x10/solo6x10-core.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/pci/solo6x10/solo6x10-core.c +1 -0
@@ -420,6 +420,7 @@ static int solo_sysfs_init(struct solo_dev *solo_dev) solo_dev->nr_chans);if (device_register (dev)) { +put_device (dev); dev->parent =NULL ;return -ENOMEM ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 213/731 media: platform: exynos4-is: Fix error handling in fimc_md_init()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit b434422c45282a0573d8123239abc41fa72665d4 ]
A problem about modprobe s5p_fimc failed is triggered with the following log given:
[ 272.075275] Error: Driver 'exynos4-fimc' is already registered, aborting... modprobe: ERROR: could not insert 's5p_fimc': Device or resource busy
The reason is that fimc_md_init() returns platform_driver_register() directly without checking its return value, if platform_driver_register() failed, it returns without unregister fimc_driver, resulting the s5p_fimc can never be installed later.
A simple call graph is shown as below:
fimc_md_init()
fimc_register_driver() # register fimc_driver
platform_driver_register()
platform_driver_register()
driver_register()
bus_add_driver()
dev = kzalloc(...) # OOM happened
# return without unregister fimc_driver
Fix by unregister fimc_driver when platform_driver_register() returns error.
--- drivers/media/platform/exynos4-is/fimc-core.c | 2 +- drivers/media/platform/exynos4-is/media-dev.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/media/platform/exynos4-is/fimc-core.c +1 -1
@@ -1174,7 +1174,7 @@ int __init fimc_register_driver(void)return platform_driver_register (&fimc_driver); } -void __exit fimc_unregister_driver(void) +void fimc_unregister_driver (void ) {platform_driver_unregister (&fimc_driver); }
drivers/media/platform/exynos4-is/media-dev.c +5 -1
@@ -1584,7 +1584,11 @@ static int __init fimc_md_init(void)if (ret)return ret; -return platform_driver_register (&fimc_md_driver); + ret =platform_driver_register (&fimc_md_driver); +if (ret) +fimc_unregister_driver (); + +return ret; } static void __exit fimc_md_exit(void)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 214/731 media: videobuf-dma-contig: use dma_mmap_coherent
In reply to Greg Kroah-HartmanFrom: Christoph Hellwig <[email protected]>
[ Upstream commit b3dc3f8e49577840dc8ac8a365c5b3da4edb10b8 ]
dma_alloc_coherent does not return a physical address, but a DMA address, which might be remapped or have an offset. Passing the DMA address to vm_iomap_memory is thus broken.
Use the proper dma_mmap_coherent helper instead, and stop passing __GFP_COMP to dma_alloc_coherent, as the memory management inside the DMA allocator is hidden from the callers and does not require it.
With this the gfp_t argument to __videobuf_dc_alloc can be removed and hard coded to GFP_KERNEL.
--- drivers/media/v4l2-core/videobuf-dma-contig.c | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-)
drivers/media/v4l2-core/videobuf-dma-contig.c +8 -14
@@ -36,12 +36,11 @@ struct videobuf_dma_contig_memory {static int __videobuf_dc_alloc (struct device *dev,struct videobuf_dma_contig_memory *mem, -unsigned long size,gfp_t flags) +unsigned long size) { mem->size = size; - mem->vaddr =dma_alloc_coherent (dev, mem->size, - &mem->dma_handle, flags); - + mem->vaddr =dma_alloc_coherent (dev, mem->size, &mem->dma_handle, +GFP_KERNEL );if (!mem->vaddr) {dev_err (dev,"memory alloc size %ld failed\n" , mem->size);return -ENOMEM ;
@@ -258,8 +257,7 @@ static int __videobuf_iolock(struct videobuf_queue *q,return videobuf_dma_contig_user_get (mem, vb);/* allocate memory for the read() method */ -if (__videobuf_dc_alloc (q->dev, mem,PAGE_ALIGN (vb->size), -GFP_KERNEL )) +if (__videobuf_dc_alloc (q->dev, mem,PAGE_ALIGN (vb->size)))return -ENOMEM ;break ;case V4L2_MEMORY_OVERLAY :
@@ -295,22 +293,18 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q,BUG_ON (!mem);MAGIC_CHECK (mem->magic,MAGIC_DC_MEM ); -if (__videobuf_dc_alloc (q->dev, mem,PAGE_ALIGN (buf->bsize), -GFP_KERNEL | __GFP_COMP)) +if (__videobuf_dc_alloc (q->dev, mem,PAGE_ALIGN (buf->bsize))) goto error; -/* Try to remap memory */ - vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); -/* the "vm_pgoff" is just used in v4l2 to find the * corresponding buffer data structure which is allocated * earlier and it does not mean the offset from the physical * buffer start address as usual. So set it to 0 to pass -* the sanity check in vm_iomap_memory(). +* the sanity check in dma_mmap_coherent(). */ vma->vm_pgoff =0 ; - - retval =vm_iomap_memory (vma, mem->dma_handle, mem->size); + retval =dma_mmap_coherent (q->dev, vma, mem->vaddr, mem->dma_handle, + mem->size);if (retval) {dev_err (q->dev,"mmap: remap failed with error %d. " , retval);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 215/731 inet: add READ_ONCE(sk->sk_bound_dev_if) in inet_csk_bind_conflict()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit d2c135619cb89d1d5693df81ab408c5e8e97e898 ]
inet_csk_bind_conflict() can access sk->sk_bound_dev_if for unlocked sockets.
--- net/ipv4/inet_connection_sock.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
net/ipv4/inet_connection_sock.c +8 -4
@@ -155,10 +155,14 @@ static int inet_csk_bind_conflict(const struct sock *sk,*/ sk_for_each_bound (sk2, &tb->owners) { -if (sk != sk2 && - (!sk->sk_bound_dev_if || - !sk2->sk_bound_dev_if || - sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) { +int bound_dev_if2; + +if (sk == sk2) +continue ; + bound_dev_if2 =READ_ONCE (sk2->sk_bound_dev_if); +if ((!sk->sk_bound_dev_if || + !bound_dev_if2 || + sk->sk_bound_dev_if == bound_dev_if2)) {if (reuse && sk2->sk_reuse && sk2->sk_state !=TCP_LISTEN ) { if ((!relax ||
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 216/731 mtd: spi-nor: hide jedec_id sysfs attribute if not present
In reply to Greg Kroah-HartmanFrom: Michael Walle <[email protected]>
[ Upstream commit 7d388551b6888f3725e6c957f472526b35161a5b ]
Some non-jedec compliant flashes (like the Everspin flashes) don't have an ID at all. Hide the attribute in this case.
--- .../ABI/testing/sysfs-bus-spi-devices-spi-nor | 3 +++ drivers/mtd/spi-nor/sysfs.c | 14 ++++++++++++++ 2 files changed, 17 insertions(+)
Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor +3 -0
@@ -5,6 +5,9 @@ Contact: [email protected] Description: (RO) The JEDEC ID of the SPI NOR flash as reported by the flash device. + The attribute is not present if the flash doesn't support + the "Read JEDEC ID" command (9Fh). This is the case for + non-JEDEC compliant flashes. What: /sys/bus/spi/devices/.../spi-nor/manufacturer Date: April 2021
drivers/mtd/spi-nor/sysfs.c +14 -0
@@ -67,6 +67,19 @@ static struct bin_attribute *spi_nor_sysfs_bin_entries[] = { NULL }; +static umode_t spi_nor_sysfs_is_visible (struct kobject *kobj, +struct attribute *attr,int n) +{ +struct spi_device *spi =to_spi_device (kobj_to_dev (kobj)); +struct spi_mem *spimem =spi_get_drvdata (spi); +struct spi_nor *nor =spi_mem_get_drvdata (spimem); + +if (attr == &dev_attr_jedec_id.attr && !nor->info->id_len) +return 0 ; + +return 0444 ; +} +static umode_t spi_nor_sysfs_is_bin_visible (struct kobject *kobj,struct bin_attribute *attr,int n) {
@@ -82,6 +95,7 @@ static umode_t spi_nor_sysfs_is_bin_visible(struct kobject *kobj,static const struct attribute_group spi_nor_sysfs_group = { .name ="spi-nor" , + .is_visible = spi_nor_sysfs_is_visible, .is_bin_visible = spi_nor_sysfs_is_bin_visible, .attrs = spi_nor_sysfs_entries, .bin_attrs = spi_nor_sysfs_bin_entries,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 217/731 mtd: spi-nor: Fix the number of bytes for the dummy cycles
In reply to Greg Kroah-HartmanFrom: Allen-KH Cheng <[email protected]>
[ Upstream commit fdc20370d93e8c6d2f448a539d08c2c064af7694 ]
The number of bytes used by spi_nor_spimem_check_readop() may be incorrect for the dummy cycles. Since nor->read_dummy is not initialized before spi_nor_spimem_adjust_hwcaps().
We use both mode and wait state clock cycles instead of nor->read_dummy.
--- drivers/mtd/spi-nor/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/core.c +2 -1
@@ -2155,7 +2155,8 @@ static int spi_nor_spimem_check_readop(struct spi_nor *nor,spi_nor_spimem_setup_op (nor, &op, read->proto);/* convert the dummy cycles to the number of bytes */ - op.dummy.nbytes = (nor->read_dummy * op.dummy.buswidth) /8 ; + op.dummy.nbytes = (read->num_mode_clocks + read->num_wait_states) * + op.dummy.buswidth /8 ;if (spi_nor_protocol_is_dtr (nor->read_proto)) op.dummy.nbytes *=2 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 218/731 bpf: Move skb->len == 0 checks into __bpf_redirect
In reply to Greg Kroah-HartmanFrom: Stanislav Fomichev <[email protected]>
[ Upstream commit 114039b342014680911c35bd6b72624180fd669a ]
To avoid potentially breaking existing users.
Both mac/no-mac cases have to be amended; mac_header >= network_header is not enough (verified with a new test, see next patch).
--- net/bpf/test_run.c | 3 --- net/core/filter.c | 7 ++++++- 2 files changed, 6 insertions(+), 4 deletions(-)
net/bpf/test_run.c +0 -3
@@ -470,9 +470,6 @@ static int convert___skb_to_skb(struct sk_buff *skb, struct __sk_buff *__skb) {struct qdisc_skb_cb *cb = (struct qdisc_skb_cb *)skb->cb; -if (!skb->len) -return -EINVAL ; -if (!__skb)return 0 ;
net/core/filter.c +6 -1
@@ -2123,6 +2123,11 @@ static int __bpf_redirect_no_mac(struct sk_buff *skb, struct net_device *dev, {unsigned int mlen =skb_network_offset (skb); +if (unlikely (skb->len <= mlen)) { +kfree_skb (skb); +return -ERANGE ; + } +if (mlen) {__skb_pull (skb, mlen);
@@ -2144,7 +2149,7 @@ static int __bpf_redirect_common(struct sk_buff *skb, struct net_device *dev, u32 flags) {/* Verify that a link layer header is carried */ -if (unlikely (skb->mac_header >= skb->network_header)) { +if (unlikely (skb->mac_header >= skb->network_header || skb->len ==0 )) {kfree_skb (skb);return -ERANGE ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 219/731 HID: hid-sensor-custom: set fixed size for custom attributes
In reply to Greg Kroah-HartmanFrom: Marcus Folkesson <[email protected]>
[ Upstream commit 9d013910df22de91333a0acc81d1dbb115bd76f6 ]
This is no bugfix (so no Fixes: tag is necessary) as it is taken care of in hid_sensor_custom_add_attributes().
The motivation for this patch is that:
hid_sensor_custom_field.attr_name and hid_sensor_custom_field.attrs
has the size of HID_CUSTOM_TOTAL_ATTRS and used in same context.
We compare against HID_CUSTOM_TOTAL_ATTRS when
looping through hid_custom_attrs.
We will silent the smatch error:hid_sensor_custom_add_attributes() error: buffer overflow 'hid_custom_attrs' 8 <= 10
--- drivers/hid/hid-sensor-custom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-sensor-custom.c +1 -1
@@ -62,7 +62,7 @@ struct hid_sensor_sample {u32 raw_len; } __packed; -static struct attribute hid_custom_attrs[] = { +static struct attribute hid_custom_attrs[HID_CUSTOM_TOTAL_ATTRS ] = { {.name ="name" , .mode =S_IRUGO }, {.name ="units" , .mode =S_IRUGO }, {.name ="unit-expo" , .mode =S_IRUGO },
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 220/731 pinctrl: k210: call of_node_put()
In reply to Greg Kroah-HartmanFrom: ZhangPeng <[email protected]>
[ Upstream commit a8acc11643082a706de86a19f1f824712d971984 ]
Since for_each_available_child_of_node() will increase the refcount of node, we need to call of_node_put() manually when breaking out of the iteration.
--- drivers/pinctrl/pinctrl-k210.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pinctrl/pinctrl-k210.c +3 -1
@@ -862,8 +862,10 @@ static int k210_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,for_each_available_child_of_node (np_config, np) { ret =k210_pinctrl_dt_subnode_to_map (pctldev, np, map, &reserved_maps, num_maps); -if (ret <0 ) +if (ret <0 ) { +of_node_put (np); goto err; + } }return 0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 221/731 ALSA: pcm: fix undefined behavior in bit shift for SNDRV_PCM_RATE_KNOT
In reply to Greg Kroah-HartmanFrom: Baisong Zhong <[email protected]>
[ Upstream commit b5172e62458f8e6ff359e5f096044a488db90ac5 ]
Shifting signed 32-bit value by 31 bits is undefined, so changing significant bit to unsigned. The UBSAN warning calltrace like below:
UBSAN: shift-out-of-bounds in sound/core/pcm_native.c:2676:21 left shift of 1 by 31 places cannot be represented in type 'int' ... Call Trace: <TASK> dump_stack_lvl+0x8d/0xcf ubsan_epilogue+0xa/0x44 __ubsan_handle_shift_out_of_bounds+0x1e7/0x208 snd_pcm_open_substream+0x9f0/0xa90 snd_pcm_oss_open.part.26+0x313/0x670 snd_pcm_oss_open+0x30/0x40 soundcore_open+0x18b/0x2e0 chrdev_open+0xe2/0x270 do_dentry_open+0x2f7/0x620 path_openat+0xd66/0xe70 do_filp_open+0xe3/0x170 do_sys_openat2+0x357/0x4a0 do_sys_open+0x87/0xd0 do_syscall_64+0x34/0x80
--- include/sound/pcm.h | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)
include/sound/pcm.h +18 -18
@@ -106,24 +106,24 @@ struct snd_pcm_ops {#define SNDRV_PCM_POS_XRUN ((snd_pcm_uframes_t)-1)/* If you change this don't forget to change rates[] table in pcm_native.c */ -#define SNDRV_PCM_RATE_5512 (1<<0)/* 5512Hz */ -#define SNDRV_PCM_RATE_8000 (1<<1)/* 8000Hz */ -#define SNDRV_PCM_RATE_11025 (1<<2)/* 11025Hz */ -#define SNDRV_PCM_RATE_16000 (1<<3)/* 16000Hz */ -#define SNDRV_PCM_RATE_22050 (1<<4)/* 22050Hz */ -#define SNDRV_PCM_RATE_32000 (1<<5)/* 32000Hz */ -#define SNDRV_PCM_RATE_44100 (1<<6)/* 44100Hz */ -#define SNDRV_PCM_RATE_48000 (1<<7)/* 48000Hz */ -#define SNDRV_PCM_RATE_64000 (1<<8)/* 64000Hz */ -#define SNDRV_PCM_RATE_88200 (1<<9)/* 88200Hz */ -#define SNDRV_PCM_RATE_96000 (1<<10)/* 96000Hz */ -#define SNDRV_PCM_RATE_176400 (1<<11)/* 176400Hz */ -#define SNDRV_PCM_RATE_192000 (1<<12)/* 192000Hz */ -#define SNDRV_PCM_RATE_352800 (1<<13)/* 352800Hz */ -#define SNDRV_PCM_RATE_384000 (1<<14)/* 384000Hz */ - -#define SNDRV_PCM_RATE_CONTINUOUS (1<<30)/* continuous range */ -#define SNDRV_PCM_RATE_KNOT (1<<31)/* supports more non-continuos rates */ +#define SNDRV_PCM_RATE_5512 (1U<<0)/* 5512Hz */ +#define SNDRV_PCM_RATE_8000 (1U<<1)/* 8000Hz */ +#define SNDRV_PCM_RATE_11025 (1U<<2)/* 11025Hz */ +#define SNDRV_PCM_RATE_16000 (1U<<3)/* 16000Hz */ +#define SNDRV_PCM_RATE_22050 (1U<<4)/* 22050Hz */ +#define SNDRV_PCM_RATE_32000 (1U<<5)/* 32000Hz */ +#define SNDRV_PCM_RATE_44100 (1U<<6)/* 44100Hz */ +#define SNDRV_PCM_RATE_48000 (1U<<7)/* 48000Hz */ +#define SNDRV_PCM_RATE_64000 (1U<<8)/* 64000Hz */ +#define SNDRV_PCM_RATE_88200 (1U<<9)/* 88200Hz */ +#define SNDRV_PCM_RATE_96000 (1U<<10)/* 96000Hz */ +#define SNDRV_PCM_RATE_176400 (1U<<11)/* 176400Hz */ +#define SNDRV_PCM_RATE_192000 (1U<<12)/* 192000Hz */ +#define SNDRV_PCM_RATE_352800 (1U<<13)/* 352800Hz */ +#define SNDRV_PCM_RATE_384000 (1U<<14)/* 384000Hz */ + +#define SNDRV_PCM_RATE_CONTINUOUS (1U<<30)/* continuous range */ +#define SNDRV_PCM_RATE_KNOT (1U<<31)/* supports more non-continuos rates */ #define SNDRV_PCM_RATE_8000_44100 (SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_11025|\ SNDRV_PCM_RATE_16000|SNDRV_PCM_RATE_22050|\
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 222/731 ALSA: seq: fix undefined behavior in bit shift for SNDRV_SEQ_FILTER_USE_EVENT
In reply to Greg Kroah-HartmanFrom: Baisong Zhong <[email protected]>
[ Upstream commit cf59e1e4c79bf741905484cdb13c130b53576a16 ]
Shifting signed 32-bit value by 31 bits is undefined, so changing significant bit to unsigned. The UBSAN warning calltrace like below:
UBSAN: shift-out-of-bounds in sound/core/seq/seq_clientmgr.c:509:22 left shift of 1 by 31 places cannot be represented in type 'int' ... Call Trace: <TASK> dump_stack_lvl+0x8d/0xcf ubsan_epilogue+0xa/0x44 __ubsan_handle_shift_out_of_bounds+0x1e7/0x208 snd_seq_deliver_single_event.constprop.21+0x191/0x2f0 snd_seq_deliver_event+0x1a2/0x350 snd_seq_kernel_client_dispatch+0x8b/0xb0 snd_seq_client_notify_subscription+0x72/0xa0 snd_seq_ioctl_subscribe_port+0x128/0x160 snd_seq_kernel_client_ctl+0xce/0xf0 snd_seq_oss_create_client+0x109/0x15b alsa_seq_oss_init+0x11c/0x1aa do_one_initcall+0x80/0x440 kernel_init_freeable+0x370/0x3c3 kernel_init+0x1b/0x190 ret_from_fork+0x1f/0x30 </TASK>
--- include/uapi/sound/asequencer.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
include/uapi/sound/asequencer.h +4 -4
@@ -344,10 +344,10 @@ typedef int __bitwise snd_seq_client_type_t;#define KERNEL_CLIENT ((__force snd_seq_client_type_t) 2)/* event filter flags */ -#define SNDRV_SEQ_FILTER_BROADCAST (1<<0)/* accept broadcast messages */ -#define SNDRV_SEQ_FILTER_MULTICAST (1<<1)/* accept multicast messages */ -#define SNDRV_SEQ_FILTER_BOUNCE (1<<2)/* accept bounce event in error */ -#define SNDRV_SEQ_FILTER_USE_EVENT (1<<31)/* use event filter */ +#define SNDRV_SEQ_FILTER_BROADCAST (1U<<0)/* accept broadcast messages */ +#define SNDRV_SEQ_FILTER_MULTICAST (1U<<1)/* accept multicast messages */ +#define SNDRV_SEQ_FILTER_BOUNCE (1U<<2)/* accept bounce event in error */ +#define SNDRV_SEQ_FILTER_USE_EVENT (1U<<31)/* use event filter */ struct snd_seq_client_info {int client;/* client number to inquire */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 223/731 regulator: core: use kfree_const() to free space conditionally
In reply to Greg Kroah-HartmanFrom: Wang ShaoBo <[email protected]>
[ Upstream commit dc8d006d15b623c1d80b90b45d6dcb6e890dad09 ]
Use kfree_const() to free supply_name conditionally in create_regulator() as supply_name may be allocated from kmalloc() or directly from .rodata section.
--- drivers/regulator/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/core.c +1 -1
@@ -1750,7 +1750,7 @@ static struct regulator *create_regulator(struct regulator_dev *rdev, regulator =kzalloc (sizeof (*regulator),GFP_KERNEL );if (regulator ==NULL ) { -kfree (supply_name); +kfree_const (supply_name);return NULL ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 224/731 clk: rockchip: Fix memory leak in rockchip_clk_register_pll()
In reply to Greg Kroah-HartmanFrom: Xiu Jianfeng <[email protected]>
[ Upstream commit 739a6a6bbdb793bd57938cb24aa5a6df89983546 ]
If clk_register() fails, @pll->rate_table may have allocated memory by kmemdup(), so it needs to be freed, otherwise will cause memory leak issue, this patch fixes it.
--- drivers/clk/rockchip/clk-pll.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/rockchip/clk-pll.c +1 -0
@@ -981,6 +981,7 @@ struct clk *rockchip_clk_register_pll(struct rockchip_clk_provider *ctx,return mux_clk; err_pll: +kfree (pll->rate_table);clk_unregister (mux_clk); mux_clk = pll_clk; err_mux:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 225/731 drm/amdgpu: fix pci device refcount leak
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit b85e285e3d6352b02947fc1b72303673dfacb0aa ]
As comment of pci_get_domain_bus_and_slot() says, it returns a pci device with refcount increment, when finish using it, the caller must decrement the reference count by calling pci_dev_put().
So before returning from amdgpu_device_resume|suspend_display_audio(), pci_dev_put() is called to avoid refcount leak.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -0
@@ -4902,6 +4902,8 @@ static void amdgpu_device_resume_display_audio(struct amdgpu_device *adev)pm_runtime_enable (&(p->dev));pm_runtime_resume (&(p->dev)); } + +pci_dev_put (p); }static int amdgpu_device_suspend_display_audio (struct amdgpu_device *adev)
@@ -4940,6 +4942,7 @@ static int amdgpu_device_suspend_display_audio(struct amdgpu_device *adev)if (expires <ktime_get_mono_fast_ns ()) {dev_warn (adev->dev,"failed to suspend display audio\n" ); +pci_dev_put (p);/* TODO: abort the succeeding gpu reset? */ return -ETIMEDOUT ; }
@@ -4947,6 +4950,7 @@ static int amdgpu_device_suspend_display_audio(struct amdgpu_device *adev)pm_runtime_disable (&(p->dev)); +pci_dev_put (p);return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 226/731 bonding: fix link recovery in mode 2 when updelay is nonzero
In reply to Greg Kroah-HartmanFrom: Jonathan Toppins <[email protected]>
[ Upstream commit f8a65ab2f3ff7410921ebbf0dc55453102c33c56 ]
Before this change when a bond in mode 2 lost link, all of its slaves lost link, the bonding device would never recover even after the expiration of updelay. This change removes the updelay when the bond currently has no usable links. Conforming to bonding.txt section 13.1 paragraph 4.
--- drivers/net/bonding/bond_main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/net/bonding/bond_main.c +10 -1
@@ -2504,7 +2504,16 @@ static int bond_miimon_inspect(struct bonding *bond)struct slave *slave;bool ignore_updelay; - ignore_updelay = !rcu_dereference (bond->curr_active_slave); +if (BOND_MODE (bond) ==BOND_MODE_ACTIVEBACKUP ) { + ignore_updelay = !rcu_dereference (bond->curr_active_slave); + }else { +struct bond_up_slave *usable_slaves; + + usable_slaves =rcu_dereference (bond->usable_slaves); + +if (usable_slaves && usable_slaves->count ==0 ) + ignore_updelay = true; + }bond_for_each_slave_rcu (bond, slave, iter) {bond_propose_link_state (slave,BOND_LINK_NOCHANGE );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 227/731 mtd: maps: pxa2xx-flash: fix memory leak in probe
In reply to Greg Kroah-HartmanFrom: Zheng Yongjun <[email protected]>
[ Upstream commit 2399401feee27c639addc5b7e6ba519d3ca341bf ]
Free 'info' upon remapping error to avoid a memory leak.
--- drivers/mtd/maps/pxa2xx-flash.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mtd/maps/pxa2xx-flash.c +2 -0
@@ -66,6 +66,7 @@ static int pxa2xx_flash_probe(struct platform_device *pdev)if (!info->map.virt) {printk (KERN_WARNING "Failed to ioremap %s\n" , info->map.name); +kfree (info);return -ENOMEM ; } info->map.cached =ioremap_cache (info->map.phys, info->map.size);
@@ -87,6 +88,7 @@ static int pxa2xx_flash_probe(struct platform_device *pdev)iounmap ((void *)info->map.virt);if (info->map.cached)iounmap (info->map.cached); +kfree (info);return -EIO ; } info->mtd->dev.parent = &pdev->dev;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 228/731 drbd: remove call to memset before free device/resource/connection
In reply to Greg Kroah-HartmanFrom: Wang ShaoBo <[email protected]>
[ Upstream commit 6e7b854e4c1b02dba00760dfa79d8dbf6cce561e ]
This revert c2258ffc56f2 ("drbd: poison free'd device, resource and connection structs"), add memset is odd here for debugging, there are some methods to accurately show what happened, such as kdump.
Stable-dep-of: 8692814b77ca ("drbd: destroy workqueue when drbd device was freed")
--- drivers/block/drbd/drbd_main.c | 3 --- 1 file changed, 3 deletions(-)
drivers/block/drbd/drbd_main.c +0 -3
@@ -2244,7 +2244,6 @@ void drbd_destroy_device(struct kref *kref)kref_put (&peer_device->connection->kref, drbd_destroy_connection);kfree (peer_device); } -memset (device,0xfd ,sizeof (*device));kfree (device);kref_put (&resource->kref, drbd_destroy_resource); }
@@ -2336,7 +2335,6 @@ void drbd_destroy_resource(struct kref *kref)idr_destroy (&resource->devices);free_cpumask_var (resource->cpu_mask);kfree (resource->name); -memset (resource,0xf2 ,sizeof (*resource));kfree (resource); }
@@ -2677,7 +2675,6 @@ void drbd_destroy_connection(struct kref *kref)drbd_free_socket (&connection->data);kfree (connection->int_dig_in);kfree (connection->int_dig_vv); -memset (connection,0xfc ,sizeof (*connection));kfree (connection);kref_put (&resource->kref, drbd_destroy_resource); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 229/731 drbd: destroy workqueue when drbd device was freed
In reply to Greg Kroah-HartmanFrom: Wang ShaoBo <[email protected]>
[ Upstream commit 8692814b77ca4228a99da8a005de0acf40af6132 ]
A submitter workqueue is dynamically allocated by init_submitter() called by drbd_create_device(), we should destroy it when this device is not needed or destroyed.
--- drivers/block/drbd/drbd_main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/block/drbd/drbd_main.c +5 -1
@@ -2244,6 +2244,8 @@ void drbd_destroy_device(struct kref *kref)kref_put (&peer_device->connection->kref, drbd_destroy_connection);kfree (peer_device); } +if (device->submit.wq) +destroy_workqueue (device->submit.wq);kfree (device);kref_put (&resource->kref, drbd_destroy_resource); }
@@ -2797,7 +2799,7 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig err =add_disk (disk);if (err) - goto out_idr_remove_from_resource; + goto out_destroy_workqueue;/* inherit the connection state */ device->state.conn =first_connection (resource)->cstate;
@@ -2811,6 +2813,8 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsigdrbd_debugfs_device_add (device);return NO_ERROR ; +out_destroy_workqueue: +destroy_workqueue (device->submit.wq); out_idr_remove_from_resource:for_each_connection_safe (connection, n, resource) { peer_device =idr_remove (&connection->peer_devices, vnr);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 230/731 ASoC: qcom: Add checks for devm_kcalloc
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit 1bf5ee979076ceb121ee51c95197d890b1cee7f4 ]
As the devm_kcalloc may return NULL, the return value needs to be checked to avoid NULL poineter dereference.
--- sound/soc/qcom/lpass-sc7180.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/qcom/lpass-sc7180.c +3 -0
@@ -131,6 +131,9 @@ static int sc7180_lpass_init(struct platform_device *pdev) drvdata->clks =devm_kcalloc (dev, variant->num_clks,sizeof (*drvdata->clks),GFP_KERNEL ); +if (!drvdata->clks) +return -ENOMEM ; + drvdata->num_clks = variant->num_clks;for (i =0 ; i < drvdata->num_clks; i++)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 231/731 media: vimc: Fix wrong function called when vimc_init() fails
In reply to Greg Kroah-HartmanFrom: Chen Zhongjin <[email protected]>
[ Upstream commit f74d3f326d1d5b8951ce263c59a121ecfa65e7c0 ]
In vimc_init(), when platform_driver_register(&vimc_pdrv) fails, platform_driver_unregister(&vimc_pdrv) is wrongly called rather than platform_device_unregister(&vimc_pdev), which causes kernel warning:
Unexpected driver unregister!
WARNING: CPU: 1 PID: 14517 at drivers/base/driver.c:270 driver_unregister+0x8f/0xb0 RIP: 0010:driver_unregister+0x8f/0xb0 Call Trace: <TASK> vimc_init+0x7d/0x1000 [vimc] do_one_initcall+0xd0/0x4e0 do_init_module+0x1cf/0x6b0 load_module+0x65c2/0x7820
--- drivers/media/test-drivers/vimc/vimc-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/test-drivers/vimc/vimc-core.c +1 -1
@@ -357,7 +357,7 @@ static int __init vimc_init(void)if (ret) {dev_err (&vimc_pdev.dev,"platform driver registration failed (err=%d)\n" , ret); -platform_driver_unregister (&vimc_pdrv); +platform_device_unregister (&vimc_pdev);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 232/731 media: imon: fix a race condition in send_packet()
In reply to Greg Kroah-HartmanFrom: Gautam Menghani <[email protected]>
[ Upstream commit 813ceef062b53d68f296aa3cb944b21a091fabdb ]
The function send_packet() has a race condition as follows:
func send_packet()
{
// do work
call usb_submit_urb()
mutex_unlock()
wait_for_event_interruptible() <-- lock gone
mutex_lock()
}
func vfd_write()
{
mutex_lock()
call send_packet() <- prev call is not completed mutex_unlock()
}
When the mutex is unlocked and the function send_packet() waits for the call to complete, vfd_write() can start another call, which leads to the "URB submitted while active" warning in usb_submit_urb(). Fix this by removing the mutex_unlock() call in send_packet() and using mutex_lock_interruptible().
--- drivers/media/rc/imon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/rc/imon.c +3 -3
@@ -646,15 +646,14 @@ static int send_packet(struct imon_context *ictx)pr_err_ratelimited ("error submitting urb(%d)\n" , retval); }else {/* Wait for transmission to complete (or abort) */ -mutex_unlock (&ictx->lock); retval =wait_for_completion_interruptible ( &ictx->tx.finished);if (retval) {usb_kill_urb (ictx->tx_urb);pr_err_ratelimited ("task interrupted\n" ); } -mutex_lock (&ictx->lock); + ictx->tx.busy = false; retval = ictx->tx.status;if (retval)pr_err_ratelimited ("packet tx failed (%d)\n" , retval);
@@ -955,7 +954,8 @@ static ssize_t vfd_write(struct file *file, const char __user *buf,if (ictx->disconnected)return -ENODEV ; -mutex_lock (&ictx->lock); +if (mutex_lock_interruptible (&ictx->lock)) +return -ERESTARTSYS ;if (!ictx->dev_present_intf0) {pr_err_ratelimited ("no iMON device present\n" );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 233/731 clk: imx8mn: rename vpu_pll to m7_alt_pll
In reply to Greg Kroah-HartmanFrom: Dario Binacchi <[email protected]>
[ Upstream commit a429c60baefd95ab43a2ce7f25d5b2d7a2e431df ]
The IMX8MN platform does not have any video processing unit (VPU), and indeed in the reference manual (document IMX8MNRM Rev 2, 07/2022) there is no occurrence of its pll. From an analysis of the code and the RM itself, I think vpu pll is used instead of m7 alternate pll, probably for copy and paste of code taken from modules of similar architectures.
As an example for all, if we consider the second row of the "Clock Root" table of chapter 5 (Clocks and Power Management) of the RM:
Clock Root offset Source Select (CCM_TARGET_ROOTn[MUX])
... ... ...
ARM_M7_CLK_ROOT 0x8080 000 - 24M_REF_CLK
001 - SYSTEM_PLL2_DIV5
010 - SYSTEM_PLL2_DIV4
011 - M7_ALT_PLL_CLK
100 - SYSTEM_PLL1_CLK
101 - AUDIO_PLL1_CLK
110 - VIDEO_PLL_CLK
111 - SYSTEM_PLL3_CLK
... ... ...but in the source code, the imx8mn_m7_sels clocks list contains vpu_pll for the source select bits 011b.
So, let's rename "vpu_pll" to "m7_alt_pll" to be consistent with the RM.
The IMX8MN_VPU_* constants have not been removed to ensure backward compatibility of the patch.
No functional changes intended.
--- drivers/clk/imx/clk-imx8mn.c | 16 ++++++++-------- include/dt-bindings/clock/imx8mn-clock.h | 12 ++++++++---- 2 files changed, 16 insertions(+), 12 deletions(-)
drivers/clk/imx/clk-imx8mn.c +8 -8
@@ -30,7 +30,7 @@ static const char * const audio_pll2_bypass_sels[] = {"audio_pll2", "audio_pll2_static const char *const video_pll1_bypass_sels[] = {"video_pll1" ,"video_pll1_ref_sel" , };static const char *const dram_pll_bypass_sels[] = {"dram_pll" ,"dram_pll_ref_sel" , };static const char *const gpu_pll_bypass_sels[] = {"gpu_pll" ,"gpu_pll_ref_sel" , }; -static const char *const vpu_pll_bypass_sels[] = {"vpu_pll" ,"vpu_pll_ref_sel" , }; +static const char *const m7_alt_pll_bypass_sels[] = {"m7_alt_pll" ,"m7_alt_pll_ref_sel" , };static const char *const arm_pll_bypass_sels[] = {"arm_pll" ,"arm_pll_ref_sel" , };static const char *const sys_pll3_bypass_sels[] = {"sys_pll3" ,"sys_pll3_ref_sel" , };
@@ -40,7 +40,7 @@ static const char * const imx8mn_a53_sels[] = {"osc_24m", "arm_pll_out", "sys_plstatic const char *const imx8mn_a53_core_sels[] = {"arm_a53_div" ,"arm_pll_out" , }; -static const char *const imx8mn_m7_sels[] = {"osc_24m" ,"sys_pll2_200m" ,"sys_pll2_250m" ,"vpu_pll_out" , +static const char *const imx8mn_m7_sels[] = {"osc_24m" ,"sys_pll2_200m" ,"sys_pll2_250m" ,"m7_alt_pll_out" ,"sys_pll1_800m" ,"audio_pll1_out" ,"video_pll1_out" ,"sys_pll3_out" , };static const char *const imx8mn_gpu_core_sels[] = {"osc_24m" ,"gpu_pll_out" ,"sys_pll1_800m" ,
@@ -228,10 +228,10 @@ static const char * const imx8mn_pwm4_sels[] = {"osc_24m", "sys_pll2_100m", "sys "sys_pll1_80m", "video_pll1_out", };static const char *const imx8mn_wdog_sels[] = {"osc_24m" ,"sys_pll1_133m" ,"sys_pll1_160m" , -"vpu_pll_out" ,"sys_pll2_125m" ,"sys_pll3_out" , +"m7_alt_pll_out" ,"sys_pll2_125m" ,"sys_pll3_out" ,"sys_pll1_80m" ,"sys_pll2_166m" , }; -static const char *const imx8mn_wrclk_sels[] = {"osc_24m" ,"sys_pll1_40m" ,"vpu_pll_out" , +static const char *const imx8mn_wrclk_sels[] = {"osc_24m" ,"sys_pll1_40m" ,"m7_alt_pll_out" ,"sys_pll3_out" ,"sys_pll2_200m" ,"sys_pll1_266m" ,"sys_pll2_500m" ,"sys_pll1_100m" , };
@@ -328,7 +328,7 @@ static int imx8mn_clocks_probe(struct platform_device *pdev) hws[IMX8MN_VIDEO_PLL1_REF_SEL ] =imx_clk_hw_mux ("video_pll1_ref_sel" , base +0x28 ,0 ,2 , pll_ref_sels,ARRAY_SIZE (pll_ref_sels)); hws[IMX8MN_DRAM_PLL_REF_SEL ] =imx_clk_hw_mux ("dram_pll_ref_sel" , base +0x50 ,0 ,2 , pll_ref_sels,ARRAY_SIZE (pll_ref_sels)); hws[IMX8MN_GPU_PLL_REF_SEL ] =imx_clk_hw_mux ("gpu_pll_ref_sel" , base +0x64 ,0 ,2 , pll_ref_sels,ARRAY_SIZE (pll_ref_sels)); - hws[IMX8MN_VPU_PLL_REF_SEL ] =imx_clk_hw_mux ("vpu_pll_ref_sel" , base +0x74 ,0 ,2 , pll_ref_sels,ARRAY_SIZE (pll_ref_sels)); + hws[IMX8MN_M7_ALT_PLL_REF_SEL ] =imx_clk_hw_mux ("m7_alt_pll_ref_sel" , base +0x74 ,0 ,2 , pll_ref_sels,ARRAY_SIZE (pll_ref_sels)); hws[IMX8MN_ARM_PLL_REF_SEL ] =imx_clk_hw_mux ("arm_pll_ref_sel" , base +0x84 ,0 ,2 , pll_ref_sels,ARRAY_SIZE (pll_ref_sels)); hws[IMX8MN_SYS_PLL3_REF_SEL ] =imx_clk_hw_mux ("sys_pll3_ref_sel" , base +0x114 ,0 ,2 , pll_ref_sels,ARRAY_SIZE (pll_ref_sels));
@@ -337,7 +337,7 @@ static int imx8mn_clocks_probe(struct platform_device *pdev) hws[IMX8MN_VIDEO_PLL1 ] =imx_clk_hw_pll14xx ("video_pll1" ,"video_pll1_ref_sel" , base +0x28 , &imx_1443x_pll); hws[IMX8MN_DRAM_PLL ] =imx_clk_hw_pll14xx ("dram_pll" ,"dram_pll_ref_sel" , base +0x50 , &imx_1443x_dram_pll); hws[IMX8MN_GPU_PLL ] =imx_clk_hw_pll14xx ("gpu_pll" ,"gpu_pll_ref_sel" , base +0x64 , &imx_1416x_pll); - hws[IMX8MN_VPU_PLL ] =imx_clk_hw_pll14xx ("vpu_pll" ,"vpu_pll_ref_sel" , base +0x74 , &imx_1416x_pll); + hws[IMX8MN_M7_ALT_PLL ] =imx_clk_hw_pll14xx ("m7_alt_pll" ,"m7_alt_pll_ref_sel" , base +0x74 , &imx_1416x_pll); hws[IMX8MN_ARM_PLL ] =imx_clk_hw_pll14xx ("arm_pll" ,"arm_pll_ref_sel" , base +0x84 , &imx_1416x_pll); hws[IMX8MN_SYS_PLL1 ] =imx_clk_hw_fixed ("sys_pll1" ,800000000 ); hws[IMX8MN_SYS_PLL2 ] =imx_clk_hw_fixed ("sys_pll2" ,1000000000 );
@@ -349,7 +349,7 @@ static int imx8mn_clocks_probe(struct platform_device *pdev) hws[IMX8MN_VIDEO_PLL1_BYPASS ] =imx_clk_hw_mux_flags ("video_pll1_bypass" , base +0x28 ,16 ,1 , video_pll1_bypass_sels,ARRAY_SIZE (video_pll1_bypass_sels),CLK_SET_RATE_PARENT ); hws[IMX8MN_DRAM_PLL_BYPASS ] =imx_clk_hw_mux_flags ("dram_pll_bypass" , base +0x50 ,16 ,1 , dram_pll_bypass_sels,ARRAY_SIZE (dram_pll_bypass_sels),CLK_SET_RATE_PARENT ); hws[IMX8MN_GPU_PLL_BYPASS ] =imx_clk_hw_mux_flags ("gpu_pll_bypass" , base +0x64 ,28 ,1 , gpu_pll_bypass_sels,ARRAY_SIZE (gpu_pll_bypass_sels),CLK_SET_RATE_PARENT ); - hws[IMX8MN_VPU_PLL_BYPASS ] =imx_clk_hw_mux_flags ("vpu_pll_bypass" , base +0x74 ,28 ,1 , vpu_pll_bypass_sels,ARRAY_SIZE (vpu_pll_bypass_sels),CLK_SET_RATE_PARENT ); + hws[IMX8MN_M7_ALT_PLL_BYPASS ] =imx_clk_hw_mux_flags ("m7_alt_pll_bypass" , base +0x74 ,28 ,1 , m7_alt_pll_bypass_sels,ARRAY_SIZE (m7_alt_pll_bypass_sels),CLK_SET_RATE_PARENT ); hws[IMX8MN_ARM_PLL_BYPASS ] =imx_clk_hw_mux_flags ("arm_pll_bypass" , base +0x84 ,28 ,1 , arm_pll_bypass_sels,ARRAY_SIZE (arm_pll_bypass_sels),CLK_SET_RATE_PARENT ); hws[IMX8MN_SYS_PLL3_BYPASS ] =imx_clk_hw_mux_flags ("sys_pll3_bypass" , base +0x114 ,28 ,1 , sys_pll3_bypass_sels,ARRAY_SIZE (sys_pll3_bypass_sels),CLK_SET_RATE_PARENT );
@@ -359,7 +359,7 @@ static int imx8mn_clocks_probe(struct platform_device *pdev) hws[IMX8MN_VIDEO_PLL1_OUT ] =imx_clk_hw_gate ("video_pll1_out" ,"video_pll1_bypass" , base +0x28 ,13 ); hws[IMX8MN_DRAM_PLL_OUT ] =imx_clk_hw_gate ("dram_pll_out" ,"dram_pll_bypass" , base +0x50 ,13 ); hws[IMX8MN_GPU_PLL_OUT ] =imx_clk_hw_gate ("gpu_pll_out" ,"gpu_pll_bypass" , base +0x64 ,11 ); - hws[IMX8MN_VPU_PLL_OUT ] =imx_clk_hw_gate ("vpu_pll_out" ,"vpu_pll_bypass" , base +0x74 ,11 ); + hws[IMX8MN_M7_ALT_PLL_OUT ] =imx_clk_hw_gate ("m7_alt_pll_out" ,"m7_alt_pll_bypass" , base +0x74 ,11 ); hws[IMX8MN_ARM_PLL_OUT ] =imx_clk_hw_gate ("arm_pll_out" ,"arm_pll_bypass" , base +0x84 ,11 ); hws[IMX8MN_SYS_PLL3_OUT ] =imx_clk_hw_gate ("sys_pll3_out" ,"sys_pll3_bypass" , base +0x114 ,11 );
include/dt-bindings/clock/imx8mn-clock.h +8 -4
@@ -19,7 +19,8 @@#define IMX8MN_VIDEO_PLL1_REF_SEL 10#define IMX8MN_DRAM_PLL_REF_SEL 11#define IMX8MN_GPU_PLL_REF_SEL 12 -#define IMX8MN_VPU_PLL_REF_SEL 13 +#define IMX8MN_M7_ALT_PLL_REF_SEL 13 +#define IMX8MN_VPU_PLL_REF_SEL IMX8MN_M7_ALT_PLL_REF_SEL#define IMX8MN_ARM_PLL_REF_SEL 14#define IMX8MN_SYS_PLL1_REF_SEL 15#define IMX8MN_SYS_PLL2_REF_SEL 16
@@ -29,7 +30,8 @@#define IMX8MN_VIDEO_PLL1 20#define IMX8MN_DRAM_PLL 21#define IMX8MN_GPU_PLL 22 -#define IMX8MN_VPU_PLL 23 +#define IMX8MN_M7_ALT_PLL 23 +#define IMX8MN_VPU_PLL IMX8MN_M7_ALT_PLL#define IMX8MN_ARM_PLL 24#define IMX8MN_SYS_PLL1 25#define IMX8MN_SYS_PLL2 26
@@ -39,7 +41,8 @@#define IMX8MN_VIDEO_PLL1_BYPASS 30#define IMX8MN_DRAM_PLL_BYPASS 31#define IMX8MN_GPU_PLL_BYPASS 32 -#define IMX8MN_VPU_PLL_BYPASS 33 +#define IMX8MN_M7_ALT_PLL_BYPASS 33 +#define IMX8MN_VPU_PLL_BYPASS IMX8MN_M7_ALT_PLL_BYPASS#define IMX8MN_ARM_PLL_BYPASS 34#define IMX8MN_SYS_PLL1_BYPASS 35#define IMX8MN_SYS_PLL2_BYPASS 36
@@ -49,7 +52,8 @@#define IMX8MN_VIDEO_PLL1_OUT 40#define IMX8MN_DRAM_PLL_OUT 41#define IMX8MN_GPU_PLL_OUT 42 -#define IMX8MN_VPU_PLL_OUT 43 +#define IMX8MN_M7_ALT_PLL_OUT 43 +#define IMX8MN_VPU_PLL_OUT IMX8MN_M7_ALT_PLL_OUT#define IMX8MN_ARM_PLL_OUT 44#define IMX8MN_SYS_PLL1_OUT 45#define IMX8MN_SYS_PLL2_OUT 46
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 234/731 clk: imx: replace osc_hdmi with dummy
In reply to Greg Kroah-HartmanFrom: Dario Binacchi <[email protected]>
[ Upstream commit e7fa365ff66f16772dc06b480cd78f858d10856b ]
There is no occurrence of the hdmi oscillator in the reference manual (document IMX8MNRM Rev 2, 07/2022). Further, if we consider the indexes 76-81 and 134 of the "Clock Root" table of chapter 5 of the RM, there is no entry for the source select bits 101b, which is the setting referenced by "osc_hdmi".
Fix by renaming "osc_hdmi" with "dummy", a clock which has already been used for missing source select bits.
Tested on the BSH SystemMaster (SMM) S2 board.
--- drivers/clk/imx/clk-imx8mn.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/clk/imx/clk-imx8mn.c +6 -6
@@ -108,27 +108,27 @@ static const char * const imx8mn_disp_pixel_sels[] = {"osc_24m", "video_pll1_out "sys_pll3_out", "clk_ext4", };static const char *const imx8mn_sai2_sels[] = {"osc_24m" ,"audio_pll1_out" ,"audio_pll2_out" , -"video_pll1_out" ,"sys_pll1_133m" ,"osc_hdmi" , +"video_pll1_out" ,"sys_pll1_133m" ,"dummy" ,"clk_ext3" ,"clk_ext4" , };static const char *const imx8mn_sai3_sels[] = {"osc_24m" ,"audio_pll1_out" ,"audio_pll2_out" , -"video_pll1_out" ,"sys_pll1_133m" ,"osc_hdmi" , +"video_pll1_out" ,"sys_pll1_133m" ,"dummy" ,"clk_ext3" ,"clk_ext4" , };static const char *const imx8mn_sai5_sels[] = {"osc_24m" ,"audio_pll1_out" ,"audio_pll2_out" , -"video_pll1_out" ,"sys_pll1_133m" ,"osc_hdmi" , +"video_pll1_out" ,"sys_pll1_133m" ,"dummy" ,"clk_ext2" ,"clk_ext3" , };static const char *const imx8mn_sai6_sels[] = {"osc_24m" ,"audio_pll1_out" ,"audio_pll2_out" , -"video_pll1_out" ,"sys_pll1_133m" ,"osc_hdmi" , +"video_pll1_out" ,"sys_pll1_133m" ,"dummy" ,"clk_ext3" ,"clk_ext4" , };static const char *const imx8mn_sai7_sels[] = {"osc_24m" ,"audio_pll1_out" ,"audio_pll2_out" , -"video_pll1_out" ,"sys_pll1_133m" ,"osc_hdmi" , +"video_pll1_out" ,"sys_pll1_133m" ,"dummy" ,"clk_ext3" ,"clk_ext4" , };static const char *const imx8mn_spdif1_sels[] = {"osc_24m" ,"audio_pll1_out" ,"audio_pll2_out" , -"video_pll1_out" ,"sys_pll1_133m" ,"osc_hdmi" , +"video_pll1_out" ,"sys_pll1_133m" ,"dummy" ,"clk_ext2" ,"clk_ext3" , }; static const char * const imx8mn_enet_ref_sels[] = {"osc_24m", "sys_pll2_125m", "sys_pll2_50m",
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 235/731 clk: imx8mn: fix imx8mn_sai2_sels clocks list
In reply to Greg Kroah-HartmanFrom: Dario Binacchi <[email protected]>
[ Upstream commit 34d996747a74e3a86990f9f9c48de09159d78edb ]
According to the "Clock Root" table of the reference manual (document IMX8MNRM Rev 2, 07/2022):
Clock Root offset Source Select (CCM_TARGET_ROOTn[MUX])
... ... ...
SAI2_CLK_ROOT 0xA600 000 - 24M_REF_CLK
001 - AUDIO_PLL1_CLK
010 - AUDIO_PLL2_CLK
011 - VIDEO_PLL_CLK
100 - SYSTEM_PLL1_DIV6
110 - EXT_CLK_2
111 - EXT_CLK_3
... ... ...while the imx8mn_sai2_sels list contained clk_ext3 and clk_ext4 for source select bits 110b and 111b.
--- drivers/clk/imx/clk-imx8mn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/imx/clk-imx8mn.c +1 -1
@@ -109,7 +109,7 @@ static const char * const imx8mn_disp_pixel_sels[] = {"osc_24m", "video_pll1_outstatic const char *const imx8mn_sai2_sels[] = {"osc_24m" ,"audio_pll1_out" ,"audio_pll2_out" ,"video_pll1_out" ,"sys_pll1_133m" ,"dummy" , -"clk_ext3" ,"clk_ext4" , }; +"clk_ext2" ,"clk_ext3" , };static const char *const imx8mn_sai3_sels[] = {"osc_24m" ,"audio_pll1_out" ,"audio_pll2_out" ,"video_pll1_out" ,"sys_pll1_133m" ,"dummy" ,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 236/731 clk: imx8mn: fix imx8mn_enet_phy_sels clocks list
In reply to Greg Kroah-HartmanFrom: Dario Binacchi <[email protected]>
[ Upstream commit 2626cf67f20b28446dfc3a5b9493dd535cdb747b ]
According to the "Clock Root" table of the reference manual (document IMX8MNRM Rev 2, 07/2022):
Clock Root offset Source Select (CCM_TARGET_ROOTn[MUX])
... ... ...
ENET_PHY_REF_CLK_ROOT 0xAA80 000 - 24M_REF_CLK
001 - SYSTEM_PLL2_DIV20
010 - SYSTEM_PLL2_DIV8
011 - SYSTEM_PLL2_DIV5
100 - SYSTEM_PLL2_DIV2
101 - AUDIO_PLL1_CLK
110 - VIDEO_PLL_CLK
111 - AUDIO_PLL2_CLK
... ... ...while the imx8mn_enet_phy_sels list didn't contained audio_pll1_out for source select bits 101b.
--- drivers/clk/imx/clk-imx8mn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/imx/clk-imx8mn.c +2 -2
@@ -140,8 +140,8 @@ static const char * const imx8mn_enet_timer_sels[] = {"osc_24m", "sys_pll2_100m" "clk_ext4", "video_pll1_out", };static const char *const imx8mn_enet_phy_sels[] = {"osc_24m" ,"sys_pll2_50m" ,"sys_pll2_125m" , -"sys_pll2_200m" ,"sys_pll2_500m" ,"video_pll1_out" , -"audio_pll2_out" , }; +"sys_pll2_200m" ,"sys_pll2_500m" ,"audio_pll1_out" , +"video_pll_out" ,"audio_pll2_out" , };static const char *const imx8mn_nand_sels[] = {"osc_24m" ,"sys_pll2_500m" ,"audio_pll1_out" , "sys_pll1_400m", "audio_pll2_out", "sys_pll3_out",
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 237/731 pinctrl: pinconf-generic: add missing of_node_put()
In reply to Greg Kroah-HartmanFrom: ZhangPeng <[email protected]>
[ Upstream commit 5ead93289815a075d43c415e35c8beafafb801c9 ]
of_node_put() needs to be called when jumping out of the loop, since for_each_available_child_of_node() will increase the refcount of node.
--- drivers/pinctrl/pinconf-generic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pinctrl/pinconf-generic.c +3 -1
@@ -393,8 +393,10 @@ int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev,for_each_available_child_of_node (np_config, np) { ret =pinconf_generic_dt_subnode_to_map (pctldev, np, map, &reserved_maps, num_maps, type); -if (ret <0 ) +if (ret <0 ) { +of_node_put (np); goto exit; + } }return 0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 238/731 media: dvb-core: Fix ignored return value in dvb_register_frontend()
In reply to Greg Kroah-HartmanFrom: Chen Zhongjin <[email protected]>
[ Upstream commit a574359e2e71ce16be212df3a082ed60a4bd2c5f ]
In dvb_register_frontend(), dvb_register_device() is possible to fail but its return value is ignored.
It will cause use-after-free when module is removed, because in dvb_unregister_frontend() it tries to unregister a not registered device.
BUG: KASAN: use-after-free in dvb_remove_device+0x18b/0x1f0 [dvb_core] Read of size 4 at addr ffff88800dff4824 by task rmmod/428 CPU: 3 PID: 428 Comm: rmmod Call Trace: <TASK> ... dvb_remove_device+0x18b/0x1f0 [dvb_core] dvb_unregister_frontend+0x7b/0x130 [dvb_core] vidtv_bridge_remove+0x6e/0x160 [dvb_vidtv_bridge] ...
Fix this by catching return value of dvb_register_device(). However the fe->refcount can't be put to zero immediately, because there are still modules calling dvb_frontend_detach() when dvb_register_frontend() fails.
--- drivers/media/dvb-core/dvb_frontend.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/media/dvb-core/dvb_frontend.c +7 -1
@@ -2985,6 +2985,7 @@ int dvb_register_frontend(struct dvb_adapter *dvb, .name = fe->ops.info.name,#endif }; +int ret;dev_dbg (dvb->device,"%s:\n" , __func__);
@@ -3018,8 +3019,13 @@ int dvb_register_frontend(struct dvb_adapter *dvb,"DVB: registering adapter %i frontend %i (%s)...\n" , fe->dvb->num, fe->id, fe->ops.info.name); -dvb_register_device (fe->dvb, &fepriv->dvbdev, &dvbdev_template, + ret =dvb_register_device (fe->dvb, &fepriv->dvbdev, &dvbdev_template, fe,DVB_DEVICE_FRONTEND ,0 ); +if (ret) { +dvb_frontend_put (fe); +mutex_unlock (&frontend_mutex); +return ret; + }/* * Initialize the cache to the proper values according with the
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 239/731 media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()
In reply to Greg Kroah-HartmanFrom: Baisong Zhong <[email protected]>
[ Upstream commit 0ed554fd769a19ea8464bb83e9ac201002ef74ad ]
Wei Chen reports a kernel bug as blew:
general protection fault, probably for non-canonical address KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017] ... Call Trace: <TASK> __i2c_transfer+0x77e/0x1930 drivers/i2c/i2c-core-base.c:2109 i2c_transfer+0x1d5/0x3d0 drivers/i2c/i2c-core-base.c:2170 i2cdev_ioctl_rdwr+0x393/0x660 drivers/i2c/i2c-dev.c:297 i2cdev_ioctl+0x75d/0x9f0 drivers/i2c/i2c-dev.c:458 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl+0xfb/0x170 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3d/0x90 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7fd834a8bded
In az6027_i2c_xfer(), if msg[i].addr is 0x99, a null-ptr-deref will caused when accessing msg[i].buf. For msg[i].len is 0 and msg[i].buf is null.
Fix this by checking msg[i].len in az6027_i2c_xfer().
--- drivers/media/usb/dvb-usb/az6027.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/usb/dvb-usb/az6027.c +4 -0
@@ -975,6 +975,10 @@ static int az6027_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int nif (msg[i].addr ==0x99 ) { req =0xBE ; index =0 ; +if (msg[i].len <1 ) { + i = -EOPNOTSUPP ; +break ; + } value = msg[i].buf[0 ] &0x00ff ; length =1 ;az6027_usb_out_op (d, req, value, index, data, length);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 240/731 media: s5p-mfc: Add variant data for MFC v7 hardware for Exynos 3250 SoC
In reply to Greg Kroah-HartmanFrom: Aakarsh Jain <[email protected]>
[ Upstream commit f50ebe10f5d8092c37e2bd430c78e03bf38b1e20 ]
Commit 5441e9dafdfc6dc40 ("[media] s5p-mfc: Core support for MFC v7") which adds mfc v7 support for Exynos3250 and use the same compatible string as used by Exynos5240 but both the IPs are a bit different in terms of IP clock.
Add variant driver data based on the new compatible string "samsung,exynos3250-mfc" for Exynos3250 SoC.
--- drivers/media/platform/s5p-mfc/s5p_mfc.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/media/platform/s5p-mfc/s5p_mfc.c +15 -2
@@ -1583,8 +1583,18 @@ static struct s5p_mfc_variant mfc_drvdata_v7 = { .port_num = MFC_NUM_PORTS_V7, .buf_size = &buf_size_v7, .fw_name[0] = "s5p-mfc-v7.fw", - .clk_names = {"mfc", "sclk_mfc"}, - .num_clocks = 2, + .clk_names = {"mfc"}, + .num_clocks = 1, +}; + +static struct s5p_mfc_variant mfc_drvdata_v7_3250 = { + .version =MFC_VERSION_V7 , + .version_bit =MFC_V7_BIT , + .port_num =MFC_NUM_PORTS_V7 , + .buf_size = &buf_size_v7, + .fw_name[0 ] ="s5p-mfc-v7.fw" , + .clk_names = {"mfc" ,"sclk_mfc" }, + .num_clocks =2 , }; static struct s5p_mfc_buf_size_v6 mfc_buf_size_v8 = {
@@ -1654,6 +1664,9 @@ static const struct of_device_id exynos_mfc_match[] = { }, { .compatible = "samsung,mfc-v7", .data = &mfc_drvdata_v7, + }, { + .compatible = "samsung,exynos3250-mfc", + .data = &mfc_drvdata_v7_3250, }, { .compatible = "samsung,mfc-v8", .data = &mfc_drvdata_v8,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 241/731 drm/tegra: Add missing clk_disable_unprepare() in tegra_dc_probe()
In reply to Greg Kroah-HartmanFrom: Zhang Zekun <[email protected]>
[ Upstream commit 7ad4384d53c67672a8720cdc2ef638d7d1710ab8 ]
Add the missing clk_disable_unprepare() before return from tegra_dc_probe() in the error handling path.
--- drivers/gpu/drm/tegra/dc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/tegra/dc.c +3 -1
@@ -3022,8 +3022,10 @@ static int tegra_dc_probe(struct platform_device *pdev)usleep_range (2000 ,4000 ); err =reset_control_assert (dc->rst); -if (err <0 ) +if (err <0 ) { +clk_disable_unprepare (dc->clk);return err; + }usleep_range (2000 ,4000 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 242/731 ASoC: dt-bindings: wcd9335: fix reset line polarity in example
In reply to Greg Kroah-HartmanFrom: Dmitry Torokhov <[email protected]>
[ Upstream commit 34cb111f8a7b98b5fec809dd194003bca20ef1b2 ]
When resetting the block, the reset line is being driven low and then high, which means that the line in DTS should be annotated as "active low".
--- Documentation/devicetree/bindings/sound/qcom,wcd9335.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/qcom,wcd9335.txt +1 -1
@@ -109,7 +109,7 @@ audio-codec@1{ reg = <1 0>; interrupts = <&msmgpio 54 IRQ_TYPE_LEVEL_HIGH>; interrupt-names = "intr2" - reset-gpios = <&msmgpio 64 0>; + reset-gpios = <&msmgpio 64 GPIO_ACTIVE_LOW>; slim-ifc-dev = <&wc9335_ifd>; clock-names = "mclk", "native"; clocks = <&rpmcc RPM_SMD_DIV_CLK1>,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 243/731 ASoC: mediatek: mtk-btcvsd: Add checks for write and read of mtk_btcvsd_snd
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit d067b3378a78c9c3048ac535e31c171b6f5b5846 ]
As the mtk_btcvsd_snd_write and mtk_btcvsd_snd_read may return error, it should be better to catch the exception.
--- sound/soc/mediatek/common/mtk-btcvsd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
sound/soc/mediatek/common/mtk-btcvsd.c +2 -4
@@ -1038,11 +1038,9 @@ static int mtk_pcm_btcvsd_copy(struct snd_soc_component *component,struct mtk_btcvsd_snd *bt =snd_soc_component_get_drvdata (component);if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) -mtk_btcvsd_snd_write (bt, buf, count); +return mtk_btcvsd_snd_write (bt, buf, count);else -mtk_btcvsd_snd_read (bt, buf, count); - -return 0 ; +return mtk_btcvsd_snd_read (bt, buf, count); }/* kcontrol */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 244/731 NFSv4.2: Clear FATTR4_WORD2_SECURITY_LABEL when done decoding
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit eef7314caf2d73a94b68ba293cd105154d3a664e ]
We need to clear the FATTR4_WORD2_SECURITY_LABEL bitmap flag irrespective of whether or not the label is too long.
--- fs/nfs/nfs4xdr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/nfs4xdr.c +1 -1
@@ -4179,6 +4179,7 @@ static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap, p =xdr_inline_decode (xdr, len);if (unlikely (!p))return -EIO ; + bitmap[2 ] &= ~FATTR4_WORD2_SECURITY_LABEL ;if (len <NFS4_MAXLABELLEN ) {if (label) {if (label->len) {
@@ -4191,7 +4192,6 @@ static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap, label->lfs = lfs; status =NFS_ATTR_FATTR_V4_SECURITY_LABEL ; } - bitmap[2 ] &= ~FATTR4_WORD2_SECURITY_LABEL ; }else printk (KERN_WARNING "%s: label too long (%u)!\n" , __func__, len);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 245/731 NFSv4.2: Fix a memory stomp in decode_attr_security_label
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 43c1031f7110967c240cb6e922adcfc4b8899183 ]
We must not change the value of label->len if it is zero, since that indicates we stored a label.
--- fs/nfs/nfs4xdr.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
fs/nfs/nfs4xdr.c +4 -6
@@ -4181,12 +4181,10 @@ static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap,return -EIO ; bitmap[2 ] &= ~FATTR4_WORD2_SECURITY_LABEL ;if (len <NFS4_MAXLABELLEN ) { -if (label) { -if (label->len) { -if (label->len < len) -return -ERANGE ; -memcpy (label->label, p, len); - } +if (label && label->len) { +if (label->len < len) +return -ERANGE ; +memcpy (label->label, p, len); label->len = len; label->pi = pi; label->lfs = lfs;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 246/731 NFSv4.2: Fix initialisation of struct nfs4_label
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit c528f70f504434eaff993a5ddd52203a2010d51f ]
The call to nfs4_label_init_security() should return a fully initialised label.
--- fs/nfs/nfs4proc.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
fs/nfs/nfs4proc.c +10 -5
@@ -126,6 +126,11 @@ nfs4_label_init_security(struct inode *dir, struct dentry *dentry,if (nfs_server_capable (dir,NFS_CAP_SECURITY_LABEL ) ==0 )return NULL ; + label->lfs =0 ; + label->pi =0 ; + label->len =0 ; + label->label =NULL ; + err =security_dentry_init_security (dentry, sattr->ia_mode, &dentry->d_name, (void **)&label->label, &label->len);if (err ==0 )
@@ -3823,7 +3828,7 @@ nfs4_atomic_open(struct inode *dir, struct nfs_open_context *ctx, int open_flags, struct iattr *attr, int *opened) { struct nfs4_state *state; -struct nfs4_label l = {0 ,0 ,0 ,NULL }, *label =NULL ; +struct nfs4_label l, *label; label =nfs4_label_init_security (dir, ctx->dentry, attr, &l);
@@ -4657,7 +4662,7 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, int flags) {struct nfs_server *server =NFS_SERVER (dir); -struct nfs4_label l, *ilabel =NULL ; +struct nfs4_label l, *ilabel;struct nfs_open_context *ctx;struct nfs4_state *state;int status =0 ;
@@ -5017,7 +5022,7 @@ static int nfs4_proc_symlink(struct inode *dir, struct dentry *dentry,struct nfs4_exception exception = { .interruptible = true, }; -struct nfs4_label l, *label =NULL ; +struct nfs4_label l, *label;int err; label =nfs4_label_init_security (dir, dentry, sattr, &l);
@@ -5058,7 +5063,7 @@ static int nfs4_proc_mkdir(struct inode *dir, struct dentry *dentry,struct nfs4_exception exception = { .interruptible = true, }; -struct nfs4_label l, *label =NULL ; +struct nfs4_label l, *label;int err; label =nfs4_label_init_security (dir, dentry, sattr, &l);
@@ -5177,7 +5182,7 @@ static int nfs4_proc_mknod(struct inode *dir, struct dentry *dentry,struct nfs4_exception exception = { .interruptible = true, }; -struct nfs4_label l, *label =NULL ; +struct nfs4_label l, *label;int err; label =nfs4_label_init_security (dir, dentry, sattr, &l);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 247/731 NFSv4: Fix a credential leak in _nfs4_discover_trunking()
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit e83458fce080dc23c25353a1af90bfecf79c7369 ]
--- fs/nfs/nfs4proc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/nfs/nfs4proc.c +3 -1
@@ -3987,7 +3987,7 @@ static int _nfs4_discover_trunking(struct nfs_server *server, page =alloc_page (GFP_KERNEL );if (!page) -return -ENOMEM ; + goto out_put_cred; locations =kmalloc (sizeof (struct nfs4_fs_locations ),GFP_KERNEL );if (!locations) goto out_free;
@@ -4003,6 +4003,8 @@ static int _nfs4_discover_trunking(struct nfs_server *server,kfree (locations); out_free:__free_page (page); +out_put_cred: +put_cred (cred);return status; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 248/731 NFSv4: Fix a deadlock between nfs4_open_recover_helper() and delegreturn
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 51069e4aef6257b0454057359faed0ab0c9af083 ]
If we're asked to recover open state while a delegation return is outstanding, then the state manager thread cannot use a cached open, so if the server returns a delegation, we can end up deadlocked behind the pending delegreturn.
To avoid this problem, let's just ask the server not to give us a delegation unless we're explicitly reclaiming one.
--- fs/nfs/nfs4proc.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
fs/nfs/nfs4proc.c +12 -7
@@ -2144,18 +2144,18 @@ static struct nfs4_opendata *nfs4_open_recoverdata_alloc(struct nfs_open_context }static int nfs4_open_recover_helper (struct nfs4_opendata *opendata, -fmode_t fmode) +fmode_t fmode) {struct nfs4_state *newstate; +struct nfs_server *server =NFS_SB (opendata->dentry->d_sb); +int openflags = opendata->o_arg.open_flags;int ret;if (!nfs4_mode_match_open_stateid (opendata->state, fmode))return 0 ; - opendata->o_arg.open_flags =0 ; opendata->o_arg.fmode = fmode; - opendata->o_arg.share_access =nfs4_map_atomic_open_share ( -NFS_SB (opendata->dentry->d_sb), - fmode,0 ); + opendata->o_arg.share_access = +nfs4_map_atomic_open_share (server, fmode, openflags);memset (&opendata->o_res,0 ,sizeof (opendata->o_res));memset (&opendata->c_res,0 ,sizeof (opendata->c_res));nfs4_init_opendata_res (opendata);
@@ -2735,10 +2735,15 @@ static int _nfs4_open_expired(struct nfs_open_context *ctx, struct nfs4_state *sstruct nfs4_opendata *opendata;int ret; - opendata =nfs4_open_recoverdata_alloc (ctx, state, -NFS4_OPEN_CLAIM_FH ); + opendata =nfs4_open_recoverdata_alloc (ctx, state,NFS4_OPEN_CLAIM_FH );if (IS_ERR (opendata))return PTR_ERR (opendata); +/* +* We're not recovering a delegation, so ask for no delegation. +* Otherwise the recovery thread could deadlock with an outstanding +* delegation return. +*/ + opendata->o_arg.open_flags =O_DIRECT ; ret =nfs4_open_recover (opendata, state);if (ret == -ESTALE )d_drop (ctx->dentry);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 249/731 NFS: Fix an Oops in nfs_d_automount()
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 35e3b6ae84935d0d7ff76cbdaa83411b0ad5e471 ]
When mounting from a NFSv4 referral, path->dentry can end up being a negative dentry, so derive the struct nfs_server from the dentry itself instead.
--- fs/nfs/namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/namespace.c +1 -1
@@ -147,7 +147,7 @@ struct vfsmount *nfs_d_automount(struct path *path)struct nfs_fs_context *ctx;struct fs_context *fc;struct vfsmount *mnt =ERR_PTR (-ENOMEM ); -struct nfs_server *server =NFS_SERVER (d_inode (path->dentry)); +struct nfs_server *server =NFS_SB (path->dentry->d_sb);struct nfs_client *client = server->nfs_client;int timeout =READ_ONCE (nfs_mountpoint_expiry_timeout);int ret;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 250/731 ALSA: asihpi: fix missing pci_disable_device()
In reply to Greg Kroah-HartmanFrom: Liu Shixin <[email protected]>
[ Upstream commit 9d86515c3d4c0564a0c31a2df87d735353a1971e ]
pci_disable_device() need be called while module exiting, switch to use pcim_enable(), pci_disable_device() will be called in pcim_release().
--- sound/pci/asihpi/hpioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/asihpi/hpioctl.c +1 -1
@@ -361,7 +361,7 @@ int asihpi_adapter_probe(struct pci_dev *pci_dev, pci_dev->device, pci_dev->subsystem_vendor, pci_dev->subsystem_device, pci_dev->devfn); -if (pci_enable_device (pci_dev) <0 ) { +if (pcim_enable_device (pci_dev) <0 ) {dev_err (&pci_dev->dev,"pci_enable_device failed, disabling device\n" );return -EIO ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 251/731 wifi: iwlwifi: mvm: fix double free on tx path.
In reply to Greg Kroah-HartmanFrom: Ben Greear <[email protected]>
[ Upstream commit 0473cbae2137b963bd0eaa74336131cb1d3bc6c3 ]
We see kernel crashes and lockups and KASAN errors related to ax210 firmware crashes. One of the KASAN dumps pointed at the tx path, and it appears there is indeed a way to double-free an skb.
If iwl_mvm_tx_skb_sta returns non-zero, then the 'skb' sent into the method will be freed. But, in case where we build TSO skb buffer, the skb may also be freed in error case. So, return 0 in that particular error case and do cleanup manually.
BUG: KASAN: use-after-free in __list_del_entry_valid+0x12/0x90 iwlwifi 0000:06:00.0: 0x00000000 | tsf hi Read of size 8 at addr ffff88813cfa4ba0 by task btserver/9650 CPU: 4 PID: 9650 Comm: btserver Tainted: G W 5.19.8+ #5 iwlwifi 0000:06:00.0: 0x00000000 | time gp1 Hardware name: Default string Default string/SKYBAY, BIOS 5.12 02/19/2019 Call Trace: <TASK> dump_stack_lvl+0x55/0x6d print_report.cold.12+0xf2/0x684 iwlwifi 0000:06:00.0: 0x1D0915A8 | time gp2 ? __list_del_entry_valid+0x12/0x90 kasan_report+0x8b/0x180 iwlwifi 0000:06:00.0: 0x00000001 | uCode revision type ? __list_del_entry_valid+0x12/0x90 __list_del_entry_valid+0x12/0x90 iwlwifi 0000:06:00.0: 0x00000048 | uCode version major tcp_update_skb_after_send+0x5d/0x170 __tcp_transmit_skb+0xb61/0x15c0 iwlwifi 0000:06:00.0: 0xDAA05125 | uCode version minor ? __tcp_select_window+0x490/0x490 iwlwifi 0000:06:00.0: 0x00000420 | hw version ? trace_kmalloc_node+0x29/0xd0 ? __kmalloc_node_track_caller+0x12a/0x260 ? memset+0x1f/0x40 ? __build_skb_around+0x125/0x150 ? __alloc_skb+0x1d4/0x220 ? skb_zerocopy_clone+0x55/0x230 iwlwifi 0000:06:00.0: 0x00489002 | board version ? kmalloc_reserve+0x80/0x80 ? rcu_read_lock_bh_held+0x60/0xb0 tcp_write_xmit+0x3f1/0x24d0
iwlwifi 0000:06:00.0: 0x034E001C | hcmd
? __check_object_size+0x180/0x350
iwlwifi 0000:06:00.0: 0x24020000 | isr0
tcp_sendmsg_locked+0x8a9/0x1520
iwlwifi 0000:06:00.0: 0x01400000 | isr1
? tcp_sendpage+0x50/0x50
iwlwifi 0000:06:00.0: 0x48F0000A | isr2
? lock_release+0xb9/0x400 ? tcp_sendmsg+0x14/0x40 iwlwifi 0000:06:00.0: 0x00C3080C | isr3 ? lock_downgrade+0x390/0x390 ? do_raw_spin_lock+0x114/0x1d0 iwlwifi 0000:06:00.0: 0x00200000 | isr4 ? rwlock_bug.part.2+0x50/0x50 iwlwifi 0000:06:00.0: 0x034A001C | last cmd Id ? rwlock_bug.part.2+0x50/0x50 ? lockdep_hardirqs_on_prepare+0xe/0x200 iwlwifi 0000:06:00.0: 0x0000C2F0 | wait_event ? __local_bh_enable_ip+0x87/0xe0 ? inet_send_prepare+0x220/0x220 iwlwifi 0000:06:00.0: 0x000000C4 | l2p_control tcp_sendmsg+0x22/0x40 sock_sendmsg+0x5f/0x70
iwlwifi 0000:06:00.0: 0x00010034 | l2p_duration
__sys_sendto+0x19d/0x250
iwlwifi 0000:06:00.0: 0x00000007 | l2p_mhvalid
? __ia32_sys_getpeername+0x40/0x40
iwlwifi 0000:06:00.0: 0x00000000 | l2p_addr_match
? rcu_read_lock_held_common+0x12/0x50 ? rcu_read_lock_sched_held+0x5a/0xd0 ? rcu_read_lock_bh_held+0xb0/0xb0 ? rcu_read_lock_sched_held+0x5a/0xd0 ? rcu_read_lock_sched_held+0x5a/0xd0 ? lock_release+0xb9/0x400 ? lock_downgrade+0x390/0x390 ? ktime_get+0x64/0x130 ? ktime_get+0x8d/0x130 ? rcu_read_lock_held_common+0x12/0x50 ? rcu_read_lock_sched_held+0x5a/0xd0 ? rcu_read_lock_held_common+0x12/0x50 ? rcu_read_lock_sched_held+0x5a/0xd0 ? rcu_read_lock_bh_held+0xb0/0xb0 ? rcu_read_lock_bh_held+0xb0/0xb0 __x64_sys_sendto+0x6f/0x80 do_syscall_64+0x34/0xb0 entry_SYSCALL_64_after_hwframe+0x46/0xb0 RIP: 0033:0x7f1d126e4531 Code: 00 00 00 00 0f 1f 44 00 00 f3 0f 1e fa 48 8d 05 35 80 0c 00 41 89 ca 8b 00 85 c0 75 1c 45 31 c9 45 31 c0 b8 2c 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 67 c3 66 0f 1f 44 00 00 55 48 83 ec 20 48 89 RSP: 002b:00007ffe21a679d8 EFLAGS: 00000246 ORIG_RAX: 000000000000002c RAX: ffffffffffffffda RBX: 000000000000ffdc RCX: 00007f1d126e4531 RDX: 0000000000010000 RSI: 000000000374acf0 RDI: 0000000000000014 RBP: 00007ffe21a67ac0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000010 R13: 0000000000000000 R14: 0000000000000001 R15: 0000000000000000 </TASK> Allocated by task 9650: kasan_save_stack+0x1c/0x40 __kasan_slab_alloc+0x6d/0x90 kmem_cache_alloc_node+0xf3/0x2b0 __alloc_skb+0x191/0x220 tcp_stream_alloc_skb+0x3f/0x330 tcp_sendmsg_locked+0x67c/0x1520 tcp_sendmsg+0x22/0x40 sock_sendmsg+0x5f/0x70 __sys_sendto+0x19d/0x250 __x64_sys_sendto+0x6f/0x80 do_syscall_64+0x34/0xb0 entry_SYSCALL_64_after_hwframe+0x46/0xb0 Freed by task 9650: kasan_save_stack+0x1c/0x40 kasan_set_track+0x21/0x30 kasan_set_free_info+0x20/0x30 __kasan_slab_free+0x102/0x170 kmem_cache_free+0xc8/0x3e0 iwl_mvm_mac_itxq_xmit+0x124/0x270 [iwlmvm] ieee80211_queue_skb+0x874/0xd10 [mac80211] ieee80211_xmit_fast+0xf80/0x1180 [mac80211] __ieee80211_subif_start_xmit+0x287/0x680 [mac80211] ieee80211_subif_start_xmit+0xcd/0x730 [mac80211] dev_hard_start_xmit+0xf6/0x420 __dev_queue_xmit+0x165b/0x1b50 ip_finish_output2+0x66e/0xfb0 __ip_finish_output+0x487/0x6d0 ip_output+0x11c/0x350 __ip_queue_xmit+0x36b/0x9d0 __tcp_transmit_skb+0xb35/0x15c0 tcp_write_xmit+0x3f1/0x24d0 tcp_sendmsg_locked+0x8a9/0x1520 tcp_sendmsg+0x22/0x40 sock_sendmsg+0x5f/0x70 __sys_sendto+0x19d/0x250 __x64_sys_sendto+0x6f/0x80 do_syscall_64+0x34/0xb0 entry_SYSCALL_64_after_hwframe+0x46/0xb0 The buggy address belongs to the object at ffff88813cfa4b40 which belongs to the cache skbuff_fclone_cache of size 472
The buggy address is located 96 bytes inside of
472-byte region [ffff88813cfa4b40, ffff88813cfa4d18)
The buggy address belongs to the physical page:
page:ffffea0004f3e900 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88813cfa6c40 pfn:0x13cfa4
head:ffffea0004f3e900 order:2 compound_mapcount:0 compound_pincount:0
flags: 0x5fff8000010200(slab|head|node=0|zone=2|lastcpupid=0x3fff)
raw: 005fff8000010200 ffffea0004656b08 ffffea0008e8cf08 ffff8881081a5240
raw: ffff88813cfa6c40 0000000000170015 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88813cfa4a80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88813cfa4b00: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
>ffff88813cfa4b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88813cfa4c00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88813cfa4c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================--- drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/tx.c +11 -1
@@ -1150,6 +1150,7 @@ int iwl_mvm_tx_skb_sta(struct iwl_mvm *mvm, struct sk_buff *skb,struct sk_buff_head mpdus_skbs;unsigned int payload_len;int ret; +struct sk_buff *orig_skb = skb;if (WARN_ON_ONCE (!mvmsta))return -1 ;
@@ -1182,8 +1183,17 @@ int iwl_mvm_tx_skb_sta(struct iwl_mvm *mvm, struct sk_buff *skb, ret =iwl_mvm_tx_mpdu (mvm, skb, &info, sta);if (ret) { +/* Free skbs created as part of TSO logic that have not yet been dequeued */ __skb_queue_purge (&mpdus_skbs); -return ret; +/* skb here is not necessarily same as skb that entered this method, +* so free it explicitly. +*/ +if (skb == orig_skb) +ieee80211_free_txskb (mvm->hw, skb); +else +kfree_skb (skb); +/* there was error, but we consumed skb one way or another, so return 0 */ +return 0 ; } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 252/731 ASoC: mediatek: mt8173: Fix debugfs registration for components
In reply to Greg Kroah-HartmanFrom: AngeloGioacchino Del Regno <[email protected]>
[ Upstream commit 8c32984bc7da29828260ac514d5d4967f7e8f62d ]
When registering the mt8173-afe-pcm driver, we are also adding two
components: one is for the PCM DAIs and one is for the HDMI DAIs, but when debugfs is enabled, we're getting the following issue:
[ 17.279176] debugfs: Directory '11220000.audio-controller' with parent 'mtk-rt5650' already present! [ 17.288345] debugfs: Directory '11220000.audio-controller' with parent 'mtk-rt5650' already present!
To overcome to that without any potentially big rewrite of this driver, similarly to what was done in mt8195-afe-pcm, add a debugfs_prefix to the components before actually adding them.
Stable-dep-of: 4cbb264d4e91 ("ASoC: mediatek: mt8173: Enable IRQ when pdata is ready")
--- sound/soc/mediatek/mt8173/mt8173-afe-pcm.c | 51 ++++++++++++++++++---- 1 file changed, 43 insertions(+), 8 deletions(-)
sound/soc/mediatek/mt8173/mt8173-afe-pcm.c +43 -8
@@ -1054,6 +1054,7 @@ static int mt8173_afe_pcm_dev_probe(struct platform_device *pdev)int irq_id;struct mtk_base_afe *afe;struct mt8173_afe_private *afe_priv; +struct snd_soc_component *comp_pcm, *comp_hdmi; ret =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (33 ));if (ret)
@@ -1142,23 +1143,55 @@ static int mt8173_afe_pcm_dev_probe(struct platform_device *pdev)if (ret) goto err_pm_disable; - ret =devm_snd_soc_register_component (&pdev->dev, - &mt8173_afe_pcm_dai_component, - mt8173_afe_pcm_dais, -ARRAY_SIZE (mt8173_afe_pcm_dais)); + comp_pcm =devm_kzalloc (&pdev->dev,sizeof (*comp_pcm),GFP_KERNEL ); +if (!comp_pcm) { + ret = -ENOMEM ; + goto err_pm_disable; + } + + ret =snd_soc_component_initialize (comp_pcm, + &mt8173_afe_pcm_dai_component, + &pdev->dev);if (ret) goto err_pm_disable; - ret =devm_snd_soc_register_component (&pdev->dev, - &mt8173_afe_hdmi_dai_component, - mt8173_afe_hdmi_dais, -ARRAY_SIZE (mt8173_afe_hdmi_dais)); +#ifdef CONFIG_DEBUG_FS + comp_pcm->debugfs_prefix ="pcm" ; +#endif + + ret =snd_soc_add_component (comp_pcm, + mt8173_afe_pcm_dais, +ARRAY_SIZE (mt8173_afe_pcm_dais)); +if (ret) + goto err_pm_disable; + + comp_hdmi =devm_kzalloc (&pdev->dev,sizeof (*comp_hdmi),GFP_KERNEL ); +if (!comp_hdmi) { + ret = -ENOMEM ; + goto err_pm_disable; + } + + ret =snd_soc_component_initialize (comp_hdmi, + &mt8173_afe_hdmi_dai_component, + &pdev->dev);if (ret) goto err_pm_disable; +#ifdef CONFIG_DEBUG_FS + comp_hdmi->debugfs_prefix ="hdmi" ; +#endif + + ret =snd_soc_add_component (comp_hdmi, + mt8173_afe_hdmi_dais, +ARRAY_SIZE (mt8173_afe_hdmi_dais)); +if (ret) + goto err_cleanup_components; +dev_info (&pdev->dev,"MT8173 AFE driver initialized.\n" );return 0 ; +err_cleanup_components: +snd_soc_unregister_component (&pdev->dev); err_pm_disable:pm_runtime_disable (&pdev->dev);return ret;
@@ -1166,6 +1199,8 @@ static int mt8173_afe_pcm_dev_probe(struct platform_device *pdev)static int mt8173_afe_pcm_dev_remove (struct platform_device *pdev) { +snd_soc_unregister_component (&pdev->dev); +pm_runtime_disable (&pdev->dev);if (!pm_runtime_status_suspended (&pdev->dev))mt8173_afe_runtime_suspend (&pdev->dev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 253/731 ASoC: mediatek: mt8173: Enable IRQ when pdata is ready
In reply to Greg Kroah-HartmanFrom: Ricardo Ribalda <[email protected]>
[ Upstream commit 4cbb264d4e9136acab2c8fd39e39ab1b1402b84b ]
If the device does not come straight from reset, we might receive an IRQ before we are ready to handle it.
Fixes:
[ 2.334737] Unable to handle kernel read from unreadable memory at virtual address 00000000000001e4 [ 2.522601] Call trace: [ 2.525040] regmap_read+0x1c/0x80 [ 2.528434] mt8173_afe_irq_handler+0x40/0xf0 ... [ 2.598921] start_kernel+0x338/0x42c
--- sound/soc/mediatek/mt8173/mt8173-afe-pcm.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
sound/soc/mediatek/mt8173/mt8173-afe-pcm.c +10 -10
@@ -1072,16 +1072,6 @@ static int mt8173_afe_pcm_dev_probe(struct platform_device *pdev) afe->dev = &pdev->dev; - irq_id =platform_get_irq (pdev,0 ); -if (irq_id <=0 ) -return irq_id <0 ? irq_id : -ENXIO ; - ret =devm_request_irq (afe->dev, irq_id, mt8173_afe_irq_handler, -0 ,"Afe_ISR_Handle" , (void *)afe); -if (ret) { -dev_err (afe->dev,"could not request_irq\n" ); -return ret; - } - afe->base_addr =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (afe->base_addr))return PTR_ERR (afe->base_addr);
@@ -1187,6 +1177,16 @@ static int mt8173_afe_pcm_dev_probe(struct platform_device *pdev)if (ret) goto err_cleanup_components; + irq_id =platform_get_irq (pdev,0 ); +if (irq_id <=0 ) +return irq_id <0 ? irq_id : -ENXIO ; + ret =devm_request_irq (afe->dev, irq_id, mt8173_afe_irq_handler, +0 ,"Afe_ISR_Handle" , (void *)afe); +if (ret) { +dev_err (afe->dev,"could not request_irq\n" ); + goto err_pm_disable; + } +dev_info (&pdev->dev,"MT8173 AFE driver initialized.\n" );return 0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 254/731 drm/amd/pm/smu11: BACO is supported when its in BACO state
In reply to Greg Kroah-HartmanFrom: Guchun Chen <[email protected]>
[ Upstream commit 6dca7efe6e522bf213c7dab691fa580d82f48f74 ]
Return true early if ASIC is in BACO state already, no need to talk to SMU. It can fix the issue that driver was not calling BACO exit at all in runtime pm resume, and a timing issue leading to a PCI AER error happened eventually.
--- drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +4 -0
@@ -1595,6 +1595,10 @@ bool smu_v11_0_baco_is_support(struct smu_context *smu)if (amdgpu_sriov_vf (smu->adev) || !smu_baco->platform_support)return false; +/* return true if ASIC is in BACO state already */ +if (smu_v11_0_baco_get_state (smu) ==SMU_BACO_STATE_ENTER ) +return true; +/* Arcturus does not support this bit mask */ if (smu_cmn_feature_is_supported (smu,SMU_FEATURE_BACO_BIT ) && !smu_cmn_feature_is_enabled (smu,SMU_FEATURE_BACO_BIT ))
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 255/731 drm/radeon: Fix PCI device refcount leak in radeon_atrm_get_bios()
In reply to Greg Kroah-HartmanFrom: Xiongfeng Wang <[email protected]>
[ Upstream commit 725a521a18734f65de05b8d353b5bd0d3ca4c37a ]
As comment of pci_get_class() says, it returns a pci_device with its refcount increased and decreased the refcount for the input parameter @from if it is not NULL.
If we break the loop in radeon_atrm_get_bios() with 'pdev' not NULL, we need to call pci_dev_put() to decrease the refcount. Add the missing pci_dev_put() to avoid refcount leak.
--- drivers/gpu/drm/radeon/radeon_bios.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/radeon/radeon_bios.c +1 -0
@@ -227,6 +227,7 @@ static bool radeon_atrm_get_bios(struct radeon_device *rdev)if (!found)return false; +pci_dev_put (pdev); rdev->bios =kmalloc (size,GFP_KERNEL );if (!rdev->bios) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 256/731 drm/amdgpu: Fix PCI device refcount leak in amdgpu_atrm_get_bios()
In reply to Greg Kroah-HartmanFrom: Xiongfeng Wang <[email protected]>
[ Upstream commit ca54639c7752edf1304d92ff4d0c049d4efc9ba0 ]
As comment of pci_get_class() says, it returns a pci_device with its refcount increased and decreased the refcount for the input parameter @from if it is not NULL.
If we break the loop in amdgpu_atrm_get_bios() with 'pdev' not NULL, we need to call pci_dev_put() to decrease the refcount. Add the missing pci_dev_put() to avoid refcount leak.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +1 -0
@@ -317,6 +317,7 @@ static bool amdgpu_atrm_get_bios(struct amdgpu_device *adev)if (!found)return false; +pci_dev_put (pdev); adev->bios =kmalloc (size,GFP_KERNEL );if (!adev->bios) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 257/731 drm/amdkfd: Fix memory leakage
In reply to Greg Kroah-HartmanFrom: Konstantin Meskhidze <[email protected]>
[ Upstream commit 75818afff631e1ea785a82c3e8bb82eb0dee539c ]
This patch fixes potential memory leakage and seg fault in _gpuvm_import_dmabuf() function
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -1
@@ -1910,7 +1910,7 @@ int amdgpu_amdkfd_gpuvm_import_dmabuf(struct kgd_dev *kgd, ret =drm_vma_node_allow (&obj->vma_node, drm_priv);if (ret) { -kfree (mem); +kfree (*mem);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 258/731 ASoC: pcm512x: Fix PM disable depth imbalance in pcm512x_probe
In reply to Greg Kroah-HartmanFrom: Zhang Qilong <[email protected]>
[ Upstream commit 97b801be6f8e53676b9f2b105f54e35c745c1b22 ]
The pm_runtime_enable will increase power disable depth. Thus a pairing decrement is needed on the error handling path to keep it balanced according to context. We fix it by going to err_pm instead of err_clk.
--- sound/soc/codecs/pcm512x.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/pcm512x.c +4 -4
@@ -1635,7 +1635,7 @@ int pcm512x_probe(struct device *dev, struct regmap *regmap)if (val >6 ) {dev_err (dev,"Invalid pll-in\n" ); ret = -EINVAL ; - goto err_clk; + goto err_pm; } pcm512x->pll_in = val; }
@@ -1644,7 +1644,7 @@ int pcm512x_probe(struct device *dev, struct regmap *regmap)if (val >6 ) {dev_err (dev,"Invalid pll-out\n" ); ret = -EINVAL ; - goto err_clk; + goto err_pm; } pcm512x->pll_out = val; }
@@ -1653,12 +1653,12 @@ int pcm512x_probe(struct device *dev, struct regmap *regmap)dev_err (dev,"Error: both pll-in and pll-out, or none\n" ); ret = -EINVAL ; - goto err_clk; + goto err_pm; }if (pcm512x->pll_in && pcm512x->pll_in == pcm512x->pll_out) {dev_err (dev,"Error: pll-in == pll-out\n" ); ret = -EINVAL ; - goto err_clk; + goto err_pm; } }#endif
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 259/731 netfilter: conntrack: set icmpv6 redirects as RELATED
In reply to Greg Kroah-HartmanFrom: Florian Westphal <[email protected]>
[ Upstream commit 7d7cfb48d81353e826493d24c7cec7360950968f ]
icmp conntrack will set icmp redirects as RELATED, but icmpv6 will not do this.
For icmpv6, only icmp errors (code <= 128) are examined for RELATED state. ICMPV6 Redirects are part of neighbour discovery mechanism, those are handled by marking a selected subset (e.g. neighbour solicitations) as UNTRACKED, but not REDIRECT -- they will thus be flagged as INVALID.
Add minimal support for REDIRECTs. No parsing of neighbour options is added for simplicity, so this will only check that we have the embeeded original header (ND_OPT_REDIRECT_HDR), and then attempt to do a flow lookup for this tuple.
Also extend the existing test case to cover redirects.
--- net/netfilter/nf_conntrack_proto_icmpv6.c | 53 +++++++++++++++++++ .../netfilter/conntrack_icmp_related.sh | 36 ++++++++++++- 2 files changed, 87 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_proto_icmpv6.c +53 -0
@@ -129,6 +129,56 @@ static void icmpv6_error_log(const struct sk_buff *skb,nf_l4proto_log_invalid (skb, state,IPPROTO_ICMPV6 ,"%s" , msg); } +static noinline_for_stack int +nf_conntrack_icmpv6_redirect (struct nf_conn *tmpl,struct sk_buff *skb, +unsigned int dataoff, +const struct nf_hook_state *state) +{ +u8 hl =ipv6_hdr (skb)->hop_limit; +union nf_inet_addr outer_daddr; +union { +struct nd_opt_hdr nd_opt; +struct rd_msg rd_msg; + } tmp; +const struct nd_opt_hdr *nd_opt; +const struct rd_msg *rd_msg; + + rd_msg =skb_header_pointer (skb, dataoff,sizeof (*rd_msg), &tmp.rd_msg); +if (!rd_msg) { +icmpv6_error_log (skb, state,"short redirect" ); +return -NF_ACCEPT ; + } + +if (rd_msg->icmph.icmp6_code !=0 ) +return NF_ACCEPT ; + +if (hl !=255 || !(ipv6_addr_type (&ipv6_hdr (skb)->saddr) &IPV6_ADDR_LINKLOCAL )) { +icmpv6_error_log (skb, state,"invalid saddr or hoplimit for redirect" ); +return -NF_ACCEPT ; + } + + dataoff +=sizeof (*rd_msg); + +/* warning: rd_msg no longer usable after this call */ + nd_opt =skb_header_pointer (skb, dataoff,sizeof (*nd_opt), &tmp.nd_opt); +if (!nd_opt || nd_opt->nd_opt_len ==0 ) { +icmpv6_error_log (skb, state,"redirect without options" ); +return -NF_ACCEPT ; + } + +/* We could call ndisc_parse_options(), but it would need +* skb_linearize() and a bit more work. +*/ +if (nd_opt->nd_opt_type !=ND_OPT_REDIRECT_HDR ) +return NF_ACCEPT ; + +memcpy (&outer_daddr.ip6, &ipv6_hdr (skb)->daddr, +sizeof (outer_daddr.ip6)); + dataoff +=8 ; +return nf_conntrack_inet_error (tmpl, skb, dataoff, state, +IPPROTO_ICMPV6 , &outer_daddr); +} + int nf_conntrack_icmpv6_error(struct nf_conn *tmpl, struct sk_buff *skb, unsigned int dataoff,
@@ -159,6 +209,9 @@ int nf_conntrack_icmpv6_error(struct nf_conn *tmpl,return NF_ACCEPT ; } +if (icmp6h->icmp6_type ==NDISC_REDIRECT ) +return nf_conntrack_icmpv6_redirect (tmpl, skb, dataoff, state); +/* is not error message ? */ if (icmp6h->icmp6_type >=128 )return NF_ACCEPT ;
tools/testing/selftests/netfilter/conntrack_icmp_related.sh +34 -2
@@ -35,6 +35,8 @@ cleanup() { for i in 1 2;do ip netns del nsrouter$i;done } +trap cleanup EXIT + ipv4() { echo -n 192.168.$1.2 }
@@ -146,11 +148,17 @@ ip netns exec nsclient1 nft -f - <<EOF table inet filter { counter unknown { } counter related { } + counter redir4 { } + counter redir6 { } chain input { type filter hook input priority 0; policy accept; - meta l4proto { icmp, icmpv6 } ct state established,untracked accept + icmp type "redirect" ct state "related" counter name "redir4" accept + icmpv6 type "nd-redirect" ct state "related" counter name "redir6" accept + + meta l4proto { icmp, icmpv6 } ct state established,untracked accept meta l4proto { icmp, icmpv6 } ct state "related" counter name "related" accept + counter name "unknown" drop } }
@@ -279,5 +287,29 @@ else echo "ERROR: icmp error RELATED state test has failed" fi -cleanup +# add 'bad' route, expect icmp REDIRECT to be generated +ip netns exec nsclient1 ip route add 192.168.1.42 via 192.168.1.1 +ip netns exec nsclient1 ip route add dead:1::42 via dead:1::1 + +ip netns exec "nsclient1" ping -q -c 2 192.168.1.42 > /dev/null + +expect="packets 1 bytes 112" +check_counter nsclient1 "redir4" "$expect" +if [ $? -ne 0 ];then + ret=1 +fi + +ip netns exec "nsclient1" ping -c 1 dead:1::42 > /dev/null +expect="packets 1 bytes 192" +check_counter nsclient1 "redir6" "$expect" +if [ $? -ne 0 ];then + ret=1 +fi + +if [ $ret -eq 0 ];then + echo "PASS: icmp redirects had RELATED state" +else + echo "ERROR: icmp redirect RELATED state test has failed" +fi + exit $ret
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 260/731 Input: wistron_btns - disable on UML
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit b2b80d9dd14cb5b70dc254bddbc4eea932694791 ]
The wistron_btns driver calls rtc_cmos_read(), which isn't available with UML builds, so disable this driver on UML.
Prevents this build error:
ld: drivers/input/misc/wistron_btns.o: in function `poll_bios':
wistron_btns.c:(.text+0x4be): undefined reference to `rtc_cmos_read'
--- drivers/input/misc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/misc/Kconfig +1 -1
@@ -330,7 +330,7 @@ config INPUT_CPCAP_PWRBUTTON config INPUT_WISTRON_BTNS tristate "x86 Wistron laptop button interface" - depends on X86_32 + depends on X86_32 && !UML select INPUT_SPARSEKMAP select NEW_LEDS select LEDS_CLASS
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 261/731 bpf, sockmap: Fix repeated calls to sock_put() when msg has more_data
In reply to Greg Kroah-HartmanFrom: Pengcheng Yang <[email protected]>
[ Upstream commit 7a9841ca025275b5b0edfb0b618934abb6ceec15 ]
In tcp_bpf_send_verdict() redirection, the eval variable is assigned to __SK_REDIRECT after the apply_bytes data is sent, if msg has more_data, sock_put() will be called multiple times.
We should reset the eval variable to __SK_NONE every time more_data starts.
This causes:
IPv4: Attempt to release TCP socket in state 1 00000000b4c925d7
------------[ cut here ]------------ refcount_t: addition on 0; use-after-free. WARNING: CPU: 5 PID: 4482 at lib/refcount.c:25 refcount_warn_saturate+0x7d/0x110 Modules linked in: CPU: 5 PID: 4482 Comm: sockhash_bypass Kdump: loaded Not tainted 6.0.0 #1 Hardware name: Red Hat KVM, BIOS 1.11.0-2.el7 04/01/2014 Call Trace: <TASK> __tcp_transmit_skb+0xa1b/0xb90 ? __alloc_skb+0x8c/0x1a0 ? __kmalloc_node_track_caller+0x184/0x320 tcp_write_xmit+0x22a/0x1110 __tcp_push_pending_frames+0x32/0xf0 do_tcp_sendpages+0x62d/0x640 tcp_bpf_push+0xae/0x2c0 tcp_bpf_sendmsg_redir+0x260/0x410 ? preempt_count_add+0x70/0xa0 tcp_bpf_send_verdict+0x386/0x4b0 tcp_bpf_sendmsg+0x21b/0x3b0 sock_sendmsg+0x58/0x70 __sys_sendto+0xfa/0x170 ? xfd_validate_state+0x1d/0x80 ? switch_fpu_return+0x59/0xe0 __x64_sys_sendto+0x24/0x30 do_syscall_64+0x37/0x90 entry_SYSCALL_64_after_hwframe+0x63/0xcd
--- net/ipv4/tcp_bpf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv4/tcp_bpf.c +2 -1
@@ -280,7 +280,7 @@ static int tcp_bpf_send_verdict(struct sock *sk, struct sk_psock *psock,bool cork = false, enospc =sk_msg_full (msg);struct sock *sk_redir;u32 tosend, origsize, sent, delta =0 ; -u32 eval = __SK_NONE; +u32 eval;int ret; more_data:
@@ -311,6 +311,7 @@ static int tcp_bpf_send_verdict(struct sock *sk, struct sk_psock *psock, tosend = msg->sg.size;if (psock->apply_bytes && psock->apply_bytes < tosend) tosend = psock->apply_bytes; + eval = __SK_NONE;switch (psock->eval) {case __SK_PASS:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 262/731 bpf, sockmap: Fix missing BPF_F_INGRESS flag when using apply_bytes
In reply to Greg Kroah-HartmanFrom: Pengcheng Yang <[email protected]>
[ Upstream commit a351d6087bf7d3d8440d58d3bf244ec64b89394a ]
When redirecting, we use sk_msg_to_ingress() to get the BPF_F_INGRESS flag from the msg->flags. If apply_bytes is used and it is larger than the current data being processed, sk_psock_msg_verdict() will not be called when sendmsg() is called again. At this time, the msg->flags is 0, and we lost the BPF_F_INGRESS flag.
So we need to save the BPF_F_INGRESS flag in sk_psock and use it when redirection.
--- include/linux/skmsg.h | 1 + include/net/tcp.h | 4 ++-- net/core/skmsg.c | 9 ++++++--- net/ipv4/tcp_bpf.c | 11 ++++++----- net/tls/tls_sw.c | 6 ++++-- 5 files changed, 19 insertions(+), 12 deletions(-)
include/linux/skmsg.h +1 -0
@@ -83,6 +83,7 @@ struct sk_psock {u32 apply_bytes;u32 cork_bytes;u32 eval; +bool redir_ingress;/* undefined if sk_redir is null */ struct sk_msg *cork;struct sk_psock_progs progs;#if IS_ENABLED (CONFIG_BPF_STREAM_PARSER )
include/net/tcp.h +2 -2
@@ -2243,8 +2243,8 @@ int tcp_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore);void tcp_bpf_clone (const struct sock *sk,struct sock *newsk);#endif /* CONFIG_BPF_SYSCALL */ -int tcp_bpf_sendmsg_redir (struct sock *sk,struct sk_msg *msg,u32 bytes, -int flags); +int tcp_bpf_sendmsg_redir (struct sock *sk,bool ingress, +struct sk_msg *msg,u32 bytes,int flags);#endif /* CONFIG_NET_SOCK_MSG */ #if !defined(CONFIG_BPF_SYSCALL ) || !defined(CONFIG_NET_SOCK_MSG )
net/core/skmsg.c +6 -3
@@ -880,13 +880,16 @@ int sk_psock_msg_verdict(struct sock *sk, struct sk_psock *psock, ret =sk_psock_map_verd (ret, msg->sk_redir); psock->apply_bytes = msg->apply_bytes;if (ret == __SK_REDIRECT) { -if (psock->sk_redir) +if (psock->sk_redir) {sock_put (psock->sk_redir); - psock->sk_redir = msg->sk_redir; -if (!psock->sk_redir) { + psock->sk_redir =NULL ; + } +if (!msg->sk_redir) { ret = __SK_DROP; goto out; } + psock->redir_ingress =sk_msg_to_ingress (msg); + psock->sk_redir = msg->sk_redir;sock_hold (psock->sk_redir); } out:
net/ipv4/tcp_bpf.c +6 -5
@@ -131,10 +131,9 @@ static int tcp_bpf_push_locked(struct sock *sk, struct sk_msg *msg,return ret; } -int tcp_bpf_sendmsg_redir (struct sock *sk,struct sk_msg *msg, -u32 bytes,int flags) +int tcp_bpf_sendmsg_redir (struct sock *sk,bool ingress, +struct sk_msg *msg,u32 bytes,int flags) { -bool ingress =sk_msg_to_ingress (msg);struct sk_psock *psock =sk_psock_get (sk);int ret;
@@ -277,7 +276,7 @@ static int tcp_bpf_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,static int tcp_bpf_send_verdict (struct sock *sk,struct sk_psock *psock,struct sk_msg *msg,int *copied,int flags) { -bool cork = false, enospc =sk_msg_full (msg); +bool cork = false, enospc =sk_msg_full (msg), redir_ingress;struct sock *sk_redir;u32 tosend, origsize, sent, delta =0 ;u32 eval;
@@ -323,6 +322,7 @@ static int tcp_bpf_send_verdict(struct sock *sk, struct sk_psock *psock,sk_msg_apply_bytes (psock, tosend);break ;case __SK_REDIRECT: + redir_ingress = psock->redir_ingress; sk_redir = psock->sk_redir;sk_msg_apply_bytes (psock, tosend);if (!psock->apply_bytes) {
@@ -339,7 +339,8 @@ static int tcp_bpf_send_verdict(struct sock *sk, struct sk_psock *psock,release_sock (sk); origsize = msg->sg.size; - ret =tcp_bpf_sendmsg_redir (sk_redir, msg, tosend, flags); + ret =tcp_bpf_sendmsg_redir (sk_redir, redir_ingress, + msg, tosend, flags); sent = origsize - msg->sg.size;if (eval == __SK_REDIRECT)
net/tls/tls_sw.c +4 -2
@@ -801,7 +801,7 @@ static int bpf_exec_tx_verdict(struct sk_msg *msg, struct sock *sk,struct sk_psock *psock;struct sock *sk_redir;struct tls_rec *rec; -bool enospc, policy; +bool enospc, policy, redir_ingress;int err =0 , send;u32 delta =0 ;
@@ -846,6 +846,7 @@ static int bpf_exec_tx_verdict(struct sk_msg *msg, struct sock *sk, }break ;case __SK_REDIRECT: + redir_ingress = psock->redir_ingress; sk_redir = psock->sk_redir;memcpy (&msg_redir, msg,sizeof (*msg));if (msg->apply_bytes < send)
@@ -855,7 +856,8 @@ static int bpf_exec_tx_verdict(struct sk_msg *msg, struct sock *sk,sk_msg_return_zero (sk, msg, send); msg->sg.size -= send;release_sock (sk); - err =tcp_bpf_sendmsg_redir (sk_redir, &msg_redir, send, flags); + err =tcp_bpf_sendmsg_redir (sk_redir, redir_ingress, + &msg_redir, send, flags);lock_sock (sk);if (err <0 ) { *copied -=sk_msg_free_nocharge (sk, &msg_redir);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 263/731 bpf, sockmap: Fix data loss caused by using apply_bytes on ingress redirect
In reply to Greg Kroah-HartmanFrom: Pengcheng Yang <[email protected]>
[ Upstream commit 9072931f020bfd907d6d89ee21ff1481cd78b407 ]
Use apply_bytes on ingress redirect, when apply_bytes is less than the length of msg data, some data may be skipped and lost in bpf_tcp_ingress().
If there is still data in the scatterlist that has not been consumed, we cannot move the msg iter.
--- net/ipv4/tcp_bpf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/ipv4/tcp_bpf.c +4 -1
@@ -45,8 +45,11 @@ static int bpf_tcp_ingress(struct sock *sk, struct sk_psock *psock, tmp->sg.end = i;if (apply) { apply_bytes -= size; -if (!apply_bytes) +if (!apply_bytes) { +if (sge->length) +sk_msg_iter_var_prev (i);break ; + } } }while (i != msg->sg.end);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 264/731 bonding: uninitialized variable in bond_miimon_inspect()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit e5214f363dabca240446272dac54d404501ad5e5 ]
The "ignore_updelay" variable needs to be initialized to false.
--- drivers/net/bonding/bond_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/bond_main.c +1 -1
@@ -2499,10 +2499,10 @@ static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *in/* called with rcu_read_lock() */ static int bond_miimon_inspect (struct bonding *bond) { +bool ignore_updelay = false;int link_state, commit =0 ;struct list_head *iter;struct slave *slave; -bool ignore_updelay;if (BOND_MODE (bond) ==BOND_MODE_ACTIVEBACKUP ) { ignore_updelay = !rcu_dereference (bond->curr_active_slave);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 265/731 spi: spidev: mask SPI_CS_HIGH in SPI_IOC_RD_MODE
In reply to Greg Kroah-HartmanFrom: Alexander Sverdlin <[email protected]>
[ Upstream commit 7dbfa445ff7393d1c4c066c1727c9e0af1251958 ]
Commit f3186dd87669 ("spi: Optionally use GPIO descriptors for CS GPIOs") has changed the user-space interface so that bogus SPI_CS_HIGH started to appear in the mask returned by SPI_IOC_RD_MODE even for active-low CS pins. Commit 138c9c32f090
("spi: spidev: Fix CS polarity if GPIO descriptors are used") fixed only SPI_IOC_WR_MODE part of the problem. Let's fix SPI_IOC_RD_MODE symmetrically.
Test case:
#include <sys/ioctl.h>
#include <fcntl.h>
#include <linux/spi/spidev.h>
int main(int argc, char **argv)
{
char modew = SPI_CPHA;
char moder;
int f = open("/dev/spidev0.0", O_RDWR);
if (f < 0)
return 1;
ioctl(f, SPI_IOC_WR_MODE, &modew);
ioctl(f, SPI_IOC_RD_MODE, &moder);
return moder == modew ? 0 : 2;
}--- drivers/spi/spidev.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-)
drivers/spi/spidev.c +16 -5
@@ -376,12 +376,23 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)switch (cmd) {/* read requests */ case SPI_IOC_RD_MODE : - retval =put_user (spi->mode &SPI_MODE_MASK , - (__u8 __user *)arg); -break ;case SPI_IOC_RD_MODE32 : - retval =put_user (spi->mode &SPI_MODE_MASK , - (__u32 __user *)arg); + tmp = spi->mode; + + { +struct spi_controller *ctlr = spi->controller; + +if (ctlr->use_gpio_descriptors && ctlr->cs_gpiods && + ctlr->cs_gpiods[spi->chip_select]) + tmp &= ~SPI_CS_HIGH ; + } + +if (cmd ==SPI_IOC_RD_MODE ) + retval =put_user (tmp &SPI_MODE_MASK , + (__u8 __user *)arg); +else + retval =put_user (tmp &SPI_MODE_MASK , + (__u32 __user *)arg);break ;case SPI_IOC_RD_LSB_FIRST : retval = put_user((spi->mode & SPI_LSB_FIRST) ? 1 : 0,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 266/731 wifi: mac80211: fix memory leak in ieee80211_if_add()
In reply to Greg Kroah-HartmanFrom: Zhengchao Shao <[email protected]>
[ Upstream commit 13e5afd3d773c6fc6ca2b89027befaaaa1ea7293 ]
When register_netdevice() failed in ieee80211_if_add(), ndev->tstats isn't released. Fix it.
--- net/mac80211/iface.c | 1 + 1 file changed, 1 insertion(+)
net/mac80211/iface.c +1 -0
@@ -2059,6 +2059,7 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name, ret =cfg80211_register_netdevice (ndev);if (ret) { +ieee80211_if_free (ndev);free_netdev (ndev);return ret; }
Signature · 1 line
2.35.1