Netdev List
 help / color / mirror / Atom feed
* Re: [BACKPORT 4.14.y 4/8] net: sctp: fix warning "NULL check before some freeing functions is not needed"
From: Marcelo Ricardo Leitner @ 2019-09-03 14:52 UTC (permalink / raw)
  To: Baolin Wang
  Cc: stable, vyasevich, nhorman, davem, hariprasad.kelam, linux-sctp,
	netdev, arnd, orsonzhai, vincent.guittot, linux-kernel
In-Reply-To: <0e71732006c11f119826b3be9c1a9ccd102742d8.1567492316.git.baolin.wang@linaro.org>

On Tue, Sep 03, 2019 at 02:58:16PM +0800, Baolin Wang wrote:
> From: Hariprasad Kelam <hariprasad.kelam@gmail.com>
> 
> This patch removes NULL checks before calling kfree.
> 
> fixes below issues reported by coccicheck
> net/sctp/sm_make_chunk.c:2586:3-8: WARNING: NULL check before some
> freeing functions is not needed.
> net/sctp/sm_make_chunk.c:2652:3-8: WARNING: NULL check before some
> freeing functions is not needed.
> net/sctp/sm_make_chunk.c:2667:3-8: WARNING: NULL check before some
> freeing functions is not needed.
> net/sctp/sm_make_chunk.c:2684:3-8: WARNING: NULL check before some
> freeing functions is not needed.

Hi. This doesn't seem the kind of patch that should be backported to
such old/stable releases. After all, it's just a cleanup.

  Marcelo

^ permalink raw reply

* Re: memory leak in nr_rx_frame (2)
From: syzbot @ 2019-09-03 14:35 UTC (permalink / raw)
  To: davem, linux-hams, linux-kernel, netdev, ralf, syzkaller-bugs
In-Reply-To: <0000000000003d789d05915a9fa3@google.com>

syzbot has found a reproducer for the following crash on:

HEAD commit:    089cf7f6 Linux 5.3-rc7
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=14100532600000
kernel config:  https://syzkaller.appspot.com/x/.config?x=b10436cfda3838d9
dashboard link: https://syzkaller.appspot.com/bug?extid=0145ea560de205bc09f0
compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=124dcf8e600000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=115f2346600000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+0145ea560de205bc09f0@syzkaller.appspotmail.com

executing program
executing program
executing program
executing program
executing program
BUG: memory leak
unreferenced object 0xffff88810de01800 (size 2048):
   comm "softirq", pid 0, jiffies 4294947090 (age 27.260s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     06 00 07 40 00 00 00 00 00 00 00 00 00 00 00 00  ...@............
   backtrace:
     [<0000000002377dcf>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<0000000002377dcf>] slab_post_alloc_hook mm/slab.h:522 [inline]
     [<0000000002377dcf>] slab_alloc mm/slab.c:3319 [inline]
     [<0000000002377dcf>] __do_kmalloc mm/slab.c:3653 [inline]
     [<0000000002377dcf>] __kmalloc+0x169/0x300 mm/slab.c:3664
     [<00000000af16d1f0>] kmalloc include/linux/slab.h:557 [inline]
     [<00000000af16d1f0>] sk_prot_alloc+0x112/0x170 net/core/sock.c:1603
     [<00000000b9033c4c>] sk_alloc+0x35/0x2f0 net/core/sock.c:1657
     [<00000000fb9e6269>] nr_make_new net/netrom/af_netrom.c:476 [inline]
     [<00000000fb9e6269>] nr_rx_frame+0x339/0x8ee net/netrom/af_netrom.c:959
     [<00000000fca3a307>] nr_loopback_timer+0x4e/0xd0  
net/netrom/nr_loopback.c:59
     [<0000000009d4e723>] call_timer_fn+0x45/0x1e0 kernel/time/timer.c:1322
     [<0000000047ea1d35>] expire_timers kernel/time/timer.c:1366 [inline]
     [<0000000047ea1d35>] __run_timers kernel/time/timer.c:1685 [inline]
     [<0000000047ea1d35>] __run_timers kernel/time/timer.c:1653 [inline]
     [<0000000047ea1d35>] run_timer_softirq+0x256/0x740  
kernel/time/timer.c:1698
     [<00000000e53c6536>] __do_softirq+0x115/0x33f kernel/softirq.c:292
     [<0000000024be59bc>] invoke_softirq kernel/softirq.c:373 [inline]
     [<0000000024be59bc>] irq_exit+0xbb/0xe0 kernel/softirq.c:413
     [<0000000080d19282>] exiting_irq arch/x86/include/asm/apic.h:537  
[inline]
     [<0000000080d19282>] smp_apic_timer_interrupt+0x96/0x190  
arch/x86/kernel/apic/apic.c:1133
     [<000000000e93dbd5>] apic_timer_interrupt+0xf/0x20  
arch/x86/entry/entry_64.S:830
     [<000000002864ce39>] native_safe_halt+0xe/0x10  
arch/x86/include/asm/irqflags.h:60
     [<000000007e3841ad>] arch_cpu_idle+0xa/0x10  
arch/x86/kernel/process.c:571
     [<00000000546bc34f>] default_idle_call+0x1e/0x40 kernel/sched/idle.c:94
     [<00000000e98df687>] cpuidle_idle_call kernel/sched/idle.c:154 [inline]
     [<00000000e98df687>] do_idle+0x1ea/0x2c0 kernel/sched/idle.c:263
     [<000000001e3f823f>] cpu_startup_entry+0x1b/0x20 kernel/sched/idle.c:354

BUG: memory leak
unreferenced object 0xffff88810fa3c9a0 (size 32):
   comm "softirq", pid 0, jiffies 4294947090 (age 27.260s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     03 00 00 00 03 00 00 00 0f 00 00 00 00 00 00 00  ................
   backtrace:
     [<00000000e9077829>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000e9077829>] slab_post_alloc_hook mm/slab.h:522 [inline]
     [<00000000e9077829>] slab_alloc mm/slab.c:3319 [inline]
     [<00000000e9077829>] kmem_cache_alloc_trace+0x145/0x2c0 mm/slab.c:3548
     [<0000000037f78c54>] kmalloc include/linux/slab.h:552 [inline]
     [<0000000037f78c54>] kzalloc include/linux/slab.h:748 [inline]
     [<0000000037f78c54>] selinux_sk_alloc_security+0x48/0xb0  
security/selinux/hooks.c:5073
     [<00000000313a65ff>] security_sk_alloc+0x49/0x70  
security/security.c:2029
     [<00000000ffa4a0b0>] sk_prot_alloc+0x12d/0x170 net/core/sock.c:1606
     [<00000000b9033c4c>] sk_alloc+0x35/0x2f0 net/core/sock.c:1657
     [<00000000fb9e6269>] nr_make_new net/netrom/af_netrom.c:476 [inline]
     [<00000000fb9e6269>] nr_rx_frame+0x339/0x8ee net/netrom/af_netrom.c:959
     [<00000000fca3a307>] nr_loopback_timer+0x4e/0xd0  
net/netrom/nr_loopback.c:59
     [<0000000009d4e723>] call_timer_fn+0x45/0x1e0 kernel/time/timer.c:1322
     [<0000000047ea1d35>] expire_timers kernel/time/timer.c:1366 [inline]
     [<0000000047ea1d35>] __run_timers kernel/time/timer.c:1685 [inline]
     [<0000000047ea1d35>] __run_timers kernel/time/timer.c:1653 [inline]
     [<0000000047ea1d35>] run_timer_softirq+0x256/0x740  
kernel/time/timer.c:1698
     [<00000000e53c6536>] __do_softirq+0x115/0x33f kernel/softirq.c:292
     [<0000000024be59bc>] invoke_softirq kernel/softirq.c:373 [inline]
     [<0000000024be59bc>] irq_exit+0xbb/0xe0 kernel/softirq.c:413
     [<0000000080d19282>] exiting_irq arch/x86/include/asm/apic.h:537  
[inline]
     [<0000000080d19282>] smp_apic_timer_interrupt+0x96/0x190  
arch/x86/kernel/apic/apic.c:1133
     [<000000000e93dbd5>] apic_timer_interrupt+0xf/0x20  
arch/x86/entry/entry_64.S:830
     [<000000002864ce39>] native_safe_halt+0xe/0x10  
arch/x86/include/asm/irqflags.h:60
     [<000000007e3841ad>] arch_cpu_idle+0xa/0x10  
arch/x86/kernel/process.c:571
     [<00000000546bc34f>] default_idle_call+0x1e/0x40 kernel/sched/idle.c:94

BUG: memory leak
unreferenced object 0xffff88810de01800 (size 2048):
   comm "softirq", pid 0, jiffies 4294947090 (age 30.780s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     06 00 07 40 00 00 00 00 00 00 00 00 00 00 00 00  ...@............
   backtrace:
     [<0000000002377dcf>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<0000000002377dcf>] slab_post_alloc_hook mm/slab.h:522 [inline]
     [<0000000002377dcf>] slab_alloc mm/slab.c:3319 [inline]
     [<0000000002377dcf>] __do_kmalloc mm/slab.c:3653 [inline]
     [<0000000002377dcf>] __kmalloc+0x169/0x300 mm/slab.c:3664
     [<00000000af16d1f0>] kmalloc include/linux/slab.h:557 [inline]
     [<00000000af16d1f0>] sk_prot_alloc+0x112/0x170 net/core/sock.c:1603
     [<00000000b9033c4c>] sk_alloc+0x35/0x2f0 net/core/sock.c:1657
     [<00000000fb9e6269>] nr_make_new net/netrom/af_netrom.c:476 [inline]
     [<00000000fb9e6269>] nr_rx_frame+0x339/0x8ee net/netrom/af_netrom.c:959
     [<00000000fca3a307>] nr_loopback_timer+0x4e/0xd0  
net/netrom/nr_loopback.c:59
     [<0000000009d4e723>] call_timer_fn+0x45/0x1e0 kernel/time/timer.c:1322
     [<0000000047ea1d35>] expire_timers kernel/time/timer.c:1366 [inline]
     [<0000000047ea1d35>] __run_timers kernel/time/timer.c:1685 [inline]
     [<0000000047ea1d35>] __run_timers kernel/time/timer.c:1653 [inline]
     [<0000000047ea1d35>] run_timer_softirq+0x256/0x740  
kernel/time/timer.c:1698
     [<00000000e53c6536>] __do_softirq+0x115/0x33f kernel/softirq.c:292
     [<0000000024be59bc>] invoke_softirq kernel/softirq.c:373 [inline]
     [<0000000024be59bc>] irq_exit+0xbb/0xe0 kernel/softirq.c:413
     [<0000000080d19282>] exiting_irq arch/x86/include/asm/apic.h:537  
[inline]
     [<0000000080d19282>] smp_apic_timer_interrupt+0x96/0x190  
arch/x86/kernel/apic/apic.c:1133
     [<000000000e93dbd5>] apic_timer_interrupt+0xf/0x20  
arch/x86/entry/entry_64.S:830
     [<000000002864ce39>] native_safe_halt+0xe/0x10  
arch/x86/include/asm/irqflags.h:60
     [<000000007e3841ad>] arch_cpu_idle+0xa/0x10  
arch/x86/kernel/process.c:571
     [<00000000546bc34f>] default_idle_call+0x1e/0x40 kernel/sched/idle.c:94
     [<00000000e98df687>] cpuidle_idle_call kernel/sched/idle.c:154 [inline]
     [<00000000e98df687>] do_idle+0x1ea/0x2c0 kernel/sched/idle.c:263
     [<000000001e3f823f>] cpu_startup_entry+0x1b/0x20 kernel/sched/idle.c:354

BUG: memory leak
unreferenced object 0xffff88810fa3c9a0 (size 32):
   comm "softirq", pid 0, jiffies 4294947090 (age 30.780s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     03 00 00 00 03 00 00 00 0f 00 00 00 00 00 00 00  ................
   backtrace:
     [<00000000e9077829>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000e9077829>] slab_post_alloc_hook mm/slab.h:522 [inline]
     [<00000000e9077829>] slab_alloc mm/slab.c:3319 [inline]
     [<00000000e9077829>] kmem_cache_alloc_trace+0x145/0x2c0 mm/slab.c:3548
     [<0000000037f78c54>] kmalloc include/linux/slab.h:552 [inline]
     [<0000000037f78c54>] kzalloc include/linux/slab.h:748 [inline]
     [<0000000037f78c54>] selinux_sk_alloc_security+0x48/0xb0  
security/selinux/hooks.c:5073
     [<00000000313a65ff>] security_sk_alloc+0x49/0x70  
security/security.c:2029
     [<00000000ffa4a0b0>] sk_prot_alloc+0x12d/0x170 net/core/sock.c:1606
     [<00000000b9033c4c>] sk_alloc+0x35/0x2f0 net/core/sock.c:1657
     [<00000000fb9e6269>] nr_make_new net/netrom/af_netrom.c:476 [inline]
     [<00000000fb9e6269>] nr_rx_frame+0x339/0x8ee net/netrom/af_netrom.c:959
     [<00000000fca3a307>] nr_loopback_timer+0x4e/0xd0  
net/netrom/nr_loopback.c:59
     [<0000000009d4e723>] call_timer_fn+0x45/0x1e0 kernel/time/timer.c:1322
     [<0000000047ea1d35>] expire_timers kernel/time/timer.c:1366 [inline]
     [<0000000047ea1d35>] __run_timers kernel/time/timer.c:1685 [inline]
     [<0000000047ea1d35>] __run_timers kernel/time/timer.c:1653 [inline]
     [<0000000047ea1d35>] run_timer_softirq+0x256/0x740  
kernel/time/timer.c:1698
     [<00000000e53c6536>] __do_softirq+0x115/0x33f kernel/softirq.c:292
     [<0000000024be59bc>] invoke_softirq kernel/softirq.c:373 [inline]
     [<0000000024be59bc>] irq_exit+0xbb/0xe0 kernel/softirq.c:413
     [<0000000080d19282>] exiting_irq arch/x86/include/asm/apic.h:537  
[inline]
     [<0000000080d19282>] smp_apic_timer_interrupt+0x96/0x190  
arch/x86/kernel/apic/apic.c:1133
     [<000000000e93dbd5>] apic_timer_interrupt+0xf/0x20  
arch/x86/entry/entry_64.S:830
     [<000000002864ce39>] native_safe_halt+0xe/0x10  
arch/x86/include/asm/irqflags.h:60
     [<000000007e3841ad>] arch_cpu_idle+0xa/0x10  
arch/x86/kernel/process.c:571
     [<00000000546bc34f>] default_idle_call+0x1e/0x40 kernel/sched/idle.c:94

BUG: memory leak
unreferenced object 0xffff88810de01800 (size 2048):
   comm "softirq", pid 0, jiffies 4294947090 (age 32.010s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     06 00 07 40 00 00 00 00 00 00 00 00 00 00 00 00  ...@............
   backtrace:
     [<0000000002377dcf>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<0000000002377dcf>] slab_post_alloc_hook mm/slab.h:522 [inline]
     [<0000000002377dcf>] slab_alloc mm/slab.c:3319 [inline]
     [<0000000002377dcf>] __do_kmalloc mm/slab.c:3653 [inline]
     [<0000000002377dcf>] __kmalloc+0x169/0x300 mm/slab.c:3664
     [<00000000af16d1f0>] kmalloc include/linux/slab.h:557 [inline]
     [<00000000af16d1f0>] sk_prot_alloc+0x112/0x170 net/core/sock.c:1603
     [<00000000b9033c4c>] sk_alloc+0x35/0x2f0 net/core/sock.c:1657
     [<00000000fb9e6269>] nr_make_new net/netrom/af_netrom.c:476 [inline]
     [<00000000fb9e6269>] nr_rx_frame+0x339/0x8ee net/netrom/af_netrom.c:959
     [<00000000fca3a307>] nr_loopback_timer+0x4e/0xd0  
net/netrom/nr_loopback.c:59
     [<0000000009d4e723>] call_timer_fn+0x45/0x1e0 kernel/time/timer.c:1322
     [<0000000047ea1d35>] expire_timers kernel/time/timer.c:1366 [inline]
     [<0000000047ea1d35>] __run_timers kernel/time/timer.c:1685 [inline]
     [<0000000047ea1d35>] __run_timers kernel/time/timer.c:1653 [inline]
     [<0000000047ea1d35>] run_timer_softirq+0x256/0x740  
kernel/time/timer.c:1698
     [<00000000e53c6536>] __do_softirq+0x115/0x33f kernel/softirq.c:292
     [<0000000024be59bc>] invoke_softirq kernel/softirq.c:373 [inline]
     [<0000000024be59bc>] irq_exit+0xbb/0xe0 kernel/softirq.c:413
     [<0000000080d19282>] exiting_irq arch/x86/include/asm/apic.h:537  
[inline]
     [<0000000080d19282>] smp_apic_timer_interrupt+0x96/0x190  
arch/x86/kernel/apic/apic.c:1133
     [<000000000e93dbd5>] apic_timer_interrupt+0xf/0x20  
arch/x86/entry/entry_64.S:830
     [<000000002864ce39>] native_safe_halt+0xe/0x10  
arch/x86/include/asm/irqflags.h:60
     [<000000007e3841ad>] arch_cpu_idle+0xa/0x10  
arch/x86/kernel/process.c:571
     [<00000000546bc34f>] default_idle_call+0x1e/0x40 kernel/sched/idle.c:94
     [<00000000e98df687>] cpuidle_idle_call kernel/sched/idle.c:154 [inline]
     [<00000000e98df687>] do_idle+0x1ea/0x2c0 kernel/sched/idle.c:263
     [<000000001e3f823f>] cpu_startup_entry+0x1b/0x20 kernel/sched/idle.c:354

BUG: memory leak
unreferenced object 0xffff88810fa3c9a0 (size 32):
   comm "softirq", pid 0, jiffies 4294947090 (age 32.010s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     03 00 00 00 03 00 00 00 0f 00 00 00 00 00 00 00  ................
   backtrace:
     [<00000000e9077829>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000e9077829>] slab_post_alloc_hook mm/slab.h:522 [inline]
     [<00000000e9077829>] slab_alloc mm/slab.c:3319 [inline]
     [<00000000e9077829>] kmem_cache_alloc_trace+0x145/0x2c0 mm/slab.c:3548
     [<0000000037f78c54>] kmalloc include/linux/slab.h:552 [inline]
     [<0000000037f78c54>] kzalloc include/linux/slab.h:748 [inline]
     [<0000000037f78c54>] selinux_sk_alloc_security+0x48/0xb0  
security/selinux/hooks.c:5073
     [<00000000313a65ff>] security_sk_alloc+0x49/0x70  
security/security.c:2029
     [<00000000ffa4a0b0>] sk_prot_alloc+0x12d/0x170 net/core/sock.c:1606
     [<00000000b9033c4c>] sk_alloc+0x35/0x2f0 net/core/sock.c:1657
     [<00000000fb9e6269>] nr_make_new net/netrom/af_netrom.c:476 [inline]
     [<00000000fb9e6269>] nr_rx_frame+0x339/0x8ee net/netrom/af_netrom.c:959
     [<00000000fca3a307>] nr_loopback_timer+0x4e/0xd0  
net/netrom/nr_loopback.c:59
     [<0000000009d4e723>] call_timer_fn+0x45/0x1e0 kernel/time/timer.c:1322
     [<0000000047ea1d35>] expire_timers kernel/time/timer.c:1366 [inline]
     [<0000000047ea1d35>] __run_timers kernel/time/timer.c:1685 [inline]
     [<0000000047ea1d35>] __run_timers kernel/time/timer.c:1653 [inline]
     [<0000000047ea1d35>] run_timer_softirq+0x256/0x740  
kernel/time/timer.c:1698
     [<00000000e53c6536>] __do_softirq+0x115/0x33f kernel/softirq.c:292
     [<0000000024be59bc>] invoke_softirq kernel/softirq.c:373 [inline]
     [<0000000024be59bc>] irq_exit+0xbb/0xe0 kernel/softirq.c:413
     [<0000000080d19282>] exiting_irq arch/x86/include/asm/apic.h:537  
[inline]
     [<0000000080d19282>] smp_apic_timer_interrupt+0x96/0x190  
arch/x86/kernel/apic/apic.c:1133
     [<000000000e93dbd5>] apic_timer_interrupt+0xf/0x20  
arch/x86/entry/entry_64.S:830
     [<000000002864ce39>] native_safe_halt+0xe/0x10  
arch/x86/include/asm/irqflags.h:60
     [<000000007e3841ad>] arch_cpu_idle+0xa/0x10  
arch/x86/kernel/process.c:571
     [<00000000546bc34f>] default_idle_call+0x1e/0x40 kernel/sched/idle.c:94

BUG: memory leak
unreferenced object 0xffff88810de01800 (size 2048):
   comm "softirq", pid 0, jiffies 4294947090 (age 32.080s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     06 00 07 40 00 00 00 00 00 00 00 00 00 00 00 00  ...@............
   backtrace:
     [<0000000002377dcf>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<0000000002377dcf>] slab_post_alloc_hook mm/slab.h:522 [inline]
     [<0000000002377dcf>] slab_alloc mm/slab.c:3319 [inline]
     [<0000000002377dcf>] __do_kmalloc mm/slab.c:3653 [inline]
     [<0000000002377dcf>] __kmalloc+0x169/0x300 mm/slab.c:3664
     [<00000000af16d1f0>] kmalloc include/linux/slab.h:557 [inline]
     [<00000000af16d1f0>] sk_prot_alloc+0x112/0x170 net/core/sock.c:1603
     [<00000000b9033c4c>] sk_alloc+0x35/0x2f0 net/core/sock.c:1657
     [<00000000fb9e6269>] nr_make_new net/netrom/af_netrom.c:476 [inline]
     [<00000000fb9e6269>] nr_rx_frame+0x339/0x8ee net/netrom/af_netrom.c:959
     [<00000000fca3a307>] nr_loopback_timer+0x4e/0xd0  
net/netrom/nr_loopback.c:59
     [<0000000009d4e723>] call_timer_fn+0x45/0x1e0 kernel/time/timer.c:1322
     [<0000000047ea1d35>] expire_timers kernel/time/timer.c:1366 [inline]
     [<0000000047ea1d35>] __run_timers kernel/time/timer.c:1685 [inline]
     [<0000000047ea1d35>] __run_timers kernel/time/timer.c:1653 [inline]
     [<0000000047ea1d35>] run_timer_softirq+0x256/0x740  
kernel/time/timer.c:1698
     [<00000000e53c6536>] __do_softirq+0x115/0x33f kernel/softirq.c:292
     [<0000000024be59bc>] invoke_softirq kernel/softirq.c:373 [inline]
     [<0000000024be59bc>] irq_exit+0xbb/0xe0 kernel/softirq.c:413
     [<0000000080d19282>] exiting_irq arch/x86/include/asm/apic.h:537  
[inline]
     [<0000000080d19282>] smp_apic_timer_interrupt+0x96/0x190  
arch/x86/kernel/apic/apic.c:1133
     [<000000000e93dbd5>] apic_timer_interrupt+0xf/0x20  
arch/x86/entry/entry_64.S:830
     [<000000002864ce39>] native_safe_halt+0xe/0x10  
arch/x86/include/asm/irqflags.h:60
     [<000000007e3841ad>] arch_cpu_idle+0xa/0x10  
arch/x86/kernel/process.c:571
     [<00000000546bc34f>] default_idle_call+0x1e/0x40 kernel/sched/idle.c:94
     [<00000000e98df687>] cpuidle_idle_call kernel/sched/idle.c:154 [inline]
     [<00000000e98df687>] do_idle+0x1ea/0x2c0 kernel/sched/idle.c:263
     [<000000001e3f823f>] cpu_startup_entry+0x1b/0x20 kernel/sched/idle.c:354

BUG: memory leak
unreferenced object 0xffff88810fa3c9a0 (size 32):
   comm "softirq", pid 0, jiffies 4294947090 (age 32.080s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     03 00 00 00 03 00 00 00 0f 00 00 00 00 00 00 00  ................
   backtrace:
     [<00000000e9077829>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000e9077829>] slab_post_alloc_hook mm/slab.h:522 [inline]
     [<00000000e9077829>] slab_alloc mm/slab.c:3319 [inline]
     [<00000000e9077829>] kmem_cache_alloc_trace+0x145/0x2c0 mm/slab.c:3548
     [<0000000037f78c54>] kmalloc include/linux/slab.h:552 [inline]
     [<0000000037f78c54>] kzalloc include/linux/slab.h:748 [inline]
     [<0000000037f78c54>] selinux_sk_alloc_security+0x48/0xb0  
security/selinux/hooks.c:5073
     [<00000000313a65ff>] security_sk_alloc+0x49/0x70  
security/security.c:2029
     [<00000000ffa4a0b0>] sk_prot_alloc+0x12d/0x170 net/core/sock.c:1606
     [<00000000b9033c4c>] sk_alloc+0x35/0x2f0 net/core/sock.c:1657
     [<00000000fb9e6269>] nr_make_new net/netrom/af_netrom.c:476 [inline]
     [<00000000fb9e6269>] nr_rx_frame+0x339/0x8ee net/netrom/af_netrom.c:959
     [<00000000fca3a307>] nr_loopback_timer+0x4e/0xd0  
net/netrom/nr_loopback.c:59
     [<0000000009d4e723>] call_timer_fn+0x45/0x1e0 kernel/time/timer.c:1322
     [<0000000047ea1d35>] expire_timers kernel/time/timer.c:1366 [inline]
     [<0000000047ea1d35>] __run_timers kernel/time/timer.c:1685 [inline]
     [<0000000047ea1d35>] __run_timers kernel/time/timer.c:1653 [inline]
     [<0000000047ea1d35>] run_timer_softirq+0x256/0x740  
kernel/time/timer.c:1698
     [<00000000e53c6536>] __do_softirq+0x115/0x33f kernel/softirq.c:292
     [<0000000024be59bc>] invoke_softirq kernel/softirq.c:373 [inline]
     [<0000000024be59bc>] irq_exit+0xbb/0xe0 kernel/softirq.c:413
     [<0000000080d19282>] exiting_irq arch/x86/include/asm/apic.h:537  
[inline]
     [<0000000080d19282>] smp_apic_timer_interrupt+0x96/0x190  
arch/x86/kernel/apic/apic.c:1133
     [<000000000e93dbd5>] apic_timer_interrupt+0xf/0x20  
arch/x86/entry/entry_64.S:830
     [<000000002864ce39>] native_safe_halt+0xe/0x10  
arch/x86/include/asm/irqflags.h:60
     [<000000007e3841ad>] arch_cpu_idle+0xa/0x10  
arch/x86/kernel/process.c:571
     [<00000000546bc34f>] default_idle_call+0x1e/0x40 kernel/sched/idle.c:94

BUG: memory leak
unreferenced object 0xffff88810de01800 (size 2048):
   comm "softirq", pid 0, jiffies 4294947090 (age 32.150s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     06 00 07 40 00 00 00 00 00 00 00 00 00 00 00 00  ...@............
   backtrace:
     [<0000000002377dcf>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<0000000002377dcf>] slab_post_alloc_hook mm/slab.h:522 [inline]
     [<0000000002377dcf>] slab_alloc mm/slab.c:3319 [inline]
     [<0000000002377dcf>] __do_kmalloc mm/slab.c:3653 [inline]
     [<0000000002377dcf>] __kmalloc+0x169/0x300 mm/slab.c:3664
     [<00000000af16d1f0>] kmalloc include/linux/slab.h:557 [inline]
     [<00000000af16d1f0>] sk_prot_alloc+0x112/0x170 net/core/sock.c:1603
     [<00000000b9033c4c>] sk_alloc+0x35/0x2f0 net/core/sock.c:1657
     [<00000000fb9e6269>] nr_make_new net/netrom/af_netrom.c:476 [inline]
     [<00000000fb9e6269>] nr_rx_frame+0x339/0x8ee net/netrom/af_netrom.c:959
     [<00000000fca3a307>] nr_loopback_timer+0x4e/0xd0  
net/netrom/nr_loopback.c:59
     [<0000000009d4e723>] call_timer_fn+0x45/0x1e0 kernel/time/timer.c:1322
     [<0000000047ea1d35>] expire_timers kernel/time/timer.c:1366 [inline]
     [<0000000047ea1d35>] __run_timers kernel/time/timer.c:1685 [inline]
     [<0000000047ea1d35>] __run_timers kernel/time/timer.c:1653 [inline]
     [<0000000047ea1d35>] run_timer_softirq+0x256/0x740  
kernel/time/timer.c:1698
     [<00000000e53c6536>] __do_softirq+0x115/0x33f kernel/softirq.c:292
     [<0000000024be59bc>] invoke_softirq kernel/softirq.c:373 [inline]
     [<0000000024be59bc>] irq_exit+0xbb/0xe0 kernel/softirq.c:413
     [<0000000080d19282>] exiting_irq arch/x86/include/asm/apic.h:537  
[inline]
     [<0000000080d19282>] smp_apic_timer_interrupt+0x96/0x190  
arch/x86/kernel/apic/apic.c:1133
     [<000000000e93dbd5>] apic_timer_interrupt+0xf/0x20  
arch/x86/entry/entry_64.S:830
     [<000000002864ce39>] native_safe_halt+0xe/0x10  
arch/x86/include/asm/irqflags.h:60
     [<000000007e3841ad>] arch_cpu_idle+0xa/0x10  
arch/x86/kernel/process.c:571
     [<00000000546bc34f>] default_idle_call+0x1e/0x40 kernel/sched/idle.c:94
     [<00000000e98df687>] cpuidle_idle_call kernel/sched/idle.c:154 [inline]
     [<00000000e98df687>] do_idle+0x1ea/0x2c0 kernel/sched/idle.c:263
     [<000000001e3f823f>] cpu_startup_entry+0x1b/0x20 kernel/sched/idle.c:354

BUG: memory leak
unreferenced object 0xffff88810fa3c9a0 (size 32):
   comm "softirq", pid 0, jiffies 4294947090 (age 32.150s)
   hex dump (first 32 bytes):
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
     03 00 00 00 03 00 00 00 0f 00 00 00 00 00 00 00  ................
   backtrace:
     [<00000000e9077829>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:43 [inline]
     [<00000000e9077829>] slab_post_alloc_hook mm/slab.h:522 [inline]
     [<00000000e9077829>] slab_alloc mm/slab.c:3319 [inline]
     [<00000000e9077829>] kmem_cache_alloc_trace+0x145/0x2c0 mm/slab.c:3548
     [<0000000037f78c54>] kmalloc include/linux/slab.h:552 [inline]
     [<0000000037f78c54>] kzalloc include/linux/slab.h:748 [inline]
     [<0000000037f78c54>] selinux_sk_alloc_security+0x48/0xb0  
security/selinux/hooks.c:5073
     [<00000000313a65ff>] security_sk_alloc+0x49/0x70  
security/security.c:2029
     [<00000000ffa4a0b0>] sk_prot_alloc+0x12d/0x170 net/core/sock.c:1606
     [<00000000b9033c4c>] sk_alloc+0x35/0x2f0 net/core/sock.c:1657
     [<00000000fb9e6269>] nr_make_new net/netrom/af_netrom.c:476 [inline]
     [<00000000fb9e6269>] nr_rx_frame+0x339/0x8ee net/netrom/af_netrom.c:959
     [<00000000fca3a307>] nr_loopback_timer+0x4e/0xd0  
net/netrom/nr_loopback.c:59
     [<0000000009d4e723>] call_timer_fn+0x45/0x1e0 kernel/time/timer.c:1322
     [<0000000047ea1d35>] expire_timers kernel/time/timer.c:1366 [inline]
     [<0000000047ea1d35>] __run_timers kernel/time/timer.c:1685 [inline]
     [<0000000047ea1d35>] __run_timers kernel/time/timer.c:1653 [inline]
     [<0000000047ea1d35>] run_timer_softirq+0x256/0x740  
kernel/time/timer.c:1698
     [<00000000e53c6536>] __do_softirq+0x115/0x33f kernel/softirq.c:292
     [<0000000024be59bc>] invoke_softirq kernel/softirq.c:373 [inline]
     [<0000000024be59bc>] irq_exit+0xbb/0xe0 kernel/softirq.c:413
     [<0000000080d19282>] exiting_irq arch/x86/include/asm/apic.h:537  
[inline]
     [<0000000080d19282>] smp_apic_timer_interrupt+0x96/0x190  
arch/x86/kernel/apic/apic.c:1133
     [<000000000e93dbd5>] apic_timer_interrupt+0xf/0x20  
arch/x86/entry/entry_64.S:830
     [<000000002864ce39>] native_safe_halt+0xe/0x10  
arch/x86/include/asm/irqflags.h:60
     [<000000007e3841ad>] arch_cpu_idle+0xa/0x10  
arch/x86/kernel/process.c:571
     [<00000000546bc34f>] default_idle_call+0x1e/0x40 kernel/sched/idle.c:94

executing program
executing program
executing program


^ permalink raw reply

* Re: [PATCH 2/2] Fix a NULL-ptr-deref bug in ath10k_usb_alloc_urb_from_pipe
From: Kalle Valo @ 2019-09-03 14:14 UTC (permalink / raw)
  To: Hui Peng
  Cc: davem, Hui Peng, Mathias Payer, ath10k, linux-wireless, netdev,
	linux-kernel
In-Reply-To: <20190804003101.11541-1-benquike@gmail.com>

Hui Peng <benquike@gmail.com> wrote:

> The `ar_usb` field of `ath10k_usb_pipe_usb_pipe` objects
> are initialized to point to the containing `ath10k_usb` object
> according to endpoint descriptors read from the device side, as shown
> below in `ath10k_usb_setup_pipe_resources`:
> 
> for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
>         endpoint = &iface_desc->endpoint[i].desc;
> 
>         // get the address from endpoint descriptor
>         pipe_num = ath10k_usb_get_logical_pipe_num(ar_usb,
>                                                 endpoint->bEndpointAddress,
>                                                 &urbcount);
>         ......
>         // select the pipe object
>         pipe = &ar_usb->pipes[pipe_num];
> 
>         // initialize the ar_usb field
>         pipe->ar_usb = ar_usb;
> }
> 
> The driver assumes that the addresses reported in endpoint
> descriptors from device side  to be complete. If a device is
> malicious and does not report complete addresses, it may trigger
> NULL-ptr-deref `ath10k_usb_alloc_urb_from_pipe` and
> `ath10k_usb_free_urb_to_pipe`.
> 
> This patch fixes the bug by preventing potential NULL-ptr-deref.
> 
> Signed-off-by: Hui Peng <benquike@gmail.com>
> Reported-by: Hui Peng <benquike@gmail.com>
> Reported-by: Mathias Payer <mathias.payer@nebelwelt.net>
> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

This causes a new warning, please build test your patches.

In file included from ./include/uapi/linux/posix_types.h:5,
                 from ./include/uapi/linux/types.h:14,
                 from ./include/linux/types.h:6,
                 from ./include/linux/list.h:5,
                 from ./include/linux/module.h:9,
                 from drivers/net/wireless/ath/ath10k/usb.c:8:
drivers/net/wireless/ath/ath10k/usb.c: In function 'ath10k_usb_free_urb_to_pipe':
./include/linux/stddef.h:8:14: warning: 'return' with a value, in function returning void
 #define NULL ((void *)0)
              ^
drivers/net/wireless/ath/ath10k/usb.c:64:10: note: in expansion of macro 'NULL'
   return NULL;
          ^~~~
drivers/net/wireless/ath/ath10k/usb.c:57:13: note: declared here
 static void ath10k_usb_free_urb_to_pipe(struct ath10k_usb_pipe *pipe,
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~

Patch set to Changes Requested.

-- 
https://patchwork.kernel.org/patch/11074657/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply

* KSZ8863 ethernet PHY support question
From: HOLTZ Matthieu @ 2019-09-03 13:59 UTC (permalink / raw)
  To: netdev@vger.kernel.org; +Cc: matthieu.holtz@gmail.com

Hello,

I’d like to use a switch phy KSZ8863 with an NXP i.mx8mm MPU (new motherboard dev) and a kernel 4.14.x but I am a bit lost regarding the driver support.

Is the Phy supported by the driver under linux/drivers/net/phy/micrel.c and what about the switch configuration, is it implemented in the DSA subsystem ?

KR,
Matthieu H

^ permalink raw reply

* Re: [PATCH bpf-next] arm64: bpf: optimize modulo operation
From: Daniel Borkmann @ 2019-09-03 14:05 UTC (permalink / raw)
  To: jerinj, netdev, Alexei Starovoitov, Zi Shen Lim, Catalin Marinas,
	Will Deacon, Martin KaFai Lau, Song Liu, Yonghong Song,
	open list:BPF JIT for ARM64,
	moderated list:ARM64 PORT (AARCH64 ARCHITECTURE), open list
In-Reply-To: <20190902061448.28252-1-jerinj@marvell.com>

On 9/2/19 8:14 AM, jerinj@marvell.com wrote:
> From: Jerin Jacob <jerinj@marvell.com>
> 
> Optimize modulo operation instruction generation by
> using single MSUB instruction vs MUL followed by SUB
> instruction scheme.
> 
> Signed-off-by: Jerin Jacob <jerinj@marvell.com>

Applied, thanks!

^ permalink raw reply

* Re: [PATCH] rsi: fix a double free bug in rsi_91x_deinit()
From: Kalle Valo @ 2019-09-03 13:55 UTC (permalink / raw)
  To: Hui Peng
  Cc: security, Hui Peng, Mathias Payer, David S. Miller,
	linux-wireless, netdev, linux-kernel
In-Reply-To: <20190819220230.10597-1-benquike@gmail.com>

Hui Peng <benquike@gmail.com> wrote:

> `dev` (struct rsi_91x_usbdev *) field of adapter
> (struct rsi_91x_usbdev *) is allocated  and initialized in
> `rsi_init_usb_interface`. If any error is detected in information
> read from the device side,  `rsi_init_usb_interface` will be
> freed. However, in the higher level error handling code in
> `rsi_probe`, if error is detected, `rsi_91x_deinit` is called
> again, in which `dev` will be freed again, resulting double free.
> 
> This patch fixes the double free by removing the free operation on
> `dev` in `rsi_init_usb_interface`, because `rsi_91x_deinit` is also
> used in `rsi_disconnect`, in that code path, the `dev` field is not
>  (and thus needs to be) freed.
> 
> This bug was found in v4.19, but is also present in the latest version
> of kernel. Fixes CVE-2019-15504.
> 
> Reported-by: Hui Peng <benquike@gmail.com>
> Reported-by: Mathias Payer <mathias.payer@nebelwelt.net>
> Signed-off-by: Hui Peng <benquike@gmail.com>
> Reviewed-by: Guenter Roeck <linux@roeck-us.net>

Patch applied to wireless-drivers.git, thanks.

8b51dc729147 rsi: fix a double free bug in rsi_91x_deinit()

-- 
https://patchwork.kernel.org/patch/11102087/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply

* Re: [PATCH][next] zd1211rw: zd_usb: Use struct_size() helper
From: Kalle Valo @ 2019-09-03 13:45 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Daniel Drake, Ulrich Kunitz, David S. Miller, linux-wireless,
	netdev, linux-kernel, Gustavo A. R. Silva
In-Reply-To: <20190830185716.GA10044@embeddedor>

"Gustavo A. R. Silva" <gustavo@embeddedor.com> wrote:

> One of the more common cases of allocation size calculations is finding
> the size of a structure that has a zero-sized array at the end, along
> with memory for some number of elements for that array. For example:
> 
> struct usb_int_regs {
> 	...
>         struct reg_data regs[0];
> } __packed;
> 
> Make use of the struct_size() helper instead of an open-coded version
> in order to avoid any potential type mistakes.
> 
> So, replace the following function:
> 
> static int usb_int_regs_length(unsigned int count)
> {
>        return sizeof(struct usb_int_regs) + count * sizeof(struct reg_data);
> }
> 
> with:
> 
> struct_size(regs, regs, count)
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Patch applied to wireless-drivers-next.git, thanks.

84b0b6635247 zd1211rw: zd_usb: Use struct_size() helper

-- 
https://patchwork.kernel.org/patch/11124457/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply

* Re: [PATCH] brcmfmac: replace strncpy() by strscpy()
From: Kalle Valo @ 2019-09-03 13:43 UTC (permalink / raw)
  To: Xulin Sun
  Cc: stefan.wahren, xulin.sun, linux-kernel, netdev,
	brcm80211-dev-list, brcm80211-dev-list.pdl, linux-wireless,
	arend.vanspriel, franky.lin, hante.meuleman, chi-hsien.lin,
	wright.feng, davem, stanley.hsu
In-Reply-To: <20190823074708.20081-1-xulin.sun@windriver.com>

Xulin Sun <xulin.sun@windriver.com> wrote:

> The strncpy() may truncate the copied string,
> replace it by the safer strscpy().
> 
> To avoid below compile warning with gcc 8.2:
> 
> drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:In function 'brcmf_vndr_ie':
> drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:4227:2:
> warning: 'strncpy' output truncated before terminating nul copying 3 bytes from a string of the same length [-Wstringop-truncation]
>   strncpy(iebuf, add_del_cmd, VNDR_IE_CMD_LEN - 1);
>   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Signed-off-by: Xulin Sun <xulin.sun@windriver.com>
> Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>

Patch applied to wireless-drivers-next.git, thanks.

5f42b382ead2 brcmfmac: replace strncpy() by strscpy()

-- 
https://patchwork.kernel.org/patch/11110841/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply

* Re: [PATCH bpf-next 1/2] selftests/bpf: test_progs: fix verbose mode garbage
From: Daniel Borkmann @ 2019-09-03 13:40 UTC (permalink / raw)
  To: Stanislav Fomichev, netdev, bpf; +Cc: davem, ast
In-Reply-To: <20190831023427.239820-1-sdf@google.com>

On 8/31/19 4:34 AM, Stanislav Fomichev wrote:
> fseeko(.., 0, SEEK_SET) on a memstream just puts the buffer pointer
> to the beginning so when we call fflush on it we get some garbage
> log data from the previous test. Let's manually set terminating
> byte to zero at the reported buffer size.
> 
> To show the issue consider the following snippet:
> 
> 	stream = open_memstream (&buf, &len);
> 
> 	fprintf(stream, "aaa");
> 	fflush(stream);
> 	printf("buf=%s, len=%zu\n", buf, len);
> 	fseeko(stream, 0, SEEK_SET);
> 
> 	fprintf(stream, "b");
> 	fflush(stream);
> 	printf("buf=%s, len=%zu\n", buf, len);
> 
> Output:
> 
> 	buf=aaa, len=3
> 	buf=baa, len=1
> 
> Fixes: 946152b3c5d6 ("selftests/bpf: test_progs: switch to open_memstream")
> Signed-off-by: Stanislav Fomichev <sdf@google.com>

Both applied, thanks!

^ permalink raw reply

* Re: [PATCH] ipw2x00: fix spelling mistake "initializationg" -> "initialization"
From: Kalle Valo @ 2019-09-03 13:40 UTC (permalink / raw)
  To: Colin King
  Cc: Stanislav Yakovlev, David S . Miller, linux-wireless, netdev,
	kernel-janitors, linux-kernel
In-Reply-To: <20190822220025.5690-1-colin.king@canonical.com>

Colin King <colin.king@canonical.com> wrote:

> From: Colin Ian King <colin.king@canonical.com>
> 
> There is a spelling mistake in an IPW_DEBUG_INFO message. Fix it.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Patch applied to wireless-drivers-next.git, thanks.

14aba89386a4 ipw2x00: fix spelling mistake "initializationg" -> "initialization"

-- 
https://patchwork.kernel.org/patch/11110159/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply

* Re: [PATCH] airo: fix memory leaks
From: Kalle Valo @ 2019-09-03 13:39 UTC (permalink / raw)
  To: Wenwen Wang
  Cc: Wenwen Wang, David S. Miller, Herbert Xu, Dan Carpenter,
	Eric Biggers, Ard Biesheuvel,
	open list:NETWORKING DRIVERS (WIRELESS),
	open list:NETWORKING DRIVERS, open list
In-Reply-To: <1565927404-4755-1-git-send-email-wenwen@cs.uga.edu>

Wenwen Wang <wenwen@cs.uga.edu> wrote:

> In proc_BSSList_open(), 'file->private_data' is allocated through kzalloc()
> and 'data->rbuffer' is allocated through kmalloc(). In the following
> execution, if an error occurs, they are not deallocated, leading to memory
> leaks. To fix this issue, free the allocated memory regions before
> returning the error.
> 
> Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>

Patch applied to wireless-drivers-next.git, thanks.

145a32fe57e3 airo: fix memory leaks

-- 
https://patchwork.kernel.org/patch/11096733/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply

* Re: [PATCHv3] zd1211rw: remove false assertion from zd_mac_clear()
From: Kalle Valo @ 2019-09-03 13:39 UTC (permalink / raw)
  To: Oliver Neukum; +Cc: davem, netdev, dsd, kune, linux-wireless, Oliver Neukum
In-Reply-To: <20190813120412.6240-1-oneukum@suse.com>

Oliver Neukum <oneukum@suse.com> wrote:

> The function is called before the lock which is asserted was ever used.
> Just remove it.
> 
> Reported-by: syzbot+74c65761783d66a9c97c@syzkaller.appspotmail.com
> Signed-off-by: Oliver Neukum <oneukum@suse.com>

Patch applied to wireless-drivers-next.git, thanks.

7a2eb7367fde zd1211rw: remove false assertion from zd_mac_clear()

-- 
https://patchwork.kernel.org/patch/11092009/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply

* Re: [PATCH] brcmfmac: remove redundant assignment to pointer hash
From: Kalle Valo @ 2019-09-03 13:38 UTC (permalink / raw)
  To: Colin King
  Cc: Arend van Spriel, Hante Meuleman, Chi-Hsien Lin, Wright Feng,
	David S . Miller, linux-wireless, brcm80211-dev-list.pdl,
	brcm80211-dev-list, netdev, kernel-janitors, linux-kernel
In-Reply-To: <20190809172217.1809-1-colin.king@canonical.com>

Colin King <colin.king@canonical.com> wrote:

> From: Colin Ian King <colin.king@canonical.com>
> 
> The pointer hash is being initialized with a value that is never read
> and is being re-assigned a little later on. The assignment is
> redundant and hence can be removed.
> 
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Patch applied to wireless-drivers-next.git, thanks.

73c742bb9c9b brcmfmac: remove redundant assignment to pointer hash

-- 
https://patchwork.kernel.org/patch/11087385/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply

* [PATCH 2/2] drm: convert to use yesno(), onoff(), enableddisabled(), plural() helpers
From: Jani Nikula @ 2019-09-03 13:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: jani.nikula, Joonas Lahtinen, Rodrigo Vivi, intel-gfx,
	Vishal Kulkarni, netdev, Greg Kroah-Hartman, linux-usb,
	Andrew Morton, Julia Lawall
In-Reply-To: <20190903133731.2094-1-jani.nikula@intel.com>

THIS IS NOT FOR MERGING; DEMO FOR PREVIOUS PATCH ONLY!

Further conversion should be done incrementally and by
driver/subsystem. This here is the result of running the following on
the below cocci patch:

$ spatch --sp-file yesno.cocci --in-place --dir drivers/gpu/drm

I wish I knew how to not duplicate stuff in the cocci patch so much...

@enableddisabled@
expression E;
@@
(
- (E) ? "enabled" : "disabled"
+ enableddisabled(E)
|
- E ? "enabled" : "disabled"
+ enableddisabled(E)
)

@reverse_enableddisabled@
expression A, B;
@@
(
- (A == B) ? "disabled" : "enabled"
+ enableddisabled(A != B)
|
- (A != B) ? "disabled" : "enabled"
+ enableddisabled(A == B)
|
- A == B ? "disabled" : "enabled"
+ enableddisabled(A != B)
|
- A != B ? "disabled" : "enabled"
+ enableddisabled(A == B)
|
- A ? "disabled" : "enabled"
+ enableddisabled(!A)
)

@yesno@
expression E;
@@
(
- (E) ? "yes" : "no"
+ yesno(E)
|
- E ? "yes" : "no"
+ yesno(E)
)

@reverse_yesno@
expression A, B;
@@
(
- (A == B) ? "no" : "yes"
+ yesno(A != B)
|
- (A != B) ? "no" : "yes"
+ yesno(A == B)
|
- A == B ? "no" : "yes"
+ yesno(A != B)
|
- A != B ? "no" : "yes"
+ yesno(A == B)
|
- A ? "no" : "yes"
+ yesno(!A)
)

@onoff@
expression E;
@@
(
- (E) ? "on" : "off"
+ onoff(E)
|
- E ? "on" : "off"
+ onoff(E)
)

@reverse_onoff@
expression A, B;
@@
(
- (A == B) ? "off" : "on"
+ onoff(A != B)
|
- (A != B) ? "off" : "on"
+ onoff(A == B)
|
- A == B ? "off" : "on"
+ onoff(A != B)
|
- A != B ? "off" : "on"
+ onoff(A == B)
|
- A ? "off" : "on"
+ onoff(!A)
)

@plural@
expression E;
@@
(
- (E > 1) ? "s" : ""
+ plural(E)
|
- E > 1 ? "s" : ""
+ plural(E)
|
- (E == 1) ? "" : "s"
+ plural(E)
|
- E == 1 ? "" : "s"
+ plural(E)
)

Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Cc: Vishal Kulkarni <vishal@chelsio.com>
Cc: netdev@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
Cc: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c           |  2 +-
 drivers/gpu/drm/amd/amdgpu/atom.c                  |  2 +-
 drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c |  3 ++-
 drivers/gpu/drm/bridge/tc358767.c                  |  2 +-
 drivers/gpu/drm/drm_client_modeset.c               |  2 +-
 drivers/gpu/drm/drm_dp_helper.c                    |  2 +-
 drivers/gpu/drm/drm_edid_load.c                    |  2 +-
 drivers/gpu/drm/drm_gem.c                          |  2 +-
 drivers/gpu/drm/i915/display/intel_display.c       |  2 +-
 drivers/gpu/drm/nouveau/nouveau_acpi.c             |  2 +-
 drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.c      |  2 +-
 drivers/gpu/drm/omapdrm/dss/dispc.c                |  2 +-
 drivers/gpu/drm/omapdrm/dss/dsi.c                  |  6 ++----
 drivers/gpu/drm/qxl/qxl_display.c                  |  2 +-
 drivers/gpu/drm/radeon/atom.c                      |  2 +-
 drivers/gpu/drm/radeon/radeon_acpi.c               |  2 +-
 drivers/gpu/drm/sti/sti_hda.c                      |  4 ++--
 drivers/gpu/drm/sti/sti_tvout.c                    |  2 +-
 drivers/gpu/drm/sun4i/sun4i_backend.c              |  2 +-
 drivers/gpu/drm/sun4i/sun8i_ui_layer.c             |  2 +-
 drivers/gpu/drm/v3d/v3d_debugfs.c                  | 10 +++++-----
 drivers/gpu/drm/virtio/virtgpu_debugfs.c           |  2 +-
 22 files changed, 29 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
index 1e41367ef74e..65f0ee0f4ccd 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
@@ -292,7 +292,7 @@ static int amdgpu_atif_get_notification_params(struct amdgpu_atif *atif)
 
 out:
 	DRM_DEBUG_DRIVER("Notification %s, command code = %#x\n",
-			(n->enabled ? "enabled" : "disabled"),
+			(enableddisabled(n->enabled)),
 			n->command_code);
 	kfree(info);
 	return err;
diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c b/drivers/gpu/drm/amd/amdgpu/atom.c
index dd30f4e61a8c..b59a83fae853 100644
--- a/drivers/gpu/drm/amd/amdgpu/atom.c
+++ b/drivers/gpu/drm/amd/amdgpu/atom.c
@@ -737,7 +737,7 @@ static void atom_op_jump(atom_exec_context *ctx, int *ptr, int arg)
 		break;
 	}
 	if (arg != ATOM_COND_ALWAYS)
-		SDEBUG("   taken: %s\n", execute ? "yes" : "no");
+		SDEBUG("   taken: %s\n", yesno(execute));
 	SDEBUG("   target: 0x%04X\n", target);
 	if (execute) {
 		if (ctx->last_jump == (ctx->start + target)) {
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
index 3be8eb21fd6e..1e025cbd5e81 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
@@ -2918,7 +2918,8 @@ static int vega10_enable_disable_PCC_limit_feature(struct pp_hwmgr *hwmgr, bool
 
 	if (data->smu_features[GNLD_PCC_LIMIT].supported) {
 		if (enable == data->smu_features[GNLD_PCC_LIMIT].enabled)
-			pr_info("GNLD_PCC_LIMIT has been %s \n", enable ? "enabled" : "disabled");
+			pr_info("GNLD_PCC_LIMIT has been %s \n",
+				enableddisabled(enable));
 		PP_ASSERT_WITH_CODE(!vega10_enable_smc_features(hwmgr,
 				enable, data->smu_features[GNLD_PCC_LIMIT].smu_feature_bitmap),
 				"Attempt to Enable PCC Limit feature Failed!",
diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
index 13ade28a36a8..debce316a02d 100644
--- a/drivers/gpu/drm/bridge/tc358767.c
+++ b/drivers/gpu/drm/bridge/tc358767.c
@@ -653,7 +653,7 @@ static int tc_get_display_props(struct tc_data *tc)
 		"enhanced" : "non-enhanced");
 	dev_dbg(tc->dev, "Downspread: %s, scrambler: %s\n",
 		tc->link.spread ? "0.5%" : "0.0%",
-		tc->link.scrambler_dis ? "disabled" : "enabled");
+		enableddisabled(!tc->link.scrambler_dis));
 	dev_dbg(tc->dev, "Display ASSR: %d, TC358767 ASSR: %d\n",
 		tc->link.assr, tc->assr);
 
diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c
index c8922b7cac09..264fa3a9ffd4 100644
--- a/drivers/gpu/drm/drm_client_modeset.c
+++ b/drivers/gpu/drm/drm_client_modeset.c
@@ -213,7 +213,7 @@ static void drm_client_connectors_enabled(struct drm_connector **connectors,
 		connector = connectors[i];
 		enabled[i] = drm_connector_enabled(connector, true);
 		DRM_DEBUG_KMS("connector %d enabled? %s\n", connector->base.id,
-			      connector->display_info.non_desktop ? "non desktop" : enabled[i] ? "yes" : "no");
+			      connector->display_info.non_desktop ? "non desktop" : yesno(enabled[i]));
 
 		any_enabled |= enabled[i];
 	}
diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
index 0b994d083a89..fabdb3222e87 100644
--- a/drivers/gpu/drm/drm_dp_helper.c
+++ b/drivers/gpu/drm/drm_dp_helper.c
@@ -600,7 +600,7 @@ void drm_dp_downstream_debug(struct seq_file *m,
 			     DP_DWN_STRM_PORT_PRESENT;
 
 	seq_printf(m, "\tDP branch device present: %s\n",
-		   branch_device ? "yes" : "no");
+		   yesno(branch_device));
 
 	if (!branch_device)
 		return;
diff --git a/drivers/gpu/drm/drm_edid_load.c b/drivers/gpu/drm/drm_edid_load.c
index d38b3b255926..a5af002adf73 100644
--- a/drivers/gpu/drm/drm_edid_load.c
+++ b/drivers/gpu/drm/drm_edid_load.c
@@ -255,7 +255,7 @@ static void *edid_load(struct drm_connector *connector, const char *name,
 
 	DRM_INFO("Got %s EDID base block and %d extension%s from "
 	    "\"%s\" for connector \"%s\"\n", (builtin >= 0) ? "built-in" :
-	    "external", valid_extensions, valid_extensions == 1 ? "" : "s",
+	    "external", valid_extensions, plural(valid_extensions),
 	    name, connector_name);
 
 out:
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index a8c4468f03d9..53c2f5705c79 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -1208,7 +1208,7 @@ void drm_gem_print_info(struct drm_printer *p, unsigned int indent,
 			  drm_vma_node_start(&obj->vma_node));
 	drm_printf_indent(p, indent, "size=%zu\n", obj->size);
 	drm_printf_indent(p, indent, "imported=%s\n",
-			  obj->import_attach ? "yes" : "no");
+			  yesno(obj->import_attach));
 
 	if (obj->funcs && obj->funcs->print_info)
 		obj->funcs->print_info(p, indent, obj);
diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 592b92782fab..5da343a753b1 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -16006,7 +16006,7 @@ int intel_modeset_init(struct drm_device *dev)
 
 	DRM_DEBUG_KMS("%d display pipe%s available.\n",
 		      INTEL_INFO(dev_priv)->num_pipes,
-		      INTEL_INFO(dev_priv)->num_pipes > 1 ? "s" : "");
+		      plural(INTEL_INFO(dev_priv)->num_pipes));
 
 	for_each_pipe(dev_priv, pipe) {
 		ret = intel_crtc_init(dev_priv, pipe);
diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c b/drivers/gpu/drm/nouveau/nouveau_acpi.c
index fe3a10255c36..eec68ebe7cad 100644
--- a/drivers/gpu/drm/nouveau/nouveau_acpi.c
+++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c
@@ -277,7 +277,7 @@ static void nouveau_dsm_pci_probe(struct pci_dev *pdev, acpi_handle *dhandle_out
 		nouveau_optimus_dsm(dhandle, NOUVEAU_DSM_OPTIMUS_CAPS, 0,
 				    &result);
 		dev_info(&pdev->dev, "optimus capabilities: %s, status %s%s\n",
-			 (result & OPTIMUS_ENABLED) ? "enabled" : "disabled",
+			 enableddisabled(result & OPTIMUS_ENABLED),
 			 (result & OPTIMUS_DYNAMIC_PWR_CAP) ? "dynamic power, " : "",
 			 (result & OPTIMUS_HDA_CODEC_MASK) ? "hda bios codec supported" : "");
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.c b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.c
index a11637b0f6cc..05c733598f4f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.c
@@ -94,7 +94,7 @@ void
 nvkm_i2c_aux_monitor(struct nvkm_i2c_aux *aux, bool monitor)
 {
 	struct nvkm_i2c_pad *pad = aux->pad;
-	AUX_TRACE(aux, "monitor: %s", monitor ? "yes" : "no");
+	AUX_TRACE(aux, "monitor: %s", yesno(monitor));
 	if (monitor)
 		nvkm_i2c_pad_mode(pad, NVKM_I2C_PAD_AUX);
 	else
diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 785c5546067a..9766101d8ab0 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -1506,7 +1506,7 @@ void dispc_enable_fifomerge(struct dispc_device *dispc, bool enable)
 		return;
 	}
 
-	DSSDBG("FIFO merge %s\n", enable ? "enabled" : "disabled");
+	DSSDBG("FIFO merge %s\n", enableddisabled(enable));
 	REG_FLD_MOD(dispc, DISPC_CONFIG, enable ? 1 : 0, 14, 14);
 }
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index b30fcaa2d0f5..671ae88cabba 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -1408,8 +1408,7 @@ static int dsi_dump_dsi_clocks(struct seq_file *s, void *p)
 				DSS_CLK_SRC_PLL2_1),
 			cinfo->clkout[HSDIV_DISPC],
 			cinfo->mX[HSDIV_DISPC],
-			dispc_clk_src == DSS_CLK_SRC_FCK ?
-			"off" : "on");
+			onoff(dispc_clk_src != DSS_CLK_SRC_FCK));
 
 	seq_printf(s,	"DSI_PLL_HSDIV_DSI (%s)\t%-16lum_dsi %u\t(%s)\n",
 			dss_get_clk_source_name(dsi_module == 0 ?
@@ -1417,8 +1416,7 @@ static int dsi_dump_dsi_clocks(struct seq_file *s, void *p)
 				DSS_CLK_SRC_PLL2_2),
 			cinfo->clkout[HSDIV_DSI],
 			cinfo->mX[HSDIV_DSI],
-			dsi_clk_src == DSS_CLK_SRC_FCK ?
-			"off" : "on");
+			onoff(dsi_clk_src != DSS_CLK_SRC_FCK));
 
 	seq_printf(s,	"- DSI%d -\n", dsi_module + 1);
 
diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index 8b319ebbb0fb..bae1d1277f21 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -355,7 +355,7 @@ static void qxl_crtc_update_monitors_config(struct drm_crtc *crtc,
 
 	DRM_DEBUG_KMS("head %d, %dx%d, at +%d+%d, %s (%s)\n",
 		      i, head.width, head.height, head.x, head.y,
-		      crtc->state->active ? "on" : "off", reason);
+		      onoff(crtc->state->active), reason);
 	if (oldcount != qdev->monitors_config->count)
 		DRM_DEBUG_KMS("active heads %d -> %d (%d total)\n",
 			      oldcount, qdev->monitors_config->count,
diff --git a/drivers/gpu/drm/radeon/atom.c b/drivers/gpu/drm/radeon/atom.c
index 2c27627b6659..e6dd0f5c67b8 100644
--- a/drivers/gpu/drm/radeon/atom.c
+++ b/drivers/gpu/drm/radeon/atom.c
@@ -722,7 +722,7 @@ static void atom_op_jump(atom_exec_context *ctx, int *ptr, int arg)
 		break;
 	}
 	if (arg != ATOM_COND_ALWAYS)
-		SDEBUG("   taken: %s\n", execute ? "yes" : "no");
+		SDEBUG("   taken: %s\n", yesno(execute));
 	SDEBUG("   target: 0x%04X\n", target);
 	if (execute) {
 		if (ctx->last_jump == (ctx->start + target)) {
diff --git a/drivers/gpu/drm/radeon/radeon_acpi.c b/drivers/gpu/drm/radeon/radeon_acpi.c
index 6cf1645e7a1a..0decdd9781f4 100644
--- a/drivers/gpu/drm/radeon/radeon_acpi.c
+++ b/drivers/gpu/drm/radeon/radeon_acpi.c
@@ -299,7 +299,7 @@ static int radeon_atif_get_notification_params(acpi_handle handle,
 
 out:
 	DRM_DEBUG_DRIVER("Notification %s, command code = %#x\n",
-			(n->enabled ? "enabled" : "disabled"),
+			(enableddisabled(n->enabled)),
 			n->command_code);
 	kfree(info);
 	return err;
diff --git a/drivers/gpu/drm/sti/sti_hda.c b/drivers/gpu/drm/sti/sti_hda.c
index 94e404f13234..80a196d13647 100644
--- a/drivers/gpu/drm/sti/sti_hda.c
+++ b/drivers/gpu/drm/sti/sti_hda.c
@@ -317,7 +317,7 @@ static void hda_enable_hd_dacs(struct sti_hda *hda, bool enable)
 static void hda_dbg_cfg(struct seq_file *s, int val)
 {
 	seq_puts(s, "\tAWG ");
-	seq_puts(s, val & CFG_AWG_ASYNC_EN ? "enabled" : "disabled");
+	seq_puts(s, enableddisabled(val & CFG_AWG_ASYNC_EN));
 }
 
 static void hda_dbg_awg_microcode(struct seq_file *s, void __iomem *reg)
@@ -338,7 +338,7 @@ static void hda_dbg_video_dacs_ctrl(struct seq_file *s, void __iomem *reg)
 
 	seq_printf(s, "\n\n  %-25s 0x%08X", "VIDEO_DACS_CONTROL", val);
 	seq_puts(s, "\tHD DACs ");
-	seq_puts(s, val & DAC_CFG_HD_HZUVW_OFF_MASK ? "disabled" : "enabled");
+	seq_puts(s, enableddisabled(!(val & DAC_CFG_HD_HZUVW_OFF_MASK)));
 }
 
 static int hda_dbg_show(struct seq_file *s, void *data)
diff --git a/drivers/gpu/drm/sti/sti_tvout.c b/drivers/gpu/drm/sti/sti_tvout.c
index e1b3c8cb7287..1f169ed177e9 100644
--- a/drivers/gpu/drm/sti/sti_tvout.c
+++ b/drivers/gpu/drm/sti/sti_tvout.c
@@ -491,7 +491,7 @@ static void tvout_dbg_vip(struct seq_file *s, int val)
 static void tvout_dbg_hd_dac_cfg(struct seq_file *s, int val)
 {
 	seq_printf(s, "\t%-24s %s", "HD DAC:",
-		   val & 1 ? "disabled" : "enabled");
+		   enableddisabled(!(val & 1)));
 }
 
 static int tvout_dbg_show(struct seq_file *s, void *data)
diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c
index 78d8c3afe825..f1e301060123 100644
--- a/drivers/gpu/drm/sun4i/sun4i_backend.c
+++ b/drivers/gpu/drm/sun4i/sun4i_backend.c
@@ -273,7 +273,7 @@ int sun4i_backend_update_layer_formats(struct sun4i_backend *backend,
 			   interlaced ? SUN4I_BACKEND_MODCTL_ITLMOD_EN : 0);
 
 	DRM_DEBUG_DRIVER("Switching display backend interlaced mode %s\n",
-			 interlaced ? "on" : "off");
+			 onoff(interlaced));
 
 	val = SUN4I_BACKEND_ATTCTL_REG0_LAY_GLBALPHA(state->alpha >> 8);
 	if (state->alpha != DRM_BLEND_ALPHA_OPAQUE)
diff --git a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
index dd2a1c851939..c48b1cf07439 100644
--- a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
+++ b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
@@ -126,7 +126,7 @@ static int sun8i_ui_layer_update_coord(struct sun8i_mixer *mixer, int channel,
 				   val);
 
 		DRM_DEBUG_DRIVER("Switching display mixer interlaced mode %s\n",
-				 interlaced ? "on" : "off");
+				 onoff(interlaced));
 	}
 
 	/* Set height and width */
diff --git a/drivers/gpu/drm/v3d/v3d_debugfs.c b/drivers/gpu/drm/v3d/v3d_debugfs.c
index 78a78938e81f..0ca71eb2e760 100644
--- a/drivers/gpu/drm/v3d/v3d_debugfs.c
+++ b/drivers/gpu/drm/v3d/v3d_debugfs.c
@@ -147,15 +147,15 @@ static int v3d_v3d_debugfs_ident(struct seq_file *m, void *unused)
 		   V3D_GET_FIELD(ident3, V3D_HUB_IDENT3_IPREV),
 		   V3D_GET_FIELD(ident3, V3D_HUB_IDENT3_IPIDX));
 	seq_printf(m, "MMU:        %s\n",
-		   (ident2 & V3D_HUB_IDENT2_WITH_MMU) ? "yes" : "no");
+		   yesno(ident2 & V3D_HUB_IDENT2_WITH_MMU));
 	seq_printf(m, "TFU:        %s\n",
-		   (ident1 & V3D_HUB_IDENT1_WITH_TFU) ? "yes" : "no");
+		   yesno(ident1 & V3D_HUB_IDENT1_WITH_TFU));
 	seq_printf(m, "TSY:        %s\n",
-		   (ident1 & V3D_HUB_IDENT1_WITH_TSY) ? "yes" : "no");
+		   yesno(ident1 & V3D_HUB_IDENT1_WITH_TSY));
 	seq_printf(m, "MSO:        %s\n",
-		   (ident1 & V3D_HUB_IDENT1_WITH_MSO) ? "yes" : "no");
+		   yesno(ident1 & V3D_HUB_IDENT1_WITH_MSO));
 	seq_printf(m, "L3C:        %s (%dkb)\n",
-		   (ident1 & V3D_HUB_IDENT1_WITH_L3C) ? "yes" : "no",
+		   yesno(ident1 & V3D_HUB_IDENT1_WITH_L3C),
 		   V3D_GET_FIELD(ident2, V3D_HUB_IDENT2_L3C_NKB));
 
 	for (core = 0; core < cores; core++) {
diff --git a/drivers/gpu/drm/virtio/virtgpu_debugfs.c b/drivers/gpu/drm/virtio/virtgpu_debugfs.c
index ed0fcda713c3..4b6bf4e9abb1 100644
--- a/drivers/gpu/drm/virtio/virtgpu_debugfs.c
+++ b/drivers/gpu/drm/virtio/virtgpu_debugfs.c
@@ -31,7 +31,7 @@
 static void virtio_add_bool(struct seq_file *m, const char *name,
 				    bool value)
 {
-	seq_printf(m, "%-16s : %s\n", name, value ? "yes" : "no");
+	seq_printf(m, "%-16s : %s\n", name, yesno(value));
 }
 
 static void virtio_add_int(struct seq_file *m, const char *name,
-- 
2.20.1


^ permalink raw reply related

* Re: [PATCH] brcm80211: Avoid possible null-pointer dereferences in wlc_phy_radio_init_2056()
From: Kalle Valo @ 2019-09-03 13:37 UTC (permalink / raw)
  To: Jia-Ju Bai
  Cc: arend.vanspriel, franky.lin, hante.meuleman, chi-hsien.lin,
	wright.feng, davem, pieter-paul.giesberts, plaes, rvarsha016,
	linux-wireless, brcm80211-dev-list.pdl, brcm80211-dev-list,
	netdev, linux-kernel, Jia-Ju Bai
In-Reply-To: <20190729095652.1976-1-baijiaju1990@gmail.com>

Jia-Ju Bai <baijiaju1990@gmail.com> wrote:

> In wlc_phy_radio_init_2056(), regs_SYN_2056_ptr, regs_TX_2056_ptr and
> regs_RX_2056_ptr may be not assigned, and thus they are still NULL.
> Then, they are used on lines 20042-20050:
>     wlc_phy_init_radio_regs(pi, regs_SYN_2056_ptr, (u16) RADIO_2056_SYN);
> 	wlc_phy_init_radio_regs(pi, regs_TX_2056_ptr, (u16) RADIO_2056_TX0);
> 	wlc_phy_init_radio_regs(pi, regs_TX_2056_ptr, (u16) RADIO_2056_TX1);
> 	wlc_phy_init_radio_regs(pi, regs_RX_2056_ptr, (u16) RADIO_2056_RX0);
> 	wlc_phy_init_radio_regs(pi, regs_RX_2056_ptr, (u16) RADIO_2056_RX1);
> 
> Thus, possible null-pointer dereferences may occur.
> 
> To avoid these bugs, when these variables are not assigned,
> wlc_phy_radio_init_2056() directly returns.
> 
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>

Patch applied to wireless-drivers-next.git, thanks.

b80df89f3909 brcm80211: Avoid possible null-pointer dereferences in wlc_phy_radio_init_2056()

-- 
https://patchwork.kernel.org/patch/11063553/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply

* [PATCH 1/2] linux/kernel.h: add yesno(), onoff(), enableddisabled(), plural() helpers
From: Jani Nikula @ 2019-09-03 13:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: jani.nikula, Joonas Lahtinen, Rodrigo Vivi, intel-gfx,
	Vishal Kulkarni, netdev, Greg Kroah-Hartman, linux-usb,
	Andrew Morton, Julia Lawall

The kernel has plenty of ternary operators to choose between constant
strings, such as condition ? "yes" : "no", as well as value == 1 ? "" :
"s":

$ git grep '? "yes" : "no"' | wc -l
258
$ git grep '? "on" : "off"' | wc -l
204
$ git grep '? "enabled" : "disabled"' | wc -l
196
$ git grep '? "" : "s"' | wc -l
25

Additionally, there are some occurences of the same in reverse order,
split to multiple lines, or otherwise not caught by the simple grep.

Add helpers to return the constant strings. Remove existing equivalent
and conflicting functions in i915, cxgb4, and USB core. Further
conversion can be done incrementally.

While the main goal here is to abstract recurring patterns, and slightly
clean up the code base by not open coding the ternary operators, there
are also some space savings to be had via better string constant
pooling.

Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Cc: Vishal Kulkarni <vishal@chelsio.com>
Cc: netdev@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
Cc: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/i915_utils.h             | 15 -------------
 .../ethernet/chelsio/cxgb4/cxgb4_debugfs.c    | 11 ----------
 drivers/usb/core/config.c                     |  5 -----
 drivers/usb/core/generic.c                    |  5 -----
 include/linux/kernel.h                        | 21 +++++++++++++++++++
 5 files changed, 21 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_utils.h b/drivers/gpu/drm/i915/i915_utils.h
index 2987219a6300..9754e277622f 100644
--- a/drivers/gpu/drm/i915/i915_utils.h
+++ b/drivers/gpu/drm/i915/i915_utils.h
@@ -355,19 +355,4 @@ wait_remaining_ms_from_jiffies(unsigned long timestamp_jiffies, int to_wait_ms)
 #define MBps(x) KBps(1000 * (x))
 #define GBps(x) ((u64)1000 * MBps((x)))
 
-static inline const char *yesno(bool v)
-{
-	return v ? "yes" : "no";
-}
-
-static inline const char *onoff(bool v)
-{
-	return v ? "on" : "off";
-}
-
-static inline const char *enableddisabled(bool v)
-{
-	return v ? "enabled" : "disabled";
-}
-
 #endif /* !__I915_UTILS_H */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
index d692251ee252..d0be14d93df7 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
@@ -2023,17 +2023,6 @@ static const struct file_operations rss_debugfs_fops = {
 /* RSS Configuration.
  */
 
-/* Small utility function to return the strings "yes" or "no" if the supplied
- * argument is non-zero.
- */
-static const char *yesno(int x)
-{
-	static const char *yes = "yes";
-	static const char *no = "no";
-
-	return x ? yes : no;
-}
-
 static int rss_config_show(struct seq_file *seq, void *v)
 {
 	struct adapter *adapter = seq->private;
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 9d6cb709ca7b..7da06aa06ced 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -19,11 +19,6 @@
 #define USB_MAXCONFIG			8	/* Arbitrary limit */
 
 
-static inline const char *plural(int n)
-{
-	return (n == 1 ? "" : "s");
-}
-
 static int find_next_descriptor(unsigned char *buffer, int size,
     int dt1, int dt2, int *num_skipped)
 {
diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
index 1ac9c1e5f773..95a87b6cd35f 100644
--- a/drivers/usb/core/generic.c
+++ b/drivers/usb/core/generic.c
@@ -24,11 +24,6 @@
 #include <uapi/linux/usb/audio.h>
 #include "usb.h"
 
-static inline const char *plural(int n)
-{
-	return (n == 1 ? "" : "s");
-}
-
 static int is_rndis(struct usb_interface_descriptor *desc)
 {
 	return desc->bInterfaceClass == USB_CLASS_COMM
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 4fa360a13c1e..3375f054aefd 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -1008,4 +1008,25 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
 	 /* OTHER_WRITABLE?  Generally considered a bad idea. */		\
 	 BUILD_BUG_ON_ZERO((perms) & 2) +					\
 	 (perms))
+
+static inline const char *yesno(bool v)
+{
+	return v ? "yes" : "no";
+}
+
+static inline const char *onoff(bool v)
+{
+	return v ? "on" : "off";
+}
+
+static inline const char *enableddisabled(bool v)
+{
+	return v ? "enabled" : "disabled";
+}
+
+static inline const char *plural(long v)
+{
+	return v == 1 ? "" : "s";
+}
+
 #endif
-- 
2.20.1


^ permalink raw reply related

* Re: [Bridge] [PATCH v3 1/2] net: bridge: use mac_len in bridge forwarding
From: Zahari Doychev @ 2019-09-03 13:36 UTC (permalink / raw)
  To: Toshiaki Makita
  Cc: netdev, makita.toshiaki, jiri, nikolay, simon.horman, roopa,
	bridge, jhs, dsahern, xiyou.wangcong, johannes,
	alexei.starovoitov
In-Reply-To: <76b7723b-68dd-0efc-9a93-0597e9d9b827@gmail.com>

On Tue, Sep 03, 2019 at 08:37:36PM +0900, Toshiaki Makita wrote:
> Hi Zahari,
> 
> Sorry for reviewing this late.
> 
> On 2019/09/03 3:09, Zahari Doychev wrote:
> ...
> > @@ -466,13 +466,14 @@ static bool __allowed_ingress(const struct net_bridge *br,
> >   		/* Tagged frame */
> >   		if (skb->vlan_proto != br->vlan_proto) {
> >   			/* Protocol-mismatch, empty out vlan_tci for new tag */
> > -			skb_push(skb, ETH_HLEN);
> > +			skb_push(skb, skb->mac_len);
> >   			skb = vlan_insert_tag_set_proto(skb, skb->vlan_proto,
> >   							skb_vlan_tag_get(skb));
> 
> I think we should insert vlan at skb->data, i.e. mac_header + mac_len, while this
> function inserts the tag at mac_header + ETH_HLEN which is not always the correct
> offset.

Maybe I am misunderstanding the concern here but this should make sure that
the VLAN tag from the skb is move back in the payload as the outer most tag.
So it should follow the ethernet header. It looks like this e.g.,:

VLAN1 in skb:
+------+------+-------+
| DMAC | SMAC | ETYPE |
+------+------+-------+

VLAN1 moved to payload:
+------+------+-------+-------+
| DMAC | SMAC | VLAN1 | ETYPE |
+------+------+-------+-------+

VLAN2 in skb:
+------+------+-------+-------+
| DMAC | SMAC | VLAN1 | ETYPE |
+------+------+-------+-------+

VLAN2 moved to payload:

+------+------+-------+-------+
| DMAC | SMAC | VLAN2 | VLAN1 | ....
+------+------+-------+-------+

Doing the skb push with mac_len makes sure that VLAN tag is inserted in the
correct offset. For mac_len == ETH_HLEN this does not change the current
behaviour.

> 
> >   			if (unlikely(!skb))
> >   				return false;
> >   			skb_pull(skb, ETH_HLEN);
> 
> Now skb->data is mac_header + ETH_HLEN which would be broken when mac_len is not
> ETH_HLEN?

I thought it would be better to point in this case to the outer tag as otherwise
if mac_len is used the skb->data will point to the next tag which I find somehow
inconsistent or do you see some case where this can cause problems?


> 
> > +			skb_reset_network_header(skb);
> >   			skb_reset_mac_len(skb);
> >   			*vid = 0;
> >   			tagged = false;
> > 
> 
> Toshiaki Makita

^ permalink raw reply

* Re: [PATCH] rtw88: remove redundant assignment to pointer debugfs_topdir
From: Kalle Valo @ 2019-09-03 13:36 UTC (permalink / raw)
  To: Colin King
  Cc: Yan-Hsuan Chuang, David S . Miller, linux-wireless, netdev,
	kernel-janitors, linux-kernel
In-Reply-To: <20190822113728.25494-1-colin.king@canonical.com>

Colin King <colin.king@canonical.com> wrote:

> From: Colin Ian King <colin.king@canonical.com>
> 
> Pointer debugfs_topdir is initialized to a value that is never read
> and it is re-assigned later. The initialization is redundant and can
> be removed.
> 
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Patch applied to wireless-drivers-next.git, thanks.

9f7d65fb3935 rtw88: remove redundant assignment to pointer debugfs_topdir

-- 
https://patchwork.kernel.org/patch/11109159/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply

* Re: [PATCH] rtlwifi: remove unused variables 'RTL8712_SDIO_EFUSE_TABLE' and 'MAX_PGPKT_SIZE'
From: Kalle Valo @ 2019-09-03 13:28 UTC (permalink / raw)
  To: YueHaibing
  Cc: pkshih, davem, linux-kernel, netdev, linux-wireless, YueHaibing
In-Reply-To: <20190816140513.72572-1-yuehaibing@huawei.com>

YueHaibing <yuehaibing@huawei.com> wrote:

> drivers/net/wireless/realtek/rtlwifi/efuse.c:16:31:
>  warning: RTL8712_SDIO_EFUSE_TABLE defined but not used [-Wunused-const-variable=]
> drivers/net/wireless/realtek/rtlwifi/efuse.c:9:17:
>  warning: MAX_PGPKT_SIZE defined but not used [-Wunused-const-variable=]
> 
> They are never used, so can be removed.
> 
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Patch applied to wireless-drivers-next.git, thanks.

84d31d3b6234 rtlwifi: remove unused variables 'RTL8712_SDIO_EFUSE_TABLE' and 'MAX_PGPKT_SIZE'

-- 
https://patchwork.kernel.org/patch/11097803/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply

* [PATCH net-next v3] net: openvswitch: Set OvS recirc_id from tc chain index
From: Paul Blakey @ 2019-09-03 13:23 UTC (permalink / raw)
  To: Pravin B Shelar, netdev, David S. Miller, Justin Pettit,
	Simon Horman, Marcelo Ricardo Leitner, Vlad Buslov, Paul Blakey
  Cc: Jiri Pirko, Roi Dayan, Yossi Kuperman, Rony Efraim, Oz Shlomo
In-Reply-To: <1567517015-10778-1-git-send-email-paulb@mellanox.com>

Offloaded OvS datapath rules are translated one to one to tc rules,
for example the following simplified OvS rule:

recirc_id(0),in_port(dev1),eth_type(0x0800),ct_state(-trk) actions:ct(),recirc(2)

Will be translated to the following tc rule:

$ tc filter add dev dev1 ingress \
	    prio 1 chain 0 proto ip \
		flower tcp ct_state -trk \
		action ct pipe \
		action goto chain 2

Received packets will first travel though tc, and if they aren't stolen
by it, like in the above rule, they will continue to OvS datapath.
Since we already did some actions (action ct in this case) which might
modify the packets, and updated action stats, we would like to continue
the proccessing with the correct recirc_id in OvS (here recirc_id(2))
where we left off.

To support this, introduce a new skb extension for tc, which
will be used for translating tc chain to ovs recirc_id to
handle these miss cases. Last tc chain index will be set
by tc goto chain action and read by OvS datapath.

Signed-off-by: Paul Blakey <paulb@mellanox.com>
Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
---
 include/linux/skbuff.h           | 13 +++++++++++++
 include/net/sch_generic.h        |  5 ++++-
 include/uapi/linux/openvswitch.h |  3 +++
 net/core/skbuff.c                |  6 ++++++
 net/openvswitch/datapath.c       | 38 +++++++++++++++++++++++++++++++++-----
 net/openvswitch/datapath.h       |  2 ++
 net/openvswitch/flow.c           | 13 +++++++++++++
 net/sched/Kconfig                | 13 +++++++++++++
 net/sched/act_api.c              |  1 +
 net/sched/cls_api.c              | 12 ++++++++++++
 10 files changed, 100 insertions(+), 6 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 77c6dc88..028e684 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -279,6 +279,16 @@ struct nf_bridge_info {
 };
 #endif
 
+#if IS_ENABLED(CONFIG_NET_TC_SKB_EXT)
+/* Chain in tc_skb_ext will be used to share the tc chain with
+ * ovs recirc_id. It will be set to the current chain by tc
+ * and read by ovs to recirc_id.
+ */
+struct tc_skb_ext {
+	__u32 chain;
+};
+#endif
+
 struct sk_buff_head {
 	/* These two members must be first. */
 	struct sk_buff	*next;
@@ -4058,6 +4068,9 @@ enum skb_ext_id {
 #ifdef CONFIG_XFRM
 	SKB_EXT_SEC_PATH,
 #endif
+#if IS_ENABLED(CONFIG_NET_TC_SKB_EXT)
+	TC_SKB_EXT,
+#endif
 	SKB_EXT_NUM, /* must be last */
 };
 
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 43f5b7e..2fdc746 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -274,7 +274,10 @@ struct tcf_result {
 			unsigned long	class;
 			u32		classid;
 		};
-		const struct tcf_proto *goto_tp;
+		struct {
+			const struct tcf_proto *goto_tp;
+			u32 goto_index;
+		};
 
 		/* used in the skb_tc_reinsert function */
 		struct {
diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h
index f271f1e..1887a45 100644
--- a/include/uapi/linux/openvswitch.h
+++ b/include/uapi/linux/openvswitch.h
@@ -123,6 +123,9 @@ struct ovs_vport_stats {
 /* Allow datapath to associate multiple Netlink PIDs to each vport */
 #define OVS_DP_F_VPORT_PIDS	(1 << 1)
 
+/* Allow tc offload recirc sharing */
+#define OVS_DP_F_TC_RECIRC_SHARING	(1 << 2)
+
 /* Fixed logical ports. */
 #define OVSP_LOCAL      ((__u32)0)
 
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index ea8e8d3..2b40b5a 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -4087,6 +4087,9 @@ int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb)
 #ifdef CONFIG_XFRM
 	[SKB_EXT_SEC_PATH] = SKB_EXT_CHUNKSIZEOF(struct sec_path),
 #endif
+#if IS_ENABLED(CONFIG_NET_TC_SKB_EXT)
+	[TC_SKB_EXT] = SKB_EXT_CHUNKSIZEOF(struct tc_skb_ext),
+#endif
 };
 
 static __always_inline unsigned int skb_ext_total_length(void)
@@ -4098,6 +4101,9 @@ static __always_inline unsigned int skb_ext_total_length(void)
 #ifdef CONFIG_XFRM
 		skb_ext_type_len[SKB_EXT_SEC_PATH] +
 #endif
+#if IS_ENABLED(CONFIG_NET_TC_SKB_EXT)
+		skb_ext_type_len[TC_SKB_EXT] +
+#endif
 		0;
 }
 
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 65122bb..dde9d76 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -1545,10 +1545,34 @@ static void ovs_dp_reset_user_features(struct sk_buff *skb, struct genl_info *in
 	dp->user_features = 0;
 }
 
-static void ovs_dp_change(struct datapath *dp, struct nlattr *a[])
+DEFINE_STATIC_KEY_FALSE(tc_recirc_sharing_support);
+
+static int ovs_dp_change(struct datapath *dp, struct nlattr *a[])
 {
-	if (a[OVS_DP_ATTR_USER_FEATURES])
-		dp->user_features = nla_get_u32(a[OVS_DP_ATTR_USER_FEATURES]);
+	u32 user_features = 0;
+
+	if (a[OVS_DP_ATTR_USER_FEATURES]) {
+		user_features = nla_get_u32(a[OVS_DP_ATTR_USER_FEATURES]);
+
+		if (user_features & ~(OVS_DP_F_VPORT_PIDS |
+				      OVS_DP_F_UNALIGNED |
+				      OVS_DP_F_TC_RECIRC_SHARING))
+			return -EOPNOTSUPP;
+
+#if !IS_ENABLED(CONFIG_NET_TC_SKB_EXT)
+		if (user_features & OVS_DP_F_TC_RECIRC_SHARING)
+			return -EOPNOTSUPP;
+#endif
+	}
+
+	dp->user_features = user_features;
+
+	if (dp->user_features & OVS_DP_F_TC_RECIRC_SHARING)
+		static_branch_enable(&tc_recirc_sharing_support);
+	else
+		static_branch_disable(&tc_recirc_sharing_support);
+
+	return 0;
 }
 
 static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
@@ -1610,7 +1634,9 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
 	parms.port_no = OVSP_LOCAL;
 	parms.upcall_portids = a[OVS_DP_ATTR_UPCALL_PID];
 
-	ovs_dp_change(dp, a);
+	err = ovs_dp_change(dp, a);
+	if (err)
+		goto err_destroy_meters;
 
 	/* So far only local changes have been made, now need the lock. */
 	ovs_lock();
@@ -1736,7 +1762,9 @@ static int ovs_dp_cmd_set(struct sk_buff *skb, struct genl_info *info)
 	if (IS_ERR(dp))
 		goto err_unlock_free;
 
-	ovs_dp_change(dp, info->attrs);
+	err = ovs_dp_change(dp, info->attrs);
+	if (err)
+		goto err_unlock_free;
 
 	err = ovs_dp_cmd_fill_info(dp, reply, info->snd_portid,
 				   info->snd_seq, 0, OVS_DP_CMD_SET);
diff --git a/net/openvswitch/datapath.h b/net/openvswitch/datapath.h
index 751d34a..81e85dd 100644
--- a/net/openvswitch/datapath.h
+++ b/net/openvswitch/datapath.h
@@ -218,6 +218,8 @@ static inline struct datapath *get_dp(struct net *net, int dp_ifindex)
 extern struct notifier_block ovs_dp_device_notifier;
 extern struct genl_family dp_vport_genl_family;
 
+DECLARE_STATIC_KEY_FALSE(tc_recirc_sharing_support);
+
 void ovs_dp_process_packet(struct sk_buff *skb, struct sw_flow_key *key);
 void ovs_dp_detach_port(struct vport *);
 int ovs_dp_upcall(struct datapath *, struct sk_buff *,
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index bc89e16..b84929f 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -816,6 +816,9 @@ static int key_extract_mac_proto(struct sk_buff *skb)
 int ovs_flow_key_extract(const struct ip_tunnel_info *tun_info,
 			 struct sk_buff *skb, struct sw_flow_key *key)
 {
+#if IS_ENABLED(CONFIG_NET_TC_SKB_EXT)
+	struct tc_skb_ext *tc_ext;
+#endif
 	int res, err;
 
 	/* Extract metadata from packet. */
@@ -848,7 +851,17 @@ int ovs_flow_key_extract(const struct ip_tunnel_info *tun_info,
 	if (res < 0)
 		return res;
 	key->mac_proto = res;
+
+#if IS_ENABLED(CONFIG_NET_TC_SKB_EXT)
+	if (static_branch_unlikely(&tc_recirc_sharing_support)) {
+		tc_ext = skb_ext_find(skb, TC_SKB_EXT);
+		key->recirc_id = tc_ext ? tc_ext->chain : 0;
+	} else {
+		key->recirc_id = 0;
+	}
+#else
 	key->recirc_id = 0;
+#endif
 
 	err = key_extract(skb, key);
 	if (!err)
diff --git a/net/sched/Kconfig b/net/sched/Kconfig
index afd2ba1..b3faafe 100644
--- a/net/sched/Kconfig
+++ b/net/sched/Kconfig
@@ -963,6 +963,19 @@ config NET_IFE_SKBTCINDEX
         tristate "Support to encoding decoding skb tcindex on IFE action"
         depends on NET_ACT_IFE
 
+config NET_TC_SKB_EXT
+	bool "TC recirculation support"
+	depends on NET_CLS_ACT
+	default y if NET_CLS_ACT
+	select SKB_EXTENSIONS
+
+	help
+	  Say Y here to allow tc chain misses to continue in OvS datapath in
+	  the correct recirc_id, and hardware chain misses to continue in
+	  the correct chain in tc software datapath.
+
+	  Say N here if you won't be using tc<->ovs offload or tc chains offload.
+
 endif # NET_SCHED
 
 config NET_SCH_FIFO
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 3397122..c393604 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -27,6 +27,7 @@ static void tcf_action_goto_chain_exec(const struct tc_action *a,
 {
 	const struct tcf_chain *chain = rcu_dereference_bh(a->goto_chain);
 
+	res->goto_index = chain->index;
 	res->goto_tp = rcu_dereference_bh(chain->filter_chain);
 }
 
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 671ca90..dd147be 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -1514,6 +1514,18 @@ int tcf_classify(struct sk_buff *skb, const struct tcf_proto *tp,
 			goto reset;
 		} else if (unlikely(TC_ACT_EXT_CMP(err, TC_ACT_GOTO_CHAIN))) {
 			first_tp = res->goto_tp;
+
+#if IS_ENABLED(CONFIG_NET_TC_SKB_EXT)
+			{
+				struct tc_skb_ext *ext;
+
+				ext = skb_ext_add(skb, TC_SKB_EXT);
+				if (WARN_ON_ONCE(!ext))
+					return TC_ACT_SHOT;
+
+				ext->chain = res->goto_index;
+			}
+#endif
 			goto reset;
 		}
 #endif
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH net-next v3] tc SKB extension for tc Chains/Conntrack hardware offload
From: Paul Blakey @ 2019-09-03 13:23 UTC (permalink / raw)
  To: Pravin B Shelar, netdev, David S. Miller, Justin Pettit,
	Simon Horman, Marcelo Ricardo Leitner, Vlad Buslov, Paul Blakey
  Cc: Jiri Pirko, Roi Dayan, Yossi Kuperman, Rony Efraim, Oz Shlomo

The following patch introduces a new SKB extension to support hardware offload of 
multi chain rules such as by connection tracking scenarios.
The patch is required for two use-cases. The first, implemented here,
uses the extension for tc -> OvS miss path. 
A following patch set will reuse this extension to pass information from HW/Driver -> tc miss path.

The HW/Driver -> tc miss path:
In tc multi chain rules scenarios, some of the rules might be offloaded
and some not (e.g skip_hw, unsupported rules by HW, vxlan encapsulation, 
offload order, etc).
Therefore, HW can miss at any point of the processing chain.
SW will need to continue processing in correct tc chain where the HW 
left off, as HW might have modified the packet and updated stats for it.
This scenario can reuse this tc SKB extension to restore the tc chain.

skb extension was chosen over skb control block, as skb control block acts a scratchpad area
for storing temporary information and isn't suppose to be pass around between different
layers of processing. HW/Driver -> tc - >OvS  are different layers, and not necessarily 
processing the packet one after another.
There can be bridges, tunnel devices, VLAN devices, Netfilter (Conntrack) and a host of
other entities processing the packet in between so we can't guarantee the control block
integrity between this main processing entities (HW/Driver, Tc, Ovs).
So if we'll use the control block, it will restrict such use cases.
For example, the napi API which we use, uses the control block and comes right after our
driver layer. This will overwrite any usage of CB by us.

Thanks,
Paul B.


Paul Blakey (1):
  net: openvswitch: Set OvS recirc_id from tc chain index

 include/linux/skbuff.h           | 13 +++++++++++++
 include/net/sch_generic.h        |  5 ++++-
 include/uapi/linux/openvswitch.h |  3 +++
 net/core/skbuff.c                |  6 ++++++
 net/openvswitch/datapath.c       | 38 +++++++++++++++++++++++++++++++++-----
 net/openvswitch/datapath.h       |  2 ++
 net/openvswitch/flow.c           | 13 +++++++++++++
 net/sched/Kconfig                | 13 +++++++++++++
 net/sched/act_api.c              |  1 +
 net/sched/cls_api.c              | 12 ++++++++++++
 10 files changed, 100 insertions(+), 6 deletions(-)

-- 
1.8.3.1


^ permalink raw reply

* Re: [PATCH] net/skbuff: silence warnings under memory pressure
From: Michal Hocko @ 2019-09-03 13:22 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: Qian Cai, davem, netdev, linux-mm, linux-kernel
In-Reply-To: <229ebc3b-1c7e-474f-36f9-0fa603b889fb@gmail.com>

On Fri 30-08-19 18:15:22, Eric Dumazet wrote:
> If there is a risk of flooding the syslog, we should fix this generically
> in mm layer, not adding hundred of __GFP_NOWARN all over the places.

We do already ratelimit in warn_alloc. If it isn't sufficient then we
can think of a different parameters. Or maybe it is the ratelimiting
which doesn't work here. Hard to tell and something to explore.

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply

* Re: [PATCH net] ipmr: remove cache_resolve_queue_len
From: Nikolay Aleksandrov @ 2019-09-03 13:18 UTC (permalink / raw)
  To: Hangbin Liu
  Cc: netdev, Phil Karn, Sukumar Gopalakrishnan, David S . Miller,
	Alexey Kuznetsov, Hideaki YOSHIFUJI
In-Reply-To: <20190903125547.GH18865@dhcp-12-139.nay.redhat.com>

On 03/09/2019 15:55, Hangbin Liu wrote:
> Hi Nikolay,
> 
> Thanks for the feedback, see comments below.
> 
> On Tue, Sep 03, 2019 at 12:15:34PM +0300, Nikolay Aleksandrov wrote:
>> On 03/09/2019 11:43, Hangbin Liu wrote:
>>> This is a re-post of previous patch wrote by David Miller[1].
>>>
>>> Phil Karn reported[2] that on busy networks with lots of unresolved
>>> multicast routing entries, the creation of new multicast group routes
>>> can be extremely slow and unreliable.
>>>
>>> The reason is we hard-coded multicast route entries with unresolved source
>>> addresses(cache_resolve_queue_len) to 10. If some multicast route never
>>> resolves and the unresolved source addresses increased, there will
>>> be no ability to create new multicast route cache.
>>>
>>> To resolve this issue, we need either add a sysctl entry to make the
>>> cache_resolve_queue_len configurable, or just remove cache_resolve_queue_len
>>> directly, as we already have the socket receive queue limits of mrouted
>>> socket, pointed by David.
>>>
>>> From my side, I'd perfer to remove the cache_resolve_queue_len instead
>>> of creating two more(IPv4 and IPv6 version) sysctl entry.
>>>
>>> [1] https://lkml.org/lkml/2018/7/22/11
>>> [2] https://lkml.org/lkml/2018/7/21/343
>>>
>>> Reported-by: Phil Karn <karn@ka9q.net>
>>> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
>>> ---
>>>  include/linux/mroute_base.h |  2 --
>>>  net/ipv4/ipmr.c             | 27 ++++++++++++++++++---------
>>>  net/ipv6/ip6mr.c            | 10 +++-------
>>>  3 files changed, 21 insertions(+), 18 deletions(-)
>>>
>>
>> Hi,
>> IMO this is definitely net-next material. A few more comments below.
> 
> I thoug this is a bug fix. But it looks more suitable to net-next as you said.
>>
>> Note that hosts will automatically have this limit lifted to about 270
>> entries with current defaults, some might be surprised if they have
>> higher limits set and could be left with queues allowing for thousands
>> of entries in a linked list.
> 
> I think this is just a cache list and should be expired soon. The cache
> creation would also failed if there is no buffer.
> 
> But if you like, I can write a patch with sysctl parameter.

I wasn't suggesting the sysctl, I'm actually against it as I've said before when
commenting these patches. Just wanted to note that some setups will end up with
the possibility of having thousands of entries in a linked list after updating. Unless
we change the data structure I guess we just have to live with it, I wouldn't want to
add a sysctl or another hard limit that will have to be removed after a while. In the
long run we might update the algorithm used for unres entries.

So to make it clear: I'm fine with this patch as it is, definitely an improvement IMO.

>>
>>> +static int queue_count(struct mr_table *mrt)
>>> +{
>>> +	struct list_head *pos;
>>> +	int count = 0;
>>> +
>>> +	list_for_each(pos, &mrt->mfc_unres_queue)
>>> +		count++;
>>> +	return count;
>>> +}
>>
>> I don't think we hold the mfc_unres_lock here while walking
>> the unresolved list below in ipmr_fill_table().
> 
> ah, yes, I will fix this.
> 
> Thanks
> Hangbin
> 


^ permalink raw reply

* Re: [PATCH v2 4/4] can: mcp251x: Get rid of legacy platform data
From: Marc Kleine-Budde @ 2019-09-03 13:17 UTC (permalink / raw)
  To: Andy Shevchenko, Wolfgang Grandegger, linux-can, David S. Miller,
	netdev
  Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Russell King
In-Reply-To: <20190903124259.60920-5-andriy.shevchenko@linux.intel.com>


[-- Attachment #1.1: Type: text/plain, Size: 1950 bytes --]

On 9/3/19 2:42 PM, Andy Shevchenko wrote:
> Instead of using legacy platform data, switch to use device properties.
> For clock frequency we are using well established clock-frequency property.
> 
> Users, two for now, are also converted here.

[...]

> diff --git a/drivers/net/can/spi/mcp251x.c b/drivers/net/can/spi/mcp251x.c
> index 6ee0ea51399a..3a4d7089dc7c 100644
> --- a/drivers/net/can/spi/mcp251x.c
> +++ b/drivers/net/can/spi/mcp251x.c
> @@ -20,29 +20,26 @@
>   *
>   * Your platform definition file should specify something like:
>   *
> - * static struct mcp251x_platform_data mcp251x_info = {
> - *         .oscillator_frequency = 8000000,
> + * static const struct property_entry mpc251x_properties[] = {
> + *         PROPERTY_ENTRY_U32("clock-frequency", 8000000),
> + *         {}
>   * };
>   *
>   * static struct spi_board_info spi_board_info[] = {
>   *         {
>   *                 .modalias = "mcp2510",
>   *			// "mcp2515" or "mcp25625" depending on your controller
> - *                 .platform_data = &mcp251x_info,
> + *                 .properties = &mcp251x_properties,
>   *                 .irq = IRQ_EINT13,
>   *                 .max_speed_hz = 2*1000*1000,
>   *                 .chip_select = 2,
>   *         },
>   * };
> - *
> - * Please see mcp251x.h for a description of the fields in
> - * struct mcp251x_platform_data.
>   */

I've removed this section already in this patch:

https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git/commit/?h=linux-can-next-for-5.4-20190903&id=f6cae800bfdb6711f0d45af98643a944998be6f2

...I've dropped that hunk.

regards,
Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply

* Re: [PATCH net] sctp: use transport pf_retrans in sctp_do_8_2_transport_strike
From: Neil Horman @ 2019-09-03 13:15 UTC (permalink / raw)
  To: Xin Long; +Cc: network dev, linux-sctp, davem, Marcelo Ricardo Leitner
In-Reply-To: <41769d6033d27d629798e060671a3b21f22e2a21.1567437861.git.lucien.xin@gmail.com>

On Mon, Sep 02, 2019 at 11:24:21PM +0800, Xin Long wrote:
> Transport should use its own pf_retrans to do the error_count
> check, instead of asoc's. Otherwise, it's meaningless to make
> pf_retrans per transport.
> 
> Fixes: 5aa93bcf66f4 ("sctp: Implement quick failover draft from tsvwg")
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> ---
>  net/sctp/sm_sideeffect.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
> index 1cf5bb5..e52b212 100644
> --- a/net/sctp/sm_sideeffect.c
> +++ b/net/sctp/sm_sideeffect.c
> @@ -547,7 +547,7 @@ static void sctp_do_8_2_transport_strike(struct sctp_cmd_seq *commands,
>  	if (net->sctp.pf_enable &&
>  	   (transport->state == SCTP_ACTIVE) &&
>  	   (transport->error_count < transport->pathmaxrxt) &&
> -	   (transport->error_count > asoc->pf_retrans)) {
> +	   (transport->error_count > transport->pf_retrans)) {
>  
>  		sctp_assoc_control_transport(asoc, transport,
>  					     SCTP_TRANSPORT_PF,
> -- 
> 2.1.0
> 
> 
Acked-by: Neil Horman <nhorman@tuxdriver.com>


^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox