6.0.16-rc1 review
Subsystems (13)
Greg Kroah-Hartman
maintainerPATCH 114/1073 lib/debugobjects: fix stat count and optimize debug_objects_mem_init
In reply to Greg Kroah-HartmanFrom: wuchi <[email protected]>
[ Upstream commit eabb7f1ace53e127309407b2b5e74e8199e85270 ]
1. Var debug_objects_allocated tracks valid kmem_cache_alloc calls, so track it in debug_objects_replace_static_objects. Do similar things in object_cpu_offline.
2. In debug_objects_mem_init, there is no need to call function cpuhp_setup_state_nocalls when debug_objects_enabled = 0 (out of memory).
--- lib/debugobjects.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
lib/debugobjects.c +10 -0
@@ -437,6 +437,7 @@ static int object_cpu_offline(unsigned int cpu)struct debug_percpu_free *percpu_pool;struct hlist_node *tmp;struct debug_obj *obj; +unsigned long flags;/* Remote access is safe as the CPU is dead already */ percpu_pool =per_cpu_ptr (&percpu_obj_pool, cpu);
@@ -444,6 +445,12 @@ static int object_cpu_offline(unsigned int cpu)hlist_del (&obj->node);kmem_cache_free (obj_cache, obj); } + +raw_spin_lock_irqsave (&pool_lock, flags); + obj_pool_used -= percpu_pool->obj_free; + debug_objects_freed += percpu_pool->obj_free; +raw_spin_unlock_irqrestore (&pool_lock, flags); + percpu_pool->obj_free =0 ;return 0 ;
@@ -1318,6 +1325,8 @@ static int __init debug_objects_replace_static_objects(void)hlist_add_head (&obj->node, &objects); } + debug_objects_allocated += i; +/* * debug_objects_mem_init() is now called early that only one CPU is up * and interrupts have been disabled, so it is safe to replace the
@@ -1386,6 +1395,7 @@ void __init debug_objects_mem_init(void) debug_objects_enabled =0 ;kmem_cache_destroy (obj_cache);pr_warn ("out of memory.\n" ); +return ; }else debug_objects_selftest ();
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 115/1073 platform/x86: huawei-wmi: fix return value calculation
In reply to Greg Kroah-HartmanFrom: Barnabás Pőcze <[email protected]>
[ Upstream commit 0b9a1dcdb6a2c841899389bf2dd7a3e0e2aa0e99 ]
Previously, huawei_wmi_input_setup() returned the result of logical or-ing the return values of two functions that return negative errno-style error codes and one that returns acpi_status. If this returned value was non-zero, then it was propagated from the platform driver's probe function. That function should return a negative errno-style error code, so the result of the logical or that huawei_wmi_input_setup() returned was not appropriate.
Fix that by checking each function separately and returning the error code unmodified.
--- drivers/platform/x86/huawei-wmi.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/platform/x86/huawei-wmi.c +16 -4
@@ -760,6 +760,9 @@ static int huawei_wmi_input_setup(struct device *dev,const char *guid, struct input_dev **idev) { + acpi_status status; +int err; + *idev =devm_input_allocate_device (dev);if (!*idev)return -ENOMEM ;
@@ -769,10 +772,19 @@ static int huawei_wmi_input_setup(struct device *dev, (*idev)->id.bustype =BUS_HOST ; (*idev)->dev.parent = dev; -return sparse_keymap_setup (*idev, huawei_wmi_keymap,NULL ) || -input_register_device (*idev) || -wmi_install_notify_handler (guid, huawei_wmi_input_notify, - *idev); + err =sparse_keymap_setup (*idev, huawei_wmi_keymap,NULL ); +if (err) +return err; + + err =input_register_device (*idev); +if (err) +return err; + + status =wmi_install_notify_handler (guid, huawei_wmi_input_notify, *idev); +if (ACPI_FAILURE (status)) +return -EIO ; + +return 0 ; }static void huawei_wmi_input_exit (struct device *dev,const char *guid)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 116/1073 timerqueue: Use rb_entry_safe() in timerqueue_getnext()
In reply to Greg Kroah-HartmanFrom: Barnabás Pőcze <[email protected]>
[ Upstream commit 2f117484329b233455ee278f2d9b0a4356835060 ]
When timerqueue_getnext() is called on an empty timer queue, it will use rb_entry() on a NULL pointer, which is invalid. Fix that by using rb_entry_safe() which handles NULL pointers.
This has not caused any issues so far because the offset of the rb_node member in timerqueue_node is 0, so rb_entry() is essentially a no-op.
--- include/linux/timerqueue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/timerqueue.h +1 -1
@@ -35,7 +35,7 @@ struct timerqueue_node *timerqueue_getnext(struct timerqueue_head *head) {struct rb_node *leftmost =rb_first_cached (&head->rb_root); - return rb_entry(leftmost, struct timerqueue_node, node); + return rb_entry_safe(leftmost, struct timerqueue_node, node); }static inline void timerqueue_init (struct timerqueue_node *node)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 117/1073 proc: fixup uptime selftest
In reply to Greg Kroah-HartmanFrom: Alexey Dobriyan <[email protected]>
[ Upstream commit 5cc81d5c81af0dee54da9a67a3ebe4be076a13db ]
syscall(3) returns -1 and sets errno on error, unlike "syscall" instruction.
Systems which have <= 32/64 CPUs are unaffected. Test won't bounce to all CPUs before completing if there are more of them.
--- tools/testing/selftests/proc/proc-uptime-002.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/proc/proc-uptime-002.c +2 -1
@@ -17,6 +17,7 @@// while shifting across CPUs. #undef NDEBUG#include <assert.h> +#include <errno.h> #include <unistd.h> #include <sys/syscall.h> #include <stdlib.h>
@@ -54,7 +55,7 @@ int main(void) len +=sizeof (unsigned long );free (m); m =malloc (len); - }while (sys_sched_getaffinity (0 , len, m) == -EINVAL ); + }while (sys_sched_getaffinity (0 , len, m) ==-1 && errno ==EINVAL ); fd =open ("/proc/uptime" ,O_RDONLY );assert (fd >=0 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 118/1073 lib/fonts: fix undefined behavior in bit shift for get_default_font
In reply to Greg Kroah-HartmanFrom: Gaosheng Cui <[email protected]>
[ Upstream commit 6fe888c4d2fb174408e4540bb2d5602b9f507f90 ]
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 lib/fonts/fonts.c:139:20 left shift of 1 by 31 places cannot be represented in type 'int' <TASK> dump_stack_lvl+0x7d/0xa5 dump_stack+0x15/0x1b ubsan_epilogue+0xe/0x4e __ubsan_handle_shift_out_of_bounds+0x1e7/0x20c get_default_font+0x1c7/0x1f0 fbcon_startup+0x347/0x3a0 do_take_over_console+0xce/0x270 do_fbcon_takeover+0xa1/0x170 do_fb_registered+0x2a8/0x340 fbcon_fb_registered+0x47/0xe0 register_framebuffer+0x294/0x4a0 __drm_fb_helper_initial_config_and_unlock+0x43c/0x880 [drm_kms_helper] drm_fb_helper_initial_config+0x52/0x80 [drm_kms_helper] drm_fbdev_client_hotplug+0x156/0x1b0 [drm_kms_helper] drm_fbdev_generic_setup+0xfc/0x290 [drm_kms_helper] bochs_pci_probe+0x6ca/0x772 [bochs] local_pci_probe+0x4d/0xb0 pci_device_probe+0x119/0x320 really_probe+0x181/0x550 __driver_probe_device+0xc6/0x220 driver_probe_device+0x32/0x100 __driver_attach+0x195/0x200 bus_for_each_dev+0xbb/0x120 driver_attach+0x27/0x30 bus_add_driver+0x22e/0x2f0 driver_register+0xa9/0x190 __pci_register_driver+0x90/0xa0 bochs_pci_driver_init+0x52/0x1000 [bochs] do_one_initcall+0x76/0x430 do_init_module+0x61/0x28a load_module+0x1f82/0x2e50 __do_sys_finit_module+0xf8/0x190 __x64_sys_finit_module+0x23/0x30 do_syscall_64+0x58/0x80 entry_SYSCALL_64_after_hwframe+0x63/0xcd </TASK>
--- lib/fonts/fonts.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/fonts/fonts.c +2 -2
@@ -135,8 +135,8 @@ const struct font_desc *get_default_font(int xres, int yres, u32 font_w,if (res >20 ) c +=20 - res; -if ((font_w & (1 << (f->width -1 ))) && - (font_h & (1 << (f->height -1 )))) +if ((font_w & (1U << (f->width -1 ))) && + (font_h & (1U << (f->height -1 )))) c +=1000 ;if (c > cc) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 119/1073 ocfs2: fix memory leak in ocfs2_stack_glue_init()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
[ Upstream commit 13b6269dd022aaa69ca8d1df374ab327504121cf ]
ocfs2_table_header should be free in ocfs2_stack_glue_init() if ocfs2_sysfs_init() failed, otherwise kmemleak will report memleak.
BUG: memory leak
unreferenced object 0xffff88810eeb5800 (size 128):
comm "modprobe", pid 4507, jiffies 4296182506 (age 55.888s)
hex dump (first 32 bytes):
c0 40 14 a0 ff ff ff ff 00 00 00 00 01 00 00 00 .@..............
01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<000000001e59e1cd>] __register_sysctl_table+0xca/0xef0
[<00000000c04f70f7>] 0xffffffffa0050037
[<000000001bd12912>] do_one_initcall+0xdb/0x480
[<0000000064f766c9>] do_init_module+0x1cf/0x680
[<000000002ba52db0>] load_module+0x6441/0x6f20
[<000000009772580d>] __do_sys_finit_module+0x12f/0x1c0
[<00000000380c1f22>] do_syscall_64+0x3f/0x90
[<000000004cf473bc>] entry_SYSCALL_64_after_hwframe+0x63/0xcd--- fs/ocfs2/stackglue.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
fs/ocfs2/stackglue.c +7 -1
@@ -669,6 +669,8 @@ static struct ctl_table_header *ocfs2_table_header;static int __init ocfs2_stack_glue_init (void ) { +int ret; +strcpy (cluster_stack_name,OCFS2_STACK_PLUGIN_O2CB ); ocfs2_table_header =register_sysctl ("fs/ocfs2/nm" , ocfs2_nm_table);
@@ -678,7 +680,11 @@ static int __init ocfs2_stack_glue_init(void)return -ENOMEM ;/* or something. */ } -return ocfs2_sysfs_init (); + ret =ocfs2_sysfs_init (); +if (ret) +unregister_sysctl_table (ocfs2_table_header); + +return ret; } static void __exit ocfs2_stack_glue_exit(void)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 120/1073 selftests: cgroup: fix unsigned comparison with less than zero
In reply to Greg Kroah-HartmanFrom: YueHaibing <[email protected]>
[ Upstream commit 333d073dee3a6865171d43e3b0a9ff688bff5891 ]
'size' is unsigned, it never less than zero.
--- tools/testing/selftests/cgroup/cgroup_util.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/testing/selftests/cgroup/cgroup_util.c +3 -2
@@ -555,6 +555,7 @@ int proc_mount_contains(const char *option)ssize_t proc_read_text (int pid,bool thread,const char *item,char *buf,size_t size) {char path[PATH_MAX ]; +ssize_t ret;if (!pid) snprintf(path, sizeof(path), "/proc/%s/%s",
@@ -562,8 +563,8 @@ ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, size_telse snprintf (path,sizeof (path),"/proc/%d/%s" , pid, item); - size =read_text (path, buf, size); -return size <0 ?-1 : size; + ret =read_text (path, buf, size); +return ret <0 ?-1 : ret; }int proc_read_strstr (int pid,bool thread,const char *item,const char *needle)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 121/1073 cpufreq: qcom-hw: Fix the frequency returned by cpufreq_driver->get()
In reply to Greg Kroah-HartmanFrom: Manivannan Sadhasivam <[email protected]>
[ Upstream commit c72cf0cb1d77f6b1b58c334dcc3d09fa13111c4c ]
The cpufreq_driver->get() callback is supposed to return the current frequency of the CPU and not the one requested by the CPUFreq core. Fix it by returning the frequency that gets supplied to the CPU after the DCVS operation of EPSS/OSM.
--- drivers/cpufreq/qcom-cpufreq-hw.c | 42 +++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 13 deletions(-)
drivers/cpufreq/qcom-cpufreq-hw.c +29 -13
@@ -122,7 +122,35 @@ static int qcom_cpufreq_hw_target_index(struct cpufreq_policy *policy,return 0 ; } +static unsigned long qcom_lmh_get_throttle_freq (struct qcom_cpufreq_data *data) +{ +unsigned int lval; + +if (data->soc_data->reg_current_vote) + lval =readl_relaxed (data->base + data->soc_data->reg_current_vote) &0x3ff ; +else + lval =readl_relaxed (data->base + data->soc_data->reg_domain_state) &0xff ; + +return lval * xo_rate; +} + +/* Get the current frequency of the CPU (after throttling) */ static unsigned int qcom_cpufreq_hw_get (unsigned int cpu) +{ +struct qcom_cpufreq_data *data; +struct cpufreq_policy *policy; + + policy =cpufreq_cpu_get_raw (cpu); +if (!policy) +return 0 ; + + data = policy->driver_data; + +return qcom_lmh_get_throttle_freq (data) /HZ_PER_KHZ ; +} + +/* Get the frequency requested by the cpufreq core for the CPU */ +static unsigned int qcom_cpufreq_get_freq (unsigned int cpu) {struct qcom_cpufreq_data *data;const struct qcom_cpufreq_soc_data *soc_data;
@@ -284,18 +312,6 @@ static void qcom_get_related_cpus(int index, struct cpumask *m) } } -static unsigned long qcom_lmh_get_throttle_freq (struct qcom_cpufreq_data *data) -{ -unsigned int lval; - -if (data->soc_data->reg_current_vote) - lval =readl_relaxed (data->base + data->soc_data->reg_current_vote) &0x3ff ; -else - lval =readl_relaxed (data->base + data->soc_data->reg_domain_state) &0xff ; - -return lval * xo_rate; -} -static void qcom_lmh_dcvs_notify (struct qcom_cpufreq_data *data) {struct cpufreq_policy *policy = data->policy;
@@ -337,7 +353,7 @@ static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data)* If h/w throttled frequency is higher than what cpufreq has requested * for, then stop polling and switch back to interrupt mechanism. */ -if (throttled_freq >=qcom_cpufreq_hw_get (cpu)) +if (throttled_freq >=qcom_cpufreq_get_freq (cpu))enable_irq (data->throttle_irq);else mod_delayed_work(system_highpri_wq, &data->throttle_work,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 122/1073 MIPS: vpe-mt: fix possible memory leak while module exiting
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 5822e8cc84ee37338ab0bdc3124f6eec04dc232d ]
Afer commit 1fa5ae857bb1 ("driver core: get rid of struct device's bus_id string array"), the name of device is allocated dynamically, it need be freed when module exiting, call put_device() to give up reference, so that it can be freed in kobject_cleanup() when the refcount hit to 0. The vpe_device is static, so remove kfree() from vpe_device_release().
--- arch/mips/kernel/vpe-mt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/kernel/vpe-mt.c +2 -2
@@ -313,7 +313,6 @@ ATTRIBUTE_GROUPS(vpe);static void vpe_device_release (struct device *cd) { -kfree (cd); }static struct class vpe_class = {
@@ -497,6 +496,7 @@ int __init vpe_module_init(void)device_del (&vpe_device); out_class: +put_device (&vpe_device);class_unregister (&vpe_class); out_chrdev:
@@ -509,7 +509,7 @@ void __exit vpe_module_exit(void) {struct vpe *v, *n; -device_del (&vpe_device); +device_unregister (&vpe_device);class_unregister (&vpe_class);unregister_chrdev (major,VPE_MODULE_NAME );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 123/1073 MIPS: vpe-cmp: fix possible memory leak while module exiting
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit c5ed1fe0801f0c66b0fbce2785239a5664629057 ]
dev_set_name() allocates memory for name, it need be freed when module exiting, call put_device() to give up reference, so that it can be freed in kobject_cleanup() when the refcount hit to 0. The vpe_device is static, so remove kfree() from vpe_device_release().
--- arch/mips/kernel/vpe-cmp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/kernel/vpe-cmp.c +2 -2
@@ -75,7 +75,6 @@ ATTRIBUTE_GROUPS(vpe);static void vpe_device_release (struct device *cd) { -kfree (cd); }static struct class vpe_class = {
@@ -157,6 +156,7 @@ int __init vpe_module_init(void)device_del (&vpe_device); out_class: +put_device (&vpe_device);class_unregister (&vpe_class); out_chrdev:
@@ -169,7 +169,7 @@ void __exit vpe_module_exit(void) {struct vpe *v, *n; -device_del (&vpe_device); +device_unregister (&vpe_device);class_unregister (&vpe_class);unregister_chrdev (major,VPE_MODULE_NAME );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 124/1073 selftests/efivarfs: Add checking of the test return value
In reply to Greg Kroah-HartmanFrom: Zhao Gongyi <[email protected]>
[ Upstream commit c93924267fe6f2b44af1849f714ae9cd8117a9cd ]
Add checking of the test return value, otherwise it will report success forever for test_create_read().
--- tools/testing/selftests/efivarfs/efivarfs.sh | 5 +++++ 1 file changed, 5 insertions(+)
tools/testing/selftests/efivarfs/efivarfs.sh +5 -0
@@ -87,6 +87,11 @@ test_create_read() { local file=$efivarfs_mount/$FUNCNAME-$test_guid ./create-read $file + if [ $? -ne 0 ]; then + echo "create and read $file failed" + file_cleanup $file + exit 1 + fi file_cleanup $file }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 125/1073 PNP: fix name memory leak in pnp_alloc_dev()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 110d7b0325c55ff3620073ba4201845f59e22ebf ]
After commit 1fa5ae857bb1 ("driver core: get rid of struct device's bus_id string array"), the name of device is allocated dynamically, move dev_set_name() after pnp_add_id() to avoid memory leak.
--- drivers/pnp/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pnp/core.c +2 -2
@@ -148,14 +148,14 @@ struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, dev->dev.coherent_dma_mask = dev->dma_mask; dev->dev.release = &pnp_release_device; -dev_set_name (&dev->dev,"%02x:%02x" , dev->protocol->number, dev->number); - dev_id =pnp_add_id (dev, pnpid);if (!dev_id) {kfree (dev);return NULL ; } +dev_set_name (&dev->dev,"%02x:%02x" , dev->protocol->number, dev->number); +return dev; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 126/1073 mailbox: pcc: Reset pcc_chan_count to zero in case of PCC probe failure
In reply to Greg Kroah-HartmanFrom: Huisong Li <[email protected]>
[ Upstream commit 6d7d3c287410c0ad499e478e2338dc3d7e3392b1 ]
Currently, 'pcc_chan_count' is remains set to a non-zero value if PCC subspaces are parsed successfully but something else fail later during the initial PCC probing phase. This will result in pcc_mbox_request_channel trying to access the resources that are not initialised or allocated and may end up in a system crash.
Reset pcc_chan_count to 0 when the PCC probe fails in order to prevent the possible issue as described above.
--- drivers/mailbox/pcc.c | 1 + 1 file changed, 1 insertion(+)
drivers/mailbox/pcc.c +1 -0
@@ -743,6 +743,7 @@ static int __init pcc_init(void)if (IS_ERR (pcc_pdev)) {pr_debug ("Err creating PCC platform bundle\n" ); + pcc_chan_count =0 ;return PTR_ERR (pcc_pdev); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 127/1073 ACPI: pfr_telemetry: use ACPI_FREE() to free acpi_object
In reply to Greg Kroah-HartmanFrom: Wang ShaoBo <[email protected]>
[ Upstream commit 0f2aa7fc2a9aee05bafb965d5b1638d3e74b4c61 ]
acpi_evaluate_dsm_typed()/acpi_evaluate_dsm() should be coupled with ACPI_FREE() to free the ACPI memory, because we need to track the allocation of acpi_object when ACPI_DBG_TRACK_ALLOCATIONS enabled, so use ACPI_FREE() instead of kfree().
--- drivers/acpi/pfr_telemetry.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/acpi/pfr_telemetry.c +3 -3
@@ -144,7 +144,7 @@ static int get_pfrt_log_data_info(struct pfrt_log_data_info *data_info, ret =0 ; free_acpi_buffer: -kfree (out_obj); +ACPI_FREE (out_obj);return ret; }
@@ -180,7 +180,7 @@ static int set_pfrt_log_level(int level, struct pfrt_log_device *pfrt_log_dev) ret = -EBUSY ; } -kfree (out_obj); +ACPI_FREE (out_obj);return ret; }
@@ -218,7 +218,7 @@ static int get_pfrt_log_level(struct pfrt_log_device *pfrt_log_dev) ret = obj->integer.value; free_acpi_buffer: -kfree (out_obj); +ACPI_FREE (out_obj);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 128/1073 ACPI: pfr_update: use ACPI_FREE() to free acpi_object
In reply to Greg Kroah-HartmanFrom: Wang ShaoBo <[email protected]>
[ Upstream commit e335beed78ec82656dcb554f9fe560709f0dc408 ]
acpi_evaluate_dsm_typed()/acpi_evaluate_dsm() should be coupled with ACPI_FREE() to free the ACPI memory, because we need to track the allocation of acpi_object when ACPI_DBG_TRACK_ALLOCATIONS enabled, so use ACPI_FREE() instead of kfree().
--- drivers/acpi/pfr_update.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/acpi/pfr_update.c +3 -3
@@ -178,7 +178,7 @@ static int query_capability(struct pfru_update_cap_info *cap_hdr, ret =0 ; free_acpi_buffer: -kfree (out_obj); +ACPI_FREE (out_obj);return ret; }
@@ -224,7 +224,7 @@ static int query_buffer(struct pfru_com_buf_info *info, ret =0 ; free_acpi_buffer: -kfree (out_obj); +ACPI_FREE (out_obj);return ret; }
@@ -385,7 +385,7 @@ static int start_update(int action, struct pfru_device *pfru_dev) ret =0 ; free_acpi_buffer: -kfree (out_obj); +ACPI_FREE (out_obj);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 129/1073 perf/x86/intel/uncore: Fix reference count leak in sad_cfg_iio_topology()
In reply to Greg Kroah-HartmanFrom: Xiongfeng Wang <[email protected]>
[ Upstream commit c508eb042d9739bf9473526f53303721b70e9100 ]
pci_get_device() will increase the reference count for the returned pci_dev, and also decrease the reference count for the input parameter *from* if it is not NULL.
If we break the loop in sad_cfg_iio_topology() with 'dev' not NULL. We need to call pci_dev_put() to decrease the reference count. Since pci_dev_put() can handle the NULL input parameter, we can just add one pci_dev_put() right before 'return ret'.
--- arch/x86/events/intel/uncore_snbep.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/events/intel/uncore_snbep.c +2 -0
@@ -4492,6 +4492,8 @@ static int sad_cfg_iio_topology(struct intel_uncore_type *type, u8 *sad_pmon_map type->topology =NULL ; } +pci_dev_put (dev); +return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 130/1073 perf/x86/intel/uncore: Fix reference count leak in hswep_has_limit_sbox()
In reply to Greg Kroah-HartmanFrom: Xiongfeng Wang <[email protected]>
[ Upstream commit 1ff9dd6e7071a561f803135c1d684b13c7a7d01d ]
pci_get_device() will increase the reference count for the returned 'dev'. We need to call pci_dev_put() to decrease the reference count. Since 'dev' is only used in pci_read_config_dword(), let's add pci_dev_put() right after it.
--- arch/x86/events/intel/uncore_snbep.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/events/intel/uncore_snbep.c +1 -0
@@ -2891,6 +2891,7 @@ static bool hswep_has_limit_sbox(unsigned int device)return false;pci_read_config_dword (dev,HSWEP_PCU_CAPID4_OFFET , &capid4); +pci_dev_put (dev);if (!hswep_get_chop (capid4))return true;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 131/1073 perf/x86/intel/uncore: Fix reference count leak in snr_uncore_mmio_map()
In reply to Greg Kroah-HartmanFrom: Xiongfeng Wang <[email protected]>
[ Upstream commit 8ebd16c11c346751b3944d708e6c181ed4746c39 ]
pci_get_device() will increase the reference count for the returned pci_dev, so snr_uncore_get_mc_dev() will return a pci_dev with its reference count increased. We need to call pci_dev_put() to decrease the reference count. Let's add the missing pci_dev_put().
--- arch/x86/events/intel/uncore_snbep.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/events/intel/uncore_snbep.c +2 -0
@@ -4860,6 +4860,8 @@ static int snr_uncore_mmio_map(struct intel_uncore_box *box, addr += box_ctl; +pci_dev_put (pdev); + box->io_addr =ioremap (addr, type->mmio_map_size);if (!box->io_addr) {pr_warn ("perf uncore: Failed to ioremap for %s.\n" , type->name);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 132/1073 perf/x86/intel/uncore: Fix reference count leak in __uncore_imc_init_box()
In reply to Greg Kroah-HartmanFrom: Xiongfeng Wang <[email protected]>
[ Upstream commit 17b8d847b92d815d1638f0de154654081d66b281 ]
pci_get_device() will increase the reference count for the returned pci_dev, so tgl_uncore_get_mc_dev() will return a pci_dev with its reference count increased. We need to call pci_dev_put() to decrease the reference count before exiting from __uncore_imc_init_box(). Add pci_dev_put() for both normal and error path.
--- arch/x86/events/intel/uncore_snb.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/events/intel/uncore_snb.c +3 -0
@@ -1338,6 +1338,7 @@ static void __uncore_imc_init_box(struct intel_uncore_box *box,/* MCHBAR is disabled */ if (!(mch_bar &BIT (0 ))) {pr_warn ("perf uncore: MCHBAR is disabled. Failed to map IMC free-running counters.\n" ); +pci_dev_put (pdev);return ; } mch_bar &= ~BIT (0 );
@@ -1352,6 +1353,8 @@ static void __uncore_imc_init_box(struct intel_uncore_box *box, box->io_addr =ioremap (addr, type->mmio_map_size);if (!box->io_addr)pr_warn ("perf uncore: Failed to ioremap for %s.\n" , type->name); + +pci_dev_put (pdev); }static void tgl_uncore_imc_freerunning_init_box (struct intel_uncore_box *box)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 133/1073 platform/chrome: cros_usbpd_notify: Fix error handling in cros_usbpd_notify_init()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit 5a2d96623670155d94aca72c320c0ac27bdc6bd2 ]
The following WARNING message was given when rmmod cros_usbpd_notify:
Unexpected driver unregister!
WARNING: CPU: 0 PID: 253 at drivers/base/driver.c:270 driver_unregister+0x8a/0xb0 Modules linked in: cros_usbpd_notify(-) CPU: 0 PID: 253 Comm: rmmod Not tainted 6.1.0-rc3 #24 ... Call Trace: <TASK> cros_usbpd_notify_exit+0x11/0x1e [cros_usbpd_notify] __x64_sys_delete_module+0x3c7/0x570 ? __ia32_sys_delete_module+0x570/0x570 ? lock_is_held_type+0xe3/0x140 ? syscall_enter_from_user_mode+0x17/0x50 ? rcu_read_lock_sched_held+0xa0/0xd0 ? syscall_enter_from_user_mode+0x1c/0x50 do_syscall_64+0x37/0x90 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f333fe9b1b7
The reason is that the cros_usbpd_notify_init() does not check the return value of platform_driver_register(), and the cros_usbpd_notify can install successfully even if platform_driver_register() failed.
Fix by checking the return value of platform_driver_register() and unregister cros_usbpd_notify_plat_driver when it failed.
--- drivers/platform/chrome/cros_usbpd_notify.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/platform/chrome/cros_usbpd_notify.c +5 -1
@@ -239,7 +239,11 @@ static int __init cros_usbpd_notify_init(void)return ret;#ifdef CONFIG_ACPI -platform_driver_register (&cros_usbpd_notify_acpi_driver); + ret =platform_driver_register (&cros_usbpd_notify_acpi_driver); +if (ret) { +platform_driver_unregister (&cros_usbpd_notify_plat_driver); +return ret; + }#endif return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 134/1073 thermal: core: fix some possible name leaks in error paths
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 4748f9687caaeefab8578285b97b2f30789fc4b4 ]
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/thermal/thermal_core.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/thermal/thermal_core.c +10 -8
@@ -903,10 +903,6 @@ __thermal_cooling_device_register(struct device_node *np, cdev->id = ret; id = ret; - ret =dev_set_name (&cdev->device,"cooling_device%d" , cdev->id); -if (ret) - goto out_ida_remove; - cdev->type =kstrdup (type ? type :"" ,GFP_KERNEL );if (!cdev->type) { ret = -ENOMEM ;
@@ -921,6 +917,11 @@ __thermal_cooling_device_register(struct device_node *np, cdev->device.class = &thermal_class; cdev->devdata = devdata;thermal_cooling_device_setup_sysfs (cdev); + ret =dev_set_name (&cdev->device,"cooling_device%d" , cdev->id); +if (ret) { +thermal_cooling_device_destroy_sysfs (cdev); + goto out_kfree_type; + } ret =device_register (&cdev->device);if (ret) goto out_kfree_type;
@@ -1241,10 +1242,6 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t tz->id = id;strlcpy (tz->type, type,sizeof (tz->type)); - result =dev_set_name (&tz->device,"thermal_zone%d" , tz->id); -if (result) - goto remove_id; -if (!ops->critical) ops->critical = thermal_zone_device_critical;
@@ -1267,6 +1264,11 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t/* A new thermal zone needs to be updated anyway. */ atomic_set (&tz->need_update,1 ); + result =dev_set_name (&tz->device,"thermal_zone%d" , tz->id); +if (result) { +thermal_zone_destroy_device_groups (tz); + goto remove_id; + } result =device_register (&tz->device);if (result) goto release_device;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 135/1073 irqchip/loongson-pch-pic: Fix translate callback for DT path
In reply to Greg Kroah-HartmanFrom: Jianmin Lv <[email protected]>
[ Upstream commit c7c00138015975c8f0e268564249cc47d8de632c ]
In DT path of translate callback, if fwspec->param_count==1 and of_node is non-null, fwspec->param[1] will be accessed, which is introduced from previous commit bcdd75c596c8 (irqchip/loongson-pch-pic: Add ACPI init support).
Before the patch, for non-null of_node, translate callback (use irq_domain_translate_twocell()) will return -EINVAL if fwspec->param_count < 2, so the check in the patch is added.
--- drivers/irqchip/irq-loongson-pch-pic.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/irqchip/irq-loongson-pch-pic.c +3 -0
@@ -159,6 +159,9 @@ static int pch_pic_domain_translate(struct irq_domain *d,return -EINVAL ;if (of_node) { +if (fwspec->param_count <2 ) +return -EINVAL ; + *hwirq = fwspec->param[0 ] + priv->ht_vec_base; *type = fwspec->param[1 ] &IRQ_TYPE_SENSE_MASK ; }else {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 136/1073 irqchip: gic-pm: Use pm_runtime_resume_and_get() in gic_probe()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
[ Upstream commit f9ee20c85b3a3ba0afd3672630ec4f93d339f015 ]
gic_probe() calls pm_runtime_get_sync() and added fail path as rpm_put to put usage_counter. However, pm_runtime_get_sync() will increment usage_counter even it failed. Fix it by replacing it with pm_runtime_resume_and_get() to keep usage counter balanced.
--- drivers/irqchip/irq-gic-pm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic-pm.c +1 -1
@@ -102,7 +102,7 @@ static int gic_probe(struct platform_device *pdev)pm_runtime_enable (dev); - ret =pm_runtime_get_sync (dev); + ret =pm_runtime_resume_and_get (dev);if (ret <0 ) goto rpm_disable;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 137/1073 irqchip/wpcm450: Fix memory leak in wpcm450_aic_of_init()
In reply to Greg Kroah-HartmanFrom: Wei Yongjun <[email protected]>
[ Upstream commit 4208d4faf36573a507b5e5de17abe342e9276759 ]
If of_iomap() failed, 'aic' should be freed before return. Otherwise there is a memory leak.
--- drivers/irqchip/irq-wpcm450-aic.c | 1 + 1 file changed, 1 insertion(+)
drivers/irqchip/irq-wpcm450-aic.c +1 -0
@@ -146,6 +146,7 @@ static int __init wpcm450_aic_of_init(struct device_node *node, aic->regs =of_iomap (node,0 );if (!aic->regs) {pr_err ("Failed to map WPCM450 AIC registers\n" ); +kfree (aic);return -ENOMEM ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 138/1073 irqchip/loongson-liointc: Fix improper error handling in liointc_init()
In reply to Greg Kroah-HartmanFrom: Liu Peibao <[email protected]>
[ Upstream commit 4a60a3cdcf1875c965095eb9e22c3d12bbc5a53d ]
For cores less than 4, eg, loongson2k1000 with 2 cores, the of_property_match_string() may return with an error value, which causes that liointc could not work. At least isr0 is what should be checked like previous commit b2c4c3969fd7 ("irqchip/loongson-liointc: irqchip add 2.0 version") did.
--- drivers/irqchip/irq-loongson-liointc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/irqchip/irq-loongson-liointc.c +4 -1
@@ -207,10 +207,13 @@ static int liointc_init(phys_addr_t addr, unsigned long size, int revision, "reg-names", core_reg_names[i]);if (index <0 ) - goto out_iounmap; +continue ; priv->core_isr[i] =of_iomap (node, index); } + +if (!priv->core_isr[0 ]) + goto out_iounmap; }/* Setup IRQ domain */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 139/1073 EDAC/i10nm: fix refcount leak in pci_get_dev_wrapper()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 9c8921555907f4d723f01ed2d859b66f2d14f08e ]
As the comment of pci_get_domain_bus_and_slot() says, it returns a PCI device with refcount incremented, so it doesn't need to call an extra pci_dev_get() in pci_get_dev_wrapper(), and the PCI device needs to be put in the error path.
--- drivers/edac/i10nm_base.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/edac/i10nm_base.c +1 -2
@@ -198,11 +198,10 @@ static struct pci_dev *pci_get_dev_wrapper(int dom, unsigned int bus,if (unlikely (pci_enable_device (pdev) <0 )) {edac_dbg (2 ,"Failed to enable device %02x:%02x.%x\n" , bus, dev, fun); +pci_dev_put (pdev);return NULL ; } -pci_dev_get (pdev); -return pdev; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 140/1073 NFSD: Finish converting the NFSv2 GETACL result encoder
In reply to Greg Kroah-HartmanFrom: Chuck Lever <[email protected]>
[ Upstream commit ea5021e911d3479346a75ac9b7d9dcd751b0fb99 ]
The xdr_stream conversion inadvertently left some code that set the page_len of the send buffer. The XDR stream encoders should handle this automatically now.
This oversight adds garbage past the end of the Reply message. Clients typically ignore the garbage, but NFSD does not need to send it, as it leaks stale memory contents onto the wire.
--- fs/nfsd/nfs2acl.c | 10 ---------- 1 file changed, 10 deletions(-)
fs/nfsd/nfs2acl.c +0 -10
@@ -246,7 +246,6 @@ nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr)struct nfsd3_getaclres *resp = rqstp->rq_resp;struct dentry *dentry = resp->fh.fh_dentry;struct inode *inode; -int w;if (!svcxdr_encode_stat (xdr, resp->status))return false;
@@ -260,15 +259,6 @@ nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr)if (xdr_stream_encode_u32 (xdr, resp->mask) <0 )return false; - rqstp->rq_res.page_len = w =nfsacl_size ( - (resp->mask &NFS_ACL ) ? resp->acl_access :NULL , - (resp->mask &NFS_DFACL ) ? resp->acl_default :NULL ); -while (w >0 ) { -if (!*(rqstp->rq_next_page++)) -return true; - w -=PAGE_SIZE ; - } -if (!nfs_stream_encode_acl (xdr, inode, resp->acl_access, resp->mask &NFS_ACL ,0 ))return false;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 141/1073 NFSD: Finish converting the NFSv3 GETACL result encoder
In reply to Greg Kroah-HartmanFrom: Chuck Lever <[email protected]>
[ Upstream commit 841fd0a3cb490eae5dfd262eccb8c8b11d57f8b8 ]
For some reason, the NFSv2 GETACL result encoder was fully converted to use the new nfs_stream_encode_acl(), but the NFSv3 equivalent was not similarly converted.
--- fs/nfsd/nfs3acl.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-)
fs/nfsd/nfs3acl.c +6 -24
@@ -171,11 +171,7 @@ nfs3svc_encode_getaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr) {struct nfsd3_getaclres *resp = rqstp->rq_resp;struct dentry *dentry = resp->fh.fh_dentry; -struct kvec *head = rqstp->rq_res.head;struct inode *inode; -unsigned int base; -int n; -int w;if (!svcxdr_encode_nfsstat3 (xdr, resp->status))return false;
@@ -187,26 +183,12 @@ nfs3svc_encode_getaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr)if (xdr_stream_encode_u32 (xdr, resp->mask) <0 )return false; - base = (char *)xdr->p - (char *)head->iov_base; - - rqstp->rq_res.page_len = w =nfsacl_size ( - (resp->mask &NFS_ACL ) ? resp->acl_access :NULL , - (resp->mask &NFS_DFACL ) ? resp->acl_default :NULL ); -while (w >0 ) { -if (!*(rqstp->rq_next_page++)) -return false; - w -=PAGE_SIZE ; - } - - n =nfsacl_encode (&rqstp->rq_res, base, inode, - resp->acl_access, - resp->mask &NFS_ACL ,0 ); -if (n >0 ) - n =nfsacl_encode (&rqstp->rq_res, base + n, inode, - resp->acl_default, - resp->mask &NFS_DFACL , -NFS_ACL_DEFAULT ); -if (n <=0 ) +if (!nfs_stream_encode_acl (xdr, inode, resp->acl_access, + resp->mask &NFS_ACL ,0 )) +return false; +if (!nfs_stream_encode_acl (xdr, inode, resp->acl_default, + resp->mask &NFS_DFACL , +NFS_ACL_DEFAULT ))return false;break ;default :
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 142/1073 nfsd: dont call nfsd_file_put from client states seqfile display
In reply to Greg Kroah-HartmanFrom: Jeff Layton <[email protected]>
[ Upstream commit e0aa651068bfd520afcd357af8ecd2de005fc83d ]
We had a report of this:
BUG: sleeping function called from invalid context at fs/nfsd/filecache.c:440
...with a stack trace showing nfsd_file_put being called from nfs4_show_open. This code has always tried to call fput while holding a spinlock, but we recently changed this to use the filecache, and that started triggering the might_sleep() in nfsd_file_put.
states_start takes and holds the cl_lock while iterating over the client's states, and we can't sleep with that held.
Have the various nfs4_show_* functions instead hold the fi_lock instead of taking a nfsd_file reference.
--- fs/nfsd/nfs4state.c | 51 +++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 18 deletions(-)
fs/nfsd/nfs4state.c +33 -18
@@ -664,15 +664,26 @@ find_any_file(struct nfs4_file *f)return ret; } -static struct nfsd_file *find_deleg_file (struct nfs4_file *f) +static struct nfsd_file *find_any_file_locked (struct nfs4_file *f) { -struct nfsd_file *ret =NULL ; +lockdep_assert_held (&f->fi_lock); + +if (f->fi_fds[O_RDWR ]) +return f->fi_fds[O_RDWR ]; +if (f->fi_fds[O_WRONLY ]) +return f->fi_fds[O_WRONLY ]; +if (f->fi_fds[O_RDONLY ]) +return f->fi_fds[O_RDONLY ]; +return NULL ; +} + +static struct nfsd_file *find_deleg_file_locked (struct nfs4_file *f) +{ +lockdep_assert_held (&f->fi_lock); -spin_lock (&f->fi_lock);if (f->fi_deleg_file) - ret =nfsd_file_get (f->fi_deleg_file); -spin_unlock (&f->fi_lock); -return ret; +return f->fi_deleg_file; +return NULL ; }static atomic_long_t num_delegations;
@@ -2606,9 +2617,11 @@ static int nfs4_show_open(struct seq_file *s, struct nfs4_stid *st) ols =openlockstateid (st); oo = ols->st_stateowner; nf = st->sc_file; - file =find_any_file (nf); + +spin_lock (&nf->fi_lock); + file =find_any_file_locked (nf);if (!file) -return 0 ; + goto out;seq_printf (s,"- " );nfs4_show_stateid (s, &st->sc_stateid);
@@ -2630,8 +2643,8 @@ static int nfs4_show_open(struct seq_file *s, struct nfs4_stid *st)seq_printf (s,", " );nfs4_show_owner (s, oo);seq_printf (s," }\n" ); -nfsd_file_put (file); - +out: +spin_unlock (&nf->fi_lock);return 0 ; }
@@ -2645,9 +2658,10 @@ static int nfs4_show_lock(struct seq_file *s, struct nfs4_stid *st) ols =openlockstateid (st); oo = ols->st_stateowner; nf = st->sc_file; - file =find_any_file (nf); +spin_lock (&nf->fi_lock); + file =find_any_file_locked (nf);if (!file) -return 0 ; + goto out;seq_printf (s,"- " );nfs4_show_stateid (s, &st->sc_stateid);
@@ -2667,8 +2681,8 @@ static int nfs4_show_lock(struct seq_file *s, struct nfs4_stid *st)seq_printf (s,", " );nfs4_show_owner (s, oo);seq_printf (s," }\n" ); -nfsd_file_put (file); - +out: +spin_unlock (&nf->fi_lock);return 0 ; }
@@ -2680,9 +2694,10 @@ static int nfs4_show_deleg(struct seq_file *s, struct nfs4_stid *st) ds =delegstateid (st); nf = st->sc_file; - file =find_deleg_file (nf); +spin_lock (&nf->fi_lock); + file =find_deleg_file_locked (nf);if (!file) -return 0 ; + goto out;seq_printf (s,"- " );nfs4_show_stateid (s, &st->sc_stateid);
@@ -2698,8 +2713,8 @@ static int nfs4_show_deleg(struct seq_file *s, struct nfs4_stid *st)seq_printf (s,", " );nfs4_show_fname (s, file);seq_printf (s," }\n" ); -nfsd_file_put (file); - +out: +spin_unlock (&nf->fi_lock);return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 143/1073 genirq/irqdesc: Dont try to remove non-existing sysfs files
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 9049e1ca41983ab773d7ea244bee86d7835ec9f5 ]
Fault injection tests trigger warnings like this:
kernfs: can not remove 'chip_name', no directory
WARNING: CPU: 0 PID: 253 at fs/kernfs/dir.c:1616 kernfs_remove_by_name_ns+0xce/0xe0 RIP: 0010:kernfs_remove_by_name_ns+0xce/0xe0 Call Trace: <TASK> remove_files.isra.1+0x3f/0xb0 sysfs_remove_group+0x68/0xe0 sysfs_remove_groups+0x41/0x70 __kobject_del+0x45/0xc0 kobject_del+0x29/0x40 free_desc+0x42/0x70 irq_free_descs+0x5e/0x90
The reason is that the interrupt descriptor sysfs handling does not roll back on a failing kobject_add() during allocation. If the descriptor is freed later on, kobject_del() is invoked with a not added kobject resulting in the above warnings.
A proper rollback in case of a kobject_add() failure would be the straight forward solution. But this is not possible due to the way how interrupt descriptor sysfs handling works.
Interrupt descriptors are allocated before sysfs becomes available. So the sysfs files for the early allocated descriptors are added later in the boot process. At this point there can be nothing useful done about a failing kobject_add(). For consistency the interrupt descriptor allocation always treats kobject_add() failures as non-critical and just emits a warning.
To solve this problem, keep track in the interrupt descriptor whether kobject_add() was successful or not and make the invocation of kobject_del() conditional on that.
[ tglx: Massage changelog, comments and use a state bit. ]
--- kernel/irq/internals.h | 2 ++ kernel/irq/irqdesc.c | 15 +++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-)
kernel/irq/internals.h +2 -0
@@ -52,6 +52,7 @@ enum {* IRQS_PENDING - irq is pending and replayed later * IRQS_SUSPENDED - irq is suspended * IRQS_NMI - irq line is used to deliver NMIs +* IRQS_SYSFS - descriptor has been added to sysfs */ enum {IRQS_AUTODETECT =0x00000001 ,
@@ -64,6 +65,7 @@ enum {IRQS_SUSPENDED =0x00000800 ,IRQS_TIMINGS =0x00001000 ,IRQS_NMI =0x00002000 , + IRQS_SYSFS = 0x00004000, };#include "debug.h"
kernel/irq/irqdesc.c +9 -6
@@ -288,22 +288,25 @@ static void irq_sysfs_add(int irq, struct irq_desc *desc)if (irq_kobj_base) {/* * Continue even in case of failure as this is nothing -* crucial. +* crucial and failures in the late irq_sysfs_init() +* cannot be rolled back. */ if (kobject_add (&desc->kobj, irq_kobj_base,"%d" , irq))pr_warn ("Failed to add kobject for irq %d\n" , irq); +else + desc->istate |=IRQS_SYSFS ; } }static void irq_sysfs_del (struct irq_desc *desc) {/* -* If irq_sysfs_init() has not yet been invoked (early boot), then -* irq_kobj_base is NULL and the descriptor was never added. -* kobject_del() complains about a object with no parent, so make -* it conditional. +* Only invoke kobject_del() when kobject_add() was successfully +* invoked for the descriptor. This covers both early boot, where +* sysfs is not initialized yet, and the case of a failed +* kobject_add() invocation. */ -if (irq_kobj_base) +if (desc->istate &IRQS_SYSFS )kobject_del (&desc->kobj); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 144/1073 cpufreq: amd_freq_sensitivity: Add missing pci_dev_put()
In reply to Greg Kroah-HartmanFrom: Xiongfeng Wang <[email protected]>
[ Upstream commit 91fda1f88c0968f1491ab150bb01690525af150a ]
pci_get_device() will increase the reference count for the returned pci_dev. We need to use pci_dev_put() to decrease the reference count after using pci_get_device(). Let's add it.
--- drivers/cpufreq/amd_freq_sensitivity.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/cpufreq/amd_freq_sensitivity.c +2 -0
@@ -125,6 +125,8 @@ static int __init amd_freq_sensitivity_init(void)if (!pcidev) {if (!boot_cpu_has (X86_FEATURE_PROC_FEEDBACK ))return -ENODEV ; + }else { +pci_dev_put (pcidev); }if (rdmsrl_safe (MSR_AMD64_FREQ_SENSITIVITY_ACTUAL , &val))
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 145/1073 libfs: add DEFINE_SIMPLE_ATTRIBUTE_SIGNED for signed value
In reply to Greg Kroah-HartmanFrom: Akinobu Mita <[email protected]>
[ Upstream commit 2e41f274f9aa71cdcc69dc1f26a3f9304a651804 ]
Patch series "fix error when writing negative value to simple attribute files".
The simple attribute files do not accept a negative value since the commit 488dac0c9237 ("libfs: fix error cast of negative value in simple_attr_write()"), but some attribute files want to accept a negative value.
This patch (of 3):
The simple attribute files do not accept a negative value since the commit 488dac0c9237 ("libfs: fix error cast of negative value in simple_attr_write()"), so we have to use a 64-bit value to write a negative value.
This adds DEFINE_SIMPLE_ATTRIBUTE_SIGNED for a signed value.
--- fs/libfs.c | 22 +++++++++++++++++++--- include/linux/fs.h | 12 ++++++++++-- 2 files changed, 29 insertions(+), 5 deletions(-)
fs/libfs.c +19 -3
@@ -994,8 +994,8 @@ ssize_t simple_attr_read(struct file *file, char __user *buf,EXPORT_SYMBOL_GPL (simple_attr_read);/* interpret the buffer as a number to call the set function with */ -ssize_t simple_attr_write (struct file *file,const char __user *buf, -size_t len,loff_t *ppos) +static ssize_t simple_attr_write_xsigned (struct file *file,const char __user *buf, +size_t len,loff_t *ppos,bool is_signed) {struct simple_attr *attr;unsigned long long val;
@@ -1016,7 +1016,10 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf, goto out; attr->set_buf[size] ='\0' ; - ret =kstrtoull (attr->set_buf,0 , &val); +if (is_signed) + ret =kstrtoll (attr->set_buf,0 , &val); +else + ret =kstrtoull (attr->set_buf,0 , &val);if (ret) goto out; ret = attr->set (attr->data, val);
@@ -1026,8 +1029,21 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf,mutex_unlock (&attr->mutex);return ret; } + +ssize_t simple_attr_write (struct file *file,const char __user *buf, +size_t len,loff_t *ppos) +{ +return simple_attr_write_xsigned (file, buf, len, ppos, false); +}EXPORT_SYMBOL_GPL (simple_attr_write); +ssize_t simple_attr_write_signed (struct file *file,const char __user *buf, +size_t len,loff_t *ppos) +{ +return simple_attr_write_xsigned (file, buf, len, ppos, true); +} +EXPORT_SYMBOL_GPL (simple_attr_write_signed); +/** * generic_fh_to_dentry - generic helper for the fh_to_dentry export operation * @sb: filesystem to do the file handle conversion on
include/linux/fs.h +10 -2
@@ -3480,7 +3480,7 @@ void simple_transaction_set(struct file *file, size_t n);* All attributes contain a text representation of a numeric value * that are accessed with the get() and set() functions. */ -#define DEFINE_SIMPLE_ATTRIBUTE (__fops, __get, __set, __fmt) \ +#define DEFINE_SIMPLE_ATTRIBUTE_XSIGNED (__fops, __get, __set, __fmt, __is_signed) \ static int __fops ## _open(struct inode *inode, struct file *file) \ { \ __simple_attr_check_format(__fmt, 0ull); \
@@ -3491,10 +3491,16 @@ static const struct file_operations __fops = { \ .open = __fops ## _open, \ .release = simple_attr_release, \ .read = simple_attr_read, \ - .write = simple_attr_write, \ + .write = (__is_signed) ? simple_attr_write_signed : simple_attr_write, \ .llseek = generic_file_llseek, \ } +#define DEFINE_SIMPLE_ATTRIBUTE (__fops, __get, __set, __fmt) \ + DEFINE_SIMPLE_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, false) + +#define DEFINE_SIMPLE_ATTRIBUTE_SIGNED (__fops, __get, __set, __fmt) \ + DEFINE_SIMPLE_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, true) + static inline __printf(1, 2) void __simple_attr_check_format(const char *fmt, ...) {
@@ -3509,6 +3515,8 @@ ssize_t simple_attr_read(struct file *file, char __user *buf, size_t len, loff_t *ppos);ssize_t simple_attr_write (struct file *file,const char __user *buf,size_t len,loff_t *ppos); +ssize_t simple_attr_write_signed (struct file *file,const char __user *buf, +size_t len,loff_t *ppos);struct ctl_table ;int __init list_bdev_fs_names (char *buf,size_t size);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 146/1073 lib/notifier-error-inject: fix error when writing -errno to debugfs file
In reply to Greg Kroah-HartmanFrom: Akinobu Mita <[email protected]>
[ Upstream commit f883c3edd2c432a2931ec8773c70a570115a50fe ]
The simple attribute files do not accept a negative value since the commit 488dac0c9237 ("libfs: fix error cast of negative value in simple_attr_write()").
This restores the previous behaviour by using newly introduced DEFINE_SIMPLE_ATTRIBUTE_SIGNED instead of DEFINE_SIMPLE_ATTRIBUTE.
--- lib/notifier-error-inject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/notifier-error-inject.c +1 -1
@@ -15,7 +15,7 @@ static int debugfs_errno_get(void *data, u64 *val)return 0 ; } -DEFINE_SIMPLE_ATTRIBUTE (fops_errno, debugfs_errno_get, debugfs_errno_set, +DEFINE_SIMPLE_ATTRIBUTE_SIGNED (fops_errno, debugfs_errno_get, debugfs_errno_set,"%lld\n" ); static struct dentry *debugfs_create_errno(const char *name, umode_t mode,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 147/1073 debugfs: fix error when writing negative value to atomic_t debugfs file
In reply to Greg Kroah-HartmanFrom: Akinobu Mita <[email protected]>
[ Upstream commit d472cf797c4e268613dbce5ec9b95d0bcae19ecb ]
The simple attribute files do not accept a negative value since the commit 488dac0c9237 ("libfs: fix error cast of negative value in simple_attr_write()"), so we have to use a 64-bit value to write a negative value for a debugfs file created by debugfs_create_atomic_t().
This restores the previous behaviour by introducing DEFINE_DEBUGFS_ATTRIBUTE_SIGNED for a signed value.
--- .../fault-injection/fault-injection.rst | 10 +++---- fs/debugfs/file.c | 28 +++++++++++++++---- include/linux/debugfs.h | 19 +++++++++++-- 3 files changed, 43 insertions(+), 14 deletions(-)
Documentation/fault-injection/fault-injection.rst +4 -6
@@ -83,9 +83,7 @@ configuration of fault-injection capabilities. - /sys/kernel/debug/fail*/times: specifies how many times failures may happen at most. A value of -1 - means "no limit". Note, though, that this file only accepts unsigned - values. So, if you want to specify -1, you better use 'printf' instead - of 'echo', e.g.: $ printf %#x -1 > times + means "no limit". - /sys/kernel/debug/fail*/space:
@@ -284,7 +282,7 @@ Application Examples echo Y > /sys/kernel/debug/$FAILTYPE/task-filter echo 10 > /sys/kernel/debug/$FAILTYPE/probability echo 100 > /sys/kernel/debug/$FAILTYPE/interval - printf %#x -1 > /sys/kernel/debug/$FAILTYPE/times + echo -1 > /sys/kernel/debug/$FAILTYPE/times echo 0 > /sys/kernel/debug/$FAILTYPE/space echo 2 > /sys/kernel/debug/$FAILTYPE/verbose echo Y > /sys/kernel/debug/$FAILTYPE/ignore-gfp-wait
@@ -338,7 +336,7 @@ Application Examples echo N > /sys/kernel/debug/$FAILTYPE/task-filter echo 10 > /sys/kernel/debug/$FAILTYPE/probability echo 100 > /sys/kernel/debug/$FAILTYPE/interval - printf %#x -1 > /sys/kernel/debug/$FAILTYPE/times + echo -1 > /sys/kernel/debug/$FAILTYPE/times echo 0 > /sys/kernel/debug/$FAILTYPE/space echo 2 > /sys/kernel/debug/$FAILTYPE/verbose echo Y > /sys/kernel/debug/$FAILTYPE/ignore-gfp-wait
@@ -369,7 +367,7 @@ Application Examples echo N > /sys/kernel/debug/$FAILTYPE/task-filter echo 100 > /sys/kernel/debug/$FAILTYPE/probability echo 0 > /sys/kernel/debug/$FAILTYPE/interval - printf %#x -1 > /sys/kernel/debug/$FAILTYPE/times + echo -1 > /sys/kernel/debug/$FAILTYPE/times echo 0 > /sys/kernel/debug/$FAILTYPE/space echo 1 > /sys/kernel/debug/$FAILTYPE/verbose
fs/debugfs/file.c +22 -6
@@ -378,8 +378,8 @@ ssize_t debugfs_attr_read(struct file *file, char __user *buf, }EXPORT_SYMBOL_GPL (debugfs_attr_read); -ssize_t debugfs_attr_write (struct file *file,const char __user *buf, -size_t len,loff_t *ppos) +static ssize_t debugfs_attr_write_xsigned (struct file *file,const char __user *buf, +size_t len,loff_t *ppos,bool is_signed) {struct dentry *dentry =F_DENTRY (file);ssize_t ret;
@@ -387,12 +387,28 @@ ssize_t debugfs_attr_write(struct file *file, const char __user *buf, ret =debugfs_file_get (dentry);if (unlikely (ret))return ret; - ret =simple_attr_write (file, buf, len, ppos); +if (is_signed) + ret =simple_attr_write_signed (file, buf, len, ppos); +else + ret =simple_attr_write (file, buf, len, ppos);debugfs_file_put (dentry);return ret; } + +ssize_t debugfs_attr_write (struct file *file,const char __user *buf, +size_t len,loff_t *ppos) +{ +return debugfs_attr_write_xsigned (file, buf, len, ppos, false); +}EXPORT_SYMBOL_GPL (debugfs_attr_write); +ssize_t debugfs_attr_write_signed (struct file *file,const char __user *buf, +size_t len,loff_t *ppos) +{ +return debugfs_attr_write_xsigned (file, buf, len, ppos, true); +} +EXPORT_SYMBOL_GPL (debugfs_attr_write_signed); + static struct dentry *debugfs_create_mode_unsafe(const char *name, umode_t mode, struct dentry *parent, void *value, const struct file_operations *fops,
@@ -738,11 +754,11 @@ static int debugfs_atomic_t_get(void *data, u64 *val) *val =atomic_read ((atomic_t *)data);return 0 ; } -DEFINE_DEBUGFS_ATTRIBUTE (fops_atomic_t, debugfs_atomic_t_get, +DEFINE_DEBUGFS_ATTRIBUTE_SIGNED (fops_atomic_t, debugfs_atomic_t_get, debugfs_atomic_t_set,"%lld\n" ); -DEFINE_DEBUGFS_ATTRIBUTE (fops_atomic_t_ro, debugfs_atomic_t_get,NULL , +DEFINE_DEBUGFS_ATTRIBUTE_SIGNED (fops_atomic_t_ro, debugfs_atomic_t_get,NULL ,"%lld\n" ); -DEFINE_DEBUGFS_ATTRIBUTE (fops_atomic_t_wo,NULL , debugfs_atomic_t_set, +DEFINE_DEBUGFS_ATTRIBUTE_SIGNED (fops_atomic_t_wo,NULL , debugfs_atomic_t_set,"%lld\n" );/**
include/linux/debugfs.h +17 -2
@@ -45,7 +45,7 @@ struct debugfs_u32_array {extern struct dentry *arch_debugfs_dir; -#define DEFINE_DEBUGFS_ATTRIBUTE (__fops, __get, __set, __fmt) \ +#define DEFINE_DEBUGFS_ATTRIBUTE_XSIGNED (__fops, __get, __set, __fmt, __is_signed) \ static int __fops ## _open(struct inode *inode, struct file *file) \ { \ __simple_attr_check_format(__fmt, 0ull); \
@@ -56,10 +56,16 @@ static const struct file_operations __fops = { \ .open = __fops ## _open, \ .release = simple_attr_release, \ .read = debugfs_attr_read, \ - .write = debugfs_attr_write, \ + .write = (__is_signed) ? debugfs_attr_write_signed : debugfs_attr_write, \ .llseek = no_llseek, \ } +#define DEFINE_DEBUGFS_ATTRIBUTE (__fops, __get, __set, __fmt) \ + DEFINE_DEBUGFS_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, false) + +#define DEFINE_DEBUGFS_ATTRIBUTE_SIGNED (__fops, __get, __set, __fmt) \ + DEFINE_DEBUGFS_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, true) +typedef struct vfsmount *(*debugfs_automount_t )(struct dentry *,void *);#if defined(CONFIG_DEBUG_FS )
@@ -102,6 +108,8 @@ ssize_t debugfs_attr_read(struct file *file, char __user *buf, size_t len, loff_t *ppos);ssize_t debugfs_attr_write (struct file *file,const char __user *buf,size_t len,loff_t *ppos); +ssize_t debugfs_attr_write_signed (struct file *file,const char __user *buf, +size_t len,loff_t *ppos);struct dentry *debugfs_rename (struct dentry *old_dir,struct dentry *old_dentry,struct dentry *new_dir,const char *new_name);
@@ -254,6 +262,13 @@ static inline ssize_t debugfs_attr_write(struct file *file,return -ENODEV ; } +static inline ssize_t debugfs_attr_write_signed (struct file *file, +const char __user *buf, +size_t len,loff_t *ppos) +{ +return -ENODEV ; +} +static inline struct dentry *debugfs_rename (struct dentry *old_dir,struct dentry *old_dentry,struct dentry *new_dir,char *new_name) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 148/1073 ocfs2: fix memory leak in ocfs2_mount_volume()
In reply to Greg Kroah-HartmanFrom: Li Zetao <[email protected]>
[ Upstream commit ce2fcf1516d674a174d9b34d1e1024d64de9fba3 ]
There is a memory leak reported by kmemleak:
unreferenced object 0xffff88810cc65e60 (size 32):
comm "mount.ocfs2", pid 23753, jiffies 4302528942 (age 34735.105s)
hex dump (first 32 bytes):
10 00 00 00 00 00 00 00 00 01 01 01 01 01 01 01 ................
01 01 01 01 01 01 01 01 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff8170f73d>] __kmalloc+0x4d/0x150
[<ffffffffa0ac3f51>] ocfs2_compute_replay_slots+0x121/0x330 [ocfs2]
[<ffffffffa0b65165>] ocfs2_check_volume+0x485/0x900 [ocfs2]
[<ffffffffa0b68129>] ocfs2_mount_volume.isra.0+0x1e9/0x650 [ocfs2]
[<ffffffffa0b7160b>] ocfs2_fill_super+0xe0b/0x1740 [ocfs2]
[<ffffffff818e1fe2>] mount_bdev+0x312/0x400
[<ffffffff819a086d>] legacy_get_tree+0xed/0x1d0
[<ffffffff818de82d>] vfs_get_tree+0x7d/0x230
[<ffffffff81957f92>] path_mount+0xd62/0x1760
[<ffffffff81958a5a>] do_mount+0xca/0xe0
[<ffffffff81958d3c>] __x64_sys_mount+0x12c/0x1a0
[<ffffffff82f26f15>] do_syscall_64+0x35/0x80
[<ffffffff8300006a>] entry_SYSCALL_64_after_hwframe+0x46/0xb0This call stack is related to two problems. Firstly, the ocfs2 super uses "replay_map" to trace online/offline slots, in order to recover offline slots during recovery and mount. But when ocfs2_truncate_log_init() returns an error in ocfs2_mount_volume(), the memory of "replay_map" will not be freed in error handling path. Secondly, the memory of "replay_map" will not be freed if d_make_root() returns an error in ocfs2_fill_super(). But the memory of "replay_map" will be freed normally when completing recovery and mount in ocfs2_complete_mount_recovery().
Fix the first problem by adding error handling path to free "replay_map" when ocfs2_truncate_log_init() fails. And fix the second problem by calling ocfs2_free_replay_slots(osb) in the error handling path "out_dismount". In addition, since ocfs2_free_replay_slots() is static, it is necessary to remove its static attribute and declare it in header file.
--- fs/ocfs2/journal.c | 2 +- fs/ocfs2/journal.h | 1 + fs/ocfs2/super.c | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-)
fs/ocfs2/journal.c +1 -1
@@ -157,7 +157,7 @@ static void ocfs2_queue_replay_slots(struct ocfs2_super *osb, replay_map->rm_state =REPLAY_DONE ; } -static void ocfs2_free_replay_slots (struct ocfs2_super *osb) +void ocfs2_free_replay_slots (struct ocfs2_super *osb) {struct ocfs2_replay_map *replay_map = osb->replay_map;
fs/ocfs2/journal.h +1 -0
@@ -150,6 +150,7 @@ int ocfs2_recovery_init(struct ocfs2_super *osb);void ocfs2_recovery_exit (struct ocfs2_super *osb);int ocfs2_compute_replay_slots (struct ocfs2_super *osb); +void ocfs2_free_replay_slots (struct ocfs2_super *osb);/* * Journal Control: * Initialize, Load, Shutdown, Wipe a journal.
fs/ocfs2/super.c +4 -1
@@ -1159,6 +1159,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) out_dismount:atomic_set (&osb->vol_state,VOLUME_DISABLED );wake_up (&osb->osb_mount_event); +ocfs2_free_replay_slots (osb);ocfs2_dismount_volume (sb,1 ); goto out;
@@ -1824,12 +1825,14 @@ static int ocfs2_mount_volume(struct super_block *sb) status =ocfs2_truncate_log_init (osb);if (status <0 ) {mlog_errno (status); - goto out_system_inodes; + goto out_check_volume; }ocfs2_super_unlock (osb,1 );return 0 ; +out_check_volume: +ocfs2_free_replay_slots (osb); out_system_inodes:if (osb->local_alloc_state ==OCFS2_LA_ENABLED )ocfs2_shutdown_local_alloc (osb);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 149/1073 rapidio: fix possible name leaks when rio_add_device() fails
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit f9574cd48679926e2a569e1957a5a1bcc8a719ac ]
Patch series "rapidio: fix three possible memory leaks".
This patchset fixes three name leaks in error handling.
- patch #1 fixes two name leaks while rio_add_device() fails.
- patch #2 fixes a name leak while rio_register_mport() fails.
This patch (of 2):
If rio_add_device() returns error, the name allocated by dev_set_name() need be freed. It should use put_device() to give up the reference in the error path, so that the name can be freed in kobject_cleanup(), and the 'rdev' can be freed in rio_release_dev().
--- drivers/rapidio/devices/rio_mport_cdev.c | 7 +++++-- drivers/rapidio/rio-scan.c | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/rapidio/devices/rio_mport_cdev.c +5 -2
@@ -1804,8 +1804,11 @@ static int rio_mport_add_riodev(struct mport_cdev_priv *priv,rio_init_dbell_res (&rdev->riores[RIO_DOORBELL_RESOURCE ],0 ,0xffff ); err =rio_add_device (rdev); -if (err) - goto cleanup; +if (err) { +put_device (&rdev->dev); +return err; + } +rio_dev_get (rdev);return 0 ;
drivers/rapidio/rio-scan.c +6 -2
@@ -454,8 +454,12 @@ static struct rio_dev *rio_setup_device(struct rio_net *net, 0, 0xffff); ret =rio_add_device (rdev); -if (ret) - goto cleanup; +if (ret) { +if (rswitch) +kfree (rswitch->route_table); +put_device (&rdev->dev); +return NULL ; + }rio_dev_get (rdev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 150/1073 rapidio: rio: fix possible name leak in rio_register_mport()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit e92a216d16bde65d21a3227e0fb2aa0794576525 ]
If device_register() returns error, the name allocated by dev_set_name() need be freed. It should use put_device() to give up the reference in the error path, so that the name can be freed in kobject_cleanup(), and list_del() is called to delete the port from rio_mports.
--- drivers/rapidio/rio.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/rapidio/rio.c +7 -2
@@ -2186,11 +2186,16 @@ int rio_register_mport(struct rio_mport *port)atomic_set (&port->state,RIO_DEVICE_RUNNING ); res =device_register (&port->dev); -if (res) +if (res) {dev_err (&port->dev,"RIO: mport%d registration failed ERR=%d\n" , port->id, res); -else +mutex_lock (&rio_mport_list_lock); +list_del (&port->node); +mutex_unlock (&rio_mport_list_lock); +put_device (&port->dev); + }else {dev_dbg (&port->dev,"RIO: registered mport%d\n" , port->id); + }return res; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 151/1073 clocksource/drivers/sh_cmt: Access registers according to spec
In reply to Greg Kroah-HartmanFrom: Wolfram Sang <[email protected]>
[ Upstream commit 3f44f7156f59cae06e9160eafb5d8b2dfd09e639 ]
Documentation for most CMTs say that it takes two input clocks before changes propagate to the timer. This is especially relevant when the timer is stopped to change further settings.
Implement the delays according to the spec. To avoid unnecessary delays in atomic mode, also check if the to-be-written value actually differs.
CMCNT is a bit special because testing showed that it requires 3 cycles to propagate, which affects all CMTs. Also, the WRFLAG needs to be checked before writing. This fixes "cannot clear CMCNT" messages which occur often on R-Car Gen4 SoCs, but only very rarely on older SoCs for some reason.
--- drivers/clocksource/sh_cmt.c | 88 ++++++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 33 deletions(-)
drivers/clocksource/sh_cmt.c +55 -33
@@ -13,6 +13,7 @@#include <linux/init.h> #include <linux/interrupt.h> #include <linux/io.h> +#include <linux/iopoll.h> #include <linux/ioport.h> #include <linux/irq.h> #include <linux/module.h>
@@ -116,6 +117,7 @@ struct sh_cmt_device {void __iomem *mapbase;struct clk *clk;unsigned long rate; +unsigned int reg_delay;raw_spinlock_t lock;/* Protect the shared start/stop register */
@@ -247,10 +249,17 @@ static inline u32 sh_cmt_read_cmstr(struct sh_cmt_channel *ch)static inline void sh_cmt_write_cmstr (struct sh_cmt_channel *ch,u32 value) { -if (ch->iostart) - ch->cmt->info->write_control (ch->iostart,0 , value); -else - ch->cmt->info->write_control (ch->cmt->mapbase,0 , value); +u32 old_value =sh_cmt_read_cmstr (ch); + +if (value != old_value) { +if (ch->iostart) { + ch->cmt->info->write_control (ch->iostart,0 , value); +udelay (ch->cmt->reg_delay); + }else { + ch->cmt->info->write_control (ch->cmt->mapbase,0 , value); +udelay (ch->cmt->reg_delay); + } + } }static inline u32 sh_cmt_read_cmcsr (struct sh_cmt_channel *ch)
@@ -260,7 +269,12 @@ static inline u32 sh_cmt_read_cmcsr(struct sh_cmt_channel *ch)static inline void sh_cmt_write_cmcsr (struct sh_cmt_channel *ch,u32 value) { - ch->cmt->info->write_control (ch->ioctrl,CMCSR , value); +u32 old_value =sh_cmt_read_cmcsr (ch); + +if (value != old_value) { + ch->cmt->info->write_control (ch->ioctrl,CMCSR , value); +udelay (ch->cmt->reg_delay); + } }static inline u32 sh_cmt_read_cmcnt (struct sh_cmt_channel *ch)
@@ -268,14 +282,33 @@ static inline u32 sh_cmt_read_cmcnt(struct sh_cmt_channel *ch)return ch->cmt->info->read_count (ch->ioctrl,CMCNT ); } -static inline void sh_cmt_write_cmcnt (struct sh_cmt_channel *ch,u32 value) +static inline int sh_cmt_write_cmcnt (struct sh_cmt_channel *ch,u32 value) { +/* Tests showed that we need to wait 3 clocks here */ +unsigned int cmcnt_delay =DIV_ROUND_UP (3 * ch->cmt->reg_delay,2 ); +u32 reg; + +if (ch->cmt->info->model >SH_CMT_16BIT ) { +int ret =read_poll_timeout_atomic (sh_cmt_read_cmcsr, reg, + !(reg &SH_CMT32_CMCSR_WRFLG ), +1 , cmcnt_delay, false, ch); +if (ret <0 ) +return ret; + } + ch->cmt->info->write_count (ch->ioctrl,CMCNT , value); +udelay (cmcnt_delay); +return 0 ; }static inline void sh_cmt_write_cmcor (struct sh_cmt_channel *ch,u32 value) { - ch->cmt->info->write_count (ch->ioctrl,CMCOR , value); +u32 old_value = ch->cmt->info->read_count (ch->ioctrl,CMCOR ); + +if (value != old_value) { + ch->cmt->info->write_count (ch->ioctrl,CMCOR , value); +udelay (ch->cmt->reg_delay); + } }static u32 sh_cmt_get_counter (struct sh_cmt_channel *ch,u32 *has_wrapped)
@@ -319,7 +352,7 @@ static void sh_cmt_start_stop_ch(struct sh_cmt_channel *ch, int start)static int sh_cmt_enable (struct sh_cmt_channel *ch) { -int k, ret; +int ret;dev_pm_syscore_device (&ch->cmt->pdev->dev, true);
@@ -347,26 +380,9 @@ static int sh_cmt_enable(struct sh_cmt_channel *ch) }sh_cmt_write_cmcor (ch,0xffffffff ); -sh_cmt_write_cmcnt (ch,0 ); - -/* -* According to the sh73a0 user's manual, as CMCNT can be operated -* only by the RCLK (Pseudo 32 kHz), there's one restriction on -* modifying CMCNT register; two RCLK cycles are necessary before -* this register is either read or any modification of the value -* it holds is reflected in the LSI's actual operation. -* -* While at it, we're supposed to clear out the CMCNT as of this -* moment, so make sure it's processed properly here. This will -* take RCLKx2 at maximum. -*/ -for (k =0 ; k <100 ; k++) { -if (!sh_cmt_read_cmcnt (ch)) -break ; -udelay (1 ); - } + ret =sh_cmt_write_cmcnt (ch,0 ); -if (sh_cmt_read_cmcnt (ch)) { +if (ret ||sh_cmt_read_cmcnt (ch)) {dev_err (&ch->cmt->pdev->dev,"ch%u: cannot clear CMCNT\n" , ch->index); ret = -ETIMEDOUT ;
@@ -995,8 +1011,8 @@ MODULE_DEVICE_TABLE(of, sh_cmt_of_table);static int sh_cmt_setup (struct sh_cmt_device *cmt,struct platform_device *pdev) { -unsigned int mask; -unsigned int i; +unsigned int mask, i; +unsigned long rate;int ret; cmt->pdev = pdev;
@@ -1032,10 +1048,16 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)if (ret <0 ) goto err_clk_unprepare; -if (cmt->info->width ==16 ) - cmt->rate =clk_get_rate (cmt->clk) /512 ; -else - cmt->rate =clk_get_rate (cmt->clk) /8 ; + rate =clk_get_rate (cmt->clk); +if (!rate) { + ret = -EINVAL ; + goto err_clk_disable; + } + +/* We shall wait 2 input clks after register writes */ +if (cmt->info->model >=SH_CMT_48BIT ) + cmt->reg_delay =DIV_ROUND_UP (2UL *USEC_PER_SEC , rate); + cmt->rate = rate / (cmt->info->width ==16 ?512 :8 );/* Map the memory resource(s). */ ret =sh_cmt_map_memory (cmt);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 152/1073 mips: ralink: mt7621: define MT7621_SYSC_BASE with __iomem
In reply to Greg Kroah-HartmanFrom: John Thomson <[email protected]>
[ Upstream commit a2cab953b4c077cc02878d424466d3a6eac32aaf ]
So that MT7621_SYSC_BASE can be used later in multiple functions without needing to repeat this __iomem declaration each time
Stable-dep-of: 7c18b64bba3b ("mips: ralink: mt7621: do not use kzalloc too early")
--- arch/mips/include/asm/mach-ralink/mt7621.h | 4 +++- arch/mips/ralink/mt7621.c | 7 +++---- 2 files changed, 6 insertions(+), 5 deletions(-)
arch/mips/include/asm/mach-ralink/mt7621.h +3 -1
@@ -7,10 +7,12 @@#ifndef _MT7621_REGS_H_#define _MT7621_REGS_H_ +#define IOMEM (x) ((void __iomem *)(KSEG1ADDR(x))) +#define MT7621_PALMBUS_BASE 0x1C000000#define MT7621_PALMBUS_SIZE 0x03FFFFFF -#define MT7621_SYSC_BASE 0x1E000000 +#define MT7621_SYSC_BASE IOMEM(0x1E000000)#define SYSC_REG_CHIP_NAME0 0x00#define SYSC_REG_CHIP_NAME1 0x04
arch/mips/ralink/mt7621.c +3 -4
@@ -126,7 +126,6 @@ static void soc_dev_init(struct ralink_soc_info *soc_info, u32 rev)void __init prom_soc_init (struct ralink_soc_info *soc_info) { -void __iomem *sysc = (void __iomem *)KSEG1ADDR (MT7621_SYSC_BASE );unsigned char *name =NULL ;u32 n0;u32 n1;
@@ -154,8 +153,8 @@ void __init prom_soc_init(struct ralink_soc_info *soc_info)__sync (); } - n0 =__raw_readl (sysc +SYSC_REG_CHIP_NAME0 ); - n1 =__raw_readl (sysc +SYSC_REG_CHIP_NAME1 ); + n0 =__raw_readl (MT7621_SYSC_BASE +SYSC_REG_CHIP_NAME0 ); + n1 =__raw_readl (MT7621_SYSC_BASE +SYSC_REG_CHIP_NAME1 );if (n0 ==MT7621_CHIP_NAME0 && n1 ==MT7621_CHIP_NAME1 ) { name ="MT7621" ;
@@ -164,7 +163,7 @@ void __init prom_soc_init(struct ralink_soc_info *soc_info)panic ("mt7621: unknown SoC, n0:%08x n1:%08x\n" , n0, n1); } ralink_soc =MT762X_SOC_MT7621AT ; - rev =__raw_readl (sysc +SYSC_REG_CHIP_REV ); + rev =__raw_readl (MT7621_SYSC_BASE +SYSC_REG_CHIP_REV ); snprintf(soc_info->sys_type, RAMIPS_SYS_TYPE_LEN, "MediaTek %s ver:%u eco:%u",
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 153/1073 mips: ralink: mt7621: soc queries and tests as functions
In reply to Greg Kroah-HartmanFrom: John Thomson <[email protected]>
[ Upstream commit b4767d4c072583dec987225b6fe3f5524a735f42 ]
Move the SoC register value queries and tests to specific functions, to remove repetition of logic
No functional changes intended
Stable-dep-of: 7c18b64bba3b ("mips: ralink: mt7621: do not use kzalloc too early")
--- arch/mips/ralink/mt7621.c | 86 +++++++++++++++++++++++++++------------ 1 file changed, 61 insertions(+), 25 deletions(-)
arch/mips/ralink/mt7621.c +61 -25
@@ -97,7 +97,57 @@ void __init ralink_of_remap(void)panic ("Failed to remap core resources" ); } -static void soc_dev_init (struct ralink_soc_info *soc_info,u32 rev) +static unsigned int __init mt7621_get_soc_name0 (void ) +{ +return __raw_readl (MT7621_SYSC_BASE +SYSC_REG_CHIP_NAME0 ); +} + +static unsigned int __init mt7621_get_soc_name1 (void ) +{ +return __raw_readl (MT7621_SYSC_BASE +SYSC_REG_CHIP_NAME1 ); +} + +static bool __init mt7621_soc_valid (void ) +{ +if (mt7621_get_soc_name0 () ==MT7621_CHIP_NAME0 && +mt7621_get_soc_name1 () ==MT7621_CHIP_NAME1 ) +return true; +else +return false; +} + +static const char __init *mt7621_get_soc_id (void ) +{ +if (mt7621_soc_valid ()) +return "MT7621" ; +else +return "invalid" ; +} + +static unsigned int __init mt7621_get_soc_rev (void ) +{ +return __raw_readl (MT7621_SYSC_BASE +SYSC_REG_CHIP_REV ); +} + +static unsigned int __init mt7621_get_soc_ver (void ) +{ +return (mt7621_get_soc_rev () >>CHIP_REV_VER_SHIFT ) &CHIP_REV_VER_MASK ; +} + +static unsigned int __init mt7621_get_soc_eco (void ) +{ +return (mt7621_get_soc_rev () &CHIP_REV_ECO_MASK ); +} + +static const char __init *mt7621_get_soc_revision (void ) +{ +if (mt7621_get_soc_rev () ==1 &&mt7621_get_soc_eco () ==1 ) +return "E2" ; +else +return "E1" ; +} + +static void soc_dev_init (struct ralink_soc_info *soc_info) {struct soc_device *soc_dev;struct soc_device_attribute *soc_dev_attr;
@@ -108,12 +158,7 @@ static void soc_dev_init(struct ralink_soc_info *soc_info, u32 rev) soc_dev_attr->soc_id ="mt7621" ; soc_dev_attr->family ="Ralink" ; - -if (((rev >>CHIP_REV_VER_SHIFT ) &CHIP_REV_VER_MASK ) ==1 && - (rev &CHIP_REV_ECO_MASK ) ==1 ) - soc_dev_attr->revision ="E2" ; -else - soc_dev_attr->revision ="E1" ; + soc_dev_attr->revision =mt7621_get_soc_revision (); soc_dev_attr->data = soc_info;
@@ -126,11 +171,6 @@ static void soc_dev_init(struct ralink_soc_info *soc_info, u32 rev)void __init prom_soc_init (struct ralink_soc_info *soc_info) { -unsigned char *name =NULL ; -u32 n0; -u32 n1; -u32 rev; -/* Early detection of CMP support */ mips_cm_probe ();mips_cpc_probe ();
@@ -153,27 +193,23 @@ void __init prom_soc_init(struct ralink_soc_info *soc_info)__sync (); } - n0 =__raw_readl (MT7621_SYSC_BASE +SYSC_REG_CHIP_NAME0 ); - n1 =__raw_readl (MT7621_SYSC_BASE +SYSC_REG_CHIP_NAME1 ); - -if (n0 ==MT7621_CHIP_NAME0 && n1 ==MT7621_CHIP_NAME1 ) { - name ="MT7621" ; +if (mt7621_soc_valid ()) soc_info->compatible ="mediatek,mt7621-soc" ; - }else { -panic ("mt7621: unknown SoC, n0:%08x n1:%08x\n" , n0, n1); - } +else +panic ("mt7621: unknown SoC, n0:%08x n1:%08x\n" , +mt7621_get_soc_name0 (), +mt7621_get_soc_name1 ()); ralink_soc =MT762X_SOC_MT7621AT ; - rev =__raw_readl (MT7621_SYSC_BASE +SYSC_REG_CHIP_REV );snprintf (soc_info->sys_type,RAMIPS_SYS_TYPE_LEN ,"MediaTek %s ver:%u eco:%u" , - name, - (rev >>CHIP_REV_VER_SHIFT ) &CHIP_REV_VER_MASK , - (rev &CHIP_REV_ECO_MASK )); +mt7621_get_soc_id (), +mt7621_get_soc_ver (), +mt7621_get_soc_eco ()); soc_info->mem_detect = mt7621_memory_detect; -soc_dev_init (soc_info, rev); +soc_dev_init (soc_info);if (!register_cps_smp_ops ())return ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 154/1073 mips: ralink: mt7621: do not use kzalloc too early
In reply to Greg Kroah-HartmanFrom: John Thomson <[email protected]>
[ Upstream commit 7c18b64bba3bcad1be94b404f47b94a04b91ce79 ]
With CONFIG_SLUB=y, following commit 6edf2576a6cc ("mm/slub: enable debugging memory wasting of kmalloc") mt7621 failed to boot very early, without showing any console messages.
This exposed the pre-existing bug of mt7621.c using kzalloc before normal memory management was available.
Prior to this slub change, there existed the unintended protection against "kmem_cache *s" being NULL as slab_pre_alloc_hook() happened to return NULL and bailed out of slab_alloc_node().
This allowed mt7621 prom_soc_init to fail in the soc_dev_init kzalloc, but continue booting without the SOC_BUS driver device registered.
Console output from a DEBUG_ZBOOT vmlinuz kernel loading, with mm/slub modified to warn on kmem_cache zero or null:
zimage at: 80B842A0 810B4BC0
Uncompressing Linux at load address 80001000
Copy device tree to address 80B80EE0
Now, booting the kernel...
[ 0.000000] Linux version 6.1.0-rc3+ (john@john)
(mipsel-buildroot-linux-gnu-gcc.br_real (Buildroot
2021.11-4428-g6b6741b) 12.2.0, GNU ld (GNU Binutils) 2.39) #73 SMP Wed
Nov 2 05:10:01 AEST 2022
[ 0.000000] ------------[ cut here ]------------
[ 0.000000] WARNING: CPU: 0 PID: 0 at mm/slub.c:3416
kmem_cache_alloc+0x5a4/0x5e8
[ 0.000000] Modules linked in:
[ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 6.1.0-rc3+ #73
[ 0.000000] Stack : 810fff78 80084d98 00000000 00000004 00000000
00000000 80889d04 80c90000
[ 0.000000] 80920000 807bd328 8089d368 80923bd3 00000000
00000001 80889cb0 00000000
[ 0.000000] 00000000 00000000 807bd328 8084bcb1 00000002
00000002 00000001 6d6f4320
[ 0.000000] 00000000 80c97d3d 80c97d68 fffffffc 807bd328
00000000 00000000 00000000
[ 0.000000] 00000000 a0000000 80910000 8110a0b4 00000000
00000020 80010000 80010000
[ 0.000000] ...
[ 0.000000] Call Trace:
[ 0.000000] [<80008260>] show_stack+0x28/0xf0
[ 0.000000] [<8070c958>] dump_stack_lvl+0x60/0x80
[ 0.000000] [<8002e184>] __warn+0xc4/0xf8
[ 0.000000] [<8002e210>] warn_slowpath_fmt+0x58/0xa4
[ 0.000000] [<801c0fac>] kmem_cache_alloc+0x5a4/0x5e8
[ 0.000000] [<8092856c>] prom_soc_init+0x1fc/0x2b4
[ 0.000000] [<80928060>] prom_init+0x44/0xf0
[ 0.000000] [<80929214>] setup_arch+0x4c/0x6a8
[ 0.000000] [<809257e0>] start_kernel+0x88/0x7c0
[ 0.000000]
[ 0.000000] ---[ end trace 0000000000000000 ]---
[ 0.000000] SoC Type: MediaTek MT7621 ver:1 eco:3
[ 0.000000] printk: bootconsole [early0] enabledAllowing soc_device_register to work exposed oops in the mt7621 phy pci, and pci controller drivers from soc_device_match_attr, due to missing sentinels in the quirks tables. These were fixed with:
commit 819b885cd886 ("phy: ralink: mt7621-pci: add sentinel to quirks table")
not yet applied ("PCI: mt7621: add sentinel to quirks table")
--- arch/mips/ralink/mt7621.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
arch/mips/ralink/mt7621.c +9 -5
@@ -25,6 +25,7 @@#define MT7621_MEM_TEST_PATTERN 0xaa5555aastatic u32 detect_magic__initdata ; +static struct ralink_soc_info *soc_info_ptr;int pcibios_root_bridge_prepare (struct pci_host_bridge *bridge) {
@@ -147,27 +148,30 @@ static const char __init *mt7621_get_soc_revision(void)return "E1" ; } -static void soc_dev_init (struct ralink_soc_info *soc_info) +static int __init mt7621_soc_dev_init (void ) {struct soc_device *soc_dev;struct soc_device_attribute *soc_dev_attr; soc_dev_attr =kzalloc (sizeof (*soc_dev_attr),GFP_KERNEL );if (!soc_dev_attr) -return ; +return -ENOMEM ; soc_dev_attr->soc_id ="mt7621" ; soc_dev_attr->family ="Ralink" ; soc_dev_attr->revision =mt7621_get_soc_revision (); - soc_dev_attr->data = soc_info; + soc_dev_attr->data = soc_info_ptr; soc_dev =soc_device_register (soc_dev_attr);if (IS_ERR (soc_dev)) {kfree (soc_dev_attr); -return ; +return PTR_ERR (soc_dev); } + +return 0 ; } +device_initcall (mt7621_soc_dev_init);void __init prom_soc_init (struct ralink_soc_info *soc_info) {
@@ -209,7 +213,7 @@ void __init prom_soc_init(struct ralink_soc_info *soc_info) soc_info->mem_detect = mt7621_memory_detect; -soc_dev_init (soc_info); + soc_info_ptr = soc_info;if (!register_cps_smp_ops ())return ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 155/1073 futex: Resend potentially swallowed owner death notification
In reply to Greg Kroah-HartmanFrom: Alexey Izbyshev <[email protected]>
[ Upstream commit 90d758896787048fa3d4209309d4800f3920e66f ]
Commit ca16d5bee598 ("futex: Prevent robust futex exit race") addressed two cases when tasks waiting on a robust non-PI futex remained blocked despite the futex not being owned anymore:
* if the owner died after writing zero to the futex word, but before waking up a waiter
* if a task waiting on the futex was woken up, but died before updating the futex word (effectively swallowing the notification without acting on it)
In the second case, the task could be woken up either by the previous owner (after the futex word was reset to zero) or by the kernel (after the OWNER_DIED bit was set and the TID part of the futex word was reset to zero) if the previous owner died without the resetting the futex.
Because the referenced commit wakes up a potential waiter only if the whole futex word is zero, the latter subcase remains unaddressed.
Fix this by looking only at the TID part of the futex when deciding whether a wake up is needed.
--- kernel/futex/core.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-)
kernel/futex/core.c +17 -9
@@ -638,6 +638,7 @@ static int handle_futex_death(u32 __user *uaddr, struct task_struct *curr, bool pi, bool pending_op) {u32 uval, nval, mval; +pid_t owner;int err;/* Futex address must be 32bit aligned */
@@ -659,6 +660,10 @@ static int handle_futex_death(u32 __user *uaddr, struct task_struct *curr,* 2. A woken up waiter is killed before it can acquire the * futex in user space. * +* In the second case, the wake up notification could be generated +* by the unlock path in user space after setting the futex value +* to zero or by the kernel after setting the OWNER_DIED bit below. +* * In both cases the TID validation below prevents a wakeup of * potential waiters which can cause these waiters to block * forever.
@@ -667,24 +672,27 @@ static int handle_futex_death(u32 __user *uaddr, struct task_struct *curr,* * 1) task->robust_list->list_op_pending != NULL * @pending_op == true -* 2) User space futex value == 0 +* 2) The owner part of user space futex value == 0 * 3) Regular futex: @pi == false * * If these conditions are met, it is safe to attempt waking up a * potential waiter without touching the user space futex value and -* trying to set the OWNER_DIED bit. The user space futex value is -* uncontended and the rest of the user space mutex state is -* consistent, so a woken waiter will just take over the -* uncontended futex. Setting the OWNER_DIED bit would create -* inconsistent state and malfunction of the user space owner died -* handling. +* trying to set the OWNER_DIED bit. If the futex value is zero, +* the rest of the user space mutex state is consistent, so a woken +* waiter will just take over the uncontended futex. Setting the +* OWNER_DIED bit would create inconsistent state and malfunction +* of the user space owner died handling. Otherwise, the OWNER_DIED +* bit is already set, and the woken waiter is expected to deal with +* this. */ -if (pending_op && !pi && !uval) { + owner = uval &FUTEX_TID_MASK ; + +if (pending_op && !pi && !owner) {futex_wake (uaddr,1 ,1 ,FUTEX_BITSET_MATCH_ANY );return 0 ; } -if ((uval &FUTEX_TID_MASK ) !=task_pid_vnr (curr)) +if (owner !=task_pid_vnr (curr))return 0 ;/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 156/1073 cpu/hotplug: Make target_store() a nop when target == state
In reply to Greg Kroah-HartmanFrom: Phil Auld <[email protected]>
[ Upstream commit 64ea6e44f85b9b75925ebe1ba0e6e8430cc4e06f ]
Writing the current state back in hotplug/target calls cpu_down() which will set cpu dying even when it isn't and then nothing will ever clear it. A stress test that reads values and writes them back for all cpu device files in sysfs will trigger the BUG() in select_fallback_rq once all cpus are marked as dying.
kernel/cpu.c::target_store()
...
if (st->state < target)
ret = cpu_up(dev->id, target);
else
ret = cpu_down(dev->id, target);cpu_down() -> cpu_set_state()
bool bringup = st->state < target; ... if (cpu_dying(cpu) != !bringup) set_cpu_dying(cpu, !bringup);
Fix this by letting state==target fall through in the target_store() conditional. Also make sure st->target == target in that case.
--- kernel/cpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/cpu.c +3 -1
@@ -2326,8 +2326,10 @@ static ssize_t target_store(struct device *dev, struct device_attribute *attr,if (st->state < target) ret =cpu_up (dev->id, target); -else +else if (st->state > target) ret =cpu_down (dev->id, target); +else if (WARN_ON (st->target != target)) + st->target = target; out:unlock_device_hotplug ();return ret ? ret : count;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 157/1073 cpu/hotplug: Do not bail-out in DYING/STARTING sections
In reply to Greg Kroah-HartmanFrom: Vincent Donnefort <[email protected]>
[ Upstream commit 6f855b39e4602b6b42a8e5cbcfefb8a1b8b5f0be ]
The DYING/STARTING callbacks are not expected to fail. However, as reported by Derek, buggy drivers such as tboot are still free to return errors within those sections, which halts the hot(un)plug and leaves the CPU in an unrecoverable state.
As there is no rollback possible, only log the failures and proceed with the following steps.
This restores the hotplug behaviour prior to commit 453e41085183 ("cpu/hotplug: Add cpuhp_invoke_callback_range()")
--- kernel/cpu.c | 56 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 16 deletions(-)
kernel/cpu.c +40 -16
@@ -663,21 +663,51 @@ static bool cpuhp_next_state(bool bringup,return true; } -static int cpuhp_invoke_callback_range (bool bringup, -unsigned int cpu, -struct cpuhp_cpu_state *st, -enum cpuhp_state target) +static int __cpuhp_invoke_callback_range (bool bringup, +unsigned int cpu, +struct cpuhp_cpu_state *st, +enum cpuhp_state target, +bool nofail) {enum cpuhp_state state; -int err =0 ; +int ret =0 ;while (cpuhp_next_state (bringup, &state, st, target)) { +int err; + err =cpuhp_invoke_callback (cpu, state, bringup,NULL ,NULL ); -if (err) +if (!err) +continue ; + +if (nofail) { +pr_warn ("CPU %u %s state %s (%d) failed (%d)\n" , + cpu, bringup ?"UP" :"DOWN" , +cpuhp_get_step (st->state)->name, + st->state, err); + ret =-1 ; + }else { + ret = err;break ; + } } -return err; +return ret; +} + +static inline int cpuhp_invoke_callback_range (bool bringup, +unsigned int cpu, +struct cpuhp_cpu_state *st, +enum cpuhp_state target) +{ +return __cpuhp_invoke_callback_range (bringup, cpu, st, target, false); +} + +static inline void cpuhp_invoke_callback_range_nofail (bool bringup, +unsigned int cpu, +struct cpuhp_cpu_state *st, +enum cpuhp_state target) +{ +__cpuhp_invoke_callback_range (bringup, cpu, st, target, true); }static inline bool can_rollback_cpu (struct cpuhp_cpu_state *st)
@@ -999,7 +1029,6 @@ static int take_cpu_down(void *_param)struct cpuhp_cpu_state *st =this_cpu_ptr (&cpuhp_state);enum cpuhp_state target =max ((int )st->target,CPUHP_AP_OFFLINE );int err, cpu =smp_processor_id (); -int ret;/* Ensure this CPU doesn't handle any more interrupts. */ err =__cpu_disable ();
@@ -1012,13 +1041,10 @@ static int take_cpu_down(void *_param)*/ WARN_ON (st->state != (CPUHP_TEARDOWN_CPU -1 )); -/* Invoke the former CPU_DYING callbacks */ - ret =cpuhp_invoke_callback_range (false, cpu, st, target); -/* -* DYING must not fail! +* Invoke the former CPU_DYING callbacks. DYING must not fail! */ -WARN_ON_ONCE (ret); +cpuhp_invoke_callback_range_nofail (false, cpu, st, target);/* Give up timekeeping duties */ tick_handover_do_timer ();
@@ -1296,16 +1322,14 @@ void notify_cpu_starting(unsigned int cpu) {struct cpuhp_cpu_state *st =per_cpu_ptr (&cpuhp_state, cpu);enum cpuhp_state target =min ((int )st->target,CPUHP_AP_ONLINE ); -int ret;rcu_cpu_starting (cpu);/* Enables RCU usage on this CPU. */ cpumask_set_cpu (cpu, &cpus_booted_once_mask); - ret =cpuhp_invoke_callback_range (true, cpu, st, target);/* * STARTING must not fail! */ -WARN_ON_ONCE (ret); +cpuhp_invoke_callback_range_nofail (true, cpu, st, target); }/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 158/1073 clocksource/drivers/timer-ti-dm: Fix warning for omap_timer_match
In reply to Greg Kroah-HartmanFrom: Tony Lindgren <[email protected]>
[ Upstream commit 9688498b1648aa98a3ee45d9f07763c099f6fb12 ]
We can now get a warning for 'omap_timer_match' defined but not used. Let's fix this by dropping of_match_ptr for omap_timer_match.
--- drivers/clocksource/timer-ti-dm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/timer-ti-dm.c +1 -1
@@ -1081,7 +1081,7 @@ static struct platform_driver omap_dm_timer_driver = { .remove = omap_dm_timer_remove, .driver = { .name = "omap_timer", - .of_match_table = of_match_ptr(omap_timer_match), + .of_match_table = omap_timer_match, .pm = &omap_dm_timer_pm_ops, }, };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 159/1073 clocksource/drivers/timer-ti-dm: Fix missing clk_disable_unprepare in dmtimer_systimer_init_clock()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 180d35a7c05d520314a590c99ad8643d0213f28b ]
If clk_get_rate() fails which is called after clk_prepare_enable(), clk_disable_unprepare() need be called in error path to disable the clock in dmtimer_systimer_init_clock().
--- drivers/clocksource/timer-ti-dm-systimer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clocksource/timer-ti-dm-systimer.c +3 -1
@@ -345,8 +345,10 @@ static int __init dmtimer_systimer_init_clock(struct dmtimer_systimer *t,return error; r =clk_get_rate (clock); -if (!r) +if (!r) { +clk_disable_unprepare (clock);return -ENODEV ; + }if (is_ick) t->ick = clock;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 160/1073 ACPICA: Fix use-after-free in acpi_ut_copy_ipackage_to_ipackage()
In reply to Greg Kroah-HartmanFrom: Li Zetao <[email protected]>
[ Upstream commit 470188b09e92d83c5a997f25f0e8fb8cd2bc3469 ]
There is an use-after-free reported by KASAN:
BUG: KASAN: use-after-free in acpi_ut_remove_reference+0x3b/0x82 Read of size 1 at addr ffff888112afc460 by task modprobe/2111 CPU: 0 PID: 2111 Comm: modprobe Not tainted 6.1.0-rc7-dirty Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), Call Trace: <TASK> kasan_report+0xae/0xe0 acpi_ut_remove_reference+0x3b/0x82 acpi_ut_copy_iobject_to_iobject+0x3be/0x3d5 acpi_ds_store_object_to_local+0x15d/0x3a0 acpi_ex_store+0x78d/0x7fd acpi_ex_opcode_1A_1T_1R+0xbe4/0xf9b acpi_ps_parse_aml+0x217/0x8d5 ... </TASK>
The root cause of the problem is that the acpi_operand_object is freed when acpi_ut_walk_package_tree() fails in acpi_ut_copy_ipackage_to_ipackage(), lead to repeated release in acpi_ut_copy_iobject_to_iobject(). The problem was introduced by "8aa5e56eeb61" commit, this commit is to fix memory leak in acpi_ut_copy_iobject_to_iobject(), repeatedly adding remove operation, lead to "acpi_operand_object" used after free.
Fix it by removing acpi_ut_remove_reference() in acpi_ut_copy_ipackage_to_ipackage(). acpi_ut_copy_ipackage_to_ipackage() is called to copy an internal package object into another internal package object, when it fails, the memory of acpi_operand_object should be freed by the caller.
--- drivers/acpi/acpica/utcopy.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/acpi/acpica/utcopy.c +0 -7
@@ -916,13 +916,6 @@ acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj, status =acpi_ut_walk_package_tree (source_obj, dest_obj, acpi_ut_copy_ielement_to_ielement, walk_state); -if (ACPI_FAILURE (status)) { - -/* On failure, delete the destination package object */ - -acpi_ut_remove_reference (dest_obj); - } -return_ACPI_STATUS (status); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 161/1073 uprobes/x86: Allow to probe a NOP instruction with 0x66 prefix
In reply to Greg Kroah-HartmanFrom: Oleg Nesterov <[email protected]>
[ Upstream commit cefa72129e45313655d53a065b8055aaeb01a0c9 ]
Intel ICC -hotpatch inserts 2-byte "0x66 0x90" NOP at the start of each function to reserve extra space for hot-patching, and currently it is not possible to probe these functions because branch_setup_xol_ops() wrongly rejects NOP with REP prefix as it treats them like word-sized branch instructions.
--- arch/x86/kernel/uprobes.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kernel/uprobes.c +3 -1
@@ -722,8 +722,9 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn)switch (opc1) {case 0xeb :/* jmp 8 */ case 0xe9 :/* jmp 32 */ -case 0x90 :/* prefix* + nop; same as jmp with .offs = 0 */ break ; +case 0x90 :/* prefix* + nop; same as jmp with .offs = 0 */ + goto setup;case 0xe8 :/* call relative */ branch_clear_offset (auprobe, insn);
@@ -753,6 +754,7 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn)return -ENOTSUPP ; } +setup: auprobe->branch.opc1 = opc1; auprobe->branch.ilen = insn->length; auprobe->branch.offs = insn->immediate.value;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 162/1073 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 163/1073 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 164/1073 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 165/1073 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 166/1073 erofs: Fix pcluster memleak when its block address is zero
In reply to Greg Kroah-HartmanFrom: Chen Zhongjin <[email protected]>
[ Upstream commit c42c0ffe81176940bd5dead474216b7198d77675 ]
syzkaller reported a memleak:
https://syzkaller.appspot.com/bug?id=62f37ff612f0021641eda5b17f056f1668aa9aed
unreferenced object 0xffff88811009c7f8 (size 136):
...
backtrace:
[<ffffffff821db19b>] z_erofs_do_read_page+0x99b/0x1740
[<ffffffff821dee9e>] z_erofs_readahead+0x24e/0x580
[<ffffffff814bc0d6>] read_pages+0x86/0x3d0
...syzkaller constructed a case: in z_erofs_register_pcluster(), ztailpacking = false and map->m_pa = zero. This makes pcl->obj.index be zero although pcl is not a inline pcluster.
Then following path adds refcount for grp, but the refcount won't be put because pcl is inline.
z_erofs_readahead()
z_erofs_do_read_page() # for another page
z_erofs_collector_begin()
erofs_find_workgroup()
erofs_workgroup_get()
Since it's illegal for the block address of a non-inlined pcluster to be zero, add check here to avoid registering the pcluster which would be leaked.
--- fs/erofs/zdata.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/erofs/zdata.c +2 -1
@@ -487,7 +487,8 @@ static int z_erofs_register_pcluster(struct z_erofs_decompress_frontend *fe)struct erofs_workgroup *grp;int err; -if (!(map->m_flags &EROFS_MAP_ENCODED )) { +if (!(map->m_flags &EROFS_MAP_ENCODED ) || + (!ztailpacking && !(map->m_pa >>PAGE_SHIFT ))) {DBG_BUGON (1 );return -EFSCORRUPTED ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 167/1073 erofs: fix missing unmap if z_erofs_get_extent_compressedlen() fails
In reply to Greg Kroah-HartmanFrom: Gao Xiang <[email protected]>
[ Upstream commit d5d188b8f8b38d3d71dd05993874b4fc9284ce95 ]
Otherwise, meta buffers could be leaked.
--- fs/erofs/zmap.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/erofs/zmap.c +2 -4
@@ -673,7 +673,7 @@ static int z_erofs_do_map_blocks(struct inode *inode, map->m_pa =blknr_to_addr (m.pblk); err =z_erofs_get_extent_compressedlen (&m, initial_lcn);if (err) - goto out; + goto unmap_out; }if (m.headtype ==Z_EROFS_VLE_CLUSTER_TYPE_PLAIN )
@@ -691,14 +691,12 @@ static int z_erofs_do_map_blocks(struct inode *inode,if (!err) map->m_flags |=EROFS_MAP_FULL_MAPPED ; } + unmap_out:erofs_unmap_metabuf (&m.map->buf); - -out:erofs_dbg ("%s, m_la %llu m_pa %llu m_llen %llu m_plen %llu m_flags 0%o" , __func__, map->m_la, map->m_pa, map->m_llen, map->m_plen, map->m_flags); -return err; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 168/1073 erofs: support interlaced uncompressed data for compressed files
In reply to Greg Kroah-HartmanFrom: Yue Hu <[email protected]>
[ Upstream commit fdffc091e6f94602558bba712b51bc16f79fd6d5 ]
Currently, uncompressed data is all handled in the shifted way, which means we have to shift the whole on-disk plain pcluster to get the
logical data. However, since we are also using in-place I/O for
uncompressed data, data copy will be reduced a lot if pcluster is recorded in the interlaced way as illustrated below:
_______________________________________________________________
| | | |_ tail part |_ head part _| |<- blk0 ->| .. |<- blkn-2 ->|<- blkn-1 ->|
The logical data then becomes:
________________________________________________________
|_ head part _|_ blk0 _| .. |_ blkn-2 _|_ tail part _|
In addition, non-4k plain pclusters are also survived by the interlaced way, which can be used for non-4k lclusters as well.
However, it's almost impossible to de-duplicate uncompressed data in the interlaced way, therefore shifted uncompressed data is still useful.
Stable-dep-of: c505feba4c0d ("erofs: validate the extent length for uncompressed pclusters")
--- fs/erofs/decompressor.c | 47 ++++++++++++++++++++++++----------------- fs/erofs/erofs_fs.h | 2 ++ fs/erofs/internal.h | 1 + fs/erofs/zmap.c | 14 ++++++++---- 4 files changed, 41 insertions(+), 23 deletions(-)
fs/erofs/decompressor.c +28 -19
@@ -317,52 +317,61 @@ static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq,return ret; } -static int z_erofs_shifted_transform (struct z_erofs_decompress_req *rq, -struct page **pagepool) +static int z_erofs_transform_plain (struct z_erofs_decompress_req *rq, +struct page **pagepool) { -const unsigned int nrpages_out = +const unsigned int inpages =PAGE_ALIGN (rq->inputsize) >>PAGE_SHIFT ; +const unsigned int outpages =PAGE_ALIGN (rq->pageofs_out + rq->outputsize) >>PAGE_SHIFT ; const unsigned int righthalf = min_t(unsigned int, rq->outputsize,PAGE_SIZE - rq->pageofs_out);const unsigned int lefthalf = rq->outputsize - righthalf; +const unsigned int interlaced_offset = + rq->alg ==Z_EROFS_COMPRESSION_SHIFTED ?0 : rq->pageofs_out;unsigned char *src, *dst; -if (nrpages_out >2 ) { +if (outpages >2 && rq->alg ==Z_EROFS_COMPRESSION_SHIFTED ) {DBG_BUGON (1 ); -return -EIO ; +return -EFSCORRUPTED ; }if (rq->out[0 ] == *rq->in) { -DBG_BUGON (nrpages_out !=1 ); +DBG_BUGON (rq->pageofs_out);return 0 ; } - src =kmap_atomic (*rq->in) + rq->pageofs_in; + src =kmap_local_page (rq->in[inpages -1 ]) + rq->pageofs_in;if (rq->out[0 ]) { - dst =kmap_atomic (rq->out[0 ]); -memcpy (dst + rq->pageofs_out, src, righthalf); -kunmap_atomic (dst); + dst =kmap_local_page (rq->out[0 ]); +memcpy (dst + rq->pageofs_out, src + interlaced_offset, + righthalf); +kunmap_local (dst); } -if (nrpages_out ==2 ) { -DBG_BUGON (!rq->out[1 ]); -if (rq->out[1 ] == *rq->in) { +if (outpages > inpages) { +DBG_BUGON (!rq->out[outpages -1 ]); +if (rq->out[outpages -1 ] != rq->in[inpages -1 ]) { + dst =kmap_local_page (rq->out[outpages -1 ]); +memcpy (dst, interlaced_offset ? src : + (src + righthalf), lefthalf); +kunmap_local (dst); + }else if (!interlaced_offset) {memmove (src, src + righthalf, lefthalf); - }else { - dst =kmap_atomic (rq->out[1 ]); -memcpy (dst, src + righthalf, lefthalf); -kunmap_atomic (dst); } } -kunmap_atomic (src); +kunmap_local (src);return 0 ; }static struct z_erofs_decompressor decompressors[] = { [Z_EROFS_COMPRESSION_SHIFTED ] = { - .decompress = z_erofs_shifted_transform, + .decompress = z_erofs_transform_plain, .name ="shifted" }, + [Z_EROFS_COMPRESSION_INTERLACED ] = { + .decompress = z_erofs_transform_plain, + .name ="interlaced" + }, [Z_EROFS_COMPRESSION_LZ4 ] = { .decompress = z_erofs_lz4_decompress, .name ="lz4"
fs/erofs/erofs_fs.h +2 -0
@@ -295,11 +295,13 @@ struct z_erofs_lzma_cfgs {* bit 1 : HEAD1 big pcluster (0 - off; 1 - on) * bit 2 : HEAD2 big pcluster (0 - off; 1 - on) * bit 3 : tailpacking inline pcluster (0 - off; 1 - on) +* bit 4 : interlaced plain pcluster (0 - off; 1 - on) */ #define Z_EROFS_ADVISE_COMPACTED_2B 0x0001#define Z_EROFS_ADVISE_BIG_PCLUSTER_1 0x0002#define Z_EROFS_ADVISE_BIG_PCLUSTER_2 0x0004#define Z_EROFS_ADVISE_INLINE_PCLUSTER 0x0008 +#define Z_EROFS_ADVISE_INTERLACED_PCLUSTER 0x0010struct z_erofs_map_header {__le16 h_reserved1;
fs/erofs/internal.h +1 -0
@@ -407,6 +407,7 @@ struct erofs_map_blocks {enum {Z_EROFS_COMPRESSION_SHIFTED =Z_EROFS_COMPRESSION_MAX , +Z_EROFS_COMPRESSION_INTERLACED ,Z_EROFS_COMPRESSION_RUNTIME_MAX };
fs/erofs/zmap.c +10 -4
@@ -676,12 +676,18 @@ static int z_erofs_do_map_blocks(struct inode *inode, goto unmap_out; } -if (m.headtype ==Z_EROFS_VLE_CLUSTER_TYPE_PLAIN ) - map->m_algorithmformat =Z_EROFS_COMPRESSION_SHIFTED ; -else if (m.headtype ==Z_EROFS_VLE_CLUSTER_TYPE_HEAD2 ) +if (m.headtype ==Z_EROFS_VLE_CLUSTER_TYPE_PLAIN ) { +if (vi->z_advise &Z_EROFS_ADVISE_INTERLACED_PCLUSTER ) + map->m_algorithmformat = +Z_EROFS_COMPRESSION_INTERLACED ; +else + map->m_algorithmformat = +Z_EROFS_COMPRESSION_SHIFTED ; + }else if (m.headtype ==Z_EROFS_VLE_CLUSTER_TYPE_HEAD2 ) { map->m_algorithmformat = vi->z_algorithmtype[1 ]; -else + }else { map->m_algorithmformat = vi->z_algorithmtype[0 ]; + } if ((flags & EROFS_GET_BLOCKS_FIEMAP) || ((flags & EROFS_GET_BLOCKS_READMORE) &&
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 169/1073 erofs: validate the extent length for uncompressed pclusters
In reply to Greg Kroah-HartmanFrom: Gao Xiang <[email protected]>
[ Upstream commit c505feba4c0d76084e56ec498ce819f02a7043ae ]
syzkaller reported a KASAN use-after-free:
https://syzkaller.appspot.com/bug?extid=2ae90e873e97f1faf6f2
The referenced fuzzed image actually has two issues:
- m_pa == 0 as a non-inlined pcluster;
- The logical length is longer than its physical length.
The first issue has already been addressed. This patch addresses the second issue by checking the extent length validity.
--- fs/erofs/zmap.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/erofs/zmap.c +5 -0
@@ -677,6 +677,11 @@ static int z_erofs_do_map_blocks(struct inode *inode, }if (m.headtype ==Z_EROFS_VLE_CLUSTER_TYPE_PLAIN ) { +if (map->m_llen > map->m_plen) { +DBG_BUGON (1 ); + err = -EFSCORRUPTED ; + goto unmap_out; + }if (vi->z_advise &Z_EROFS_ADVISE_INTERLACED_PCLUSTER ) map->m_algorithmformat =Z_EROFS_COMPRESSION_INTERLACED ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 170/1073 platform/chrome: cros_ec_typec: Cleanup switch handle return paths
In reply to Greg Kroah-HartmanFrom: Prashant Malani <[email protected]>
[ Upstream commit d5f66527db9e0e6a871d9005200b3394156cf16f ]
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
@@ -159,12 +159,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 171/1073 platform/chrome: cros_ec_typec: Get retimer handle
In reply to Greg Kroah-HartmanFrom: Prashant Malani <[email protected]>
[ Upstream commit 1a8912caba02522f612d465a4849ce98915b96ad ]
Where available, obtain the handle to retimer switch specified via firmware, and update the mux configuration callsites to add retimer support for supported modes.
Stable-dep-of: 9a8aadcf0b45 ("platform/chrome: cros_ec_typec: zero out stale pointers")
--- drivers/platform/chrome/cros_ec_typec.c | 44 +++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-)
drivers/platform/chrome/cros_ec_typec.c +41 -3
@@ -20,6 +20,7 @@#include <linux/usb/typec_altmode.h> #include <linux/usb/typec_dp.h> #include <linux/usb/typec_mux.h> +#include <linux/usb/typec_retimer.h> #include <linux/usb/typec_tbt.h> #include <linux/usb/role.h>
@@ -56,6 +57,7 @@ struct cros_typec_port {struct usb_pd_identity c_identity;struct typec_switch *ori_sw;struct typec_mux *mux; +struct typec_retimer *retimer;struct usb_role_switch *role_sw;/* Variables keeping track of switch state. */
@@ -144,6 +146,12 @@ static int cros_typec_get_switch_handles(struct cros_typec_port *port, goto mux_err; } + port->retimer =fwnode_typec_retimer_get (fwnode); +if (IS_ERR (port->retimer)) { +dev_dbg (dev,"Retimer handle not found.\n" ); + goto retimer_sw_err; + } + port->ori_sw =fwnode_typec_switch_get (fwnode);if (IS_ERR (port->ori_sw)) {dev_dbg (dev,"Orientation switch handle not found.\n" );
@@ -161,6 +169,8 @@ static int cros_typec_get_switch_handles(struct cros_typec_port *port, role_sw_err:typec_switch_put (port->ori_sw); ori_sw_err: +typec_retimer_put (port->retimer); +retimer_sw_err:typec_mux_put (port->mux); mux_err:return -ENODEV ;
@@ -205,6 +215,21 @@ static void cros_typec_unregister_altmodes(struct cros_typec_data *typec, int po } } +/* +* Map the Type-C Mux state to retimer state and call the retimer set function. We need this +* because we re-use the Type-C mux state for retimers. +*/ +static int cros_typec_retimer_set (struct typec_retimer *retimer,struct typec_mux_state state) +{ +struct typec_retimer_state rstate = { + .alt = state.alt, + .mode = state.mode, + .data = state.data, + }; + +return typec_retimer_set (retimer, &rstate); +} +static int cros_typec_usb_disconnect_state (struct cros_typec_port *port) { port->state.alt =NULL ;
@@ -213,6 +238,7 @@ static int cros_typec_usb_disconnect_state(struct cros_typec_port *port)usb_role_switch_set_role (port->role_sw,USB_ROLE_NONE );typec_switch_set (port->ori_sw,TYPEC_ORIENTATION_NONE ); +cros_typec_retimer_set (port->retimer, port->state);return typec_mux_set (port->mux, &port->state); }
@@ -410,9 +436,14 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)static int cros_typec_usb_safe_state (struct cros_typec_port *port) { +int ret; port->state.mode =TYPEC_STATE_SAFE ; -return typec_mux_set (port->mux, &port->state); + ret =cros_typec_retimer_set (port->retimer, port->state); +if (!ret) + ret =typec_mux_set (port->mux, &port->state); + +return ret; }/*
@@ -509,7 +540,11 @@ static int cros_typec_enable_dp(struct cros_typec_data *typec, port->state.data = &dp_data; port->state.mode =TYPEC_MODAL_STATE (ffs (pd_ctrl->dp_mode)); -return typec_mux_set (port->mux, &port->state); + ret =cros_typec_retimer_set (port->retimer, port->state); +if (!ret) + ret =typec_mux_set (port->mux, &port->state); + +return ret; } static int cros_typec_enable_usb4(struct cros_typec_data *typec,
@@ -598,7 +633,10 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num, }else if (port->mux_flags &USB_PD_MUX_USB_ENABLED ) { port->state.alt =NULL ; port->state.mode =TYPEC_STATE_USB ; - ret =typec_mux_set (port->mux, &port->state); + + ret =cros_typec_retimer_set (port->retimer, port->state); +if (!ret) + ret =typec_mux_set (port->mux, &port->state); }else { dev_dbg(typec->dev, "Unrecognized mode requested, mux flags: %x\n",
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 172/1073 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 | 3 +++ 1 file changed, 3 insertions(+)
drivers/platform/chrome/cros_ec_typec.c +3 -0
@@ -168,10 +168,13 @@ 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_retimer_put (port->retimer); + port->retimer =NULL ; retimer_sw_err:typec_mux_put (port->mux); + port->mux =NULL ; mux_err:return -ENODEV ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 173/1073 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 174/1073 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 175/1073 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 176/1073 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
@@ -1096,7 +1096,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 177/1073 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 178/1073 nfsd: return error if nfs4_setacl fails
In reply to Greg Kroah-HartmanFrom: Jeff Layton <[email protected]>
[ Upstream commit 01d53a88c08951f88f2a42f1f1e6568928e0590e ]
With the addition of POSIX ACLs to struct nfsd_attrs, we no longer return an error if setting the ACL fails. Ensure we return the na_aclerr error on SETATTR if there is one.
--- fs/nfsd/nfs4proc.c | 2 ++ 1 file changed, 2 insertions(+)
fs/nfsd/nfs4proc.c +2 -0
@@ -1141,6 +1141,8 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, 0, (time64_t)0);if (!status) status =nfserrno (attrs.na_labelerr); +if (!status) + status =nfserrno (attrs.na_aclerr); out:nfsd_attrs_free (&attrs);fh_drop_write (&cstate->current_fh);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 179/1073 NFSD: pass range end to vfs_fsync_range() instead of count
In reply to Greg Kroah-HartmanFrom: Brian Foster <[email protected]>
[ Upstream commit 79a1d88a36f77374c77fd41a4386d8c2736b8704 ]
_nfsd_copy_file_range() calls vfs_fsync_range() with an offset and count (bytes written), but the former wants the start and end bytes of the range to sync. Fix it up.
--- fs/nfsd/nfs4proc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/nfsd/nfs4proc.c +3 -2
@@ -1650,6 +1650,7 @@ static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy,u64 src_pos = copy->cp_src_pos;u64 dst_pos = copy->cp_dst_pos;int status; +loff_t end;/* See RFC 7862 p.67: */ if (bytes_total ==0 )
@@ -1669,8 +1670,8 @@ static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy,/* for a non-zero asynchronous copy do a commit of data */ if (nfsd4_copy_is_async (copy) && copy->cp_res.wr_bytes_written >0 ) { since =READ_ONCE (dst->f_wb_err); - status =vfs_fsync_range (dst, copy->cp_dst_pos, - copy->cp_res.wr_bytes_written,0 ); + end = copy->cp_dst_pos + copy->cp_res.wr_bytes_written -1 ; + status =vfs_fsync_range (dst, copy->cp_dst_pos, end,0 );if (!status) status =filemap_check_wb_err (dst->f_mapping, since);if (!status)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 180/1073 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 181/1073 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
@@ -1904,10 +1904,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);
@@ -1926,6 +1922,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 182/1073 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 183/1073 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 184/1073 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 185/1073 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
@@ -1912,6 +1912,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 186/1073 ipc: fix memory leak in init_mqueue_fs()
In reply to Greg Kroah-HartmanFrom: Zhengchao Shao <[email protected]>
[ Upstream commit 12b677f2c697d61e5ddbcb6c1650050a39392f54 ]
When setup_mq_sysctls() failed in init_mqueue_fs(), mqueue_inode_cachep is not released. In order to fix this issue, the release path is reordered.
--- ipc/mqueue.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
ipc/mqueue.c +4 -2
@@ -1727,7 +1727,8 @@ static int __init init_mqueue_fs(void)if (!setup_mq_sysctls (&init_ipc_ns)) {pr_warn ("sysctl registration failed\n" ); -return -ENOMEM ; + error = -ENOMEM ; + goto out_kmem; } error =register_filesystem (&mqueue_fs_type);
@@ -1745,8 +1746,9 @@ static int __init init_mqueue_fs(void) out_filesystem:unregister_filesystem (&mqueue_fs_type); out_sysctl: -kmem_cache_destroy (mqueue_inode_cachep);retire_mq_sysctls (&init_ipc_ns); +out_kmem: +kmem_cache_destroy (mqueue_inode_cachep);return error; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 187/1073 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 188/1073 wifi: fix multi-link element subelement iteration
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 1177aaa7fe9373c762cd5bf5f5de8517bac989d5 ]
The subelements obviously start after the common data, including the common multi-link element structure definition itself. This bug was possibly just hidden by the higher bits of the control being set to 0, so the iteration just found one bogus element and most of the code could continue anyway.
--- include/linux/ieee80211.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/ieee80211.h +1 -1
@@ -4588,7 +4588,7 @@ static inline u8 ieee80211_mle_common_size(const u8 *data)return 0 ; } -return common + mle->variable[0 ]; +return sizeof (*mle) + common + mle->variable[0 ]; }/**
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 189/1073 wifi: mac80211: mlme: fix null-ptr deref on failed assoc
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 78a6a43aaf87180ec7425a2a90468e1b4d09a1ec ]
If association to an AP without a link 0 fails, then we crash in tracing because it assumes that either ap_mld_addr or link 0 BSS is valid, since we clear sdata->vif.valid_links and then don't add the ap_mld_addr to the struct.
Since we clear also sdata->vif.cfg.ap_addr, keep a local copy of it and assign it earlier, before clearing valid_links, to fix this.
--- net/mac80211/mlme.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
net/mac80211/mlme.c +6 -2
@@ -4955,6 +4955,7 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,struct cfg80211_rx_assoc_resp resp = { .uapsd_queues =-1 , }; +u8 ap_mld_addr[ETH_ALEN ]__aligned(2) ;unsigned int link_id;sdata_assert_lock (sdata);
@@ -5119,6 +5120,11 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, resp.uapsd_queues |= ieee80211_ac_to_qos_mask[ac]; } +if (sdata->vif.valid_links) { +ether_addr_copy (ap_mld_addr, sdata->vif.cfg.ap_addr); + resp.ap_mld_addr = ap_mld_addr; + } + ieee80211_destroy_assoc_data(sdata, status_code == WLAN_STATUS_SUCCESS ? ASSOC_SUCCESS :
@@ -5128,8 +5134,6 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, resp.len = len; resp.req_ies = ifmgd->assoc_req_ies; resp.req_ies_len = ifmgd->assoc_req_ies_len; -if (sdata->vif.valid_links) - resp.ap_mld_addr = sdata->vif.cfg.ap_addr;cfg80211_rx_assoc_resp (sdata->dev, &resp); notify_driver:drv_mgd_complete_tx (sdata->local, sdata, &info);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 190/1073 wifi: mac80211: check link ID in auth/assoc continuation
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 85176a3fcd9748558cff72d4cdff5465b8732282 ]
Ensure that the link ID matches in auth/assoc continuation, otherwise we need to reset all the data.
--- net/mac80211/ieee80211_i.h | 1 + net/mac80211/mlme.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-)
net/mac80211/ieee80211_i.h +1 -0
@@ -389,6 +389,7 @@ struct ieee80211_mgd_auth_data {bool done, waiting;bool peer_confirmed;bool timeout_started; +int link_id;u8 ap_addr[ETH_ALEN ]__aligned(2) ;
net/mac80211/mlme.c +5 -2
@@ -6582,6 +6582,7 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, req->ap_mld_addr ?: req->bss->bssid, ETH_ALEN); auth_data->bss = req->bss; + auth_data->link_id = req->link_id;if (req->auth_data_len >=4 ) {if (req->auth_type ==NL80211_AUTHTYPE_SAE ) {
@@ -6600,7 +6601,8 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,* removal and re-addition of the STA entry in * ieee80211_prep_connection(). */ - cont_auth = ifmgd->auth_data && req->bss == ifmgd->auth_data->bss; + cont_auth = ifmgd->auth_data && req->bss == ifmgd->auth_data->bss && + ifmgd->auth_data->link_id == req->link_id;if (req->ie && req->ie_len) { memcpy(&auth_data->data[auth_data->data_len],
@@ -6937,7 +6939,8 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,/* keep sta info, bssid if matching */ match =ether_addr_equal (ifmgd->auth_data->ap_addr, - assoc_data->ap_addr); + assoc_data->ap_addr) && + ifmgd->auth_data->link_id == req->link_id;ieee80211_destroy_auth_data (sdata, match); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 191/1073 wifi: mac80211: fix ifdef symbol name
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 9d13aff91ecd3f077b432df35291c945bde585be ]
This should of course be CONFIG_, not CPTCFG_, which is an artifact from working with backports.
--- net/mac80211/tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/tx.c +1 -1
@@ -2934,7 +2934,7 @@ static struct sk_buff *ieee80211_build_hdr(struct ieee80211_sub_if_data *sdata,if (pre_conf_link_id != link_id && link_id !=IEEE80211_LINK_UNSPECIFIED ) { -#ifdef CPTCFG_MAC80211_VERBOSE_DEBUG +#ifdef CONFIG_MAC80211_VERBOSE_DEBUG net_info_ratelimited ("%s: dropped frame to %pM with bad link ID request (%d vs. %d)\n" , sdata->name, hdr.addr1, pre_conf_link_id, link_id);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 192/1073 drm/atomic-helper: Dont allocate new plane state in CRTC check
In reply to Greg Kroah-HartmanFrom: Thomas Zimmermann <[email protected]>
[ Upstream commit dbbf933d365da1a76a540211bee3d57bde520194 ]
In drm_atomic_helper_check_crtc_state(), do not add a new plane state to the global state if it does not exist already. Adding a new plane state will result in overhead for the plane during the atomic-commit step.
For the test in drm_atomic_helper_check_crtc_state() to succeed, it is important that the CRTC has an enabled primary plane after the commit. Simply testing the CRTC state's plane_mask for a primary plane is sufficient.
Note that the helper still only tests for an attached primary plane. Drivers have to ensure that the plane contains valid pixel information.
v5:
* fix commit description (Javier)
v3:
* test for a primary plane in plane_mask (Ville)
v2:
* remove unnecessary test for plane->crtc (Ville)
* inline drm_atomic_get_next_plane_state() (Ville)
* acquire plane lock before accessing plane->state (Ville)
--- drivers/gpu/drm/drm_atomic_helper.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +1 -9
@@ -899,7 +899,6 @@ int drm_atomic_helper_check_crtc_state(struct drm_crtc_state *crtc_state, bool can_disable_primary_planes) {struct drm_device *dev = crtc_state->crtc->dev; -struct drm_atomic_state *state = crtc_state->state;if (!crtc_state->enable)return 0 ;
@@ -910,14 +909,7 @@ int drm_atomic_helper_check_crtc_state(struct drm_crtc_state *crtc_state,struct drm_plane *plane;drm_for_each_plane_mask (plane, dev, crtc_state->plane_mask) { -struct drm_plane_state *plane_state; - -if (plane->type !=DRM_PLANE_TYPE_PRIMARY ) -continue ; - plane_state =drm_atomic_get_plane_state (state, plane); -if (IS_ERR (plane_state)) -return PTR_ERR (plane_state); -if (plane_state->fb && plane_state->crtc) { +if (plane->type ==DRM_PLANE_TYPE_PRIMARY ) { has_primary_plane = true;break ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 193/1073 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
@@ -780,14 +780,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 194/1073 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
@@ -708,14 +708,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 :
@@ -724,7 +723,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 );
@@ -735,25 +734,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 ); }
@@ -762,12 +763,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 195/1073 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
@@ -1608,18 +1608,18 @@ static int rtl8xxxu_identify_chip(struct rtl8xxxu_priv *priv) {struct device *dev = &priv->udev->dev;struct ieee80211_hw *hw = priv->hw; -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 ;
@@ -1641,7 +1641,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 ==
@@ -1692,7 +1692,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 ;
@@ -1709,7 +1709,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 · 12 lines
2.35.1 [email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Sasha Levin <[email protected]> --- fs/ocfs2/journal.c | 2 +- fs/ocfs2/journal.h | 1 + fs/ocfs2/super.c | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-)
fs/ocfs2/journal.c +1 -1
@@ -157,7 +157,7 @@ static void ocfs2_queue_replay_slots(struct ocfs2_super *osb, replay_map->rm_state =REPLAY_DONE ; } -static void ocfs2_free_replay_slots (struct ocfs2_super *osb) +void ocfs2_free_replay_slots (struct ocfs2_super *osb) {struct ocfs2_replay_map *replay_map = osb->replay_map;
fs/ocfs2/journal.h +1 -0
@@ -150,6 +150,7 @@ int ocfs2_recovery_init(struct ocfs2_super *osb);void ocfs2_recovery_exit (struct ocfs2_super *osb);int ocfs2_compute_replay_slots (struct ocfs2_super *osb); +void ocfs2_free_replay_slots (struct ocfs2_super *osb);/* * Journal Control: * Initialize, Load, Shutdown, Wipe a journal.
fs/ocfs2/super.c +4 -1
@@ -1159,6 +1159,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) out_dismount:atomic_set (&osb->vol_state,VOLUME_DISABLED );wake_up (&osb->osb_mount_event); +ocfs2_free_replay_slots (osb);ocfs2_dismount_volume (sb,1 ); goto out;
@@ -1822,12 +1823,14 @@ static int ocfs2_mount_volume(struct super_block *sb) status =ocfs2_truncate_log_init (osb);if (status <0 ) {mlog_errno (status); - goto out_system_inodes; + goto out_check_volume; }ocfs2_super_unlock (osb,1 );return 0 ; +out_check_volume: +ocfs2_free_replay_slots (osb); out_system_inodes:if (osb->local_alloc_state ==OCFS2_LA_ENABLED )ocfs2_shutdown_local_alloc (osb);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 196/1073 wifi: ath11k: move firmware stats out of debugfs
In reply to Greg Kroah-HartmanFrom: Aditya Kumar Singh <[email protected]>
[ Upstream commit ec8918f922b8a40a12cb86793245026f08b79812 ]
Currently, firmware stats, comprising pdev, vdev and beacon stats are part of debugfs. In firmware pdev stats, firmware reports the final Tx power used to transmit each packet. If driver wants to know the final Tx power being used at firmware level, it can leverage from firmware pdev stats.
Move firmware stats out of debugfs context in order to leverage the final Tx power reported in it even when debugfs is disabled.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.5.0.1-01100-QCAHKSWPL_SILICONZ-1
Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.5.0.1-01100-QCAHKSWPL_SILICONZ-1
Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3
Stable-dep-of: 3ff51d7416ee ("wifi: ath11k: fix firmware assert during bandwidth change for peer sta")
--- drivers/net/wireless/ath/ath11k/core.c | 46 +++++++ drivers/net/wireless/ath/ath11k/core.h | 12 +- drivers/net/wireless/ath/ath11k/debugfs.c | 139 +++++----------------- drivers/net/wireless/ath/ath11k/debugfs.h | 6 +- drivers/net/wireless/ath/ath11k/wmi.c | 48 +++++++- 5 files changed, 137 insertions(+), 114 deletions(-)
drivers/net/wireless/ath/ath11k/core.c +46 -0
@@ -535,6 +535,52 @@ static inline struct ath11k_pdev *ath11k_core_get_single_pdev(struct ath11k_basereturn &ab->pdevs[0 ]; } +void ath11k_fw_stats_pdevs_free (struct list_head *head) +{ +struct ath11k_fw_stats_pdev *i, *tmp; + +list_for_each_entry_safe (i, tmp, head, list) { +list_del (&i->list); +kfree (i); + } +} + +void ath11k_fw_stats_vdevs_free (struct list_head *head) +{ +struct ath11k_fw_stats_vdev *i, *tmp; + +list_for_each_entry_safe (i, tmp, head, list) { +list_del (&i->list); +kfree (i); + } +} + +void ath11k_fw_stats_bcn_free (struct list_head *head) +{ +struct ath11k_fw_stats_bcn *i, *tmp; + +list_for_each_entry_safe (i, tmp, head, list) { +list_del (&i->list); +kfree (i); + } +} + +void ath11k_fw_stats_init (struct ath11k *ar) +{ +INIT_LIST_HEAD (&ar->fw_stats.pdevs); +INIT_LIST_HEAD (&ar->fw_stats.vdevs); +INIT_LIST_HEAD (&ar->fw_stats.bcn); + +init_completion (&ar->fw_stats_complete); +} + +void ath11k_fw_stats_free (struct ath11k_fw_stats *stats) +{ +ath11k_fw_stats_pdevs_free (&stats->pdevs); +ath11k_fw_stats_vdevs_free (&stats->vdevs); +ath11k_fw_stats_bcn_free (&stats->bcn); +} +int ath11k_core_suspend (struct ath11k_base *ab) {int ret;
drivers/net/wireless/ath/ath11k/core.h +9 -3
@@ -545,9 +545,6 @@ struct ath11k_debug {struct dentry *debugfs_pdev;struct ath11k_dbg_htt_stats htt_stats;u32 extd_tx_stats; -struct ath11k_fw_stats fw_stats; -struct completion fw_stats_complete; -bool fw_stats_done;u32 extd_rx_stats;u32 pktlog_filter;u32 pktlog_mode;
@@ -710,6 +707,9 @@ struct ath11k {u8 twt_enabled;bool nlo_enabled;u8 alpha2[REG_ALPHA2_LEN +1 ]; +struct ath11k_fw_stats fw_stats; +struct completion fw_stats_complete; +bool fw_stats_done; };struct ath11k_band_cap {
@@ -1112,6 +1112,12 @@ struct ath11k_fw_stats_bcn {u32 tx_bcn_outage_cnt; }; +void ath11k_fw_stats_init (struct ath11k *ar); +void ath11k_fw_stats_pdevs_free (struct list_head *head); +void ath11k_fw_stats_vdevs_free (struct list_head *head); +void ath11k_fw_stats_bcn_free (struct list_head *head); +void ath11k_fw_stats_free (struct ath11k_fw_stats *stats); +extern const struct ce_pipe_config ath11k_target_ce_config_wlan_ipq8074[];extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_ipq8074[];extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_ipq6018[];
drivers/net/wireless/ath/ath11k/debugfs.c +32 -107
238 lines not on this page · raw message
drivers/net/wireless/ath/ath11k/debugfs.h +3 -3
@@ -269,7 +269,7 @@ int ath11k_debugfs_pdev_create(struct ath11k_base *ab);void ath11k_debugfs_pdev_destroy (struct ath11k_base *ab);int ath11k_debugfs_register (struct ath11k *ar);void ath11k_debugfs_unregister (struct ath11k *ar); -void ath11k_debugfs_fw_stats_process (struct ath11k_base *ab,struct sk_buff *skb); +void ath11k_debugfs_fw_stats_process (struct ath11k *ar,struct ath11k_fw_stats *stats);void ath11k_debugfs_fw_stats_init (struct ath11k *ar); int ath11k_debugfs_get_fw_stats(struct ath11k *ar, u32 pdev_id,
@@ -341,8 +341,8 @@ static inline void ath11k_debugfs_unregister(struct ath11k *ar) { } -static inline void ath11k_debugfs_fw_stats_process (struct ath11k_base *ab, -struct sk_buff *skb) +static inline void ath11k_debugfs_fw_stats_process (struct ath11k *ar, +struct ath11k_fw_stats *stats) { }
drivers/net/wireless/ath/ath11k/wmi.c +47 -1
54 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 197/1073 wifi: ath11k: fix firmware assert during bandwidth change for peer sta
In reply to Greg Kroah-HartmanFrom: Aditya Kumar Singh <[email protected]>
[ Upstream commit 3ff51d7416ee1ea2d771051a0ffa1ec8be054768 ]
Currently, ath11k sends peer assoc command for each peer to firmware when bandwidth changes. Peer assoc command is a bulky command and if many clients are connected, this could lead to firmware buffer getting overflowed leading to a firmware assert.
However, during bandwidth change, only phymode and bandwidth also can be updated by WMI set peer param command. This makes the overall command light when compared to peer assoc and for multi-client cases, firmware buffer overflow also does not occur.
Remove sending peer assoc command during sta bandwidth change and instead add sending WMI set peer param command for phymode and bandwidth.
Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.5.0.1-01100-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath11k/core.h | 2 + drivers/net/wireless/ath/ath11k/mac.c | 122 +++++++++++++++++-------- 2 files changed, 87 insertions(+), 37 deletions(-)
drivers/net/wireless/ath/ath11k/core.h +2 -0
@@ -498,6 +498,8 @@ struct ath11k_sta {bool use_4addr_set;u16 tcl_metadata; + +u32 bw_prev; };#define ATH11K_MIN_5G_FREQ 4150
drivers/net/wireless/ath/ath11k/mac.c +85 -37
173 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 198/1073 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
@@ -402,7 +402,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) {
@@ -960,6 +969,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 199/1073 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
@@ -219,6 +219,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;
@@ -237,8 +248,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); }
@@ -1520,11 +1531,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 200/1073 libbpf: Fix memory leak in parse_usdt_arg()
In reply to Greg Kroah-HartmanFrom: Xu Kuohai <[email protected]>
[ Upstream commit 0dc9254e03704c75f2ebc9cbef2ce4de83fba603 ]
In the arm64 version of parse_usdt_arg(), when sscanf returns 2, reg_name is allocated but not freed. Fix it.
--- tools/lib/bpf/usdt.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
tools/lib/bpf/usdt.c +4 -7
@@ -1348,25 +1348,23 @@ static int calc_pt_regs_off(const char *reg_name)static int parse_usdt_arg (const char *arg_str,int arg_num,struct usdt_arg_spec *arg) { -char *reg_name =NULL ; +char reg_name[16 ];int arg_sz, len, reg_off;long off; -if (sscanf (arg_str," %d @ \[ %m[a-z0-9], %ld ] %n" , &arg_sz, ®_name, &off, &len) ==3 ) { +if (sscanf (arg_str," %d @ \[ %15[a-z0-9], %ld ] %n" , &arg_sz, reg_name, &off, &len) ==3 ) {/* Memory dereference case, e.g., -4@[sp, 96] */ arg->arg_type =USDT_ARG_REG_DEREF ; arg->val_off = off; reg_off =calc_pt_regs_off (reg_name); -free (reg_name);if (reg_off <0 )return reg_off; arg->reg_off = reg_off; - }else if (sscanf (arg_str," %d @ \[ %m[a-z0-9] ] %n" , &arg_sz, ®_name, &len) ==2 ) { + }else if (sscanf (arg_str," %d @ \[ %15[a-z0-9] ] %n" , &arg_sz, reg_name, &len) ==2 ) {/* Memory dereference case, e.g., -4@[sp] */ arg->arg_type =USDT_ARG_REG_DEREF ; arg->val_off =0 ; reg_off =calc_pt_regs_off (reg_name); -free (reg_name);if (reg_off <0 )return reg_off; arg->reg_off = reg_off;
@@ -1375,12 +1373,11 @@ static int parse_usdt_arg(const char *arg_str, int arg_num, struct usdt_arg_spec arg->arg_type =USDT_ARG_CONST ; arg->val_off = off; arg->reg_off =0 ; - }else if (sscanf (arg_str," %d @ %m[a-z0-9] %n" , &arg_sz, ®_name, &len) ==2 ) { + }else if (sscanf (arg_str," %d @ %15[a-z0-9] %n" , &arg_sz, reg_name, &len) ==2 ) {/* Register read case, e.g., -8@x4 */ arg->arg_type =USDT_ARG_REG ; arg->val_off =0 ; reg_off =calc_pt_regs_off (reg_name); -free (reg_name);if (reg_off <0 )return reg_off; arg->reg_off = reg_off;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 201/1073 selftests/bpf: Add struct argument tests with fentry/fexit programs.
In reply to Greg Kroah-HartmanFrom: Yonghong Song <[email protected]>
[ Upstream commit 1642a3945e223a922312fab2401ecdf58b3825b9 ]
Add various struct argument tests with fentry/fexit programs. Also add one test with a kernel func which does not have any argument to test BPF_PROG2 macro in such situation.
Stable-dep-of: 6e8280b958c5 ("selftests/bpf: Fix memory leak caused by not destroying skeleton")
--- .../selftests/bpf/bpf_testmod/bpf_testmod.c | 48 +++++++ .../selftests/bpf/prog_tests/tracing_struct.c | 63 +++++++++ .../selftests/bpf/progs/tracing_struct.c | 120 ++++++++++++++++++ 3 files changed, 231 insertions(+) create mode 100644 tools/testing/selftests/bpf/prog_tests/tracing_struct.c create mode 100644 tools/testing/selftests/bpf/progs/tracing_struct.c
tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c +48 -0
@@ -18,6 +18,46 @@ typedef int (*func_proto_typedef_nested1)(func_proto_typedef);typedef int (*func_proto_typedef_nested2 )(func_proto_typedef_nested1 );DEFINE_PER_CPU (int, bpf_testmod_ksym_percpu) =123 ; +long bpf_testmod_test_struct_arg_result; + +struct bpf_testmod_struct_arg_1 { +int a; +}; +struct bpf_testmod_struct_arg_2 { +long a; +long b; +}; + +noinline int +bpf_testmod_test_struct_arg_1 (struct bpf_testmod_struct_arg_2 a,int b,int c) { + bpf_testmod_test_struct_arg_result = a.a + a.b + b + c; +return bpf_testmod_test_struct_arg_result; +} + +noinline int +bpf_testmod_test_struct_arg_2 (int a,struct bpf_testmod_struct_arg_2 b,int c) { + bpf_testmod_test_struct_arg_result = a + b.a + b.b + c; +return bpf_testmod_test_struct_arg_result; +} + +noinline int +bpf_testmod_test_struct_arg_3 (int a,int b,struct bpf_testmod_struct_arg_2 c) { + bpf_testmod_test_struct_arg_result = a + b + c.a + c.b; +return bpf_testmod_test_struct_arg_result; +} + +noinline int +bpf_testmod_test_struct_arg_4 (struct bpf_testmod_struct_arg_1 a,int b, +int c,int d,struct bpf_testmod_struct_arg_2 e) { + bpf_testmod_test_struct_arg_result = a.a + b + c + d + e.a + e.b; +return bpf_testmod_test_struct_arg_result; +} + +noinline int +bpf_testmod_test_struct_arg_5 (void ) { + bpf_testmod_test_struct_arg_result =1 ; +return bpf_testmod_test_struct_arg_result; +} noinline voidbpf_testmod_test_mod_kfunc (int i)
@@ -115,11 +155,19 @@ bpf_testmod_test_read(struct file *file, struct kobject *kobj, .off = off, .len = len, }; +struct bpf_testmod_struct_arg_1 struct_arg1 = {10 }; +struct bpf_testmod_struct_arg_2 struct_arg2 = {2 ,3 };int i =1 ;while (bpf_testmod_return_ptr (i)) i++; + (void )bpf_testmod_test_struct_arg_1 (struct_arg2,1 ,4 ); + (void )bpf_testmod_test_struct_arg_2 (1 , struct_arg2,4 ); + (void )bpf_testmod_test_struct_arg_3 (1 ,4 , struct_arg2); + (void )bpf_testmod_test_struct_arg_4 (struct_arg1,1 ,2 ,3 , struct_arg2); + (void )bpf_testmod_test_struct_arg_5 (); +/* This is always true. Use the check to make sure the compiler * doesn't remove bpf_testmod_loop_test. */
tools/testing/selftests/bpf/prog_tests/tracing_struct.c new file +63 -0
63 lines not on this page · raw message
tools/testing/selftests/bpf/progs/tracing_struct.c new file +120 -0
120 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 202/1073 selftests/bpf: Fix memory leak caused by not destroying skeleton
In reply to Greg Kroah-HartmanFrom: Xu Kuohai <[email protected]>
[ Upstream commit 6e8280b958c5d7edc514cf347a800b23b7732b2b ]
Some test cases does not destroy skeleton object correctly, causing ASAN to report memory leak warning. Fix it.
--- tools/testing/selftests/bpf/prog_tests/map_kptr.c | 3 ++- tools/testing/selftests/bpf/prog_tests/tracing_struct.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/prog_tests/map_kptr.c +2 -1
@@ -105,7 +105,7 @@ static void test_map_kptr_success(bool test_run)ASSERT_OK (opts.retval,"test_map_kptr_ref2 retval" );if (test_run) -return ; + goto exit; ret =bpf_map__update_elem (skel->maps.array_map, &key,sizeof (key), buf,sizeof (buf),0 );
@@ -132,6 +132,7 @@ static void test_map_kptr_success(bool test_run) ret =bpf_map__delete_elem (skel->maps.lru_hash_map, &key,sizeof (key),0 );ASSERT_OK (ret,"lru_hash_map delete" ); +exit:map_kptr__destroy (skel); }
tools/testing/selftests/bpf/prog_tests/tracing_struct.c +2 -1
@@ -15,7 +15,7 @@ static void test_fentry(void) err =tracing_struct__attach (skel);if (!ASSERT_OK (err,"tracing_struct__attach" )) -return ; + goto destroy_skel;ASSERT_OK (trigger_module_test_read (256 ),"trigger_read" );
@@ -54,6 +54,7 @@ static void test_fentry(void)ASSERT_EQ (skel->bss->t5_ret,1 ,"t5 ret" );tracing_struct__detach (skel); +destroy_skel:tracing_struct__destroy (skel); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 203/1073 selftest/bpf: Fix memory leak in kprobe_multi_test
In reply to Greg Kroah-HartmanFrom: Xu Kuohai <[email protected]>
[ Upstream commit 6d2e21dc4db3933db65293552ecc1ede26febeca ]
The get_syms() function in kprobe_multi_test.c does not free the string memory allocated by sscanf correctly. Fix it.
--- .../bpf/prog_tests/kprobe_multi_test.c | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-)
tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c +14 -12
@@ -325,7 +325,7 @@ static bool symbol_equal(const void *key1, const void *key2, void *ctx __maybe_ustatic int get_syms (char ***symsp,size_t *cntp) {size_t cap =0 , cnt =0 , i; -char *name, **syms =NULL ; +char *name =NULL , **syms =NULL ;struct hashmap *map;char buf[256 ];FILE *f;
@@ -352,6 +352,8 @@ static int get_syms(char ***symsp, size_t *cntp)/* skip modules */ if (strchr (buf,'[' ))continue ; + +free (name);if (sscanf (buf,"%ms$*[^\n]\n" , &name) !=1 )continue ;/*
@@ -369,32 +371,32 @@ static int get_syms(char ***symsp, size_t *cntp)if (!strncmp (name,"__ftrace_invalid_address__" ,sizeof ("__ftrace_invalid_address__" ) -1 ))continue ; + err =hashmap__add (map, name,NULL ); -if (err) { -free (name); -if (err == -EEXIST ) -continue ; +if (err == -EEXIST ) +continue ; +if (err) goto error; - } + err =libbpf_ensure_mem ((void **) &syms, &cap,sizeof (*syms), cnt +1 ); -if (err) { -free (name); +if (err) goto error; - } - syms[cnt] = name; - cnt++; + + syms[cnt++] = name; + name =NULL ; } *symsp = syms; *cntp = cnt; error: +free (name);fclose (f);hashmap__free (map);if (err) {for (i =0 ; i < cnt; i++) -free (syms[cnt]); +free (syms[i]);free (syms); }return err;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 204/1073 selftests/bpf: Fix error failure of case test_xdp_adjust_tail_grow
In reply to Greg Kroah-HartmanFrom: Xu Kuohai <[email protected]>
[ Upstream commit 4abdb1d5b250df4b5b3afd394d5e2fa516064c04 ]
test_xdp_adjust_tail_grow failed with ipv6:
test_xdp_adjust_tail_grow:FAIL:ipv6 unexpected error: -28 (errno 28)
The reason is that this test case tests ipv4 before ipv6, and when ipv4 test finished, topts.data_size_out was set to 54, which is smaller than the ipv6 output data size 114, so ipv6 test fails with NOSPC error.
Fix it by reset topts.data_size_out to sizeof(buf) before testing ipv6.
--- tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c +1 -0
@@ -63,6 +63,7 @@ static void test_xdp_adjust_tail_grow(void) expect_sz =sizeof (pkt_v6) +40 ;/* Test grow with 40 bytes */ topts.data_in = &pkt_v6; topts.data_size_in =sizeof (pkt_v6); + topts.data_size_out =sizeof (buf); err =bpf_prog_test_run_opts (prog_fd, &topts);ASSERT_OK (err,"ipv6" );ASSERT_EQ (topts.retval,XDP_TX ,"ipv6 retval" );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 205/1073 selftest/bpf: Fix error usage of ASSERT_OK in xdp_adjust_tail.c
In reply to Greg Kroah-HartmanFrom: Xu Kuohai <[email protected]>
[ Upstream commit cbc1c998da59687e8bbc4667154a72eead2daf2d ]
xdp_adjust_tail.c calls ASSERT_OK() to check the return value of bpf_prog_test_load(), but the condition is not correct. Fix it.
--- tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c +3 -3
@@ -18,7 +18,7 @@ static void test_xdp_adjust_tail_shrink(void) ); err =bpf_prog_test_load (file,BPF_PROG_TYPE_XDP , &obj, &prog_fd); -if (ASSERT_OK (err,"test_xdp_adjust_tail_shrink" )) +if (!ASSERT_OK (err,"test_xdp_adjust_tail_shrink" ))return ; err =bpf_prog_test_run_opts (prog_fd, &topts);
@@ -53,7 +53,7 @@ static void test_xdp_adjust_tail_grow(void) ); err =bpf_prog_test_load (file,BPF_PROG_TYPE_XDP , &obj, &prog_fd); -if (ASSERT_OK (err,"test_xdp_adjust_tail_grow" )) +if (!ASSERT_OK (err,"test_xdp_adjust_tail_grow" ))return ; err =bpf_prog_test_run_opts (prog_fd, &topts);
@@ -90,7 +90,7 @@ static void test_xdp_adjust_tail_grow2(void) ); err =bpf_prog_test_load (file,BPF_PROG_TYPE_XDP , &obj, &prog_fd); -if (ASSERT_OK (err,"test_xdp_adjust_tail_grow" )) +if (!ASSERT_OK (err,"test_xdp_adjust_tail_grow" ))return ;/* Test case-64 */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 206/1073 libbpf: Reject legacy maps ELF section
In reply to Greg Kroah-HartmanFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit e19db6762c18ab1ddf7a3ef4d0023780c24dc1e8 ]
Add explicit error message if BPF object file is still using legacy BPF map definitions in SEC("maps"). Before this change, if BPF object file is still using legacy map definition user will see a bit confusing:
libbpf: elf: skipping unrecognized data section(4) maps
libbpf: prog 'handler': bad map relo against 'server_map' in section 'maps'
Now libbpf will be explicit about rejecting "maps" ELF section:
libbpf: elf: legacy map definitions in 'maps' section are not supported by libbpf v1.0+
Stable-dep-of: 51deedc9b868 ("libbpf: Use elf_getshdrnum() instead of e_shnum")
--- tools/lib/bpf/libbpf.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
tools/lib/bpf/libbpf.c +3 -5
@@ -591,7 +591,6 @@ struct elf_state {size_t strtabidx;struct elf_sec_desc *secs;int sec_cnt; -int maps_shndx;int btf_maps_shndx;__u32 btf_maps_sec_btf_id;int text_shndx;
@@ -1272,7 +1271,6 @@ static struct bpf_object *bpf_object__new(const char *path,*/ obj->efile.obj_buf = obj_buf; obj->efile.obj_buf_sz = obj_buf_sz; - obj->efile.maps_shndx =-1 ; obj->efile.btf_maps_shndx =-1 ; obj->efile.st_ops_shndx =-1 ; obj->kconfig_map_idx =-1 ;
@@ -3359,7 +3357,8 @@ static int bpf_object__elf_collect(struct bpf_object *obj)if (err)return err; }else if (strcmp (name,"maps" ) ==0 ) { - obj->efile.maps_shndx = idx; +pr_warn ("elf: legacy map definitions in 'maps' section are not supported by libbpf v1.0+\n" ); +return -ENOTSUP ; }else if (strcmp (name,MAPS_ELF_SEC ) ==0 ) { obj->efile.btf_maps_shndx = idx; }else if (strcmp (name,BTF_ELF_SEC ) ==0 ) {
@@ -3891,8 +3890,7 @@ static bool bpf_object__shndx_is_data(const struct bpf_object *obj,static bool bpf_object__shndx_is_maps (const struct bpf_object *obj,int shndx) { -return shndx == obj->efile.maps_shndx || - shndx == obj->efile.btf_maps_shndx; +return shndx == obj->efile.btf_maps_shndx; } static enum libbpf_map_type
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 207/1073 libbpf: Use elf_getshdrnum() instead of e_shnum
In reply to Greg Kroah-HartmanFrom: Shung-Hsi Yu <[email protected]>
[ Upstream commit 51deedc9b8680953437dfe359e5268120de10e30 ]
This commit replace e_shnum with the elf_getshdrnum() helper to fix two oss-fuzz-reported heap-buffer overflow in __bpf_object__open. Both reports are incorrectly marked as fixed and while still being reproducible in the latest libbpf.
# clusterfuzz-testcase-minimized-bpf-object-fuzzer-5747922482888704
libbpf: loading object 'fuzz-object' from buffer
libbpf: sec_cnt is 0
libbpf: elf: section(1) .data, size 0, link 538976288, flags 2020202020202020, type=2
libbpf: elf: section(2) .data, size 32, link 538976288, flags 202020202020ff20, type=1
=================================================================
==13==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6020000000c0 at pc 0x0000005a7b46 bp 0x7ffd12214af0 sp 0x7ffd12214ae8
WRITE of size 4 at 0x6020000000c0 thread T0
SCARINESS: 46 (4-byte-write-heap-buffer-overflow-far-from-bounds)
#0 0x5a7b45 in bpf_object__elf_collect /src/libbpf/src/libbpf.c:3414:24
#1 0x5733c0 in bpf_object_open /src/libbpf/src/libbpf.c:7223:16
#2 0x5739fd in bpf_object__open_mem /src/libbpf/src/libbpf.c:7263:20
...The issue lie in libbpf's direct use of e_shnum field in ELF header as the section header count. Where as libelf implemented an extra logic that, when e_shnum == 0 && e_shoff != 0, will use sh_size member of the initial section header as the real section header count (part of ELF spec to accommodate situation where section header counter is larger than SHN_LORESERVE).
The above inconsistency lead to libbpf writing into a zero-entry calloc area. So intead of using e_shnum directly, use the elf_getshdrnum() helper provided by libelf to retrieve the section header counter into sec_cnt.
--- tools/lib/bpf/libbpf.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
tools/lib/bpf/libbpf.c +9 -4
@@ -590,7 +590,7 @@ struct elf_state {size_t shstrndx;/* section index for section name strings */ size_t strtabidx;struct elf_sec_desc *secs; -int sec_cnt; +size_t sec_cnt;int btf_maps_shndx;__u32 btf_maps_sec_btf_id;int text_shndx;
@@ -3282,10 +3282,15 @@ static int bpf_object__elf_collect(struct bpf_object *obj)Elf64_Shdr *sh;/* ELF section indices are 0-based, but sec #0 is special "invalid" -* section. e_shnum does include sec #0, so e_shnum is the necessary -* size of an array to keep all the sections. +* section. Since section count retrieved by elf_getshdrnum() does +* include sec #0, it is already the necessary size of an array to keep +* all the sections. */ - obj->efile.sec_cnt = obj->efile.ehdr->e_shnum; +if (elf_getshdrnum (obj->efile.elf, &obj->efile.sec_cnt)) { +pr_warn ("elf: failed to get the number of sections for %s: %s\n" , + obj->path,elf_errmsg (-1 )); +return -LIBBPF_ERRNO__FORMAT ; + } obj->efile.secs =calloc (obj->efile.sec_cnt,sizeof (*obj->efile.secs));if (!obj->efile.secs)return -ENOMEM ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 208/1073 libbpf: Deal with section with no data gracefully
In reply to Greg Kroah-HartmanFrom: Shung-Hsi Yu <[email protected]>
[ Upstream commit 35a855509e6ee3442477c8ebc6827b5b5d32a7b5 ]
ELF section data pointer returned by libelf may be NULL (if section has SHT_NOBITS), so null check section data pointer before attempting to copy license and kversion section.
--- tools/lib/bpf/libbpf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +5 -1
@@ -1399,6 +1399,10 @@ static int bpf_object__check_endianness(struct bpf_object *obj)static int bpf_object__init_license (struct bpf_object *obj,void *data,size_t size) { +if (!data) { +pr_warn ("invalid license section in %s\n" , obj->path); +return -LIBBPF_ERRNO__FORMAT ; + }/* libbpf_strlcpy() only copies first N - 1 bytes, so size + 1 won't * go over allowed ELF data section buffer */
@@ -1412,7 +1416,7 @@ bpf_object__init_kversion(struct bpf_object *obj, void *data, size_t size) {__u32 kver; -if (size !=sizeof (kver)) { +if (!data || size !=sizeof (kver)) {pr_warn ("invalid kver section in %s\n" , obj->path);return -LIBBPF_ERRNO__FORMAT ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 209/1073 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
@@ -4085,6 +4085,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 210/1073 drm: lcdif: Switch to limited range for RGB to YUV conversion
In reply to Greg Kroah-HartmanFrom: Laurent Pinchart <[email protected]>
[ Upstream commit ec39dee8b25229a646271815cc86a8fc865525cf ]
Up to and including v1.3, HDMI supported limited quantization range only for YCbCr. HDMI v1.4 introduced selectable quantization ranges, but this feature isn't supported in the dw-hdmi driver that is used in conjunction with the LCDIF in the i.MX8MP. The HDMI YCbCr output is thus always advertised in the AVI infoframe as limited range.
The LCDIF driver, on the other hand, configures the CSC to produce full range YCbCr. This mismatch results in loss of details and incorrect colours. Fix it by switching to limited range YCbCr.
The coefficients are copied from drivers/media/platforms/nxp/imx-pxp.c for coherency, as the hardware is most likely identical.
--- drivers/gpu/drm/mxsfb/lcdif_kms.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/gpu/drm/mxsfb/lcdif_kms.c +12 -6
@@ -53,16 +53,22 @@ static void lcdif_set_formats(struct lcdif_drm_private *lcdif,writel (DISP_PARA_LINE_PATTERN_UYVY_H , lcdif->base +LCDC_V8_DISP_PARA ); -/* CSC: BT.601 Full Range RGB to YCbCr coefficients. */ -writel (CSC0_COEF0_A2 (0x096 ) |CSC0_COEF0_A1 (0x04c ), +/* +* CSC: BT.601 Limited Range RGB to YCbCr coefficients. +* +* |Y | | 0.2568 0.5041 0.0979| |R| |16 | +* |Cb| = |-0.1482 -0.2910 0.4392| * |G| + |128| +* |Cr| | 0.4392 0.4392 -0.3678| |B| |128| +*/ +writel (CSC0_COEF0_A2 (0x081 ) |CSC0_COEF0_A1 (0x041 ), lcdif->base +LCDC_V8_CSC0_COEF0 ); -writel (CSC0_COEF1_B1 (0x7d5 ) |CSC0_COEF1_A3 (0x01d ), +writel (CSC0_COEF1_B1 (0x7db ) |CSC0_COEF1_A3 (0x019 ), lcdif->base +LCDC_V8_CSC0_COEF1 ); -writel (CSC0_COEF2_B3 (0x080 ) |CSC0_COEF2_B2 (0x7ac ), +writel (CSC0_COEF2_B3 (0x070 ) |CSC0_COEF2_B2 (0x7b6 ), lcdif->base +LCDC_V8_CSC0_COEF2 ); -writel (CSC0_COEF3_C2 (0x795 ) |CSC0_COEF3_C1 (0x080 ), +writel (CSC0_COEF3_C2 (0x7a2 ) |CSC0_COEF3_C1 (0x070 ), lcdif->base +LCDC_V8_CSC0_COEF3 ); -writel (CSC0_COEF4_D1 (0x000 ) |CSC0_COEF4_C3 (0x7ec ), +writel (CSC0_COEF4_D1 (0x010 ) |CSC0_COEF4_C3 (0x7ee ), lcdif->base +LCDC_V8_CSC0_COEF4 );writel (CSC0_COEF5_D3 (0x080 ) |CSC0_COEF5_D2 (0x080 ), lcdif->base +LCDC_V8_CSC0_COEF5 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 211/1073 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
@@ -1392,7 +1392,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 ;
@@ -1456,8 +1457,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 212/1073 pinctrl: ocelot: add missing destroy_workqueue() in error path in ocelot_pinctrl_probe()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 8ada020ade3bc4125b639a1dca50a6df687dd986 ]
Using devm_add_action_or_reset() to make workqueue device-managed, so it can be destroy whenever the driver is unbound.
--- drivers/pinctrl/pinctrl-ocelot.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/pinctrl/pinctrl-ocelot.c +10 -10
@@ -2046,6 +2046,11 @@ static struct regmap *ocelot_pinctrl_create_pincfg(struct platform_device *pdev,return devm_regmap_init_mmio (&pdev->dev, base, ®map_config); } +static void ocelot_destroy_workqueue (void *data) +{ +destroy_workqueue (data); +} +static int ocelot_pinctrl_probe (struct platform_device *pdev) {const struct ocelot_match_data *data;
@@ -2078,6 +2083,11 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev)if (!info->wq)return -ENOMEM ; + ret =devm_add_action_or_reset (dev, ocelot_destroy_workqueue, + info->wq); +if (ret) +return ret; + info->pincfg_data = &data->pincfg_data; reset =devm_reset_control_get_optional_shared (dev,"switch" );
@@ -2125,15 +2135,6 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev)return 0 ; } -static int ocelot_pinctrl_remove (struct platform_device *pdev) -{ -struct ocelot_pinctrl *info =platform_get_drvdata (pdev); - -destroy_workqueue (info->wq); - -return 0 ; -} -static struct platform_driver ocelot_pinctrl_driver = { .driver = { .name ="pinctrl-ocelot" ,
@@ -2141,7 +2142,6 @@ static struct platform_driver ocelot_pinctrl_driver = { .suppress_bind_attrs = true, }, .probe = ocelot_pinctrl_probe, - .remove = ocelot_pinctrl_remove, };module_platform_driver (ocelot_pinctrl_driver);MODULE_LICENSE ("Dual MIT/GPL" );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 213/1073 ASoC: Intel: avs: Fix DMA mask assignment
In reply to Greg Kroah-HartmanFrom: Cezary Rojewski <[email protected]>
[ Upstream commit 83375566a7a7042cb34b24986d100f46bfa0c1e5 ]
Spelling error leads to incorrect behavior when setting up DMA mask.
--- sound/soc/intel/avs/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/intel/avs/core.c +1 -1
@@ -440,7 +440,7 @@ static int avs_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)if (bus->mlcap)snd_hdac_ext_bus_get_ml_capabilities (bus); -if (!dma_set_mask_and_coherent (dev,DMA_BIT_MASK (64 ))) +if (dma_set_mask_and_coherent (dev,DMA_BIT_MASK (64 )))dma_set_mask_and_coherent (dev,DMA_BIT_MASK (32 ));dma_set_max_seg_size (dev,UINT_MAX );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 214/1073 ASoC: Intel: avs: Fix potential RX buffer overflow
In reply to Greg Kroah-HartmanFrom: Cezary Rojewski <[email protected]>
[ Upstream commit 23ae34e033b2c0e5e88237af82b163b296fd6aa9 ]
If an event caused firmware to return invalid RX size for LARGE_CONFIG_GET, memcpy_fromio() could end up copying too many bytes. Fix by utilizing min_t().
--- sound/soc/intel/avs/ipc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/intel/avs/ipc.c +2 -1
@@ -192,7 +192,8 @@ static void avs_dsp_receive_rx(struct avs_dev *adev, u64 header)/* update size in case of LARGE_CONFIG_GET */ if (msg.msg_target ==AVS_MOD_MSG && msg.global_msg_type ==AVS_MOD_LARGE_CONFIG_GET ) - ipc->rx.size = msg.ext.large_config.data_off_size; + ipc->rx.size =min_t (u32,AVS_MAILBOX_SIZE , + msg.ext.large_config.data_off_size);memcpy_fromio (ipc->rx.data,avs_uplink_addr (adev), ipc->rx.size);trace_avs_msg_payload (ipc->rx.data, ipc->rx.size);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 215/1073 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
@@ -399,13 +399,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 216/1073 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 217/1073 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
Greg Kroah-Hartman
maintainerPATCH 218/1073 samples/bpf: Fix map iteration in xdp1_user
In reply to Greg Kroah-HartmanFrom: Gerhard Engleder <[email protected]>
[ Upstream commit 05ee658c654bacda03f7fecef367e62aaf8e1cfe ]
BPF map iteration in xdp1_user results in endless loop without any output, because the return value of bpf_map_get_next_key() is checked against the wrong value.
Other call locations of bpf_map_get_next_key() check for equal 0 for continuing the iteration. xdp1_user checks against unequal -1. This is wrong for a function which can return arbitrary negative errno values, because a return value of e.g. -2 results in an endless loop.
With this fix xdp1_user is printing statistics again:
proto 0: 1 pkt/s proto 0: 1 pkt/s proto 17: 107383 pkt/s proto 17: 881655 pkt/s proto 17: 882083 pkt/s proto 17: 881758 pkt/s
--- samples/bpf/xdp1_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
samples/bpf/xdp1_user.c +1 -1
@@ -51,7 +51,7 @@ static void poll_stats(int map_fd, int interval)sleep (interval); -while (bpf_map_get_next_key (map_fd, &key, &key) !=-1 ) { +while (bpf_map_get_next_key (map_fd, &key, &key) ==0 ) {__u64 sum =0 ;assert (bpf_map_lookup_elem (map_fd, &key, values) ==0 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 219/1073 samples/bpf: Fix MAC address swapping in xdp2_kern
In reply to Greg Kroah-HartmanFrom: Gerhard Engleder <[email protected]>
[ Upstream commit 7a698edf954cb3f8b6e8dacdb77615355170420c ]
xdp2_kern rewrites and forwards packets out on the same interface. Forwarding still works but rewrite got broken when xdp multibuffer support has been added.
With xdp multibuffer a local copy of the packet has been introduced. The MAC address is now swapped in the local copy, but the local copy in not written back.
Fix MAC address swapping be adding write back of modified packet.
--- samples/bpf/xdp2_kern.c | 4 ++++ 1 file changed, 4 insertions(+)
samples/bpf/xdp2_kern.c +4 -0
@@ -112,6 +112,10 @@ int xdp_prog1(struct xdp_md *ctx)if (ipproto ==IPPROTO_UDP ) {swap_src_dst_mac (data); + +if (bpf_xdp_store_bytes (ctx,0 , pkt,sizeof (pkt))) +return rc; + rc =XDP_TX ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 220/1073 drm/bridge: it6505: Initialize AUX channel in it6505_i2c_probe
In reply to Greg Kroah-HartmanFrom: Pin-yen Lin <[email protected]>
[ Upstream commit e577d4b13064c337b83fe7edecb3f34e87144821 ]
During device boot, the HPD interrupt could be triggered before the DRM subsystem registers it6505 as a DRM bridge. In such cases, the driver tries to access AUX channel and causes NULL pointer dereference. Initializing the AUX channel earlier to prevent such error.
--- drivers/gpu/drm/bridge/ite-it6505.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/ite-it6505.c +5 -3
@@ -2854,10 +2854,7 @@ static int it6505_bridge_attach(struct drm_bridge *bridge, }/* Register aux channel */ - it6505->aux.name ="DP-AUX" ; - it6505->aux.dev = dev; it6505->aux.drm_dev = bridge->dev; - it6505->aux.transfer = it6505_aux_transfer; ret =drm_dp_aux_register (&it6505->aux);
@@ -3310,6 +3307,11 @@ static int it6505_i2c_probe(struct i2c_client *client,DRM_DEV_DEBUG_DRIVER (dev,"it6505 device name: %s" ,dev_name (dev));debugfs_init (it6505); + it6505->aux.name ="DP-AUX" ; + it6505->aux.dev = dev; + it6505->aux.transfer = it6505_aux_transfer; +drm_dp_aux_init (&it6505->aux); + it6505->bridge.funcs = &it6505_bridge_funcs; it6505->bridge.type = DRM_MODE_CONNECTOR_DisplayPort; it6505->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID |
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 221/1073 Input: iqs7222 - set all ULP entry masks by default
In reply to Greg Kroah-HartmanFrom: Jeff LaBundy <[email protected]>
[ Upstream commit d56111ed58482de0045e1e1201122e6e71516945 ]
Some devices expose an ultra-low-power (ULP) mode entry mask for each channel. If the mask is set, the device cannot enter ULP so long as the corresponding channel remains in an active state.
The vendor has advised setting the mask for any disabled channel. To accommodate this suggestion, initially set all masks and then clear them only if specified in the device tree.
Stable-dep-of: 2f6fd2329789 ("Input: iqs7222 - protect against undefined slider size")
--- drivers/input/misc/iqs7222.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/input/misc/iqs7222.c +6 -5
@@ -1771,11 +1771,9 @@ static int iqs7222_parse_chan(struct iqs7222_private *iqs7222, int chan_index)if (!chan_node)return 0 ; -if (dev_desc->allow_offset) { - sys_setup[dev_desc->allow_offset] |=BIT (chan_index); -if (fwnode_property_present (chan_node,"azoteq,ulp-allow" )) - sys_setup[dev_desc->allow_offset] &= ~BIT (chan_index); - } +if (dev_desc->allow_offset && +fwnode_property_present (chan_node,"azoteq,ulp-allow" )) + sys_setup[dev_desc->allow_offset] &= ~BIT (chan_index); chan_setup[0 ] |=IQS7222_CHAN_SETUP_0_CHAN_EN ;
@@ -2206,6 +2204,9 @@ static int iqs7222_parse_all(struct iqs7222_private *iqs7222)u16 *sys_setup = iqs7222->sys_setup;int error, i; +if (dev_desc->allow_offset) + sys_setup[dev_desc->allow_offset] =U16_MAX ; +if (dev_desc->event_offset) sys_setup[dev_desc->event_offset] =IQS7222_EVENT_MASK_ATI ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 222/1073 Input: iqs7222 - drop unused device node references
In reply to Greg Kroah-HartmanFrom: Jeff LaBundy <[email protected]>
[ Upstream commit bbd16b0d839978e8c8bec2b9a162373f64fc2fbb ]
Each call to device/fwnode_get_named_child_node() must be matched with a call to fwnode_handle_put() once the corresponding node is no longer in use. This ensures a reference count remains balanced in the case of dynamic device tree support.
Currently, the driver never calls fwnode_handle_put(). Solve this problem by moving the node handling from iqs7222_parse_props() to the new iqs7222_parse_reg_grp(), leaving the former to do nothing but parse properties. The latter then manages the reference count in a single location and consistent fashion.
This change drastically simplifies iqs7222_parse_all(), which can then call iqs7222_parse_reg_grp() on every register group without having to treat each register group differently.
For nested event nodes, common parsing code has been factored out to the new iqs7222_parse_event() so as to allow the event node to be dropped from as few locations as possible.
As part of this refactor, the 'linux,code' property has been made optional. This enables applications that define an event with the sole purpose of enabling a GPIO.
Stable-dep-of: 2f6fd2329789 ("Input: iqs7222 - protect against undefined slider size")
--- drivers/input/misc/iqs7222.c | 340 +++++++++++++++-------------------- 1 file changed, 146 insertions(+), 194 deletions(-)
drivers/input/misc/iqs7222.c +146 -194
@@ -105,14 +105,14 @@ enum iqs7222_reg_grp_id {IQS7222_NUM_REG_GRPS }; -static const char *const iqs7222_reg_grp_names[] = { +static const char *const iqs7222_reg_grp_names[IQS7222_NUM_REG_GRPS ] = { [IQS7222_REG_GRP_CYCLE ] ="cycle" , [IQS7222_REG_GRP_CHAN ] ="channel" , [IQS7222_REG_GRP_SLDR ] ="slider" , [IQS7222_REG_GRP_GPIO ] ="gpio" , }; -static const unsigned int iqs7222_max_cols[] = { +static const unsigned int iqs7222_max_cols[IQS7222_NUM_REG_GRPS ] = { [IQS7222_REG_GRP_STAT ] =IQS7222_MAX_COLS_STAT , [IQS7222_REG_GRP_CYCLE ] =IQS7222_MAX_COLS_CYCLE , [IQS7222_REG_GRP_GLBL ] =IQS7222_MAX_COLS_GLBL ,
@@ -1567,56 +1567,17 @@ static int iqs7222_gpio_select(struct iqs7222_private *iqs7222, }static int iqs7222_parse_props (struct iqs7222_private *iqs7222, -struct fwnode_handle **child_node, -int child_index, +struct fwnode_handle *reg_grp_node, +int reg_grp_index,enum iqs7222_reg_grp_id reg_grp,enum iqs7222_reg_key_id reg_key) { -u16 *setup =iqs7222_setup (iqs7222, reg_grp, child_index); +u16 *setup =iqs7222_setup (iqs7222, reg_grp, reg_grp_index);struct i2c_client *client = iqs7222->client; -struct fwnode_handle *reg_grp_node; -char reg_grp_name[16 ];int i; -switch (reg_grp) { -case IQS7222_REG_GRP_CYCLE : -case IQS7222_REG_GRP_CHAN : -case IQS7222_REG_GRP_SLDR : -case IQS7222_REG_GRP_GPIO : -case IQS7222_REG_GRP_BTN : -/* -* These groups derive a child node and return it to the caller -* for additional group-specific processing. In some cases, the -* child node may have already been derived. -*/ - reg_grp_node = *child_node; -if (reg_grp_node) -break ; - -snprintf (reg_grp_name,sizeof (reg_grp_name),"%s-%d" , - iqs7222_reg_grp_names[reg_grp], child_index); - - reg_grp_node =device_get_named_child_node (&client->dev, - reg_grp_name); -if (!reg_grp_node) -return 0 ; - - *child_node = reg_grp_node; -break ; - -case IQS7222_REG_GRP_GLBL : -case IQS7222_REG_GRP_FILT : -case IQS7222_REG_GRP_SYS : -/* -* These groups are not organized beneath a child node, nor are -* they subject to any additional processing by the caller. -*/ - reg_grp_node =dev_fwnode (&client->dev); -break ; - -default : -return -EINVAL ; - } +if (!setup) +return 0 ;for (i =0 ; i <ARRAY_SIZE (iqs7222_props); i++) {const char *name = iqs7222_props[i].name;
@@ -1686,11 +1647,66 @@ static int iqs7222_parse_props(struct iqs7222_private *iqs7222,return 0 ; } -static int iqs7222_parse_cycle (struct iqs7222_private *iqs7222,int cycle_index) +static int iqs7222_parse_event (struct iqs7222_private *iqs7222, +struct fwnode_handle *event_node, +int reg_grp_index, +enum iqs7222_reg_grp_id reg_grp, +enum iqs7222_reg_key_id reg_key, +u16 event_enable,u16 event_link, +unsigned int *event_type, +unsigned int *event_code) +{ +struct i2c_client *client = iqs7222->client; +int error; + + error =iqs7222_parse_props (iqs7222, event_node, reg_grp_index, + reg_grp, reg_key); +if (error) +return error; + + error =iqs7222_gpio_select (iqs7222, event_node, event_enable, + event_link); +if (error) +return error; + + error =fwnode_property_read_u32 (event_node,"linux,code" , event_code); +if (error == -EINVAL ) { +return 0 ; + }else if (error) { +dev_err (&client->dev,"Failed to read %s code: %d\n" , +fwnode_get_name (event_node), error); +return error; + } + +if (!event_type) { +input_set_capability (iqs7222->keypad,EV_KEY , *event_code); +return 0 ; + } + + error =fwnode_property_read_u32 (event_node,"linux,input-type" , + event_type); +if (error == -EINVAL ) { + *event_type =EV_KEY ; + }else if (error) { +dev_err (&client->dev,"Failed to read %s input type: %d\n" , +fwnode_get_name (event_node), error); +return error; + }else if (*event_type !=EV_KEY && *event_type !=EV_SW ) { +dev_err (&client->dev,"Invalid %s input type: %d\n" , +fwnode_get_name (event_node), *event_type); +return -EINVAL ; + } + +input_set_capability (iqs7222->keypad, *event_type, *event_code); + +return 0 ; +} + +static int iqs7222_parse_cycle (struct iqs7222_private *iqs7222, +struct fwnode_handle *cycle_node,int cycle_index) {u16 *cycle_setup = iqs7222->cycle_setup[cycle_index];struct i2c_client *client = iqs7222->client; -struct fwnode_handle *cycle_node =NULL ;unsigned int pins[9 ];int error, count, i;
@@ -1698,17 +1714,7 @@ static int iqs7222_parse_cycle(struct iqs7222_private *iqs7222, int cycle_index)* Each channel shares a cycle with one other channel; the mapping of * channels to cycles is fixed. Properties defined for a cycle impact * both channels tied to the cycle. -*/ - error =iqs7222_parse_props (iqs7222, &cycle_node, cycle_index, -IQS7222_REG_GRP_CYCLE , -IQS7222_REG_KEY_NONE ); -if (error) -return error; - -if (!cycle_node) -return 0 ; - -/* +* * Unlike channels which are restricted to a select range of CRx pins * based on channel number, any cycle can claim any of the device's 9 * CTx pins (CTx0-8).
@@ -1750,11 +1756,11 @@ static int iqs7222_parse_cycle(struct iqs7222_private *iqs7222, int cycle_index)return 0 ; } -static int iqs7222_parse_chan (struct iqs7222_private *iqs7222,int chan_index) +static int iqs7222_parse_chan (struct iqs7222_private *iqs7222, +struct fwnode_handle *chan_node,int chan_index) {const struct iqs7222_dev_desc *dev_desc = iqs7222->dev_desc;struct i2c_client *client = iqs7222->client; -struct fwnode_handle *chan_node =NULL ;int num_chan = dev_desc->reg_grps[IQS7222_REG_GRP_CHAN ].num_row;int ext_chan =rounddown (num_chan,10 );int error, i;
@@ -1762,15 +1768,6 @@ static int iqs7222_parse_chan(struct iqs7222_private *iqs7222, int chan_index)u16 *sys_setup = iqs7222->sys_setup;unsigned int val; - error =iqs7222_parse_props (iqs7222, &chan_node, chan_index, -IQS7222_REG_GRP_CHAN , -IQS7222_REG_KEY_NONE ); -if (error) -return error; - -if (!chan_node) -return 0 ; -if (dev_desc->allow_offset &&fwnode_property_present (chan_node,"azoteq,ulp-allow" )) sys_setup[dev_desc->allow_offset] &= ~BIT (chan_index);
@@ -1892,18 +1889,6 @@ static int iqs7222_parse_chan(struct iqs7222_private *iqs7222, int chan_index)if (!event_node)continue ; - error =iqs7222_parse_props (iqs7222, &event_node, chan_index, -IQS7222_REG_GRP_BTN , - iqs7222_kp_events[i].reg_key); -if (error) -return error; - - error =iqs7222_gpio_select (iqs7222, event_node, -BIT (chan_index), - dev_desc->touch_link - (i ?0 :2 )); -if (error) -return error; -if (!fwnode_property_read_u32 (event_node,"azoteq,timeout-press-ms" , &val)) {
@@ -1919,7 +1904,8 @@ static int iqs7222_parse_chan(struct iqs7222_private *iqs7222, int chan_index)if (val >U8_MAX *500 ) {dev_err (&client->dev,"Invalid %s press timeout: %u\n" , -fwnode_get_name (chan_node), val); +fwnode_get_name (event_node), val); +fwnode_handle_put (event_node);return -EINVAL ; }
@@ -1927,49 +1913,16 @@ static int iqs7222_parse_chan(struct iqs7222_private *iqs7222, int chan_index) *setup |= (val /500 << i *8 ); } - error =fwnode_property_read_u32 (event_node,"linux,code" , - &val); -if (error) { -dev_err (&client->dev,"Failed to read %s code: %d\n" , -fwnode_get_name (chan_node), error); + error =iqs7222_parse_event (iqs7222, event_node, chan_index, +IQS7222_REG_GRP_BTN , + iqs7222_kp_events[i].reg_key, +BIT (chan_index), + dev_desc->touch_link - (i ?0 :2 ), + &iqs7222->kp_type[chan_index][i], + &iqs7222->kp_code[chan_index][i]); +fwnode_handle_put (event_node); +if (error)return error; - } - - iqs7222->kp_code[chan_index][i] = val; - iqs7222->kp_type[chan_index][i] =EV_KEY ; - -if (fwnode_property_present (event_node,"linux,input-type" )) { - error =fwnode_property_read_u32 (event_node, -"linux,input-type" , - &val); -if (error) { -dev_err (&client->dev, -"Failed to read %s input type: %d\n" , -fwnode_get_name (chan_node), error); -return error; - } - -if (val !=EV_KEY && val !=EV_SW ) { -dev_err (&client->dev, -"Invalid %s input type: %u\n" , -fwnode_get_name (chan_node), val); -return -EINVAL ; - } - - iqs7222->kp_type[chan_index][i] = val; - } - -/* -* Reference channels can opt out of event reporting by using -* KEY_RESERVED in place of a true key or switch code. -*/ -if (iqs7222->kp_type[chan_index][i] ==EV_KEY && - iqs7222->kp_code[chan_index][i] ==KEY_RESERVED ) -continue ; - -input_set_capability (iqs7222->keypad, - iqs7222->kp_type[chan_index][i], - iqs7222->kp_code[chan_index][i]);if (!dev_desc->event_offset)continue ;
@@ -1981,16 +1934,16 @@ static int iqs7222_parse_chan(struct iqs7222_private *iqs7222, int chan_index)* The following call handles a special pair of properties that apply * to a channel node, but reside within the button (event) group. */ -return iqs7222_parse_props (iqs7222, &chan_node, chan_index, +return iqs7222_parse_props (iqs7222, chan_node, chan_index,IQS7222_REG_GRP_BTN ,IQS7222_REG_KEY_DEBOUNCE ); } -static int iqs7222_parse_sldr (struct iqs7222_private *iqs7222,int sldr_index) +static int iqs7222_parse_sldr (struct iqs7222_private *iqs7222, +struct fwnode_handle *sldr_node,int sldr_index) {const struct iqs7222_dev_desc *dev_desc = iqs7222->dev_desc;struct i2c_client *client = iqs7222->client; -struct fwnode_handle *sldr_node =NULL ;int num_chan = dev_desc->reg_grps[IQS7222_REG_GRP_CHAN ].num_row;int ext_chan =rounddown (num_chan,10 );int count, error, reg_offset, i;
@@ -1998,15 +1951,6 @@ static int iqs7222_parse_sldr(struct iqs7222_private *iqs7222, int sldr_index)u16 *sldr_setup = iqs7222->sldr_setup[sldr_index];unsigned int chan_sel[4 ], val; - error =iqs7222_parse_props (iqs7222, &sldr_node, sldr_index, -IQS7222_REG_GRP_SLDR , -IQS7222_REG_KEY_NONE ); -if (error) -return error; - -if (!sldr_node) -return 0 ; -/* * Each slider can be spread across 3 to 4 channels. It is possible to * select only 2 channels, but doing so prevents the slider from using
@@ -2130,46 +2074,37 @@ static int iqs7222_parse_sldr(struct iqs7222_private *iqs7222, int sldr_index)for (i =0 ; i <ARRAY_SIZE (iqs7222_sl_events); i++) {const char *event_name = iqs7222_sl_events[i].name;struct fwnode_handle *event_node; +enum iqs7222_reg_key_id reg_key; event_node =fwnode_get_named_child_node (sldr_node, event_name);if (!event_node)continue ; - error =iqs7222_parse_props (iqs7222, &event_node, sldr_index, -IQS7222_REG_GRP_SLDR , - reg_offset ? -IQS7222_REG_KEY_RESERVED : - iqs7222_sl_events[i].reg_key); -if (error) -return error; +if (reg_offset) + reg_key =IQS7222_REG_KEY_RESERVED ; +else + reg_key = iqs7222_sl_events[i].reg_key;/* * The press/release event does not expose a direct GPIO link, * but one can be emulated by tying each of the participating * channels to the same GPIO. */ - error =iqs7222_gpio_select (iqs7222, event_node, + error =iqs7222_parse_event (iqs7222, event_node, sldr_index, +IQS7222_REG_GRP_SLDR , reg_key, i ? iqs7222_sl_events[i].enable : sldr_setup[3 + reg_offset], i ?1568 + sldr_index *30 - : sldr_setup[4 + reg_offset]); + : sldr_setup[4 + reg_offset], +NULL , + &iqs7222->sl_code[sldr_index][i]); +fwnode_handle_put (event_node);if (error)return error;if (!reg_offset) sldr_setup[9 ] |= iqs7222_sl_events[i].enable; - error =fwnode_property_read_u32 (event_node,"linux,code" , - &val); -if (error) { -dev_err (&client->dev,"Failed to read %s code: %d\n" , -fwnode_get_name (sldr_node), error); -return error; - } - - iqs7222->sl_code[sldr_index][i] = val; -input_set_capability (iqs7222->keypad,EV_KEY , val); -if (!dev_desc->event_offset)continue ;
@@ -2190,19 +2125,63 @@ static int iqs7222_parse_sldr(struct iqs7222_private *iqs7222, int sldr_index)* The following call handles a special pair of properties that shift * to make room for a wheel enable control in the case of IQS7222C. */ -return iqs7222_parse_props (iqs7222, &sldr_node, sldr_index, +return iqs7222_parse_props (iqs7222, sldr_node, sldr_index,IQS7222_REG_GRP_SLDR , dev_desc->wheel_enable ?IQS7222_REG_KEY_WHEEL :IQS7222_REG_KEY_NO_WHEEL ); } +static int (*iqs7222_parse_extra[IQS7222_NUM_REG_GRPS ]) + (struct iqs7222_private *iqs7222, +struct fwnode_handle *reg_grp_node, +int reg_grp_index) = { + [IQS7222_REG_GRP_CYCLE ] = iqs7222_parse_cycle, + [IQS7222_REG_GRP_CHAN ] = iqs7222_parse_chan, + [IQS7222_REG_GRP_SLDR ] = iqs7222_parse_sldr, +}; + +static int iqs7222_parse_reg_grp (struct iqs7222_private *iqs7222, +enum iqs7222_reg_grp_id reg_grp, +int reg_grp_index) +{ +struct i2c_client *client = iqs7222->client; +struct fwnode_handle *reg_grp_node; +int error; + +if (iqs7222_reg_grp_names[reg_grp]) { +char reg_grp_name[16 ]; + +snprintf (reg_grp_name,sizeof (reg_grp_name),"%s-%d" , + iqs7222_reg_grp_names[reg_grp], reg_grp_index); + + reg_grp_node =device_get_named_child_node (&client->dev, + reg_grp_name); + }else { + reg_grp_node =fwnode_handle_get (dev_fwnode (&client->dev)); + } + +if (!reg_grp_node) +return 0 ; + + error =iqs7222_parse_props (iqs7222, reg_grp_node, reg_grp_index, + reg_grp,IQS7222_REG_KEY_NONE ); + +if (!error && iqs7222_parse_extra[reg_grp]) + error = iqs7222_parse_extra[reg_grp](iqs7222, reg_grp_node, + reg_grp_index); + +fwnode_handle_put (reg_grp_node); + +return error; +} +static int iqs7222_parse_all (struct iqs7222_private *iqs7222) {const struct iqs7222_dev_desc *dev_desc = iqs7222->dev_desc;const struct iqs7222_reg_grp_desc *reg_grps = dev_desc->reg_grps;u16 *sys_setup = iqs7222->sys_setup; -int error, i; +int error, i, j;if (dev_desc->allow_offset) sys_setup[dev_desc->allow_offset] =U16_MAX ;
@@ -2210,32 +2189,13 @@ static int iqs7222_parse_all(struct iqs7222_private *iqs7222)if (dev_desc->event_offset) sys_setup[dev_desc->event_offset] =IQS7222_EVENT_MASK_ATI ; -for (i =0 ; i < reg_grps[IQS7222_REG_GRP_CYCLE ].num_row; i++) { - error =iqs7222_parse_cycle (iqs7222, i); -if (error) -return error; - } - - error =iqs7222_parse_props (iqs7222,NULL ,0 ,IQS7222_REG_GRP_GLBL , -IQS7222_REG_KEY_NONE ); -if (error) -return error; -for (i =0 ; i < reg_grps[IQS7222_REG_GRP_GPIO ].num_row; i++) { -struct fwnode_handle *gpio_node =NULL ;u16 *gpio_setup = iqs7222->gpio_setup[i]; -int j; gpio_setup[0 ] &= ~IQS7222_GPIO_SETUP_0_GPIO_EN ; gpio_setup[1 ] =0 ; gpio_setup[2 ] =0 ; - error =iqs7222_parse_props (iqs7222, &gpio_node, i, -IQS7222_REG_GRP_GPIO , -IQS7222_REG_KEY_NONE ); -if (error) -return error; -if (reg_grps[IQS7222_REG_GRP_GPIO ].num_row ==1 )continue ;
@@ -2258,29 +2218,21 @@ static int iqs7222_parse_all(struct iqs7222_private *iqs7222) chan_setup[5 ] =0 ; } -for (i =0 ; i < reg_grps[IQS7222_REG_GRP_CHAN ].num_row; i++) { - error =iqs7222_parse_chan (iqs7222, i); -if (error) -return error; - } - - error =iqs7222_parse_props (iqs7222,NULL ,0 ,IQS7222_REG_GRP_FILT , -IQS7222_REG_KEY_NONE ); -if (error) -return error; -for (i =0 ; i < reg_grps[IQS7222_REG_GRP_SLDR ].num_row; i++) {u16 *sldr_setup = iqs7222->sldr_setup[i]; sldr_setup[0 ] &= ~IQS7222_SLDR_SETUP_0_CHAN_CNT_MASK ; + } - error =iqs7222_parse_sldr (iqs7222, i); -if (error) -return error; +for (i =0 ; i <IQS7222_NUM_REG_GRPS ; i++) { +for (j =0 ; j < reg_grps[i].num_row; j++) { + error =iqs7222_parse_reg_grp (iqs7222, i, j); +if (error) +return error; + } } -return iqs7222_parse_props (iqs7222,NULL ,0 ,IQS7222_REG_GRP_SYS , -IQS7222_REG_KEY_NONE ); +return 0 ; }static int iqs7222_report (struct iqs7222_private *iqs7222)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 223/1073 Input: iqs7222 - report malformed properties
In reply to Greg Kroah-HartmanFrom: Jeff LaBundy <[email protected]>
[ Upstream commit 404f3b48e65f058d94429e4a1ec16a1f82ff3b2f ]
Nonzero return values of several calls to fwnode_property_read_u32() are silently ignored, leaving no way to know the properties were not applied in the event of an error.
Solve this problem by evaluating fwnode_property_read_u32()'s return value, and reporting an error for any nonzero return value not equal to -EINVAL which indicates the property was absent altogether.
Stable-dep-of: 2f6fd2329789 ("Input: iqs7222 - protect against undefined slider size")
--- drivers/input/misc/iqs7222.c | 44 +++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 8 deletions(-)
drivers/input/misc/iqs7222.c +36 -8
@@ -1807,8 +1807,9 @@ static int iqs7222_parse_chan(struct iqs7222_private *iqs7222, chan_setup[0 ] |=IQS7222_CHAN_SETUP_0_REF_MODE_FOLLOW ; chan_setup[4 ] = val *42 +1048 ; -if (!fwnode_property_read_u32 (chan_node,"azoteq,ref-weight" , - &val)) { + error =fwnode_property_read_u32 (chan_node,"azoteq,ref-weight" , + &val); +if (!error) {if (val >U16_MAX ) { dev_err(&client->dev, "Invalid %s reference weight: %u\n",
@@ -1817,6 +1818,11 @@ static int iqs7222_parse_chan(struct iqs7222_private *iqs7222, } chan_setup[5 ] = val; + }else if (error != -EINVAL ) { +dev_err (&client->dev, +"Failed to read %s reference weight: %d\n" , +fwnode_get_name (chan_node), error); +return error; }/*
@@ -1889,9 +1895,10 @@ static int iqs7222_parse_chan(struct iqs7222_private *iqs7222,if (!event_node)continue ; -if (!fwnode_property_read_u32 (event_node, -"azoteq,timeout-press-ms" , - &val)) { + error =fwnode_property_read_u32 (event_node, +"azoteq,timeout-press-ms" , + &val); +if (!error) {/* * The IQS7222B employs a global pair of press timeout * registers as opposed to channel-specific registers.
@@ -1911,6 +1918,12 @@ static int iqs7222_parse_chan(struct iqs7222_private *iqs7222, *setup &= ~(U8_MAX << i *8 ); *setup |= (val /500 << i *8 ); + }else if (error != -EINVAL ) { +dev_err (&client->dev, +"Failed to read %s press timeout: %d\n" , +fwnode_get_name (event_node), error); +fwnode_handle_put (event_node); +return error; } error = iqs7222_parse_event(iqs7222, event_node, chan_index,
@@ -2009,7 +2022,8 @@ static int iqs7222_parse_sldr(struct iqs7222_private *iqs7222,if (fwnode_property_present (sldr_node,"azoteq,use-prox" )) sldr_setup[4 + reg_offset] -=2 ; -if (!fwnode_property_read_u32 (sldr_node,"azoteq,slider-size" , &val)) { + error =fwnode_property_read_u32 (sldr_node,"azoteq,slider-size" , &val); +if (!error) {if (!val || val > dev_desc->sldr_res) {dev_err (&client->dev,"Invalid %s size: %u\n" ,fwnode_get_name (sldr_node), val);
@@ -2023,9 +2037,14 @@ static int iqs7222_parse_sldr(struct iqs7222_private *iqs7222, sldr_setup[2 ] |= (val /16 <<IQS7222_SLDR_SETUP_2_RES_SHIFT ); } + }else if (error != -EINVAL ) { +dev_err (&client->dev,"Failed to read %s size: %d\n" , +fwnode_get_name (sldr_node), error); +return error; } -if (!fwnode_property_read_u32 (sldr_node,"azoteq,top-speed" , &val)) { + error =fwnode_property_read_u32 (sldr_node,"azoteq,top-speed" , &val); +if (!error) {if (val > (reg_offset ?U16_MAX :U8_MAX *4 )) {dev_err (&client->dev,"Invalid %s top speed: %u\n" ,fwnode_get_name (sldr_node), val);
@@ -2038,9 +2057,14 @@ static int iqs7222_parse_sldr(struct iqs7222_private *iqs7222, sldr_setup[2 ] &= ~IQS7222_SLDR_SETUP_2_TOP_SPEED_MASK ; sldr_setup[2 ] |= (val /4 ); } + }else if (error != -EINVAL ) { +dev_err (&client->dev,"Failed to read %s top speed: %d\n" , +fwnode_get_name (sldr_node), error); +return error; } -if (!fwnode_property_read_u32 (sldr_node,"linux,axis" , &val)) { + error =fwnode_property_read_u32 (sldr_node,"linux,axis" , &val); +if (!error) {u16 sldr_max = sldr_setup[3 ] -1 ;if (!reg_offset) {
@@ -2054,6 +2078,10 @@ static int iqs7222_parse_sldr(struct iqs7222_private *iqs7222,input_set_abs_params (iqs7222->keypad, val,0 , sldr_max,0 ,0 ); iqs7222->sl_axis[sldr_index] = val; + }else if (error != -EINVAL ) { +dev_err (&client->dev,"Failed to read %s axis: %d\n" , +fwnode_get_name (sldr_node), error); +return error; }if (dev_desc->wheel_enable) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 224/1073 Input: iqs7222 - protect against undefined slider size
In reply to Greg Kroah-HartmanFrom: Jeff LaBundy <[email protected]>
[ Upstream commit 2f6fd232978906f6fb054529210b9faec384bd45 ]
Select variants of silicon do not define a default slider size, in which case the size must be specified in the device tree. If it is not, the axis's maximum value is reported as 65535 due to unsigned integer overflow.
To solve this problem, move the existing zero-check outside of the conditional block that checks whether the property is present.
--- drivers/input/misc/iqs7222.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/input/misc/iqs7222.c +8 -1
@@ -2024,7 +2024,7 @@ static int iqs7222_parse_sldr(struct iqs7222_private *iqs7222, error =fwnode_property_read_u32 (sldr_node,"azoteq,slider-size" , &val);if (!error) { -if (!val || val > dev_desc->sldr_res) { +if (val > dev_desc->sldr_res) {dev_err (&client->dev,"Invalid %s size: %u\n" ,fwnode_get_name (sldr_node), val);return -EINVAL ;
@@ -2043,6 +2043,13 @@ static int iqs7222_parse_sldr(struct iqs7222_private *iqs7222,return error; } +if (!(reg_offset ? sldr_setup[3 ] + : sldr_setup[2 ] &IQS7222_SLDR_SETUP_2_RES_MASK )) { +dev_err (&client->dev,"Undefined %s size\n" , +fwnode_get_name (sldr_node)); +return -EINVAL ; + } + error =fwnode_property_read_u32 (sldr_node,"azoteq,top-speed" , &val);if (!error) {if (val > (reg_offset ?U16_MAX :U8_MAX *4 )) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 225/1073 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
@@ -1762,7 +1762,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 226/1073 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/chips-media/coda-jpeg.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/media/platform/chips-media/coda-jpeg.c +8 -2
@@ -1053,10 +1053,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 227/1073 media: amphion: reset instance if its aborted before codec header parsed
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit 3984ea32e83bcad06b4b034ddd4b0a934c1b2f91 ]
there is hardware limitation that if it's aborted before the first codec header parsed, the codec may be stalled unless we do reset codec.
and drop the source change event if it's triggered after reset.
--- drivers/media/platform/amphion/vdec.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/media/platform/amphion/vdec.c +10 -3
@@ -753,6 +753,9 @@ static bool vdec_check_source_change(struct vpu_inst *inst)if (!inst->fh.m2m_ctx)return false; +if (vdec->reset_codec) +return false; +if (!vb2_is_streaming (v4l2_m2m_get_dst_vq (inst->fh.m2m_ctx)))return true; fmt =vpu_helper_find_format (inst, inst->cap_format.type, vdec->codec_info.pixfmt);
@@ -1088,7 +1091,8 @@ static void vdec_event_seq_hdr(struct vpu_inst *inst, struct vpu_dec_codec_info vdec->seq_tag = vdec->codec_info.tag;if (vdec->is_source_changed) {vdec_update_state (inst,VPU_CODEC_STATE_DYAMIC_RESOLUTION_CHANGE ,0 ); -vpu_notify_source_change (inst); + vdec->source_change++; +vdec_handle_resolution_change (inst); vdec->is_source_changed = false; } }
@@ -1335,6 +1339,8 @@ static void vdec_abort(struct vpu_inst *inst) vdec->decoded_frame_count, vdec->display_frame_count, vdec->sequence); +if (!vdec->seq_hdr_found) + vdec->reset_codec = true; vdec->params.end_flag =0 ; vdec->drain =0 ; vdec->params.frame_count =0 ;
@@ -1342,6 +1348,7 @@ static void vdec_abort(struct vpu_inst *inst) vdec->display_frame_count =0 ; vdec->sequence =0 ; vdec->aborting = false; + inst->extra_size =0 ; }static void vdec_stop (struct vpu_inst *inst,bool free)
@@ -1464,8 +1471,7 @@ static int vdec_start_session(struct vpu_inst *inst, u32 type) }if (V4L2_TYPE_IS_OUTPUT (type)) { -if (inst->state ==VPU_CODEC_STATE_SEEK ) -vdec_update_state (inst, vdec->state,1 ); +vdec_update_state (inst, vdec->state,1 ); vdec->eos_received =0 ;vpu_process_output_buffer (inst); }else {
@@ -1629,6 +1635,7 @@ static int vdec_open(struct file *file)return ret; vdec->fixed_fmt = false; + vdec->state =VPU_CODEC_STATE_ACTIVE ; inst->min_buffer_cap =VDEC_MIN_BUFFER_CAP ; inst->min_buffer_out =VDEC_MIN_BUFFER_OUT ;vdec_init (file);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 228/1073 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 229/1073 media: v4l2-ioctl.c: Unify YCbCr/YUV terms in format descriptions
In reply to Greg Kroah-HartmanFrom: Jernej Skrabec <[email protected]>
[ Upstream commit 6a394d563dffb60c150d87dc6678994ef8028c53 ]
Format descriptions use YCbCr and YUV terms interchangeably. Let's unify them so they all use YUV. While YCbCr is actually correct term here, YUV is shorter and thus it also fixes too long description of P010 tiled format.
--- drivers/media/v4l2-core/v4l2-ioctl.c | 34 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-)
drivers/media/v4l2-core/v4l2-ioctl.c +17 -17
@@ -1347,23 +1347,23 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)case V4L2_PIX_FMT_YUV420 : descr ="Planar YUV 4:2:0" ;break ;case V4L2_PIX_FMT_HI240 : descr ="8-bit Dithered RGB (BTTV)" ;break ;case V4L2_PIX_FMT_M420 : descr ="YUV 4:2:0 (M420)" ;break ; -case V4L2_PIX_FMT_NV12 : descr ="Y/CbCr 4:2:0" ;break ; -case V4L2_PIX_FMT_NV21 : descr ="Y/CrCb 4:2:0" ;break ; -case V4L2_PIX_FMT_NV16 : descr ="Y/CbCr 4:2:2" ;break ; -case V4L2_PIX_FMT_NV61 : descr ="Y/CrCb 4:2:2" ;break ; -case V4L2_PIX_FMT_NV24 : descr ="Y/CbCr 4:4:4" ;break ; -case V4L2_PIX_FMT_NV42 : descr ="Y/CrCb 4:4:4" ;break ; -case V4L2_PIX_FMT_P010 : descr ="10-bit Y/CbCr 4:2:0" ;break ; -case V4L2_PIX_FMT_NV12_4L4 : descr ="Y/CbCr 4:2:0 (4x4 Linear)" ;break ; -case V4L2_PIX_FMT_NV12_16L16 : descr ="Y/CbCr 4:2:0 (16x16 Linear)" ;break ; -case V4L2_PIX_FMT_NV12_32L32 : descr ="Y/CbCr 4:2:0 (32x32 Linear)" ;break ; -case V4L2_PIX_FMT_P010_4L4 : descr ="10-bit Y/CbCr 4:2:0 (4x4 Linear)" ;break ; -case V4L2_PIX_FMT_NV12M : descr ="Y/CbCr 4:2:0 (N-C)" ;break ; -case V4L2_PIX_FMT_NV21M : descr ="Y/CrCb 4:2:0 (N-C)" ;break ; -case V4L2_PIX_FMT_NV16M : descr ="Y/CbCr 4:2:2 (N-C)" ;break ; -case V4L2_PIX_FMT_NV61M : descr ="Y/CrCb 4:2:2 (N-C)" ;break ; -case V4L2_PIX_FMT_NV12MT : descr ="Y/CbCr 4:2:0 (64x32 MB, N-C)" ;break ; -case V4L2_PIX_FMT_NV12MT_16X16 : descr ="Y/CbCr 4:2:0 (16x16 MB, N-C)" ;break ; +case V4L2_PIX_FMT_NV12 : descr ="Y/UV 4:2:0" ;break ; +case V4L2_PIX_FMT_NV21 : descr ="Y/VU 4:2:0" ;break ; +case V4L2_PIX_FMT_NV16 : descr ="Y/UV 4:2:2" ;break ; +case V4L2_PIX_FMT_NV61 : descr ="Y/VU 4:2:2" ;break ; +case V4L2_PIX_FMT_NV24 : descr ="Y/UV 4:4:4" ;break ; +case V4L2_PIX_FMT_NV42 : descr ="Y/VU 4:4:4" ;break ; +case V4L2_PIX_FMT_P010 : descr ="10-bit Y/UV 4:2:0" ;break ; +case V4L2_PIX_FMT_NV12_4L4 : descr ="Y/UV 4:2:0 (4x4 Linear)" ;break ; +case V4L2_PIX_FMT_NV12_16L16 : descr ="Y/UV 4:2:0 (16x16 Linear)" ;break ; +case V4L2_PIX_FMT_NV12_32L32 : descr ="Y/UV 4:2:0 (32x32 Linear)" ;break ; +case V4L2_PIX_FMT_P010_4L4 : descr ="10-bit Y/UV 4:2:0 (4x4 Linear)" ;break ; +case V4L2_PIX_FMT_NV12M : descr ="Y/UV 4:2:0 (N-C)" ;break ; +case V4L2_PIX_FMT_NV21M : descr ="Y/VU 4:2:0 (N-C)" ;break ; +case V4L2_PIX_FMT_NV16M : descr ="Y/UV 4:2:2 (N-C)" ;break ; +case V4L2_PIX_FMT_NV61M : descr ="Y/VU 4:2:2 (N-C)" ;break ; +case V4L2_PIX_FMT_NV12MT : descr ="Y/UV 4:2:0 (64x32 MB, N-C)" ;break ; +case V4L2_PIX_FMT_NV12MT_16X16 : descr ="Y/UV 4:2:0 (16x16 MB, N-C)" ;break ;case V4L2_PIX_FMT_YUV420M : descr ="Planar YUV 4:2:0 (N-C)" ;break ;case V4L2_PIX_FMT_YVU420M : descr ="Planar YVU 4:2:0 (N-C)" ;break ;case V4L2_PIX_FMT_YUV422M : descr ="Planar YUV 4:2:2 (N-C)" ;break ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 230/1073 media: cedrus: hevc: Fix offset adjustments
In reply to Greg Kroah-HartmanFrom: Jernej Skrabec <[email protected]>
[ Upstream commit e9120e76a6f7e19a8d26c03f2964937e4ce69784 ]
As it turns out, current padding size check works fine in theory but it doesn't in practice. Most probable reason are caching issues.
Let's rework reading data from bitstream using Cedrus engine instead of CPU. That way we avoid all cache issues and make sure that we're reading same data as Cedrus.
--- .../staging/media/sunxi/cedrus/cedrus_h265.c | 25 ++++++++++++++----- .../staging/media/sunxi/cedrus/cedrus_regs.h | 2 ++ 2 files changed, 21 insertions(+), 6 deletions(-)
drivers/staging/media/sunxi/cedrus/cedrus_h265.c +19 -6
@@ -242,6 +242,18 @@ static void cedrus_h265_skip_bits(struct cedrus_dev *dev, int num) } } +static u32 cedrus_h265_show_bits (struct cedrus_dev *dev,int num) +{ +cedrus_write (dev,VE_DEC_H265_TRIGGER , +VE_DEC_H265_TRIGGER_SHOW_BITS | +VE_DEC_H265_TRIGGER_TYPE_N_BITS (num)); + +cedrus_wait_for (dev,VE_DEC_H265_STATUS , +VE_DEC_H265_STATUS_VLD_BUSY ); + +return cedrus_read (dev,VE_DEC_H265_BITS_READ ); +} +static void cedrus_h265_write_scaling_list (struct cedrus_ctx *ctx,struct cedrus_run *run) {
@@ -406,7 +418,7 @@ static int cedrus_h265_setup(struct cedrus_ctx *ctx, struct cedrus_run *run)u32 num_entry_point_offsets;u32 output_pic_list_index;u32 pic_order_cnt[2 ]; -u8 *padding; +u8 padding;int count;u32 reg;
@@ -520,21 +532,22 @@ static int cedrus_h265_setup(struct cedrus_ctx *ctx, struct cedrus_run *run)if (slice_params->data_byte_offset ==0 )return -EOPNOTSUPP ; - padding = (u8 *)vb2_plane_vaddr (&run->src->vb2_buf,0 ) + - slice_params->data_byte_offset -1 ; +cedrus_h265_skip_bits (dev, (slice_params->data_byte_offset -1 ) *8 ); + + padding =cedrus_h265_show_bits (dev,8 );/* at least one bit must be set in that byte */ -if (*padding ==0 ) +if (padding ==0 )return -EINVAL ;for (count =0 ; count <8 ; count++) -if (*padding & (1 << count)) +if (padding & (1 << count))break ;/* Include the one bit. */ count++; -cedrus_h265_skip_bits (dev, slice_params->data_byte_offset *8 - count); +cedrus_h265_skip_bits (dev,8 - count);/* Bitstream parameters. */
drivers/staging/media/sunxi/cedrus/cedrus_regs.h +2 -0
@@ -505,6 +505,8 @@#define VE_DEC_H265_LOW_ADDR_ENTRY_POINTS_BUF (a) \ SHIFT_AND_MASK_BITS(a, 7, 0) +#define VE_DEC_H265_BITS_READ (VE_ENGINE_DEC_H265 + 0xdc) +#define VE_DEC_H265_SRAM_OFFSET (VE_ENGINE_DEC_H265 + 0xe0)#define VE_DEC_H265_SRAM_OFFSET_PRED_WEIGHT_LUMA_L0 0x00
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 231/1073 media: mediatek: vcodec: fix h264 cavlc bitstream fail
In reply to Greg Kroah-HartmanFrom: Yunfei Dong <[email protected]>
[ Upstream commit d555409dd1b7cc9e7e5b9e2924c0ef4bf23f6c9b ]
Some cavlc bistream will decode fail when the frame size is less than 20 bytes. Need to add pending data at the end of the bitstream.
For the minimum size of mapped memory is 256 bytes(16x16), adding four bytes data won't lead to access unknown virtual memory.
--- .../vcodec/vdec/vdec_h264_req_multi_if.c | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-)
drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c +29 -3
@@ -539,6 +539,29 @@ static int vdec_h264_slice_core_decode(struct vdec_lat_buf *lat_buf)return 0 ; } +static void vdec_h264_insert_startcode (struct mtk_vcodec_dev *vcodec_dev,unsigned char *buf, +size_t *bs_size,struct mtk_h264_pps_param *pps) +{ +struct device *dev = &vcodec_dev->plat_dev->dev; + +/* Need to add pending data at the end of bitstream when bs_sz is small than +* 20 bytes for cavlc bitstream, or lat will decode fail. This pending data is +* useful for mt8192 and mt8195 platform. +* +* cavlc bitstream when entropy_coding_mode_flag is false. +*/ +if (pps->entropy_coding_mode_flag || *bs_size >20 || + !(of_device_is_compatible (dev->of_node,"mediatek,mt8192-vcodec-dec" ) || +of_device_is_compatible (dev->of_node,"mediatek,mt8195-vcodec-dec" ))) +return ; + + buf[*bs_size] =0 ; + buf[*bs_size +1 ] =0 ; + buf[*bs_size +2 ] =1 ; + buf[*bs_size +3 ] =0xff ; + (*bs_size) +=4 ; +} +static int vdec_h264_slice_lat_decode (void *h_vdec,struct mtk_vcodec_mem *bs,struct vdec_fb *fb,bool *res_chg) {
@@ -582,9 +605,6 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs, } inst->vsi->dec.nal_info = buf[nal_start_idx]; - inst->vsi->dec.bs_buf_addr = (u64 )bs->dma_addr; - inst->vsi->dec.bs_buf_size = bs->size; - lat_buf->src_buf_req = src_buf_info->m2m_buf.vb.vb2_buf.req_obj.req;v4l2_m2m_buf_copy_metadata (&src_buf_info->m2m_buf.vb, &lat_buf->ts_info, true);
@@ -592,6 +612,12 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,if (err) goto err_free_fb_out; +vdec_h264_insert_startcode (inst->ctx->dev, buf, &bs->size, + &share_info->h264_slice_params.pps); + + inst->vsi->dec.bs_buf_addr = (uint64_t )bs->dma_addr; + inst->vsi->dec.bs_buf_size = bs->size; + *res_chg = inst->resolution_changed;if (inst->resolution_changed) {mtk_vcodec_debug (inst,"- resolution changed -" );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 232/1073 drm/i915/guc: Limit scheduling properties to avoid overflow
In reply to Greg Kroah-HartmanFrom: John Harrison <[email protected]>
[ Upstream commit 568944af44e7538ed5d1389dabf56e938afdaf4f ]
GuC converts the pre-emption timeout and timeslice quantum values into clock ticks internally. That significantly reduces the point of 32bit overflow. On current platforms, worst case scenario is approximately 110 seconds. Rather than allowing the user to set higher values and then get confused by early timeouts, add limits when setting these values.
v2: Add helper functions for clamping (review feedback from Tvrtko).
v3: Add a bunch of BUG_ON range checks in addition to the checks already in the clamping functions (Tvrtko)
Stable-dep-of: c3bd49cd9a10 ("drm/i915: Fix compute pre-emption w/a to apply to compute engines")
--- drivers/gpu/drm/i915/gt/intel_engine.h | 6 ++ drivers/gpu/drm/i915/gt/intel_engine_cs.c | 69 +++++++++++++++++++ drivers/gpu/drm/i915/gt/sysfs_engines.c | 25 ++++--- drivers/gpu/drm/i915/gt/uc/intel_guc_fwif.h | 21 ++++++ .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 8 +++ 5 files changed, 119 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine.h +6 -0
@@ -348,4 +348,10 @@ intel_engine_get_hung_context(struct intel_engine_cs *engine) return engine->hung_ce; } +u64 intel_clamp_heartbeat_interval_ms (struct intel_engine_cs *engine,u64 value); +u64 intel_clamp_max_busywait_duration_ns (struct intel_engine_cs *engine,u64 value); +u64 intel_clamp_preempt_timeout_ms (struct intel_engine_cs *engine,u64 value); +u64 intel_clamp_stop_timeout_ms (struct intel_engine_cs *engine,u64 value); +u64 intel_clamp_timeslice_duration_ms (struct intel_engine_cs *engine,u64 value); +#endif /* _INTEL_RINGBUFFER_H_ */
drivers/gpu/drm/i915/gt/intel_engine_cs.c +69 -0
81 lines not on this page · raw message
drivers/gpu/drm/i915/gt/sysfs_engines.c +15 -10
@@ -144,7 +144,7 @@ max_spin_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) {struct intel_engine_cs *engine =kobj_to_engine (kobj); -unsigned long long duration; +unsigned long long duration, clamped;int err;/*
@@ -168,7 +168,8 @@ max_spin_store(struct kobject *kobj, struct kobj_attribute *attr,if (err)return err; -if (duration >jiffies_to_nsecs (2 )) + clamped =intel_clamp_max_busywait_duration_ns (engine, duration); +if (duration != clamped)return -EINVAL ;WRITE_ONCE (engine->props.max_busywait_duration_ns, duration);
@@ -203,7 +204,7 @@ timeslice_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) {struct intel_engine_cs *engine =kobj_to_engine (kobj); -unsigned long long duration; +unsigned long long duration, clamped;int err;/*
@@ -218,7 +219,8 @@ timeslice_store(struct kobject *kobj, struct kobj_attribute *attr,if (err)return err; -if (duration >jiffies_to_msecs (MAX_SCHEDULE_TIMEOUT )) + clamped =intel_clamp_timeslice_duration_ms (engine, duration); +if (duration != clamped)return -EINVAL ;WRITE_ONCE (engine->props.timeslice_duration_ms, duration);
@@ -256,7 +258,7 @@ stop_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) {struct intel_engine_cs *engine =kobj_to_engine (kobj); -unsigned long long duration; +unsigned long long duration, clamped;int err;/*
@@ -272,7 +274,8 @@ stop_store(struct kobject *kobj, struct kobj_attribute *attr,if (err)return err; -if (duration >jiffies_to_msecs (MAX_SCHEDULE_TIMEOUT )) + clamped =intel_clamp_stop_timeout_ms (engine, duration); +if (duration != clamped)return -EINVAL ;WRITE_ONCE (engine->props.stop_timeout_ms, duration);
@@ -306,7 +309,7 @@ preempt_timeout_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) {struct intel_engine_cs *engine =kobj_to_engine (kobj); -unsigned long long timeout; +unsigned long long timeout, clamped;int err;/*
@@ -322,7 +325,8 @@ preempt_timeout_store(struct kobject *kobj, struct kobj_attribute *attr,if (err)return err; -if (timeout >jiffies_to_msecs (MAX_SCHEDULE_TIMEOUT )) + clamped =intel_clamp_preempt_timeout_ms (engine, timeout); +if (timeout != clamped)return -EINVAL ;WRITE_ONCE (engine->props.preempt_timeout_ms, timeout);
@@ -362,7 +366,7 @@ heartbeat_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) {struct intel_engine_cs *engine =kobj_to_engine (kobj); -unsigned long long delay; +unsigned long long delay, clamped;int err;/*
@@ -379,7 +383,8 @@ heartbeat_store(struct kobject *kobj, struct kobj_attribute *attr,if (err)return err; -if (delay >=jiffies_to_msecs (MAX_SCHEDULE_TIMEOUT )) + clamped =intel_clamp_heartbeat_interval_ms (engine, delay); +if (delay != clamped)return -EINVAL ; err =intel_engine_set_heartbeat (engine, delay);
drivers/gpu/drm/i915/gt/uc/intel_guc_fwif.h +21 -0
@@ -305,6 +305,27 @@ struct guc_update_context_policy {#define GLOBAL_POLICY_DEFAULT_DPC_PROMOTE_TIME_US 500000 +/* +* GuC converts the timeout to clock ticks internally. Different platforms have +* different GuC clocks. Thus, the maximum value before overflow is platform +* dependent. Current worst case scenario is about 110s. So, the spec says to +* limit to 100s to be safe. +*/ +#define GUC_POLICY_MAX_EXEC_QUANTUM_US (100 * 1000 * 1000UL) +#define GUC_POLICY_MAX_PREEMPT_TIMEOUT_US (100 * 1000 * 1000UL) + +static inline u32 guc_policy_max_exec_quantum_ms (void ) +{ +BUILD_BUG_ON (GUC_POLICY_MAX_EXEC_QUANTUM_US >=UINT_MAX ); +return GUC_POLICY_MAX_EXEC_QUANTUM_US /1000 ; +} + +static inline u32 guc_policy_max_preempt_timeout_ms (void ) +{ +BUILD_BUG_ON (GUC_POLICY_MAX_PREEMPT_TIMEOUT_US >=UINT_MAX ); +return GUC_POLICY_MAX_PREEMPT_TIMEOUT_US /1000 ; +} +struct guc_policies {u32 submission_queue_depth[GUC_MAX_ENGINE_CLASSES ];/* In micro seconds. How much time to allow before DPC processing is
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +8 -0
@@ -2430,6 +2430,10 @@ static int guc_context_policy_init_v70(struct intel_context *ce, bool loop)int ret;/* NB: For both of these, zero means disabled. */ +GEM_BUG_ON (overflows_type (engine->props.timeslice_duration_ms *1000 , + execution_quantum)); +GEM_BUG_ON (overflows_type (engine->props.preempt_timeout_ms *1000 , + preemption_timeout)); execution_quantum = engine->props.timeslice_duration_ms *1000 ; preemption_timeout = engine->props.preempt_timeout_ms *1000 ;
@@ -2486,6 +2490,10 @@ static void guc_context_policy_init_v69(struct intel_engine_cs *engine, desc->policy_flags |=CONTEXT_POLICY_FLAG_PREEMPT_TO_IDLE_V69 ;/* NB: For both of these, zero means disabled. */ +GEM_BUG_ON (overflows_type (engine->props.timeslice_duration_ms *1000 , + desc->execution_quantum)); +GEM_BUG_ON (overflows_type (engine->props.preempt_timeout_ms *1000 , + desc->preemption_timeout)); desc->execution_quantum = engine->props.timeslice_duration_ms *1000 ; desc->preemption_timeout = engine->props.preempt_timeout_ms *1000 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 233/1073 drm/i915: Fix compute pre-emption w/a to apply to compute engines
In reply to Greg Kroah-HartmanFrom: John Harrison <[email protected]>
[ Upstream commit c3bd49cd9a1043b963331e7fd874b380bed3f2bd ]
An earlier patch added support for compute engines. However, it missed enabling the anti-pre-emption w/a for the new engine class. So move the 'compute capable' flag earlier and use it for the pre-emption w/a test.
--- drivers/gpu/drm/i915/gt/intel_engine_cs.c | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine_cs.c +12 -12
@@ -486,6 +486,17 @@ static int intel_engine_setup(struct intel_gt *gt, enum intel_engine_id id, engine->logical_mask =BIT (logical_instance);__sprint_engine_name (engine); +if ((engine->class ==COMPUTE_CLASS && !RCS_MASK (engine->gt) && +__ffs (CCS_MASK (engine->gt)) == engine->instance) || + engine->class ==RENDER_CLASS ) + engine->flags |=I915_ENGINE_FIRST_RENDER_COMPUTE ; + +/* features common between engines sharing EUs */ +if (engine->class ==RENDER_CLASS || engine->class ==COMPUTE_CLASS ) { + engine->flags |=I915_ENGINE_HAS_RCS_REG_STATE ; + engine->flags |=I915_ENGINE_HAS_EU_PRIORITY ; + } + engine->props.heartbeat_interval_ms =CONFIG_DRM_I915_HEARTBEAT_INTERVAL ; engine->props.max_busywait_duration_ns =
@@ -498,20 +509,9 @@ static int intel_engine_setup(struct intel_gt *gt, enum intel_engine_id id,CONFIG_DRM_I915_TIMESLICE_DURATION ;/* Override to uninterruptible for OpenCL workloads. */ -if (GRAPHICS_VER (i915) ==12 && engine->class ==RENDER_CLASS ) +if (GRAPHICS_VER (i915) ==12 && (engine->flags &I915_ENGINE_HAS_RCS_REG_STATE )) engine->props.preempt_timeout_ms =0 ; -if ((engine->class ==COMPUTE_CLASS && !RCS_MASK (engine->gt) && -__ffs (CCS_MASK (engine->gt)) == engine->instance) || - engine->class ==RENDER_CLASS ) - engine->flags |=I915_ENGINE_FIRST_RENDER_COMPUTE ; - -/* features common between engines sharing EUs */ -if (engine->class ==RENDER_CLASS || engine->class ==COMPUTE_CLASS ) { - engine->flags |=I915_ENGINE_HAS_RCS_REG_STATE ; - engine->flags |=I915_ENGINE_HAS_EU_PRIORITY ; - } -/* Cap properties according to any system limits */ #define CLAMP_PROP (field) \ do { \
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 234/1073 media: i2c: hi846: Fix memory leak in hi846_parse_dt()
In reply to Greg Kroah-HartmanFrom: Rafael Mendonca <[email protected]>
[ Upstream commit 80113026d415e27483669db7a88b548d1ec3d3d1 ]
If any of the checks related to the supported link frequencies fail, then the V4L2 fwnode resources don't get released before returning, which leads to a memleak. Fix this by properly freeing the V4L2 fwnode data in a designated label.
--- drivers/media/i2c/hi846.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/media/i2c/hi846.c +10 -4
@@ -2008,22 +2008,24 @@ static int hi846_parse_dt(struct hi846 *hi846, struct device *dev) bus_cfg.bus.mipi_csi2.num_data_lanes != 4) {dev_err (dev,"number of CSI2 data lanes %d is not supported" , bus_cfg.bus.mipi_csi2.num_data_lanes); -v4l2_fwnode_endpoint_free (&bus_cfg); -return -EINVAL ; + ret = -EINVAL ; + goto check_hwcfg_error; } hi846->nr_lanes = bus_cfg.bus.mipi_csi2.num_data_lanes;if (!bus_cfg.nr_of_link_frequencies) {dev_err (dev,"link-frequency property not found in DT\n" ); -return -EINVAL ; + ret = -EINVAL ; + goto check_hwcfg_error; }/* Check that link frequences for all the modes are in device tree */ fq =hi846_check_link_freqs (hi846, &bus_cfg);if (fq) {dev_err (dev,"Link frequency of %lld is not supported\n" , fq); -return -EINVAL ; + ret = -EINVAL ; + goto check_hwcfg_error; }v4l2_fwnode_endpoint_free (&bus_cfg);
@@ -2044,6 +2046,10 @@ static int hi846_parse_dt(struct hi846 *hi846, struct device *dev) }return 0 ; + +check_hwcfg_error: +v4l2_fwnode_endpoint_free (&bus_cfg); +return ret; }static int hi846_probe (struct i2c_client *client)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 235/1073 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 236/1073 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 237/1073 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
@@ -1400,7 +1400,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 238/1073 media: i2c: ov5648: Free V4L2 fwnode data on unbind
In reply to Greg Kroah-HartmanFrom: Rafael Mendonca <[email protected]>
[ Upstream commit c95770e4fc172696dcb1450893cda7d6324d96fc ]
The V4L2 fwnode data structure doesn't get freed on unbind, which leads to a memleak.
--- drivers/media/i2c/ov5648.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/i2c/ov5648.c +1 -0
@@ -2597,6 +2597,7 @@ static int ov5648_remove(struct i2c_client *client)v4l2_ctrl_handler_free (&sensor->ctrls.handler);mutex_destroy (&sensor->mutex);media_entity_cleanup (&subdev->entity); +v4l2_fwnode_endpoint_free (&sensor->endpoint);return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 239/1073 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/samsung/exynos4-is/media-dev.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/media/platform/samsung/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 240/1073 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
@@ -3889,14 +3889,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); }
@@ -3920,7 +3920,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 241/1073 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
@@ -74,6 +74,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
@@ -83,6 +85,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)
@@ -278,6 +282,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;
@@ -295,6 +321,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 {
@@ -324,6 +352,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, };
@@ -606,6 +635,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
@@ -693,6 +725,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) {
@@ -1486,7 +1628,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 242/1073 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
@@ -234,7 +234,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 ];
@@ -246,7 +246,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;
@@ -319,7 +319,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;
@@ -329,7 +329,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;
@@ -351,7 +351,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,
@@ -366,7 +366,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, };
@@ -1132,11 +1132,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.
@@ -1144,13 +1144,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 ;
@@ -1167,11 +1167,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 243/1073 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
@@ -70,6 +70,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
@@ -258,6 +259,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;
@@ -321,6 +344,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;
@@ -330,6 +354,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;
@@ -353,6 +378,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, };
@@ -367,6 +393,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, };
@@ -1304,6 +1331,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) {
@@ -1382,6 +1477,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 244/1073 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
@@ -961,20 +961,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