Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net

+2316 -1386
+4
.gitignore
··· 127 127 128 128 # Kdevelop4 129 129 *.kdev4 130 + 131 + #Automatically generated by ASN.1 compiler 132 + net/ipv4/netfilter/nf_nat_snmp_basic-asn1.c 133 + net/ipv4/netfilter/nf_nat_snmp_basic-asn1.h
+1 -1
Documentation/gpu/tve200.rst
··· 3 3 ================================== 4 4 5 5 .. kernel-doc:: drivers/gpu/drm/tve200/tve200_drv.c 6 - :doc: Faraday TV Encoder 200 6 + :doc: Faraday TV Encoder TVE200 DRM Driver
+2
Documentation/i2c/busses/i2c-i801
··· 28 28 * Intel Wildcat Point (PCH) 29 29 * Intel Wildcat Point-LP (PCH) 30 30 * Intel BayTrail (SOC) 31 + * Intel Braswell (SOC) 31 32 * Intel Sunrise Point-H (PCH) 32 33 * Intel Sunrise Point-LP (PCH) 34 + * Intel Kaby Lake-H (PCH) 33 35 * Intel DNV (SOC) 34 36 * Intel Broxton (SOC) 35 37 * Intel Lewisburg (PCH)
-1
MAINTAINERS
··· 7909 7909 F: scripts/leaking_addresses.pl 7910 7910 7911 7911 LED SUBSYSTEM 7912 - M: Richard Purdie <rpurdie@rpsys.net> 7913 7912 M: Jacek Anaszewski <jacek.anaszewski@gmail.com> 7914 7913 M: Pavel Machek <pavel@ucw.cz> 7915 7914 L: linux-leds@vger.kernel.org
+2 -1
arch/arc/include/asm/bug.h
··· 23 23 24 24 #define BUG() do { \ 25 25 pr_warn("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \ 26 - dump_stack(); \ 26 + barrier_before_unreachable(); \ 27 + __builtin_trap(); \ 27 28 } while (0) 28 29 29 30 #define HAVE_ARCH_BUG
-35
arch/arm/mach-ux500/cpu-db8500.c
··· 23 23 #include <linux/of.h> 24 24 #include <linux/of_address.h> 25 25 #include <linux/of_platform.h> 26 - #include <linux/perf/arm_pmu.h> 27 26 #include <linux/regulator/machine.h> 28 27 29 28 #include <asm/outercache.h> ··· 111 112 prcmu_system_reset(0); 112 113 } 113 114 114 - /* 115 - * The PMU IRQ lines of two cores are wired together into a single interrupt. 116 - * Bounce the interrupt to the other core if it's not ours. 117 - */ 118 - static irqreturn_t db8500_pmu_handler(int irq, void *dev, irq_handler_t handler) 119 - { 120 - irqreturn_t ret = handler(irq, dev); 121 - int other = !smp_processor_id(); 122 - 123 - if (ret == IRQ_NONE && cpu_online(other)) 124 - irq_set_affinity(irq, cpumask_of(other)); 125 - 126 - /* 127 - * We should be able to get away with the amount of IRQ_NONEs we give, 128 - * while still having the spurious IRQ detection code kick in if the 129 - * interrupt really starts hitting spuriously. 130 - */ 131 - return ret; 132 - } 133 - 134 - static struct arm_pmu_platdata db8500_pmu_platdata = { 135 - .handle_irq = db8500_pmu_handler, 136 - .irq_flags = IRQF_NOBALANCING | IRQF_NO_THREAD, 137 - }; 138 - 139 - static struct of_dev_auxdata u8500_auxdata_lookup[] __initdata = { 140 - /* Requires call-back bindings. */ 141 - OF_DEV_AUXDATA("arm,cortex-a9-pmu", 0, "arm-pmu", &db8500_pmu_platdata), 142 - {}, 143 - }; 144 - 145 115 static struct of_dev_auxdata u8540_auxdata_lookup[] __initdata = { 146 116 OF_DEV_AUXDATA("stericsson,db8500-prcmu", 0x80157000, "db8500-prcmu", NULL), 147 117 {}, ··· 133 165 if (of_machine_is_compatible("st-ericsson,u8540")) 134 166 of_platform_populate(NULL, u8500_local_bus_nodes, 135 167 u8540_auxdata_lookup, NULL); 136 - else 137 - of_platform_populate(NULL, u8500_local_bus_nodes, 138 - u8500_auxdata_lookup, NULL); 139 168 } 140 169 141 170 static const char * stericsson_dt_platform_compat[] = {
+1 -1
arch/arm64/include/asm/cputype.h
··· 20 20 21 21 #define MPIDR_UP_BITMASK (0x1 << 30) 22 22 #define MPIDR_MT_BITMASK (0x1 << 24) 23 - #define MPIDR_HWID_BITMASK 0xff00ffffffUL 23 + #define MPIDR_HWID_BITMASK UL(0xff00ffffff) 24 24 25 25 #define MPIDR_LEVEL_BITS_SHIFT 3 26 26 #define MPIDR_LEVEL_BITS (1 << MPIDR_LEVEL_BITS_SHIFT)
+1 -1
arch/arm64/include/asm/stacktrace.h
··· 28 28 unsigned long fp; 29 29 unsigned long pc; 30 30 #ifdef CONFIG_FUNCTION_GRAPH_TRACER 31 - unsigned int graph; 31 + int graph; 32 32 #endif 33 33 }; 34 34
+6 -6
arch/arm64/include/asm/uaccess.h
··· 72 72 * This is equivalent to the following test: 73 73 * (u65)addr + (u65)size <= (u65)current->addr_limit + 1 74 74 */ 75 - static inline unsigned long __range_ok(unsigned long addr, unsigned long size) 75 + static inline unsigned long __range_ok(const void __user *addr, unsigned long size) 76 76 { 77 - unsigned long limit = current_thread_info()->addr_limit; 77 + unsigned long ret, limit = current_thread_info()->addr_limit; 78 78 79 79 __chk_user_ptr(addr); 80 80 asm volatile( 81 81 // A + B <= C + 1 for all A,B,C, in four easy steps: 82 82 // 1: X = A + B; X' = X % 2^64 83 - " adds %0, %0, %2\n" 83 + " adds %0, %3, %2\n" 84 84 // 2: Set C = 0 if X > 2^64, to guarantee X' > C in step 4 85 85 " csel %1, xzr, %1, hi\n" 86 86 // 3: Set X' = ~0 if X >= 2^64. For X == 2^64, this decrements X' ··· 92 92 // testing X' - C == 0, subject to the previous adjustments. 93 93 " sbcs xzr, %0, %1\n" 94 94 " cset %0, ls\n" 95 - : "+r" (addr), "+r" (limit) : "Ir" (size) : "cc"); 95 + : "=&r" (ret), "+r" (limit) : "Ir" (size), "0" (addr) : "cc"); 96 96 97 - return addr; 97 + return ret; 98 98 } 99 99 100 100 /* ··· 104 104 */ 105 105 #define untagged_addr(addr) sign_extend64(addr, 55) 106 106 107 - #define access_ok(type, addr, size) __range_ok((unsigned long)(addr), size) 107 + #define access_ok(type, addr, size) __range_ok(addr, size) 108 108 #define user_addr_max get_fs 109 109 110 110 #define _ASM_EXTABLE(from, to) \
+3 -1
arch/arm64/kernel/armv8_deprecated.c
··· 370 370 static int swp_handler(struct pt_regs *regs, u32 instr) 371 371 { 372 372 u32 destreg, data, type, address = 0; 373 + const void __user *user_ptr; 373 374 int rn, rt2, res = 0; 374 375 375 376 perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, regs, regs->pc); ··· 402 401 aarch32_insn_extract_reg_num(instr, A32_RT2_OFFSET), data); 403 402 404 403 /* Check access in reasonable access range for both SWP and SWPB */ 405 - if (!access_ok(VERIFY_WRITE, (address & ~3), 4)) { 404 + user_ptr = (const void __user *)(unsigned long)(address & ~3); 405 + if (!access_ok(VERIFY_WRITE, user_ptr, 4)) { 406 406 pr_debug("SWP{B} emulation: access to 0x%08x not allowed!\n", 407 407 address); 408 408 goto fault;
+4 -2
arch/arm64/kernel/cpufeature.c
··· 199 199 }; 200 200 201 201 static const struct arm64_ftr_bits ftr_ctr[] = { 202 - ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_EXACT, 31, 1, 1), /* RAO */ 202 + ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_EXACT, 31, 1, 1), /* RES1 */ 203 + ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, 29, 1, 1), /* DIC */ 204 + ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, 28, 1, 1), /* IDC */ 203 205 ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_HIGHER_SAFE, 24, 4, 0), /* CWG */ 204 - ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, 20, 4, 0), /* ERG */ 206 + ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_HIGHER_SAFE, 20, 4, 0), /* ERG */ 205 207 ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, 16, 4, 1), /* DminLine */ 206 208 /* 207 209 * Linux can handle differing I-cache policies. Userspace JITs will
+2 -2
arch/arm64/kernel/perf_event.c
··· 908 908 int pmuver; 909 909 910 910 dfr0 = read_sysreg(id_aa64dfr0_el1); 911 - pmuver = cpuid_feature_extract_signed_field(dfr0, 911 + pmuver = cpuid_feature_extract_unsigned_field(dfr0, 912 912 ID_AA64DFR0_PMUVER_SHIFT); 913 - if (pmuver < 1) 913 + if (pmuver == 0xf || pmuver == 0) 914 914 return; 915 915 916 916 probe->present = true;
+9 -2
arch/arm64/kernel/process.c
··· 220 220 221 221 show_regs_print_info(KERN_DEFAULT); 222 222 print_pstate(regs); 223 - printk("pc : %pS\n", (void *)regs->pc); 224 - printk("lr : %pS\n", (void *)lr); 223 + 224 + if (!user_mode(regs)) { 225 + printk("pc : %pS\n", (void *)regs->pc); 226 + printk("lr : %pS\n", (void *)lr); 227 + } else { 228 + printk("pc : %016llx\n", regs->pc); 229 + printk("lr : %016llx\n", lr); 230 + } 231 + 225 232 printk("sp : %016llx\n", sp); 226 233 227 234 i = top_reg;
+5
arch/arm64/kernel/stacktrace.c
··· 59 59 #ifdef CONFIG_FUNCTION_GRAPH_TRACER 60 60 if (tsk->ret_stack && 61 61 (frame->pc == (unsigned long)return_to_handler)) { 62 + if (WARN_ON_ONCE(frame->graph == -1)) 63 + return -EINVAL; 64 + if (frame->graph < -1) 65 + frame->graph += FTRACE_NOTRACE_DEPTH; 66 + 62 67 /* 63 68 * This is a case where function graph tracer has 64 69 * modified a return address (LR) in a stack frame
+1 -1
arch/arm64/kernel/sys_compat.c
··· 57 57 if (end < start || flags) 58 58 return -EINVAL; 59 59 60 - if (!access_ok(VERIFY_READ, start, end - start)) 60 + if (!access_ok(VERIFY_READ, (const void __user *)start, end - start)) 61 61 return -EFAULT; 62 62 63 63 return __do_compat_cache_op(start, end);
+1 -1
arch/arm64/kernel/time.c
··· 52 52 frame.fp = regs->regs[29]; 53 53 frame.pc = regs->pc; 54 54 #ifdef CONFIG_FUNCTION_GRAPH_TRACER 55 - frame.graph = -1; /* no task info */ 55 + frame.graph = current->curr_ret_stack; 56 56 #endif 57 57 do { 58 58 int ret = unwind_frame(NULL, &frame);
+1 -9
arch/arm64/kernel/traps.c
··· 57 57 "Error" 58 58 }; 59 59 60 - int show_unhandled_signals = 1; 60 + int show_unhandled_signals = 0; 61 61 62 62 static void dump_backtrace_entry(unsigned long where) 63 63 { ··· 525 525 return ret; 526 526 } 527 527 #endif 528 - 529 - if (show_unhandled_signals_ratelimited()) { 530 - pr_info("%s[%d]: syscall %d\n", current->comm, 531 - task_pid_nr(current), regs->syscallno); 532 - dump_instr("", regs); 533 - if (user_mode(regs)) 534 - __show_regs(regs); 535 - } 536 528 537 529 return sys_ni_syscall(); 538 530 }
+10
arch/arm64/mm/mmu.c
··· 933 933 { 934 934 pgprot_t sect_prot = __pgprot(PUD_TYPE_SECT | 935 935 pgprot_val(mk_sect_prot(prot))); 936 + 937 + /* ioremap_page_range doesn't honour BBM */ 938 + if (pud_present(READ_ONCE(*pudp))) 939 + return 0; 940 + 936 941 BUG_ON(phys & ~PUD_MASK); 937 942 set_pud(pudp, pfn_pud(__phys_to_pfn(phys), sect_prot)); 938 943 return 1; ··· 947 942 { 948 943 pgprot_t sect_prot = __pgprot(PMD_TYPE_SECT | 949 944 pgprot_val(mk_sect_prot(prot))); 945 + 946 + /* ioremap_page_range doesn't honour BBM */ 947 + if (pmd_present(READ_ONCE(*pmdp))) 948 + return 0; 949 + 950 950 BUG_ON(phys & ~PMD_MASK); 951 951 set_pmd(pmdp, pfn_pmd(__phys_to_pfn(phys), sect_prot)); 952 952 return 1;
+3 -2
arch/arm64/net/bpf_jit_comp.c
··· 250 250 off = offsetof(struct bpf_array, map.max_entries); 251 251 emit_a64_mov_i64(tmp, off, ctx); 252 252 emit(A64_LDR32(tmp, r2, tmp), ctx); 253 + emit(A64_MOV(0, r3, r3), ctx); 253 254 emit(A64_CMP(0, r3, tmp), ctx); 254 - emit(A64_B_(A64_COND_GE, jmp_offset), ctx); 255 + emit(A64_B_(A64_COND_CS, jmp_offset), ctx); 255 256 256 257 /* if (tail_call_cnt > MAX_TAIL_CALL_CNT) 257 258 * goto out; ··· 260 259 */ 261 260 emit_a64_mov_i64(tmp, MAX_TAIL_CALL_CNT, ctx); 262 261 emit(A64_CMP(1, tcc, tmp), ctx); 263 - emit(A64_B_(A64_COND_GT, jmp_offset), ctx); 262 + emit(A64_B_(A64_COND_HI, jmp_offset), ctx); 264 263 emit(A64_ADD_I(1, tcc, tcc, 1), ctx); 265 264 266 265 /* prog = array->ptrs[index];
+9 -2
arch/cris/include/arch-v10/arch/bug.h
··· 44 44 * not be used like this with newer versions of gcc. 45 45 */ 46 46 #define BUG() \ 47 + do { \ 47 48 __asm__ __volatile__ ("clear.d [" __stringify(BUG_MAGIC) "]\n\t"\ 48 49 "movu.w " __stringify(__LINE__) ",$r0\n\t"\ 49 50 "jump 0f\n\t" \ 50 51 ".section .rodata\n" \ 51 52 "0:\t.string \"" __FILE__ "\"\n\t" \ 52 - ".previous") 53 + ".previous"); \ 54 + unreachable(); \ 55 + } while (0) 53 56 #endif 54 57 55 58 #else 56 59 57 60 /* This just causes an oops. */ 58 - #define BUG() (*(int *)0 = 0) 61 + #define BUG() \ 62 + do { \ 63 + barrier_before_unreachable(); \ 64 + __builtin_trap(); \ 65 + } while (0) 59 66 60 67 #endif 61 68
+5 -1
arch/ia64/include/asm/bug.h
··· 4 4 5 5 #ifdef CONFIG_BUG 6 6 #define ia64_abort() __builtin_trap() 7 - #define BUG() do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); ia64_abort(); } while (0) 7 + #define BUG() do { \ 8 + printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ 9 + barrier_before_unreachable(); \ 10 + ia64_abort(); \ 11 + } while (0) 8 12 9 13 /* should this BUG be made generic? */ 10 14 #define HAVE_ARCH_BUG
+3
arch/m68k/include/asm/bug.h
··· 8 8 #ifndef CONFIG_SUN3 9 9 #define BUG() do { \ 10 10 pr_crit("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ 11 + barrier_before_unreachable(); \ 11 12 __builtin_trap(); \ 12 13 } while (0) 13 14 #else 14 15 #define BUG() do { \ 15 16 pr_crit("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ 17 + barrier_before_unreachable(); \ 16 18 panic("BUG!"); \ 17 19 } while (0) 18 20 #endif 19 21 #else 20 22 #define BUG() do { \ 23 + barrier_before_unreachable(); \ 21 24 __builtin_trap(); \ 22 25 } while (0) 23 26 #endif
+1
arch/mips/boot/Makefile
··· 126 126 127 127 quiet_cmd_cpp_its_S = ITS $@ 128 128 cmd_cpp_its_S = $(CPP) $(cpp_flags) -P -C -o $@ $< \ 129 + -D__ASSEMBLY__ \ 129 130 -DKERNEL_NAME="\"Linux $(KERNELRELEASE)\"" \ 130 131 -DVMLINUX_BINARY="\"$(3)\"" \ 131 132 -DVMLINUX_COMPRESSION="\"$(2)\"" \
-1
arch/mips/include/asm/compat.h
··· 86 86 compat_off_t l_len; 87 87 s32 l_sysid; 88 88 compat_pid_t l_pid; 89 - short __unused; 90 89 s32 pad[4]; 91 90 }; 92 91
-3
arch/riscv/Kconfig
··· 8 8 select OF 9 9 select OF_EARLY_FLATTREE 10 10 select OF_IRQ 11 - select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE 12 11 select ARCH_WANT_FRAME_POINTERS 13 12 select CLONE_BACKWARDS 14 13 select COMMON_CLK ··· 19 20 select GENERIC_STRNLEN_USER 20 21 select GENERIC_SMP_IDLE_THREAD 21 22 select GENERIC_ATOMIC64 if !64BIT || !RISCV_ISA_A 22 - select ARCH_WANT_OPTIONAL_GPIOLIB 23 23 select HAVE_MEMBLOCK 24 24 select HAVE_MEMBLOCK_NODE_MAP 25 25 select HAVE_DMA_API_DEBUG ··· 32 34 select HAVE_ARCH_TRACEHOOK 33 35 select MODULES_USE_ELF_RELA if MODULES 34 36 select THREAD_INFO_IN_TASK 35 - select RISCV_IRQ_INTC 36 37 select RISCV_TIMER 37 38 38 39 config MMU
+3 -2
arch/riscv/kernel/entry.S
··· 172 172 move a1, sp /* pt_regs */ 173 173 tail do_IRQ 174 174 1: 175 + /* Exceptions run with interrupts enabled */ 176 + csrs sstatus, SR_SIE 177 + 175 178 /* Handle syscalls */ 176 179 li t0, EXC_SYSCALL 177 180 beq s4, t0, handle_syscall ··· 201 198 */ 202 199 addi s2, s2, 0x4 203 200 REG_S s2, PT_SEPC(sp) 204 - /* System calls run with interrupts enabled */ 205 - csrs sstatus, SR_SIE 206 201 /* Trace syscalls, but only if requested by the user. */ 207 202 REG_L t0, TASK_TI_FLAGS(tp) 208 203 andi t0, t0, _TIF_SYSCALL_TRACE
+1 -1
arch/riscv/kernel/head.S
··· 64 64 /* Start the kernel */ 65 65 mv a0, s0 66 66 mv a1, s1 67 - call sbi_save 67 + call parse_dtb 68 68 tail start_kernel 69 69 70 70 relocate:
+1 -1
arch/riscv/kernel/setup.c
··· 144 144 #endif 145 145 } 146 146 147 - void __init sbi_save(unsigned int hartid, void *dtb) 147 + void __init parse_dtb(unsigned int hartid, void *dtb) 148 148 { 149 149 early_init_dt_scan(__va(dtb)); 150 150 }
+5 -1
arch/sparc/include/asm/bug.h
··· 9 9 void do_BUG(const char *file, int line); 10 10 #define BUG() do { \ 11 11 do_BUG(__FILE__, __LINE__); \ 12 + barrier_before_unreachable(); \ 12 13 __builtin_trap(); \ 13 14 } while (0) 14 15 #else 15 - #define BUG() __builtin_trap() 16 + #define BUG() do { \ 17 + barrier_before_unreachable(); \ 18 + __builtin_trap(); \ 19 + } while (0) 16 20 #endif 17 21 18 22 #define HAVE_ARCH_BUG
+37
arch/x86/include/asm/nospec-branch.h
··· 177 177 } 178 178 179 179 #endif /* __ASSEMBLY__ */ 180 + 181 + /* 182 + * Below is used in the eBPF JIT compiler and emits the byte sequence 183 + * for the following assembly: 184 + * 185 + * With retpolines configured: 186 + * 187 + * callq do_rop 188 + * spec_trap: 189 + * pause 190 + * lfence 191 + * jmp spec_trap 192 + * do_rop: 193 + * mov %rax,(%rsp) 194 + * retq 195 + * 196 + * Without retpolines configured: 197 + * 198 + * jmp *%rax 199 + */ 200 + #ifdef CONFIG_RETPOLINE 201 + # define RETPOLINE_RAX_BPF_JIT_SIZE 17 202 + # define RETPOLINE_RAX_BPF_JIT() \ 203 + EMIT1_off32(0xE8, 7); /* callq do_rop */ \ 204 + /* spec_trap: */ \ 205 + EMIT2(0xF3, 0x90); /* pause */ \ 206 + EMIT3(0x0F, 0xAE, 0xE8); /* lfence */ \ 207 + EMIT2(0xEB, 0xF9); /* jmp spec_trap */ \ 208 + /* do_rop: */ \ 209 + EMIT4(0x48, 0x89, 0x04, 0x24); /* mov %rax,(%rsp) */ \ 210 + EMIT1(0xC3); /* retq */ 211 + #else 212 + # define RETPOLINE_RAX_BPF_JIT_SIZE 2 213 + # define RETPOLINE_RAX_BPF_JIT() \ 214 + EMIT2(0xFF, 0xE0); /* jmp *%rax */ 215 + #endif 216 + 180 217 #endif /* _ASM_X86_NOSPEC_BRANCH_H_ */
+1
arch/x86/kernel/machine_kexec_64.c
··· 542 542 goto overflow; 543 543 break; 544 544 case R_X86_64_PC32: 545 + case R_X86_64_PLT32: 545 546 value -= (u64)address; 546 547 *(u32 *)location = value; 547 548 break;
+1
arch/x86/kernel/module.c
··· 191 191 goto overflow; 192 192 break; 193 193 case R_X86_64_PC32: 194 + case R_X86_64_PLT32: 194 195 if (*(u32 *)loc != 0) 195 196 goto invalid_relocation; 196 197 val -= (u64)loc;
+5 -4
arch/x86/net/bpf_jit_comp.c
··· 13 13 #include <linux/if_vlan.h> 14 14 #include <asm/cacheflush.h> 15 15 #include <asm/set_memory.h> 16 + #include <asm/nospec-branch.h> 16 17 #include <linux/bpf.h> 17 18 18 19 /* ··· 291 290 EMIT2(0x89, 0xD2); /* mov edx, edx */ 292 291 EMIT3(0x39, 0x56, /* cmp dword ptr [rsi + 16], edx */ 293 292 offsetof(struct bpf_array, map.max_entries)); 294 - #define OFFSET1 43 /* number of bytes to jump */ 293 + #define OFFSET1 (41 + RETPOLINE_RAX_BPF_JIT_SIZE) /* number of bytes to jump */ 295 294 EMIT2(X86_JBE, OFFSET1); /* jbe out */ 296 295 label1 = cnt; 297 296 ··· 300 299 */ 301 300 EMIT2_off32(0x8B, 0x85, 36); /* mov eax, dword ptr [rbp + 36] */ 302 301 EMIT3(0x83, 0xF8, MAX_TAIL_CALL_CNT); /* cmp eax, MAX_TAIL_CALL_CNT */ 303 - #define OFFSET2 32 302 + #define OFFSET2 (30 + RETPOLINE_RAX_BPF_JIT_SIZE) 304 303 EMIT2(X86_JA, OFFSET2); /* ja out */ 305 304 label2 = cnt; 306 305 EMIT3(0x83, 0xC0, 0x01); /* add eax, 1 */ ··· 314 313 * goto out; 315 314 */ 316 315 EMIT3(0x48, 0x85, 0xC0); /* test rax,rax */ 317 - #define OFFSET3 10 316 + #define OFFSET3 (8 + RETPOLINE_RAX_BPF_JIT_SIZE) 318 317 EMIT2(X86_JE, OFFSET3); /* je out */ 319 318 label3 = cnt; 320 319 ··· 327 326 * rdi == ctx (1st arg) 328 327 * rax == prog->bpf_func + prologue_size 329 328 */ 330 - EMIT2(0xFF, 0xE0); /* jmp rax */ 329 + RETPOLINE_RAX_BPF_JIT(); 331 330 332 331 /* out: */ 333 332 BUILD_BUG_ON(cnt - label1 != OFFSET1);
+3
arch/x86/tools/relocs.c
··· 770 770 break; 771 771 772 772 case R_X86_64_PC32: 773 + case R_X86_64_PLT32: 773 774 /* 774 775 * PC relative relocations don't need to be adjusted unless 775 776 * referencing a percpu symbol. 777 + * 778 + * NB: R_X86_64_PLT32 can be treated as R_X86_64_PC32. 776 779 */ 777 780 if (is_percpu_sym(sym, symname)) 778 781 add_reloc(&relocs32neg, offset);
+1 -1
certs/blacklist_nohashes.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 #include "blacklist.h" 3 3 4 - const char __initdata *const blacklist_hashes[] = { 4 + const char __initconst *const blacklist_hashes[] = { 5 5 NULL 6 6 };
+1
crypto/asymmetric_keys/pkcs7_trust.c
··· 106 106 pr_devel("sinfo %u: Direct signer is key %x\n", 107 107 sinfo->index, key_serial(key)); 108 108 x509 = NULL; 109 + sig = sinfo->sig; 109 110 goto matched; 110 111 } 111 112 if (PTR_ERR(key) != -ENOKEY)
+7 -5
crypto/asymmetric_keys/pkcs7_verify.c
··· 270 270 sinfo->index); 271 271 return 0; 272 272 } 273 - ret = public_key_verify_signature(p->pub, p->sig); 273 + ret = public_key_verify_signature(p->pub, x509->sig); 274 274 if (ret < 0) 275 275 return ret; 276 276 x509->signer = p; ··· 366 366 * 367 367 * (*) -EBADMSG if some part of the message was invalid, or: 368 368 * 369 - * (*) 0 if no signature chains were found to be blacklisted or to contain 370 - * unsupported crypto, or: 369 + * (*) 0 if a signature chain passed verification, or: 371 370 * 372 371 * (*) -EKEYREJECTED if a blacklisted key was encountered, or: 373 372 * ··· 422 423 423 424 for (sinfo = pkcs7->signed_infos; sinfo; sinfo = sinfo->next) { 424 425 ret = pkcs7_verify_one(pkcs7, sinfo); 425 - if (sinfo->blacklisted && actual_ret == -ENOPKG) 426 - actual_ret = -EKEYREJECTED; 426 + if (sinfo->blacklisted) { 427 + if (actual_ret == -ENOPKG) 428 + actual_ret = -EKEYREJECTED; 429 + continue; 430 + } 427 431 if (ret < 0) { 428 432 if (ret == -ENOPKG) { 429 433 sinfo->unsupported_crypto = true;
+3 -1
crypto/asymmetric_keys/public_key.c
··· 79 79 80 80 BUG_ON(!pkey); 81 81 BUG_ON(!sig); 82 - BUG_ON(!sig->digest); 83 82 BUG_ON(!sig->s); 83 + 84 + if (!sig->digest) 85 + return -ENOPKG; 84 86 85 87 alg_name = sig->pkey_algo; 86 88 if (strcmp(sig->pkey_algo, "rsa") == 0) {
+13 -8
crypto/asymmetric_keys/restrict.c
··· 67 67 * 68 68 * Returns 0 if the new certificate was accepted, -ENOKEY if we couldn't find a 69 69 * matching parent certificate in the trusted list, -EKEYREJECTED if the 70 - * signature check fails or the key is blacklisted and some other error if 71 - * there is a matching certificate but the signature check cannot be performed. 70 + * signature check fails or the key is blacklisted, -ENOPKG if the signature 71 + * uses unsupported crypto, or some other error if there is a matching 72 + * certificate but the signature check cannot be performed. 72 73 */ 73 74 int restrict_link_by_signature(struct key *dest_keyring, 74 75 const struct key_type *type, ··· 89 88 return -EOPNOTSUPP; 90 89 91 90 sig = payload->data[asym_auth]; 91 + if (!sig) 92 + return -ENOPKG; 92 93 if (!sig->auth_ids[0] && !sig->auth_ids[1]) 93 94 return -ENOKEY; 94 95 ··· 142 139 return -EOPNOTSUPP; 143 140 144 141 sig = payload->data[asym_auth]; 142 + if (!sig) 143 + return -ENOPKG; 145 144 if (!sig->auth_ids[0] && !sig->auth_ids[1]) 146 145 return -ENOKEY; 147 146 ··· 227 222 * 228 223 * Returns 0 if the new certificate was accepted, -ENOKEY if we 229 224 * couldn't find a matching parent certificate in the trusted list, 230 - * -EKEYREJECTED if the signature check fails, and some other error if 231 - * there is a matching certificate but the signature check cannot be 232 - * performed. 225 + * -EKEYREJECTED if the signature check fails, -ENOPKG if the signature uses 226 + * unsupported crypto, or some other error if there is a matching certificate 227 + * but the signature check cannot be performed. 233 228 */ 234 229 int restrict_link_by_key_or_keyring(struct key *dest_keyring, 235 230 const struct key_type *type, ··· 254 249 * 255 250 * Returns 0 if the new certificate was accepted, -ENOKEY if we 256 251 * couldn't find a matching parent certificate in the trusted list, 257 - * -EKEYREJECTED if the signature check fails, and some other error if 258 - * there is a matching certificate but the signature check cannot be 259 - * performed. 252 + * -EKEYREJECTED if the signature check fails, -ENOPKG if the signature uses 253 + * unsupported crypto, or some other error if there is a matching certificate 254 + * but the signature check cannot be performed. 260 255 */ 261 256 int restrict_link_by_key_or_keyring_chain(struct key *dest_keyring, 262 257 const struct key_type *type,
+23 -6
drivers/android/binder.c
··· 1991 1991 &target_thread->reply_error.work); 1992 1992 wake_up_interruptible(&target_thread->wait); 1993 1993 } else { 1994 - WARN(1, "Unexpected reply error: %u\n", 1995 - target_thread->reply_error.cmd); 1994 + /* 1995 + * Cannot get here for normal operation, but 1996 + * we can if multiple synchronous transactions 1997 + * are sent without blocking for responses. 1998 + * Just ignore the 2nd error in this case. 1999 + */ 2000 + pr_warn("Unexpected reply error: %u\n", 2001 + target_thread->reply_error.cmd); 1996 2002 } 1997 2003 binder_inner_proc_unlock(target_thread->proc); 1998 2004 binder_thread_dec_tmpref(target_thread); ··· 2199 2193 int debug_id = buffer->debug_id; 2200 2194 2201 2195 binder_debug(BINDER_DEBUG_TRANSACTION, 2202 - "%d buffer release %d, size %zd-%zd, failed at %p\n", 2196 + "%d buffer release %d, size %zd-%zd, failed at %pK\n", 2203 2197 proc->pid, buffer->debug_id, 2204 2198 buffer->data_size, buffer->offsets_size, failed_at); 2205 2199 ··· 3711 3705 } 3712 3706 } 3713 3707 binder_debug(BINDER_DEBUG_DEAD_BINDER, 3714 - "%d:%d BC_DEAD_BINDER_DONE %016llx found %p\n", 3708 + "%d:%d BC_DEAD_BINDER_DONE %016llx found %pK\n", 3715 3709 proc->pid, thread->pid, (u64)cookie, 3716 3710 death); 3717 3711 if (death == NULL) { ··· 4382 4376 4383 4377 binder_inner_proc_unlock(thread->proc); 4384 4378 4379 + /* 4380 + * This is needed to avoid races between wake_up_poll() above and 4381 + * and ep_remove_waitqueue() called for other reasons (eg the epoll file 4382 + * descriptor being closed); ep_remove_waitqueue() holds an RCU read 4383 + * lock, so we can be sure it's done after calling synchronize_rcu(). 4384 + */ 4385 + if (thread->looper & BINDER_LOOPER_STATE_POLL) 4386 + synchronize_rcu(); 4387 + 4385 4388 if (send_reply) 4386 4389 binder_send_failed_reply(send_reply, BR_DEAD_REPLY); 4387 4390 binder_release_work(proc, &thread->todo); ··· 4406 4391 bool wait_for_proc_work; 4407 4392 4408 4393 thread = binder_get_thread(proc); 4394 + if (!thread) 4395 + return POLLERR; 4409 4396 4410 4397 binder_inner_proc_lock(thread->proc); 4411 4398 thread->looper |= BINDER_LOOPER_STATE_POLL; ··· 5051 5034 spin_lock(&t->lock); 5052 5035 to_proc = t->to_proc; 5053 5036 seq_printf(m, 5054 - "%s %d: %p from %d:%d to %d:%d code %x flags %x pri %ld r%d", 5037 + "%s %d: %pK from %d:%d to %d:%d code %x flags %x pri %ld r%d", 5055 5038 prefix, t->debug_id, t, 5056 5039 t->from ? t->from->proc->pid : 0, 5057 5040 t->from ? t->from->pid : 0, ··· 5075 5058 } 5076 5059 if (buffer->target_node) 5077 5060 seq_printf(m, " node %d", buffer->target_node->debug_id); 5078 - seq_printf(m, " size %zd:%zd data %p\n", 5061 + seq_printf(m, " size %zd:%zd data %pK\n", 5079 5062 buffer->data_size, buffer->offsets_size, 5080 5063 buffer->data); 5081 5064 }
+9 -3
drivers/crypto/s5p-sss.c
··· 1922 1922 uint32_t aes_control; 1923 1923 unsigned long flags; 1924 1924 int err; 1925 + u8 *iv; 1925 1926 1926 1927 aes_control = SSS_AES_KEY_CHANGE_MODE; 1927 1928 if (mode & FLAGS_AES_DECRYPT) 1928 1929 aes_control |= SSS_AES_MODE_DECRYPT; 1929 1930 1930 - if ((mode & FLAGS_AES_MODE_MASK) == FLAGS_AES_CBC) 1931 + if ((mode & FLAGS_AES_MODE_MASK) == FLAGS_AES_CBC) { 1931 1932 aes_control |= SSS_AES_CHAIN_MODE_CBC; 1932 - else if ((mode & FLAGS_AES_MODE_MASK) == FLAGS_AES_CTR) 1933 + iv = req->info; 1934 + } else if ((mode & FLAGS_AES_MODE_MASK) == FLAGS_AES_CTR) { 1933 1935 aes_control |= SSS_AES_CHAIN_MODE_CTR; 1936 + iv = req->info; 1937 + } else { 1938 + iv = NULL; /* AES_ECB */ 1939 + } 1934 1940 1935 1941 if (dev->ctx->keylen == AES_KEYSIZE_192) 1936 1942 aes_control |= SSS_AES_KEY_SIZE_192; ··· 1967 1961 goto outdata_error; 1968 1962 1969 1963 SSS_AES_WRITE(dev, AES_CONTROL, aes_control); 1970 - s5p_set_aes(dev, dev->ctx->aes_key, req->info, dev->ctx->keylen); 1964 + s5p_set_aes(dev, dev->ctx->aes_key, iv, dev->ctx->keylen); 1971 1965 1972 1966 s5p_set_dma_indata(dev, dev->sg_src); 1973 1967 s5p_set_dma_outdata(dev, dev->sg_dst);
+4 -32
drivers/extcon/extcon-axp288.c
··· 1 1 /* 2 2 * extcon-axp288.c - X-Power AXP288 PMIC extcon cable detection driver 3 3 * 4 - * Copyright (C) 2016-2017 Hans de Goede <hdegoede@redhat.com> 5 4 * Copyright (C) 2015 Intel Corporation 6 5 * Author: Ramakrishna Pallala <ramakrishna.pallala@intel.com> 7 6 * ··· 97 98 struct device *dev; 98 99 struct regmap *regmap; 99 100 struct regmap_irq_chip_data *regmap_irqc; 100 - struct delayed_work det_work; 101 101 int irq[EXTCON_IRQ_END]; 102 102 struct extcon_dev *edev; 103 103 unsigned int previous_cable; 104 - bool first_detect_done; 105 104 }; 106 105 107 106 /* Power up/down reason string array */ 108 - static char *axp288_pwr_up_down_info[] = { 107 + static const char * const axp288_pwr_up_down_info[] = { 109 108 "Last wake caused by user pressing the power button", 110 109 "Last wake caused by a charger insertion", 111 110 "Last wake caused by a battery insertion", ··· 121 124 */ 122 125 static void axp288_extcon_log_rsi(struct axp288_extcon_info *info) 123 126 { 124 - char **rsi; 127 + const char * const *rsi; 125 128 unsigned int val, i, clear_mask = 0; 126 129 int ret; 127 130 ··· 135 138 136 139 /* Clear the register value for next reboot (write 1 to clear bit) */ 137 140 regmap_write(info->regmap, AXP288_PS_BOOT_REASON_REG, clear_mask); 138 - } 139 - 140 - static void axp288_chrg_detect_complete(struct axp288_extcon_info *info) 141 - { 142 - /* 143 - * We depend on other drivers to do things like mux the data lines, 144 - * enable/disable vbus based on the id-pin, etc. Sometimes the BIOS has 145 - * not set these things up correctly resulting in the initial charger 146 - * cable type detection giving a wrong result and we end up not charging 147 - * or charging at only 0.5A. 148 - * 149 - * So we schedule a second cable type detection after 2 seconds to 150 - * give the other drivers time to load and do their thing. 151 - */ 152 - if (!info->first_detect_done) { 153 - queue_delayed_work(system_wq, &info->det_work, 154 - msecs_to_jiffies(2000)); 155 - info->first_detect_done = true; 156 - } 157 141 } 158 142 159 143 static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info) ··· 201 223 info->previous_cable = cable; 202 224 } 203 225 204 - axp288_chrg_detect_complete(info); 205 - 206 226 return 0; 207 227 208 228 dev_det_ret: ··· 222 246 return IRQ_HANDLED; 223 247 } 224 248 225 - static void axp288_extcon_det_work(struct work_struct *work) 249 + static void axp288_extcon_enable(struct axp288_extcon_info *info) 226 250 { 227 - struct axp288_extcon_info *info = 228 - container_of(work, struct axp288_extcon_info, det_work.work); 229 - 230 251 regmap_update_bits(info->regmap, AXP288_BC_GLOBAL_REG, 231 252 BC_GLOBAL_RUN, 0); 232 253 /* Enable the charger detection logic */ ··· 245 272 info->regmap = axp20x->regmap; 246 273 info->regmap_irqc = axp20x->regmap_irqc; 247 274 info->previous_cable = EXTCON_NONE; 248 - INIT_DELAYED_WORK(&info->det_work, axp288_extcon_det_work); 249 275 250 276 platform_set_drvdata(pdev, info); 251 277 ··· 290 318 } 291 319 292 320 /* Start charger cable type detection */ 293 - queue_delayed_work(system_wq, &info->det_work, 0); 321 + axp288_extcon_enable(info); 294 322 295 323 return 0; 296 324 }
+2 -1
drivers/extcon/extcon-intel-int3496.c
··· 153 153 return ret; 154 154 } 155 155 156 - /* queue initial processing of id-pin */ 156 + /* process id-pin so that we start with the right status */ 157 157 queue_delayed_work(system_wq, &data->work, 0); 158 + flush_delayed_work(&data->work); 158 159 159 160 platform_set_drvdata(pdev, data); 160 161
+38 -20
drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
··· 736 736 enum drm_connector_status ret = connector_status_disconnected; 737 737 int r; 738 738 739 - r = pm_runtime_get_sync(connector->dev->dev); 740 - if (r < 0) 741 - return connector_status_disconnected; 739 + if (!drm_kms_helper_is_poll_worker()) { 740 + r = pm_runtime_get_sync(connector->dev->dev); 741 + if (r < 0) 742 + return connector_status_disconnected; 743 + } 742 744 743 745 if (encoder) { 744 746 struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); ··· 759 757 /* check acpi lid status ??? */ 760 758 761 759 amdgpu_connector_update_scratch_regs(connector, ret); 762 - pm_runtime_mark_last_busy(connector->dev->dev); 763 - pm_runtime_put_autosuspend(connector->dev->dev); 760 + 761 + if (!drm_kms_helper_is_poll_worker()) { 762 + pm_runtime_mark_last_busy(connector->dev->dev); 763 + pm_runtime_put_autosuspend(connector->dev->dev); 764 + } 765 + 764 766 return ret; 765 767 } 766 768 ··· 874 868 enum drm_connector_status ret = connector_status_disconnected; 875 869 int r; 876 870 877 - r = pm_runtime_get_sync(connector->dev->dev); 878 - if (r < 0) 879 - return connector_status_disconnected; 871 + if (!drm_kms_helper_is_poll_worker()) { 872 + r = pm_runtime_get_sync(connector->dev->dev); 873 + if (r < 0) 874 + return connector_status_disconnected; 875 + } 880 876 881 877 encoder = amdgpu_connector_best_single_encoder(connector); 882 878 if (!encoder) ··· 932 924 amdgpu_connector_update_scratch_regs(connector, ret); 933 925 934 926 out: 935 - pm_runtime_mark_last_busy(connector->dev->dev); 936 - pm_runtime_put_autosuspend(connector->dev->dev); 927 + if (!drm_kms_helper_is_poll_worker()) { 928 + pm_runtime_mark_last_busy(connector->dev->dev); 929 + pm_runtime_put_autosuspend(connector->dev->dev); 930 + } 937 931 938 932 return ret; 939 933 } ··· 998 988 enum drm_connector_status ret = connector_status_disconnected; 999 989 bool dret = false, broken_edid = false; 1000 990 1001 - r = pm_runtime_get_sync(connector->dev->dev); 1002 - if (r < 0) 1003 - return connector_status_disconnected; 991 + if (!drm_kms_helper_is_poll_worker()) { 992 + r = pm_runtime_get_sync(connector->dev->dev); 993 + if (r < 0) 994 + return connector_status_disconnected; 995 + } 1004 996 1005 997 if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) { 1006 998 ret = connector->status; ··· 1127 1115 amdgpu_connector_update_scratch_regs(connector, ret); 1128 1116 1129 1117 exit: 1130 - pm_runtime_mark_last_busy(connector->dev->dev); 1131 - pm_runtime_put_autosuspend(connector->dev->dev); 1118 + if (!drm_kms_helper_is_poll_worker()) { 1119 + pm_runtime_mark_last_busy(connector->dev->dev); 1120 + pm_runtime_put_autosuspend(connector->dev->dev); 1121 + } 1132 1122 1133 1123 return ret; 1134 1124 } ··· 1373 1359 struct drm_encoder *encoder = amdgpu_connector_best_single_encoder(connector); 1374 1360 int r; 1375 1361 1376 - r = pm_runtime_get_sync(connector->dev->dev); 1377 - if (r < 0) 1378 - return connector_status_disconnected; 1362 + if (!drm_kms_helper_is_poll_worker()) { 1363 + r = pm_runtime_get_sync(connector->dev->dev); 1364 + if (r < 0) 1365 + return connector_status_disconnected; 1366 + } 1379 1367 1380 1368 if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) { 1381 1369 ret = connector->status; ··· 1445 1429 1446 1430 amdgpu_connector_update_scratch_regs(connector, ret); 1447 1431 out: 1448 - pm_runtime_mark_last_busy(connector->dev->dev); 1449 - pm_runtime_put_autosuspend(connector->dev->dev); 1432 + if (!drm_kms_helper_is_poll_worker()) { 1433 + pm_runtime_mark_last_busy(connector->dev->dev); 1434 + pm_runtime_put_autosuspend(connector->dev->dev); 1435 + } 1450 1436 1451 1437 return ret; 1452 1438 }
+23 -17
drivers/gpu/drm/cirrus/cirrus_mode.c
··· 294 294 { 295 295 } 296 296 297 - /* 298 - * This is called after a mode is programmed. It should reverse anything done 299 - * by the prepare function 300 - */ 301 - static void cirrus_crtc_commit(struct drm_crtc *crtc) 302 - { 303 - } 304 - 305 - /* 306 - * The core can pass us a set of gamma values to program. We actually only 307 - * use this for 8-bit mode so can't perform smooth fades on deeper modes, 308 - * but it's a requirement that we provide the function 309 - */ 310 - static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, 311 - u16 *blue, uint32_t size, 312 - struct drm_modeset_acquire_ctx *ctx) 297 + static void cirrus_crtc_load_lut(struct drm_crtc *crtc) 313 298 { 314 299 struct drm_device *dev = crtc->dev; 315 300 struct cirrus_device *cdev = dev->dev_private; ··· 302 317 int i; 303 318 304 319 if (!crtc->enabled) 305 - return 0; 320 + return; 306 321 307 322 r = crtc->gamma_store; 308 323 g = r + crtc->gamma_size; ··· 315 330 WREG8(PALETTE_DATA, *g++ >> 8); 316 331 WREG8(PALETTE_DATA, *b++ >> 8); 317 332 } 333 + } 334 + 335 + /* 336 + * This is called after a mode is programmed. It should reverse anything done 337 + * by the prepare function 338 + */ 339 + static void cirrus_crtc_commit(struct drm_crtc *crtc) 340 + { 341 + cirrus_crtc_load_lut(crtc); 342 + } 343 + 344 + /* 345 + * The core can pass us a set of gamma values to program. We actually only 346 + * use this for 8-bit mode so can't perform smooth fades on deeper modes, 347 + * but it's a requirement that we provide the function 348 + */ 349 + static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, 350 + u16 *blue, uint32_t size, 351 + struct drm_modeset_acquire_ctx *ctx) 352 + { 353 + cirrus_crtc_load_lut(crtc); 318 354 319 355 return 0; 320 356 }
+15
drivers/gpu/drm/drm_atomic_helper.c
··· 1878 1878 new_crtc_state->event->base.completion = &commit->flip_done; 1879 1879 new_crtc_state->event->base.completion_release = release_crtc_commit; 1880 1880 drm_crtc_commit_get(commit); 1881 + 1882 + commit->abort_completion = true; 1881 1883 } 1882 1884 1883 1885 for_each_oldnew_connector_in_state(state, conn, old_conn_state, new_conn_state, i) { ··· 3423 3421 void __drm_atomic_helper_crtc_destroy_state(struct drm_crtc_state *state) 3424 3422 { 3425 3423 if (state->commit) { 3424 + /* 3425 + * In the event that a non-blocking commit returns 3426 + * -ERESTARTSYS before the commit_tail work is queued, we will 3427 + * have an extra reference to the commit object. Release it, if 3428 + * the event has not been consumed by the worker. 3429 + * 3430 + * state->event may be freed, so we can't directly look at 3431 + * state->event->base.completion. 3432 + */ 3433 + if (state->event && state->commit->abort_completion) 3434 + drm_crtc_commit_put(state->commit); 3435 + 3426 3436 kfree(state->commit->event); 3427 3437 state->commit->event = NULL; 3438 + 3428 3439 drm_crtc_commit_put(state->commit); 3429 3440 } 3430 3441
+21
drivers/gpu/drm/drm_edid.c
··· 113 113 /* AEO model 0 reports 8 bpc, but is a 6 bpc panel */ 114 114 { "AEO", 0, EDID_QUIRK_FORCE_6BPC }, 115 115 116 + /* CPT panel of Asus UX303LA reports 8 bpc, but is a 6 bpc panel */ 117 + { "CPT", 0x17df, EDID_QUIRK_FORCE_6BPC }, 118 + 116 119 /* Belinea 10 15 55 */ 117 120 { "MAX", 1516, EDID_QUIRK_PREFER_LARGE_60 }, 118 121 { "MAX", 0x77e, EDID_QUIRK_PREFER_LARGE_60 }, ··· 165 162 166 163 /* HTC Vive VR Headset */ 167 164 { "HVR", 0xaa01, EDID_QUIRK_NON_DESKTOP }, 165 + 166 + /* Oculus Rift DK1, DK2, and CV1 VR Headsets */ 167 + { "OVR", 0x0001, EDID_QUIRK_NON_DESKTOP }, 168 + { "OVR", 0x0003, EDID_QUIRK_NON_DESKTOP }, 169 + { "OVR", 0x0004, EDID_QUIRK_NON_DESKTOP }, 170 + 171 + /* Windows Mixed Reality Headsets */ 172 + { "ACR", 0x7fce, EDID_QUIRK_NON_DESKTOP }, 173 + { "HPN", 0x3515, EDID_QUIRK_NON_DESKTOP }, 174 + { "LEN", 0x0408, EDID_QUIRK_NON_DESKTOP }, 175 + { "LEN", 0xb800, EDID_QUIRK_NON_DESKTOP }, 176 + { "FUJ", 0x1970, EDID_QUIRK_NON_DESKTOP }, 177 + { "DEL", 0x7fce, EDID_QUIRK_NON_DESKTOP }, 178 + { "SEC", 0x144a, EDID_QUIRK_NON_DESKTOP }, 179 + { "AUS", 0xc102, EDID_QUIRK_NON_DESKTOP }, 180 + 181 + /* Sony PlayStation VR Headset */ 182 + { "SNY", 0x0704, EDID_QUIRK_NON_DESKTOP }, 168 183 }; 169 184 170 185 /*
+18 -3
drivers/gpu/drm/drm_mm.c
··· 836 836 if (!mm->color_adjust) 837 837 return NULL; 838 838 839 - hole = list_first_entry(&mm->hole_stack, typeof(*hole), hole_stack); 840 - hole_start = __drm_mm_hole_node_start(hole); 841 - hole_end = hole_start + hole->hole_size; 839 + /* 840 + * The hole found during scanning should ideally be the first element 841 + * in the hole_stack list, but due to side-effects in the driver it 842 + * may not be. 843 + */ 844 + list_for_each_entry(hole, &mm->hole_stack, hole_stack) { 845 + hole_start = __drm_mm_hole_node_start(hole); 846 + hole_end = hole_start + hole->hole_size; 847 + 848 + if (hole_start <= scan->hit_start && 849 + hole_end >= scan->hit_end) 850 + break; 851 + } 852 + 853 + /* We should only be called after we found the hole previously */ 854 + DRM_MM_BUG_ON(&hole->hole_stack == &mm->hole_stack); 855 + if (unlikely(&hole->hole_stack == &mm->hole_stack)) 856 + return NULL; 842 857 843 858 DRM_MM_BUG_ON(hole_start > scan->hit_start); 844 859 DRM_MM_BUG_ON(hole_end < scan->hit_end);
+20
drivers/gpu/drm/drm_probe_helper.c
··· 654 654 } 655 655 656 656 /** 657 + * drm_kms_helper_is_poll_worker - is %current task an output poll worker? 658 + * 659 + * Determine if %current task is an output poll worker. This can be used 660 + * to select distinct code paths for output polling versus other contexts. 661 + * 662 + * One use case is to avoid a deadlock between the output poll worker and 663 + * the autosuspend worker wherein the latter waits for polling to finish 664 + * upon calling drm_kms_helper_poll_disable(), while the former waits for 665 + * runtime suspend to finish upon calling pm_runtime_get_sync() in a 666 + * connector ->detect hook. 667 + */ 668 + bool drm_kms_helper_is_poll_worker(void) 669 + { 670 + struct work_struct *work = current_work(); 671 + 672 + return work && work->func == output_poll_execute; 673 + } 674 + EXPORT_SYMBOL(drm_kms_helper_is_poll_worker); 675 + 676 + /** 657 677 * drm_kms_helper_poll_disable - disable output polling 658 678 * @dev: drm_device 659 679 *
+5 -7
drivers/gpu/drm/exynos/exynos_drm_g2d.c
··· 286 286 287 287 node = kcalloc(G2D_CMDLIST_NUM, sizeof(*node), GFP_KERNEL); 288 288 if (!node) { 289 - dev_err(dev, "failed to allocate memory\n"); 290 289 ret = -ENOMEM; 291 290 goto err; 292 291 } ··· 925 926 struct drm_device *drm_dev = g2d->subdrv.drm_dev; 926 927 struct g2d_runqueue_node *runqueue_node = g2d->runqueue_node; 927 928 struct drm_exynos_pending_g2d_event *e; 928 - struct timeval now; 929 + struct timespec64 now; 929 930 930 931 if (list_empty(&runqueue_node->event_list)) 931 932 return; ··· 933 934 e = list_first_entry(&runqueue_node->event_list, 934 935 struct drm_exynos_pending_g2d_event, base.link); 935 936 936 - do_gettimeofday(&now); 937 + ktime_get_ts64(&now); 937 938 e->event.tv_sec = now.tv_sec; 938 - e->event.tv_usec = now.tv_usec; 939 + e->event.tv_usec = now.tv_nsec / NSEC_PER_USEC; 939 940 e->event.cmdlist_no = cmdlist_no; 940 941 941 942 drm_send_event(drm_dev, &e->base); ··· 1357 1358 return -EFAULT; 1358 1359 1359 1360 runqueue_node = kmem_cache_alloc(g2d->runqueue_slab, GFP_KERNEL); 1360 - if (!runqueue_node) { 1361 - dev_err(dev, "failed to allocate memory\n"); 1361 + if (!runqueue_node) 1362 1362 return -ENOMEM; 1363 - } 1363 + 1364 1364 run_cmdlist = &runqueue_node->run_cmdlist; 1365 1365 event_list = &runqueue_node->event_list; 1366 1366 INIT_LIST_HEAD(run_cmdlist);
-19
drivers/gpu/drm/exynos/exynos_drm_rotator.h
··· 1 - /* 2 - * Copyright (c) 2012 Samsung Electronics Co., Ltd. 3 - * 4 - * Authors: 5 - * YoungJun Cho <yj44.cho@samsung.com> 6 - * Eunchul Kim <chulspro.kim@samsung.com> 7 - * 8 - * This program is free software; you can redistribute it and/or modify it 9 - * under the terms of the GNU General Public License as published by the 10 - * Free Software Foundation; either version 2 of the License, or (at your 11 - * option) any later version. 12 - */ 13 - 14 - #ifndef _EXYNOS_DRM_ROTATOR_H_ 15 - #define _EXYNOS_DRM_ROTATOR_H_ 16 - 17 - /* TODO */ 18 - 19 - #endif
+5 -2
drivers/gpu/drm/exynos/exynos_hdmi.c
··· 1068 1068 /* Configuration I2S input ports. Configure I2S_PIN_SEL_0~4 */ 1069 1069 hdmi_reg_writeb(hdata, HDMI_I2S_PIN_SEL_0, HDMI_I2S_SEL_SCLK(5) 1070 1070 | HDMI_I2S_SEL_LRCK(6)); 1071 - hdmi_reg_writeb(hdata, HDMI_I2S_PIN_SEL_1, HDMI_I2S_SEL_SDATA1(1) 1072 - | HDMI_I2S_SEL_SDATA2(4)); 1071 + 1072 + hdmi_reg_writeb(hdata, HDMI_I2S_PIN_SEL_1, HDMI_I2S_SEL_SDATA1(3) 1073 + | HDMI_I2S_SEL_SDATA0(4)); 1074 + 1073 1075 hdmi_reg_writeb(hdata, HDMI_I2S_PIN_SEL_2, HDMI_I2S_SEL_SDATA3(1) 1074 1076 | HDMI_I2S_SEL_SDATA2(2)); 1077 + 1075 1078 hdmi_reg_writeb(hdata, HDMI_I2S_PIN_SEL_3, HDMI_I2S_SEL_DSD(0)); 1076 1079 1077 1080 /* I2S_CON_1 & 2 */
+1 -1
drivers/gpu/drm/exynos/regs-fimc.h
··· 569 569 #define EXYNOS_CIIMGEFF_FIN_EMBOSSING (4 << 26) 570 570 #define EXYNOS_CIIMGEFF_FIN_SILHOUETTE (5 << 26) 571 571 #define EXYNOS_CIIMGEFF_FIN_MASK (7 << 26) 572 - #define EXYNOS_CIIMGEFF_PAT_CBCR_MASK ((0xff < 13) | (0xff < 0)) 572 + #define EXYNOS_CIIMGEFF_PAT_CBCR_MASK ((0xff << 13) | (0xff << 0)) 573 573 574 574 /* Real input DMA size register */ 575 575 #define EXYNOS_CIREAL_ISIZE_AUTOLOAD_ENABLE (1 << 31)
+1 -1
drivers/gpu/drm/exynos/regs-hdmi.h
··· 464 464 465 465 /* I2S_PIN_SEL_1 */ 466 466 #define HDMI_I2S_SEL_SDATA1(x) (((x) & 0x7) << 4) 467 - #define HDMI_I2S_SEL_SDATA2(x) ((x) & 0x7) 467 + #define HDMI_I2S_SEL_SDATA0(x) ((x) & 0x7) 468 468 469 469 /* I2S_PIN_SEL_2 */ 470 470 #define HDMI_I2S_SEL_SDATA3(x) (((x) & 0x7) << 4)
+6
drivers/gpu/drm/meson/meson_crtc.c
··· 36 36 #include "meson_venc.h" 37 37 #include "meson_vpp.h" 38 38 #include "meson_viu.h" 39 + #include "meson_canvas.h" 39 40 #include "meson_registers.h" 40 41 41 42 /* CRTC definition */ ··· 192 191 meson_vpp_setup_interlace_vscaler_osd1(priv, &dest); 193 192 } else 194 193 meson_vpp_disable_interlace_vscaler_osd1(priv); 194 + 195 + meson_canvas_setup(priv, MESON_CANVAS_ID_OSD1, 196 + priv->viu.osd1_addr, priv->viu.osd1_stride, 197 + priv->viu.osd1_height, MESON_CANVAS_WRAP_NONE, 198 + MESON_CANVAS_BLKMODE_LINEAR); 195 199 196 200 /* Enable OSD1 */ 197 201 writel_bits_relaxed(VPP_OSD1_POSTBLEND, VPP_OSD1_POSTBLEND,
+3
drivers/gpu/drm/meson/meson_drv.h
··· 43 43 bool osd1_commit; 44 44 uint32_t osd1_ctrl_stat; 45 45 uint32_t osd1_blk0_cfg[5]; 46 + uint32_t osd1_addr; 47 + uint32_t osd1_stride; 48 + uint32_t osd1_height; 46 49 } viu; 47 50 48 51 struct {
+3 -4
drivers/gpu/drm/meson/meson_plane.c
··· 164 164 /* Update Canvas with buffer address */ 165 165 gem = drm_fb_cma_get_gem_obj(fb, 0); 166 166 167 - meson_canvas_setup(priv, MESON_CANVAS_ID_OSD1, 168 - gem->paddr, fb->pitches[0], 169 - fb->height, MESON_CANVAS_WRAP_NONE, 170 - MESON_CANVAS_BLKMODE_LINEAR); 167 + priv->viu.osd1_addr = gem->paddr; 168 + priv->viu.osd1_stride = fb->pitches[0]; 169 + priv->viu.osd1_height = fb->height; 171 170 172 171 spin_unlock_irqrestore(&priv->drm->event_lock, flags); 173 172 }
+13 -5
drivers/gpu/drm/nouveau/nouveau_connector.c
··· 570 570 nv_connector->edid = NULL; 571 571 } 572 572 573 - ret = pm_runtime_get_sync(connector->dev->dev); 574 - if (ret < 0 && ret != -EACCES) 575 - return conn_status; 573 + /* Outputs are only polled while runtime active, so acquiring a 574 + * runtime PM ref here is unnecessary (and would deadlock upon 575 + * runtime suspend because it waits for polling to finish). 576 + */ 577 + if (!drm_kms_helper_is_poll_worker()) { 578 + ret = pm_runtime_get_sync(connector->dev->dev); 579 + if (ret < 0 && ret != -EACCES) 580 + return conn_status; 581 + } 576 582 577 583 nv_encoder = nouveau_connector_ddc_detect(connector); 578 584 if (nv_encoder && (i2c = nv_encoder->i2c) != NULL) { ··· 653 647 654 648 out: 655 649 656 - pm_runtime_mark_last_busy(connector->dev->dev); 657 - pm_runtime_put_autosuspend(connector->dev->dev); 650 + if (!drm_kms_helper_is_poll_worker()) { 651 + pm_runtime_mark_last_busy(connector->dev->dev); 652 + pm_runtime_put_autosuspend(connector->dev->dev); 653 + } 658 654 659 655 return conn_status; 660 656 }
+49 -25
drivers/gpu/drm/radeon/radeon_connectors.c
··· 899 899 enum drm_connector_status ret = connector_status_disconnected; 900 900 int r; 901 901 902 - r = pm_runtime_get_sync(connector->dev->dev); 903 - if (r < 0) 904 - return connector_status_disconnected; 902 + if (!drm_kms_helper_is_poll_worker()) { 903 + r = pm_runtime_get_sync(connector->dev->dev); 904 + if (r < 0) 905 + return connector_status_disconnected; 906 + } 905 907 906 908 if (encoder) { 907 909 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); ··· 926 924 /* check acpi lid status ??? */ 927 925 928 926 radeon_connector_update_scratch_regs(connector, ret); 929 - pm_runtime_mark_last_busy(connector->dev->dev); 930 - pm_runtime_put_autosuspend(connector->dev->dev); 927 + 928 + if (!drm_kms_helper_is_poll_worker()) { 929 + pm_runtime_mark_last_busy(connector->dev->dev); 930 + pm_runtime_put_autosuspend(connector->dev->dev); 931 + } 932 + 931 933 return ret; 932 934 } 933 935 ··· 1045 1039 enum drm_connector_status ret = connector_status_disconnected; 1046 1040 int r; 1047 1041 1048 - r = pm_runtime_get_sync(connector->dev->dev); 1049 - if (r < 0) 1050 - return connector_status_disconnected; 1042 + if (!drm_kms_helper_is_poll_worker()) { 1043 + r = pm_runtime_get_sync(connector->dev->dev); 1044 + if (r < 0) 1045 + return connector_status_disconnected; 1046 + } 1051 1047 1052 1048 encoder = radeon_best_single_encoder(connector); 1053 1049 if (!encoder) ··· 1116 1108 radeon_connector_update_scratch_regs(connector, ret); 1117 1109 1118 1110 out: 1119 - pm_runtime_mark_last_busy(connector->dev->dev); 1120 - pm_runtime_put_autosuspend(connector->dev->dev); 1111 + if (!drm_kms_helper_is_poll_worker()) { 1112 + pm_runtime_mark_last_busy(connector->dev->dev); 1113 + pm_runtime_put_autosuspend(connector->dev->dev); 1114 + } 1121 1115 1122 1116 return ret; 1123 1117 } ··· 1183 1173 if (!radeon_connector->dac_load_detect) 1184 1174 return ret; 1185 1175 1186 - r = pm_runtime_get_sync(connector->dev->dev); 1187 - if (r < 0) 1188 - return connector_status_disconnected; 1176 + if (!drm_kms_helper_is_poll_worker()) { 1177 + r = pm_runtime_get_sync(connector->dev->dev); 1178 + if (r < 0) 1179 + return connector_status_disconnected; 1180 + } 1189 1181 1190 1182 encoder = radeon_best_single_encoder(connector); 1191 1183 if (!encoder) ··· 1199 1187 if (ret == connector_status_connected) 1200 1188 ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, false); 1201 1189 radeon_connector_update_scratch_regs(connector, ret); 1202 - pm_runtime_mark_last_busy(connector->dev->dev); 1203 - pm_runtime_put_autosuspend(connector->dev->dev); 1190 + 1191 + if (!drm_kms_helper_is_poll_worker()) { 1192 + pm_runtime_mark_last_busy(connector->dev->dev); 1193 + pm_runtime_put_autosuspend(connector->dev->dev); 1194 + } 1195 + 1204 1196 return ret; 1205 1197 } 1206 1198 ··· 1267 1251 enum drm_connector_status ret = connector_status_disconnected; 1268 1252 bool dret = false, broken_edid = false; 1269 1253 1270 - r = pm_runtime_get_sync(connector->dev->dev); 1271 - if (r < 0) 1272 - return connector_status_disconnected; 1254 + if (!drm_kms_helper_is_poll_worker()) { 1255 + r = pm_runtime_get_sync(connector->dev->dev); 1256 + if (r < 0) 1257 + return connector_status_disconnected; 1258 + } 1273 1259 1274 1260 if (radeon_connector->detected_hpd_without_ddc) { 1275 1261 force = true; ··· 1454 1436 } 1455 1437 1456 1438 exit: 1457 - pm_runtime_mark_last_busy(connector->dev->dev); 1458 - pm_runtime_put_autosuspend(connector->dev->dev); 1439 + if (!drm_kms_helper_is_poll_worker()) { 1440 + pm_runtime_mark_last_busy(connector->dev->dev); 1441 + pm_runtime_put_autosuspend(connector->dev->dev); 1442 + } 1459 1443 1460 1444 return ret; 1461 1445 } ··· 1708 1688 if (radeon_dig_connector->is_mst) 1709 1689 return connector_status_disconnected; 1710 1690 1711 - r = pm_runtime_get_sync(connector->dev->dev); 1712 - if (r < 0) 1713 - return connector_status_disconnected; 1691 + if (!drm_kms_helper_is_poll_worker()) { 1692 + r = pm_runtime_get_sync(connector->dev->dev); 1693 + if (r < 0) 1694 + return connector_status_disconnected; 1695 + } 1714 1696 1715 1697 if (!force && radeon_check_hpd_status_unchanged(connector)) { 1716 1698 ret = connector->status; ··· 1799 1777 } 1800 1778 1801 1779 out: 1802 - pm_runtime_mark_last_busy(connector->dev->dev); 1803 - pm_runtime_put_autosuspend(connector->dev->dev); 1780 + if (!drm_kms_helper_is_poll_worker()) { 1781 + pm_runtime_mark_last_busy(connector->dev->dev); 1782 + pm_runtime_put_autosuspend(connector->dev->dev); 1783 + } 1804 1784 1805 1785 return ret; 1806 1786 }
+2 -2
drivers/gpu/ipu-v3/ipu-common.c
··· 1089 1089 { 1090 1090 struct ipu_soc *ipu = irq_desc_get_handler_data(desc); 1091 1091 struct irq_chip *chip = irq_desc_get_chip(desc); 1092 - const int int_reg[] = { 0, 1, 2, 3, 10, 11, 12, 13, 14}; 1092 + static const int int_reg[] = { 0, 1, 2, 3, 10, 11, 12, 13, 14}; 1093 1093 1094 1094 chained_irq_enter(chip, desc); 1095 1095 ··· 1102 1102 { 1103 1103 struct ipu_soc *ipu = irq_desc_get_handler_data(desc); 1104 1104 struct irq_chip *chip = irq_desc_get_chip(desc); 1105 - const int int_reg[] = { 4, 5, 8, 9}; 1105 + static const int int_reg[] = { 4, 5, 8, 9}; 1106 1106 1107 1107 chained_irq_enter(chip, desc); 1108 1108
+2
drivers/gpu/ipu-v3/ipu-cpmem.c
··· 788 788 case V4L2_PIX_FMT_SGBRG8: 789 789 case V4L2_PIX_FMT_SGRBG8: 790 790 case V4L2_PIX_FMT_SRGGB8: 791 + case V4L2_PIX_FMT_GREY: 791 792 offset = image->rect.left + image->rect.top * pix->bytesperline; 792 793 break; 793 794 case V4L2_PIX_FMT_SBGGR16: 794 795 case V4L2_PIX_FMT_SGBRG16: 795 796 case V4L2_PIX_FMT_SGRBG16: 796 797 case V4L2_PIX_FMT_SRGGB16: 798 + case V4L2_PIX_FMT_Y16: 797 799 offset = image->rect.left * 2 + 798 800 image->rect.top * pix->bytesperline; 799 801 break;
+2
drivers/gpu/ipu-v3/ipu-csi.c
··· 288 288 case MEDIA_BUS_FMT_SGBRG10_1X10: 289 289 case MEDIA_BUS_FMT_SGRBG10_1X10: 290 290 case MEDIA_BUS_FMT_SRGGB10_1X10: 291 + case MEDIA_BUS_FMT_Y10_1X10: 291 292 cfg->data_fmt = CSI_SENS_CONF_DATA_FMT_BAYER; 292 293 cfg->mipi_dt = MIPI_DT_RAW10; 293 294 cfg->data_width = IPU_CSI_DATA_WIDTH_10; ··· 297 296 case MEDIA_BUS_FMT_SGBRG12_1X12: 298 297 case MEDIA_BUS_FMT_SGRBG12_1X12: 299 298 case MEDIA_BUS_FMT_SRGGB12_1X12: 299 + case MEDIA_BUS_FMT_Y12_1X12: 300 300 cfg->data_fmt = CSI_SENS_CONF_DATA_FMT_BAYER; 301 301 cfg->mipi_dt = MIPI_DT_RAW12; 302 302 cfg->data_width = IPU_CSI_DATA_WIDTH_12;
+3
drivers/gpu/ipu-v3/ipu-pre.c
··· 129 129 if (pre_node == pre->dev->of_node) { 130 130 mutex_unlock(&ipu_pre_list_mutex); 131 131 device_link_add(dev, pre->dev, DL_FLAG_AUTOREMOVE); 132 + of_node_put(pre_node); 132 133 return pre; 133 134 } 134 135 } 135 136 mutex_unlock(&ipu_pre_list_mutex); 137 + 138 + of_node_put(pre_node); 136 139 137 140 return NULL; 138 141 }
+3
drivers/gpu/ipu-v3/ipu-prg.c
··· 102 102 mutex_unlock(&ipu_prg_list_mutex); 103 103 device_link_add(dev, prg->dev, DL_FLAG_AUTOREMOVE); 104 104 prg->id = ipu_id; 105 + of_node_put(prg_node); 105 106 return prg; 106 107 } 107 108 } 108 109 mutex_unlock(&ipu_prg_list_mutex); 110 + 111 + of_node_put(prg_node); 109 112 110 113 return NULL; 111 114 }
+3
drivers/hid/hid-ids.h
··· 645 645 #define USB_DEVICE_ID_LD_MICROCASSYTIME 0x1033 646 646 #define USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE 0x1035 647 647 #define USB_DEVICE_ID_LD_MICROCASSYPH 0x1038 648 + #define USB_DEVICE_ID_LD_POWERANALYSERCASSY 0x1040 649 + #define USB_DEVICE_ID_LD_CONVERTERCONTROLLERCASSY 0x1042 650 + #define USB_DEVICE_ID_LD_MACHINETESTCASSY 0x1043 648 651 #define USB_DEVICE_ID_LD_JWM 0x1080 649 652 #define USB_DEVICE_ID_LD_DMMP 0x1081 650 653 #define USB_DEVICE_ID_LD_UMIP 0x1090
+3
drivers/hid/hid-quirks.c
··· 809 809 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTIME) }, 810 810 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE) }, 811 811 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYPH) }, 812 + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERANALYSERCASSY) }, 813 + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CONVERTERCONTROLLERCASSY) }, 814 + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETESTCASSY) }, 812 815 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) }, 813 816 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) }, 814 817 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) },
+2
drivers/i2c/busses/Kconfig
··· 123 123 Wildcat Point (PCH) 124 124 Wildcat Point-LP (PCH) 125 125 BayTrail (SOC) 126 + Braswell (SOC) 126 127 Sunrise Point-H (PCH) 127 128 Sunrise Point-LP (PCH) 129 + Kaby Lake-H (PCH) 128 130 DNV (SOC) 129 131 Broxton (SOC) 130 132 Lewisburg (PCH)
+20 -1
drivers/i2c/busses/i2c-bcm2835.c
··· 50 50 #define BCM2835_I2C_S_CLKT BIT(9) 51 51 #define BCM2835_I2C_S_LEN BIT(10) /* Fake bit for SW error reporting */ 52 52 53 + #define BCM2835_I2C_FEDL_SHIFT 16 54 + #define BCM2835_I2C_REDL_SHIFT 0 55 + 53 56 #define BCM2835_I2C_CDIV_MIN 0x0002 54 57 #define BCM2835_I2C_CDIV_MAX 0xFFFE 55 58 ··· 84 81 85 82 static int bcm2835_i2c_set_divider(struct bcm2835_i2c_dev *i2c_dev) 86 83 { 87 - u32 divider; 84 + u32 divider, redl, fedl; 88 85 89 86 divider = DIV_ROUND_UP(clk_get_rate(i2c_dev->clk), 90 87 i2c_dev->bus_clk_rate); ··· 103 100 104 101 bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_DIV, divider); 105 102 103 + /* 104 + * Number of core clocks to wait after falling edge before 105 + * outputting the next data bit. Note that both FEDL and REDL 106 + * can't be greater than CDIV/2. 107 + */ 108 + fedl = max(divider / 16, 1u); 109 + 110 + /* 111 + * Number of core clocks to wait after rising edge before 112 + * sampling the next incoming data bit. 113 + */ 114 + redl = max(divider / 4, 1u); 115 + 116 + bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_DEL, 117 + (fedl << BCM2835_I2C_FEDL_SHIFT) | 118 + (redl << BCM2835_I2C_REDL_SHIFT)); 106 119 return 0; 107 120 } 108 121
+2 -2
drivers/i2c/busses/i2c-designware-master.c
··· 209 209 i2c_dw_disable_int(dev); 210 210 211 211 /* Enable the adapter */ 212 - __i2c_dw_enable(dev, true); 212 + __i2c_dw_enable_and_wait(dev, true); 213 213 214 214 /* Clear and enable interrupts */ 215 215 dw_readl(dev, DW_IC_CLR_INTR); ··· 644 644 gpio = devm_gpiod_get(dev->dev, "scl", GPIOD_OUT_HIGH); 645 645 if (IS_ERR(gpio)) { 646 646 r = PTR_ERR(gpio); 647 - if (r == -ENOENT) 647 + if (r == -ENOENT || r == -ENOSYS) 648 648 return 0; 649 649 return r; 650 650 }
+1
drivers/i2c/busses/i2c-i801.c
··· 58 58 * Wildcat Point (PCH) 0x8ca2 32 hard yes yes yes 59 59 * Wildcat Point-LP (PCH) 0x9ca2 32 hard yes yes yes 60 60 * BayTrail (SOC) 0x0f12 32 hard yes yes yes 61 + * Braswell (SOC) 0x2292 32 hard yes yes yes 61 62 * Sunrise Point-H (PCH) 0xa123 32 hard yes yes yes 62 63 * Sunrise Point-LP (PCH) 0x9d23 32 hard yes yes yes 63 64 * DNV (SOC) 0x19df 32 hard yes yes yes
+2 -2
drivers/i2c/busses/i2c-sirf.c
··· 341 341 platform_set_drvdata(pdev, adap); 342 342 init_completion(&siic->done); 343 343 344 - /* Controller Initalisation */ 344 + /* Controller initialisation */ 345 345 346 346 writel(SIRFSOC_I2C_RESET, siic->base + SIRFSOC_I2C_CTRL); 347 347 while (readl(siic->base + SIRFSOC_I2C_CTRL) & SIRFSOC_I2C_RESET) ··· 369 369 * but they start to affect the speed when clock is set to faster 370 370 * frequencies. 371 371 * Through the actual tests, use the different user_div value(which 372 - * in the divider formular 'Fio / (Fi2c * user_div)') to adapt 372 + * in the divider formula 'Fio / (Fi2c * user_div)') to adapt 373 373 * the different ranges of i2c bus clock frequency, to make the SCL 374 374 * more accurate. 375 375 */
+4 -3
drivers/iio/adc/aspeed_adc.c
··· 243 243 ASPEED_ADC_INIT_POLLING_TIME, 244 244 ASPEED_ADC_INIT_TIMEOUT); 245 245 if (ret) 246 - goto scaler_error; 246 + goto poll_timeout_error; 247 247 } 248 248 249 249 /* Start all channels in normal mode. */ ··· 274 274 writel(ASPEED_OPERATION_MODE_POWER_DOWN, 275 275 data->base + ASPEED_REG_ENGINE_CONTROL); 276 276 clk_disable_unprepare(data->clk_scaler->clk); 277 - reset_error: 278 - reset_control_assert(data->rst); 279 277 clk_enable_error: 278 + poll_timeout_error: 279 + reset_control_assert(data->rst); 280 + reset_error: 280 281 clk_hw_unregister_divider(data->clk_scaler); 281 282 scaler_error: 282 283 clk_hw_unregister_divider(data->clk_prescaler);
+4 -3
drivers/iio/adc/stm32-adc.c
··· 722 722 int ret; 723 723 u32 val; 724 724 725 - /* Clear ADRDY by writing one, then enable ADC */ 726 - stm32_adc_set_bits(adc, STM32H7_ADC_ISR, STM32H7_ADRDY); 727 725 stm32_adc_set_bits(adc, STM32H7_ADC_CR, STM32H7_ADEN); 728 726 729 727 /* Poll for ADRDY to be set (after adc startup time) */ ··· 729 731 val & STM32H7_ADRDY, 730 732 100, STM32_ADC_TIMEOUT_US); 731 733 if (ret) { 732 - stm32_adc_clr_bits(adc, STM32H7_ADC_CR, STM32H7_ADEN); 734 + stm32_adc_set_bits(adc, STM32H7_ADC_CR, STM32H7_ADDIS); 733 735 dev_err(&indio_dev->dev, "Failed to enable ADC\n"); 736 + } else { 737 + /* Clear ADRDY by writing one */ 738 + stm32_adc_set_bits(adc, STM32H7_ADC_ISR, STM32H7_ADRDY); 734 739 } 735 740 736 741 return ret;
+4 -3
drivers/iio/imu/adis_trigger.c
··· 46 46 if (adis->trig == NULL) 47 47 return -ENOMEM; 48 48 49 + adis->trig->dev.parent = &adis->spi->dev; 50 + adis->trig->ops = &adis_trigger_ops; 51 + iio_trigger_set_drvdata(adis->trig, adis); 52 + 49 53 ret = request_irq(adis->spi->irq, 50 54 &iio_trigger_generic_data_rdy_poll, 51 55 IRQF_TRIGGER_RISING, ··· 58 54 if (ret) 59 55 goto error_free_trig; 60 56 61 - adis->trig->dev.parent = &adis->spi->dev; 62 - adis->trig->ops = &adis_trigger_ops; 63 - iio_trigger_set_drvdata(adis->trig, adis); 64 57 ret = iio_trigger_register(adis->trig); 65 58 66 59 indio_dev->trig = iio_trigger_get(adis->trig);
+1 -1
drivers/iio/industrialio-buffer.c
··· 175 175 struct iio_dev *indio_dev = filp->private_data; 176 176 struct iio_buffer *rb = indio_dev->buffer; 177 177 178 - if (!indio_dev->info) 178 + if (!indio_dev->info || rb == NULL) 179 179 return 0; 180 180 181 181 poll_wait(filp, &rb->pollq, wait);
+2
drivers/iio/proximity/Kconfig
··· 68 68 69 69 config SRF08 70 70 tristate "Devantech SRF02/SRF08/SRF10 ultrasonic ranger sensor" 71 + select IIO_BUFFER 72 + select IIO_TRIGGERED_BUFFER 71 73 depends on I2C 72 74 help 73 75 Say Y here to build a driver for Devantech SRF02/SRF08/SRF10
+6 -1
drivers/infiniband/core/core_priv.h
··· 305 305 static inline struct ib_qp *_ib_create_qp(struct ib_device *dev, 306 306 struct ib_pd *pd, 307 307 struct ib_qp_init_attr *attr, 308 - struct ib_udata *udata) 308 + struct ib_udata *udata, 309 + struct ib_uobject *uobj) 309 310 { 310 311 struct ib_qp *qp; 312 + 313 + if (!dev->create_qp) 314 + return ERR_PTR(-EOPNOTSUPP); 311 315 312 316 qp = dev->create_qp(pd, attr, udata); 313 317 if (IS_ERR(qp)) ··· 319 315 320 316 qp->device = dev; 321 317 qp->pd = pd; 318 + qp->uobject = uobj; 322 319 /* 323 320 * We don't track XRC QPs for now, because they don't have PD 324 321 * and more importantly they are created internaly by driver,
+28 -10
drivers/infiniband/core/rdma_core.c
··· 141 141 */ 142 142 uobj->context = context; 143 143 uobj->type = type; 144 - atomic_set(&uobj->usecnt, 0); 144 + /* 145 + * Allocated objects start out as write locked to deny any other 146 + * syscalls from accessing them until they are committed. See 147 + * rdma_alloc_commit_uobject 148 + */ 149 + atomic_set(&uobj->usecnt, -1); 145 150 kref_init(&uobj->ref); 146 151 147 152 return uobj; ··· 201 196 goto free; 202 197 } 203 198 204 - uverbs_uobject_get(uobj); 199 + /* 200 + * The idr_find is guaranteed to return a pointer to something that 201 + * isn't freed yet, or NULL, as the free after idr_remove goes through 202 + * kfree_rcu(). However the object may still have been released and 203 + * kfree() could be called at any time. 204 + */ 205 + if (!kref_get_unless_zero(&uobj->ref)) 206 + uobj = ERR_PTR(-ENOENT); 207 + 205 208 free: 206 209 rcu_read_unlock(); 207 210 return uobj; ··· 412 399 return ret; 413 400 } 414 401 415 - static void lockdep_check(struct ib_uobject *uobj, bool exclusive) 402 + static void assert_uverbs_usecnt(struct ib_uobject *uobj, bool exclusive) 416 403 { 417 404 #ifdef CONFIG_LOCKDEP 418 405 if (exclusive) 419 - WARN_ON(atomic_read(&uobj->usecnt) > 0); 406 + WARN_ON(atomic_read(&uobj->usecnt) != -1); 420 407 else 421 - WARN_ON(atomic_read(&uobj->usecnt) == -1); 408 + WARN_ON(atomic_read(&uobj->usecnt) <= 0); 422 409 #endif 423 410 } 424 411 ··· 457 444 WARN(true, "ib_uverbs: Cleanup is running while removing an uobject\n"); 458 445 return 0; 459 446 } 460 - lockdep_check(uobj, true); 447 + assert_uverbs_usecnt(uobj, true); 461 448 ret = _rdma_remove_commit_uobject(uobj, RDMA_REMOVE_DESTROY); 462 449 463 450 up_read(&ucontext->cleanup_rwsem); ··· 487 474 WARN(true, "ib_uverbs: Cleanup is running while removing an uobject\n"); 488 475 return 0; 489 476 } 490 - lockdep_check(uobject, true); 477 + assert_uverbs_usecnt(uobject, true); 491 478 ret = uobject->type->type_class->remove_commit(uobject, 492 479 RDMA_REMOVE_DESTROY); 493 480 if (ret) 494 - return ret; 481 + goto out; 495 482 496 483 uobject->type = &null_obj_type; 497 484 485 + out: 498 486 up_read(&ucontext->cleanup_rwsem); 499 - return 0; 487 + return ret; 500 488 } 501 489 502 490 static void alloc_commit_idr_uobject(struct ib_uobject *uobj) ··· 541 527 return ret; 542 528 } 543 529 530 + /* matches atomic_set(-1) in alloc_uobj */ 531 + assert_uverbs_usecnt(uobj, true); 532 + atomic_set(&uobj->usecnt, 0); 533 + 544 534 uobj->type->type_class->alloc_commit(uobj); 545 535 up_read(&uobj->context->cleanup_rwsem); 546 536 ··· 579 561 580 562 void rdma_lookup_put_uobject(struct ib_uobject *uobj, bool exclusive) 581 563 { 582 - lockdep_check(uobj, exclusive); 564 + assert_uverbs_usecnt(uobj, exclusive); 583 565 uobj->type->type_class->lookup_put(uobj, exclusive); 584 566 /* 585 567 * In order to unlock an object, either decrease its usecnt for
+16 -7
drivers/infiniband/core/restrack.c
··· 7 7 #include <rdma/restrack.h> 8 8 #include <linux/mutex.h> 9 9 #include <linux/sched/task.h> 10 - #include <linux/uaccess.h> 11 10 #include <linux/pid_namespace.h> 12 11 13 12 void rdma_restrack_init(struct rdma_restrack_root *res) ··· 62 63 { 63 64 enum rdma_restrack_type type = res->type; 64 65 struct ib_device *dev; 65 - struct ib_xrcd *xrcd; 66 66 struct ib_pd *pd; 67 67 struct ib_cq *cq; 68 68 struct ib_qp *qp; ··· 79 81 qp = container_of(res, struct ib_qp, res); 80 82 dev = qp->device; 81 83 break; 82 - case RDMA_RESTRACK_XRCD: 83 - xrcd = container_of(res, struct ib_xrcd, res); 84 - dev = xrcd->device; 85 - break; 86 84 default: 87 85 WARN_ONCE(true, "Wrong resource tracking type %u\n", type); 88 86 return NULL; 89 87 } 90 88 91 89 return dev; 90 + } 91 + 92 + static bool res_is_user(struct rdma_restrack_entry *res) 93 + { 94 + switch (res->type) { 95 + case RDMA_RESTRACK_PD: 96 + return container_of(res, struct ib_pd, res)->uobject; 97 + case RDMA_RESTRACK_CQ: 98 + return container_of(res, struct ib_cq, res)->uobject; 99 + case RDMA_RESTRACK_QP: 100 + return container_of(res, struct ib_qp, res)->uobject; 101 + default: 102 + WARN_ONCE(true, "Wrong resource tracking type %u\n", res->type); 103 + return false; 104 + } 92 105 } 93 106 94 107 void rdma_restrack_add(struct rdma_restrack_entry *res) ··· 109 100 if (!dev) 110 101 return; 111 102 112 - if (!uaccess_kernel()) { 103 + if (res_is_user(res)) { 113 104 get_task_struct(current); 114 105 res->task = current; 115 106 res->kern_name = NULL;
+40 -10
drivers/infiniband/core/uverbs_cmd.c
··· 562 562 if (f.file) 563 563 fdput(f); 564 564 565 + mutex_unlock(&file->device->xrcd_tree_mutex); 566 + 565 567 uobj_alloc_commit(&obj->uobject); 566 568 567 - mutex_unlock(&file->device->xrcd_tree_mutex); 568 569 return in_len; 569 570 570 571 err_copy: ··· 604 603 605 604 uobj = uobj_get_write(uobj_get_type(xrcd), cmd.xrcd_handle, 606 605 file->ucontext); 607 - if (IS_ERR(uobj)) { 608 - mutex_unlock(&file->device->xrcd_tree_mutex); 606 + if (IS_ERR(uobj)) 609 607 return PTR_ERR(uobj); 610 - } 611 608 612 609 ret = uobj_remove_commit(uobj); 613 610 return ret ?: in_len; ··· 978 979 struct ib_uverbs_ex_create_cq_resp resp; 979 980 struct ib_cq_init_attr attr = {}; 980 981 982 + if (!ib_dev->create_cq) 983 + return ERR_PTR(-EOPNOTSUPP); 984 + 981 985 if (cmd->comp_vector >= file->device->num_comp_vectors) 982 986 return ERR_PTR(-EINVAL); 983 987 ··· 1032 1030 resp.response_length = offsetof(typeof(resp), response_length) + 1033 1031 sizeof(resp.response_length); 1034 1032 1033 + cq->res.type = RDMA_RESTRACK_CQ; 1034 + rdma_restrack_add(&cq->res); 1035 + 1035 1036 ret = cb(file, obj, &resp, ucore, context); 1036 1037 if (ret) 1037 1038 goto err_cb; 1038 1039 1039 1040 uobj_alloc_commit(&obj->uobject); 1040 - cq->res.type = RDMA_RESTRACK_CQ; 1041 - rdma_restrack_add(&cq->res); 1042 - 1043 1041 return obj; 1044 1042 1045 1043 err_cb: ··· 1520 1518 if (cmd->qp_type == IB_QPT_XRC_TGT) 1521 1519 qp = ib_create_qp(pd, &attr); 1522 1520 else 1523 - qp = _ib_create_qp(device, pd, &attr, uhw); 1521 + qp = _ib_create_qp(device, pd, &attr, uhw, 1522 + &obj->uevent.uobject); 1524 1523 1525 1524 if (IS_ERR(qp)) { 1526 1525 ret = PTR_ERR(qp); ··· 1553 1550 atomic_inc(&attr.srq->usecnt); 1554 1551 if (ind_tbl) 1555 1552 atomic_inc(&ind_tbl->usecnt); 1553 + } else { 1554 + /* It is done in _ib_create_qp for other QP types */ 1555 + qp->uobject = &obj->uevent.uobject; 1556 1556 } 1557 - qp->uobject = &obj->uevent.uobject; 1558 1557 1559 1558 obj->uevent.uobject.object = qp; 1560 1559 ··· 1976 1971 goto release_qp; 1977 1972 } 1978 1973 1974 + if ((cmd->base.attr_mask & IB_QP_AV) && 1975 + !rdma_is_port_valid(qp->device, cmd->base.dest.port_num)) { 1976 + ret = -EINVAL; 1977 + goto release_qp; 1978 + } 1979 + 1979 1980 if ((cmd->base.attr_mask & IB_QP_ALT_PATH) && 1980 - !rdma_is_port_valid(qp->device, cmd->base.alt_port_num)) { 1981 + (!rdma_is_port_valid(qp->device, cmd->base.alt_port_num) || 1982 + !rdma_is_port_valid(qp->device, cmd->base.alt_dest.port_num))) { 1981 1983 ret = -EINVAL; 1982 1984 goto release_qp; 1983 1985 } ··· 2953 2941 wq_init_attr.create_flags = cmd.create_flags; 2954 2942 obj->uevent.events_reported = 0; 2955 2943 INIT_LIST_HEAD(&obj->uevent.event_list); 2944 + 2945 + if (!pd->device->create_wq) { 2946 + err = -EOPNOTSUPP; 2947 + goto err_put_cq; 2948 + } 2956 2949 wq = pd->device->create_wq(pd, &wq_init_attr, uhw); 2957 2950 if (IS_ERR(wq)) { 2958 2951 err = PTR_ERR(wq); ··· 3101 3084 wq_attr.flags = cmd.flags; 3102 3085 wq_attr.flags_mask = cmd.flags_mask; 3103 3086 } 3087 + if (!wq->device->modify_wq) { 3088 + ret = -EOPNOTSUPP; 3089 + goto out; 3090 + } 3104 3091 ret = wq->device->modify_wq(wq, &wq_attr, cmd.attr_mask, uhw); 3092 + out: 3105 3093 uobj_put_obj_read(wq); 3106 3094 return ret; 3107 3095 } ··· 3203 3181 3204 3182 init_attr.log_ind_tbl_size = cmd.log_ind_tbl_size; 3205 3183 init_attr.ind_tbl = wqs; 3184 + 3185 + if (!ib_dev->create_rwq_ind_table) { 3186 + err = -EOPNOTSUPP; 3187 + goto err_uobj; 3188 + } 3206 3189 rwq_ind_tbl = ib_dev->create_rwq_ind_table(ib_dev, &init_attr, uhw); 3207 3190 3208 3191 if (IS_ERR(rwq_ind_tbl)) { ··· 3796 3769 struct ib_uverbs_ex_query_device cmd; 3797 3770 struct ib_device_attr attr = {0}; 3798 3771 int err; 3772 + 3773 + if (!ib_dev->query_device) 3774 + return -EOPNOTSUPP; 3799 3775 3800 3776 if (ucore->inlen < sizeof(cmd)) 3801 3777 return -EINVAL;
+3
drivers/infiniband/core/uverbs_ioctl.c
··· 59 59 return 0; 60 60 } 61 61 62 + if (test_bit(attr_id, attr_bundle_h->valid_bitmap)) 63 + return -EINVAL; 64 + 62 65 spec = &attr_spec_bucket->attrs[attr_id]; 63 66 e = &elements[attr_id]; 64 67 e->uattr = uattr_ptr;
+9 -9
drivers/infiniband/core/uverbs_ioctl_merge.c
··· 114 114 short min = SHRT_MAX; 115 115 const void *elem; 116 116 int i, j, last_stored = -1; 117 + unsigned int equal_min = 0; 117 118 118 119 for_each_element(elem, i, j, elements, num_elements, num_offset, 119 120 data_offset) { ··· 137 136 */ 138 137 iters[last_stored == i ? num_iters - 1 : num_iters++] = elem; 139 138 last_stored = i; 139 + if (min == GET_ID(id)) 140 + equal_min++; 141 + else 142 + equal_min = 1; 140 143 min = GET_ID(id); 141 144 } 142 145 ··· 151 146 * Therefore, we need to clean the beginning of the array to make sure 152 147 * all ids of final elements are equal to min. 153 148 */ 154 - for (i = num_iters - 1; i >= 0 && 155 - GET_ID(*(u16 *)(iters[i] + id_offset)) == min; i--) 156 - ; 157 - 158 - num_iters -= i + 1; 159 - memmove(iters, iters + i + 1, sizeof(*iters) * num_iters); 149 + memmove(iters, iters + num_iters - equal_min, sizeof(*iters) * equal_min); 160 150 161 151 *min_id = min; 162 - return num_iters; 152 + return equal_min; 163 153 } 164 154 165 155 #define find_max_element_entry_id(num_elements, elements, num_objects_fld, \ ··· 322 322 hash = kzalloc(sizeof(*hash) + 323 323 ALIGN(sizeof(*hash->attrs) * (attr_max_bucket + 1), 324 324 sizeof(long)) + 325 - BITS_TO_LONGS(attr_max_bucket) * sizeof(long), 325 + BITS_TO_LONGS(attr_max_bucket + 1) * sizeof(long), 326 326 GFP_KERNEL); 327 327 if (!hash) { 328 328 res = -ENOMEM; ··· 509 509 * first handler which != NULL. This also defines the 510 510 * set of flags used for this handler. 511 511 */ 512 - for (i = num_object_defs - 1; 512 + for (i = num_method_defs - 1; 513 513 i >= 0 && !method_defs[i]->handler; i--) 514 514 ; 515 515 hash->methods[min_id++] = method;
+22 -7
drivers/infiniband/core/uverbs_main.c
··· 650 650 return -1; 651 651 } 652 652 653 + static bool verify_command_idx(u32 command, bool extended) 654 + { 655 + if (extended) 656 + return command < ARRAY_SIZE(uverbs_ex_cmd_table); 657 + 658 + return command < ARRAY_SIZE(uverbs_cmd_table); 659 + } 660 + 653 661 static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, 654 662 size_t count, loff_t *pos) 655 663 { 656 664 struct ib_uverbs_file *file = filp->private_data; 657 665 struct ib_device *ib_dev; 658 666 struct ib_uverbs_cmd_hdr hdr; 667 + bool extended_command; 659 668 __u32 command; 660 669 __u32 flags; 661 670 int srcu_key; ··· 697 688 } 698 689 699 690 command = hdr.command & IB_USER_VERBS_CMD_COMMAND_MASK; 691 + flags = (hdr.command & 692 + IB_USER_VERBS_CMD_FLAGS_MASK) >> IB_USER_VERBS_CMD_FLAGS_SHIFT; 693 + 694 + extended_command = flags & IB_USER_VERBS_CMD_FLAG_EXTENDED; 695 + if (!verify_command_idx(command, extended_command)) { 696 + ret = -EINVAL; 697 + goto out; 698 + } 699 + 700 700 if (verify_command_mask(ib_dev, command)) { 701 701 ret = -EOPNOTSUPP; 702 702 goto out; ··· 717 699 goto out; 718 700 } 719 701 720 - flags = (hdr.command & 721 - IB_USER_VERBS_CMD_FLAGS_MASK) >> IB_USER_VERBS_CMD_FLAGS_SHIFT; 722 - 723 702 if (!flags) { 724 - if (command >= ARRAY_SIZE(uverbs_cmd_table) || 725 - !uverbs_cmd_table[command]) { 703 + if (!uverbs_cmd_table[command]) { 726 704 ret = -EINVAL; 727 705 goto out; 728 706 } ··· 739 725 struct ib_udata uhw; 740 726 size_t written_count = count; 741 727 742 - if (command >= ARRAY_SIZE(uverbs_ex_cmd_table) || 743 - !uverbs_ex_cmd_table[command]) { 728 + if (!uverbs_ex_cmd_table[command]) { 744 729 ret = -ENOSYS; 745 730 goto out; 746 731 } ··· 955 942 .llseek = no_llseek, 956 943 #if IS_ENABLED(CONFIG_INFINIBAND_EXP_USER_ACCESS) 957 944 .unlocked_ioctl = ib_uverbs_ioctl, 945 + .compat_ioctl = ib_uverbs_ioctl, 958 946 #endif 959 947 }; 960 948 ··· 968 954 .llseek = no_llseek, 969 955 #if IS_ENABLED(CONFIG_INFINIBAND_EXP_USER_ACCESS) 970 956 .unlocked_ioctl = ib_uverbs_ioctl, 957 + .compat_ioctl = ib_uverbs_ioctl, 971 958 #endif 972 959 }; 973 960
+8 -4
drivers/infiniband/core/uverbs_std_types.c
··· 234 234 uverbs_attr_get(ctx, UVERBS_UHW_OUT); 235 235 236 236 if (!IS_ERR(uhw_in)) { 237 - udata->inbuf = uhw_in->ptr_attr.ptr; 238 237 udata->inlen = uhw_in->ptr_attr.len; 238 + if (uverbs_attr_ptr_is_inline(uhw_in)) 239 + udata->inbuf = &uhw_in->uattr->data; 240 + else 241 + udata->inbuf = u64_to_user_ptr(uhw_in->ptr_attr.data); 239 242 } else { 240 243 udata->inbuf = NULL; 241 244 udata->inlen = 0; 242 245 } 243 246 244 247 if (!IS_ERR(uhw_out)) { 245 - udata->outbuf = uhw_out->ptr_attr.ptr; 248 + udata->outbuf = u64_to_user_ptr(uhw_out->ptr_attr.data); 246 249 udata->outlen = uhw_out->ptr_attr.len; 247 250 } else { 248 251 udata->outbuf = NULL; ··· 326 323 cq->res.type = RDMA_RESTRACK_CQ; 327 324 rdma_restrack_add(&cq->res); 328 325 329 - ret = uverbs_copy_to(attrs, CREATE_CQ_RESP_CQE, &cq->cqe); 326 + ret = uverbs_copy_to(attrs, CREATE_CQ_RESP_CQE, &cq->cqe, 327 + sizeof(cq->cqe)); 330 328 if (ret) 331 329 goto err_cq; 332 330 ··· 379 375 resp.comp_events_reported = obj->comp_events_reported; 380 376 resp.async_events_reported = obj->async_events_reported; 381 377 382 - return uverbs_copy_to(attrs, DESTROY_CQ_RESP, &resp); 378 + return uverbs_copy_to(attrs, DESTROY_CQ_RESP, &resp, sizeof(resp)); 383 379 } 384 380 385 381 static DECLARE_UVERBS_METHOD(
+1 -2
drivers/infiniband/core/verbs.c
··· 887 887 if (qp_init_attr->cap.max_rdma_ctxs) 888 888 rdma_rw_init_qp(device, qp_init_attr); 889 889 890 - qp = _ib_create_qp(device, pd, qp_init_attr, NULL); 890 + qp = _ib_create_qp(device, pd, qp_init_attr, NULL, NULL); 891 891 if (IS_ERR(qp)) 892 892 return qp; 893 893 ··· 898 898 } 899 899 900 900 qp->real_qp = qp; 901 - qp->uobject = NULL; 902 901 qp->qp_type = qp_init_attr->qp_type; 903 902 qp->rwq_ind_tbl = qp_init_attr->rwq_ind_tbl; 904 903
+1 -1
drivers/infiniband/hw/bnxt_re/bnxt_re.h
··· 120 120 #define BNXT_RE_FLAG_HAVE_L2_REF 3 121 121 #define BNXT_RE_FLAG_RCFW_CHANNEL_EN 4 122 122 #define BNXT_RE_FLAG_QOS_WORK_REG 5 123 - #define BNXT_RE_FLAG_TASK_IN_PROG 6 124 123 #define BNXT_RE_FLAG_ISSUE_ROCE_STATS 29 125 124 struct net_device *netdev; 126 125 unsigned int version, major, minor; ··· 157 158 atomic_t srq_count; 158 159 atomic_t mr_count; 159 160 atomic_t mw_count; 161 + atomic_t sched_count; 160 162 /* Max of 2 lossless traffic class supported per port */ 161 163 u16 cosq[2]; 162 164
+46 -8
drivers/infiniband/hw/bnxt_re/ib_verbs.c
··· 174 174 ib_attr->max_pd = dev_attr->max_pd; 175 175 ib_attr->max_qp_rd_atom = dev_attr->max_qp_rd_atom; 176 176 ib_attr->max_qp_init_rd_atom = dev_attr->max_qp_init_rd_atom; 177 - if (dev_attr->is_atomic) { 178 - ib_attr->atomic_cap = IB_ATOMIC_HCA; 179 - ib_attr->masked_atomic_cap = IB_ATOMIC_HCA; 180 - } 177 + ib_attr->atomic_cap = IB_ATOMIC_NONE; 178 + ib_attr->masked_atomic_cap = IB_ATOMIC_NONE; 181 179 182 180 ib_attr->max_ee_rd_atom = 0; 183 181 ib_attr->max_res_rd_atom = 0; ··· 785 787 return 0; 786 788 } 787 789 790 + static unsigned long bnxt_re_lock_cqs(struct bnxt_re_qp *qp) 791 + __acquires(&qp->scq->cq_lock) __acquires(&qp->rcq->cq_lock) 792 + { 793 + unsigned long flags; 794 + 795 + spin_lock_irqsave(&qp->scq->cq_lock, flags); 796 + if (qp->rcq != qp->scq) 797 + spin_lock(&qp->rcq->cq_lock); 798 + else 799 + __acquire(&qp->rcq->cq_lock); 800 + 801 + return flags; 802 + } 803 + 804 + static void bnxt_re_unlock_cqs(struct bnxt_re_qp *qp, 805 + unsigned long flags) 806 + __releases(&qp->scq->cq_lock) __releases(&qp->rcq->cq_lock) 807 + { 808 + if (qp->rcq != qp->scq) 809 + spin_unlock(&qp->rcq->cq_lock); 810 + else 811 + __release(&qp->rcq->cq_lock); 812 + spin_unlock_irqrestore(&qp->scq->cq_lock, flags); 813 + } 814 + 788 815 /* Queue Pairs */ 789 816 int bnxt_re_destroy_qp(struct ib_qp *ib_qp) 790 817 { 791 818 struct bnxt_re_qp *qp = container_of(ib_qp, struct bnxt_re_qp, ib_qp); 792 819 struct bnxt_re_dev *rdev = qp->rdev; 793 820 int rc; 821 + unsigned int flags; 794 822 795 823 bnxt_qplib_flush_cqn_wq(&qp->qplib_qp); 796 - bnxt_qplib_del_flush_qp(&qp->qplib_qp); 797 824 rc = bnxt_qplib_destroy_qp(&rdev->qplib_res, &qp->qplib_qp); 798 825 if (rc) { 799 826 dev_err(rdev_to_dev(rdev), "Failed to destroy HW QP"); 800 827 return rc; 801 828 } 829 + 830 + flags = bnxt_re_lock_cqs(qp); 831 + bnxt_qplib_clean_qp(&qp->qplib_qp); 832 + bnxt_re_unlock_cqs(qp, flags); 833 + bnxt_qplib_free_qp_res(&rdev->qplib_res, &qp->qplib_qp); 834 + 802 835 if (ib_qp->qp_type == IB_QPT_GSI && rdev->qp1_sqp) { 803 836 rc = bnxt_qplib_destroy_ah(&rdev->qplib_res, 804 837 &rdev->sqp_ah->qplib_ah); ··· 839 810 return rc; 840 811 } 841 812 842 - bnxt_qplib_del_flush_qp(&qp->qplib_qp); 813 + bnxt_qplib_clean_qp(&qp->qplib_qp); 843 814 rc = bnxt_qplib_destroy_qp(&rdev->qplib_res, 844 815 &rdev->qp1_sqp->qplib_qp); 845 816 if (rc) { ··· 1098 1069 goto fail; 1099 1070 } 1100 1071 qp->qplib_qp.scq = &cq->qplib_cq; 1072 + qp->scq = cq; 1101 1073 } 1102 1074 1103 1075 if (qp_init_attr->recv_cq) { ··· 1110 1080 goto fail; 1111 1081 } 1112 1082 qp->qplib_qp.rcq = &cq->qplib_cq; 1083 + qp->rcq = cq; 1113 1084 } 1114 1085 1115 1086 if (qp_init_attr->srq) { ··· 1216 1185 rc = bnxt_qplib_create_qp(&rdev->qplib_res, &qp->qplib_qp); 1217 1186 if (rc) { 1218 1187 dev_err(rdev_to_dev(rdev), "Failed to create HW QP"); 1219 - goto fail; 1188 + goto free_umem; 1220 1189 } 1221 1190 } 1222 1191 ··· 1244 1213 return &qp->ib_qp; 1245 1214 qp_destroy: 1246 1215 bnxt_qplib_destroy_qp(&rdev->qplib_res, &qp->qplib_qp); 1216 + free_umem: 1217 + if (udata) { 1218 + if (qp->rumem) 1219 + ib_umem_release(qp->rumem); 1220 + if (qp->sumem) 1221 + ib_umem_release(qp->sumem); 1222 + } 1247 1223 fail: 1248 1224 kfree(qp); 1249 1225 return ERR_PTR(rc); ··· 1641 1603 dev_dbg(rdev_to_dev(rdev), 1642 1604 "Move QP = %p out of flush list\n", 1643 1605 qp); 1644 - bnxt_qplib_del_flush_qp(&qp->qplib_qp); 1606 + bnxt_qplib_clean_qp(&qp->qplib_qp); 1645 1607 } 1646 1608 } 1647 1609 if (qp_attr_mask & IB_QP_EN_SQD_ASYNC_NOTIFY) {
+2
drivers/infiniband/hw/bnxt_re/ib_verbs.h
··· 89 89 /* QP1 */ 90 90 u32 send_psn; 91 91 struct ib_ud_header qp1_hdr; 92 + struct bnxt_re_cq *scq; 93 + struct bnxt_re_cq *rcq; 92 94 }; 93 95 94 96 struct bnxt_re_cq {
+8 -4
drivers/infiniband/hw/bnxt_re/main.c
··· 656 656 mutex_unlock(&bnxt_re_dev_lock); 657 657 658 658 synchronize_rcu(); 659 - flush_workqueue(bnxt_re_wq); 660 659 661 660 ib_dealloc_device(&rdev->ibdev); 662 661 /* rdev is gone */ ··· 1440 1441 break; 1441 1442 } 1442 1443 smp_mb__before_atomic(); 1443 - clear_bit(BNXT_RE_FLAG_TASK_IN_PROG, &rdev->flags); 1444 + atomic_dec(&rdev->sched_count); 1444 1445 kfree(re_work); 1445 1446 } 1446 1447 ··· 1502 1503 /* netdev notifier will call NETDEV_UNREGISTER again later since 1503 1504 * we are still holding the reference to the netdev 1504 1505 */ 1505 - if (test_bit(BNXT_RE_FLAG_TASK_IN_PROG, &rdev->flags)) 1506 + if (atomic_read(&rdev->sched_count) > 0) 1506 1507 goto exit; 1507 1508 bnxt_re_ib_unreg(rdev, false); 1508 1509 bnxt_re_remove_one(rdev); ··· 1522 1523 re_work->vlan_dev = (real_dev == netdev ? 1523 1524 NULL : netdev); 1524 1525 INIT_WORK(&re_work->work, bnxt_re_task); 1525 - set_bit(BNXT_RE_FLAG_TASK_IN_PROG, &rdev->flags); 1526 + atomic_inc(&rdev->sched_count); 1526 1527 queue_work(bnxt_re_wq, &re_work->work); 1527 1528 } 1528 1529 } ··· 1577 1578 */ 1578 1579 list_for_each_entry_safe_reverse(rdev, next, &to_be_deleted, list) { 1579 1580 dev_info(rdev_to_dev(rdev), "Unregistering Device"); 1581 + /* 1582 + * Flush out any scheduled tasks before destroying the 1583 + * resources 1584 + */ 1585 + flush_workqueue(bnxt_re_wq); 1580 1586 bnxt_re_dev_stop(rdev); 1581 1587 bnxt_re_ib_unreg(rdev, true); 1582 1588 bnxt_re_remove_one(rdev);
+6 -15
drivers/infiniband/hw/bnxt_re/qplib_fp.c
··· 173 173 } 174 174 } 175 175 176 - void bnxt_qplib_del_flush_qp(struct bnxt_qplib_qp *qp) 176 + void bnxt_qplib_clean_qp(struct bnxt_qplib_qp *qp) 177 177 { 178 178 unsigned long flags; 179 179 ··· 1419 1419 struct bnxt_qplib_rcfw *rcfw = res->rcfw; 1420 1420 struct cmdq_destroy_qp req; 1421 1421 struct creq_destroy_qp_resp resp; 1422 - unsigned long flags; 1423 1422 u16 cmd_flags = 0; 1424 1423 int rc; 1425 1424 ··· 1436 1437 return rc; 1437 1438 } 1438 1439 1439 - /* Must walk the associated CQs to nullified the QP ptr */ 1440 - spin_lock_irqsave(&qp->scq->hwq.lock, flags); 1440 + return 0; 1441 + } 1441 1442 1442 - __clean_cq(qp->scq, (u64)(unsigned long)qp); 1443 - 1444 - if (qp->rcq && qp->rcq != qp->scq) { 1445 - spin_lock(&qp->rcq->hwq.lock); 1446 - __clean_cq(qp->rcq, (u64)(unsigned long)qp); 1447 - spin_unlock(&qp->rcq->hwq.lock); 1448 - } 1449 - 1450 - spin_unlock_irqrestore(&qp->scq->hwq.lock, flags); 1451 - 1443 + void bnxt_qplib_free_qp_res(struct bnxt_qplib_res *res, 1444 + struct bnxt_qplib_qp *qp) 1445 + { 1452 1446 bnxt_qplib_free_qp_hdr_buf(res, qp); 1453 1447 bnxt_qplib_free_hwq(res->pdev, &qp->sq.hwq); 1454 1448 kfree(qp->sq.swq); ··· 1454 1462 if (qp->orrq.max_elements) 1455 1463 bnxt_qplib_free_hwq(res->pdev, &qp->orrq); 1456 1464 1457 - return 0; 1458 1465 } 1459 1466 1460 1467 void *bnxt_qplib_get_qp1_sq_buf(struct bnxt_qplib_qp *qp,
+3 -1
drivers/infiniband/hw/bnxt_re/qplib_fp.h
··· 478 478 int bnxt_qplib_modify_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp); 479 479 int bnxt_qplib_query_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp); 480 480 int bnxt_qplib_destroy_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp); 481 + void bnxt_qplib_clean_qp(struct bnxt_qplib_qp *qp); 482 + void bnxt_qplib_free_qp_res(struct bnxt_qplib_res *res, 483 + struct bnxt_qplib_qp *qp); 481 484 void *bnxt_qplib_get_qp1_sq_buf(struct bnxt_qplib_qp *qp, 482 485 struct bnxt_qplib_sge *sge); 483 486 void *bnxt_qplib_get_qp1_rq_buf(struct bnxt_qplib_qp *qp, ··· 503 500 void bnxt_qplib_free_nq(struct bnxt_qplib_nq *nq); 504 501 int bnxt_qplib_alloc_nq(struct pci_dev *pdev, struct bnxt_qplib_nq *nq); 505 502 void bnxt_qplib_add_flush_qp(struct bnxt_qplib_qp *qp); 506 - void bnxt_qplib_del_flush_qp(struct bnxt_qplib_qp *qp); 507 503 void bnxt_qplib_acquire_cq_locks(struct bnxt_qplib_qp *qp, 508 504 unsigned long *flags); 509 505 void bnxt_qplib_release_cq_locks(struct bnxt_qplib_qp *qp,
+1 -13
drivers/infiniband/hw/bnxt_re/qplib_sp.c
··· 52 52 53 53 /* Device */ 54 54 55 - static bool bnxt_qplib_is_atomic_cap(struct bnxt_qplib_rcfw *rcfw) 56 - { 57 - int rc; 58 - u16 pcie_ctl2; 59 - 60 - rc = pcie_capability_read_word(rcfw->pdev, PCI_EXP_DEVCTL2, 61 - &pcie_ctl2); 62 - if (rc) 63 - return false; 64 - return !!(pcie_ctl2 & PCI_EXP_DEVCTL2_ATOMIC_REQ); 65 - } 66 - 67 55 static void bnxt_qplib_query_version(struct bnxt_qplib_rcfw *rcfw, 68 56 char *fw_ver) 69 57 { ··· 153 165 attr->tqm_alloc_reqs[i * 4 + 3] = *(++tqm_alloc); 154 166 } 155 167 156 - attr->is_atomic = bnxt_qplib_is_atomic_cap(rcfw); 168 + attr->is_atomic = 0; 157 169 bail: 158 170 bnxt_qplib_rcfw_free_sbuf(rcfw, sbuf); 159 171 return rc;
+3 -1
drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c
··· 114 114 union pvrdma_cmd_resp rsp; 115 115 struct pvrdma_cmd_create_cq *cmd = &req.create_cq; 116 116 struct pvrdma_cmd_create_cq_resp *resp = &rsp.create_cq_resp; 117 + struct pvrdma_create_cq_resp cq_resp = {0}; 117 118 struct pvrdma_create_cq ucmd; 118 119 119 120 BUILD_BUG_ON(sizeof(struct pvrdma_cqe) != 64); ··· 198 197 199 198 cq->ibcq.cqe = resp->cqe; 200 199 cq->cq_handle = resp->cq_handle; 200 + cq_resp.cqn = resp->cq_handle; 201 201 spin_lock_irqsave(&dev->cq_tbl_lock, flags); 202 202 dev->cq_tbl[cq->cq_handle % dev->dsr->caps.max_cq] = cq; 203 203 spin_unlock_irqrestore(&dev->cq_tbl_lock, flags); ··· 207 205 cq->uar = &(to_vucontext(context)->uar); 208 206 209 207 /* Copy udata back. */ 210 - if (ib_copy_to_udata(udata, &cq->cq_handle, sizeof(__u32))) { 208 + if (ib_copy_to_udata(udata, &cq_resp, sizeof(cq_resp))) { 211 209 dev_warn(&dev->pdev->dev, 212 210 "failed to copy back udata\n"); 213 211 pvrdma_destroy_cq(&cq->ibcq);
+3 -1
drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c
··· 113 113 union pvrdma_cmd_resp rsp; 114 114 struct pvrdma_cmd_create_srq *cmd = &req.create_srq; 115 115 struct pvrdma_cmd_create_srq_resp *resp = &rsp.create_srq_resp; 116 + struct pvrdma_create_srq_resp srq_resp = {0}; 116 117 struct pvrdma_create_srq ucmd; 117 118 unsigned long flags; 118 119 int ret; ··· 205 204 } 206 205 207 206 srq->srq_handle = resp->srqn; 207 + srq_resp.srqn = resp->srqn; 208 208 spin_lock_irqsave(&dev->srq_tbl_lock, flags); 209 209 dev->srq_tbl[srq->srq_handle % dev->dsr->caps.max_srq] = srq; 210 210 spin_unlock_irqrestore(&dev->srq_tbl_lock, flags); 211 211 212 212 /* Copy udata back. */ 213 - if (ib_copy_to_udata(udata, &srq->srq_handle, sizeof(__u32))) { 213 + if (ib_copy_to_udata(udata, &srq_resp, sizeof(srq_resp))) { 214 214 dev_warn(&dev->pdev->dev, "failed to copy back udata\n"); 215 215 pvrdma_destroy_srq(&srq->ibsrq); 216 216 return ERR_PTR(-EINVAL);
+3 -1
drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c
··· 447 447 union pvrdma_cmd_resp rsp; 448 448 struct pvrdma_cmd_create_pd *cmd = &req.create_pd; 449 449 struct pvrdma_cmd_create_pd_resp *resp = &rsp.create_pd_resp; 450 + struct pvrdma_alloc_pd_resp pd_resp = {0}; 450 451 int ret; 451 452 void *ptr; 452 453 ··· 476 475 pd->privileged = !context; 477 476 pd->pd_handle = resp->pd_handle; 478 477 pd->pdn = resp->pd_handle; 478 + pd_resp.pdn = resp->pd_handle; 479 479 480 480 if (context) { 481 - if (ib_copy_to_udata(udata, &pd->pdn, sizeof(__u32))) { 481 + if (ib_copy_to_udata(udata, &pd_resp, sizeof(pd_resp))) { 482 482 dev_warn(&dev->pdev->dev, 483 483 "failed to copy back protection domain\n"); 484 484 pvrdma_dealloc_pd(&pd->ibpd);
-2
drivers/infiniband/ulp/ipoib/ipoib_fs.c
··· 281 281 { 282 282 struct ipoib_dev_priv *priv = ipoib_priv(dev); 283 283 284 - WARN_ONCE(!priv->mcg_dentry, "null mcg debug file\n"); 285 - WARN_ONCE(!priv->path_dentry, "null path debug file\n"); 286 284 debugfs_remove(priv->mcg_dentry); 287 285 debugfs_remove(priv->path_dentry); 288 286 priv->mcg_dentry = priv->path_dentry = NULL;
+2
drivers/message/fusion/mptctl.c
··· 2687 2687 __FILE__, __LINE__, iocnum); 2688 2688 return -ENODEV; 2689 2689 } 2690 + if (karg.hdr.id >= MPT_MAX_FC_DEVICES) 2691 + return -EINVAL; 2690 2692 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_hp_targetinfo called.\n", 2691 2693 ioc->name)); 2692 2694
-6
drivers/misc/mei/bus.c
··· 548 548 goto out; 549 549 } 550 550 551 - if (bus->dev_state == MEI_DEV_POWER_DOWN) { 552 - dev_dbg(bus->dev, "Device is powering down, don't bother with disconnection\n"); 553 - err = 0; 554 - goto out; 555 - } 556 - 557 551 err = mei_cl_disconnect(cl); 558 552 if (err < 0) 559 553 dev_err(bus->dev, "Could not disconnect from the ME client\n");
+6
drivers/misc/mei/client.c
··· 945 945 return 0; 946 946 } 947 947 948 + if (dev->dev_state == MEI_DEV_POWER_DOWN) { 949 + cl_dbg(dev, cl, "Device is powering down, don't bother with disconnection\n"); 950 + mei_cl_set_disconnected(cl); 951 + return 0; 952 + } 953 + 948 954 rets = pm_runtime_get(dev->dev); 949 955 if (rets < 0 && rets != -EINPROGRESS) { 950 956 pm_runtime_put_noidle(dev->dev);
+5
drivers/misc/mei/hw-me-regs.h
··· 132 132 #define MEI_DEV_ID_KBP 0xA2BA /* Kaby Point */ 133 133 #define MEI_DEV_ID_KBP_2 0xA2BB /* Kaby Point 2 */ 134 134 135 + #define MEI_DEV_ID_CNP_LP 0x9DE0 /* Cannon Point LP */ 136 + #define MEI_DEV_ID_CNP_LP_4 0x9DE4 /* Cannon Point LP 4 (iTouch) */ 137 + #define MEI_DEV_ID_CNP_H 0xA360 /* Cannon Point H */ 138 + #define MEI_DEV_ID_CNP_H_4 0xA364 /* Cannon Point H 4 (iTouch) */ 139 + 135 140 /* 136 141 * MEI HW Section 137 142 */
+5
drivers/misc/mei/pci-me.c
··· 98 98 {MEI_PCI_DEVICE(MEI_DEV_ID_KBP, MEI_ME_PCH8_CFG)}, 99 99 {MEI_PCI_DEVICE(MEI_DEV_ID_KBP_2, MEI_ME_PCH8_CFG)}, 100 100 101 + {MEI_PCI_DEVICE(MEI_DEV_ID_CNP_LP, MEI_ME_PCH8_CFG)}, 102 + {MEI_PCI_DEVICE(MEI_DEV_ID_CNP_LP_4, MEI_ME_PCH8_CFG)}, 103 + {MEI_PCI_DEVICE(MEI_DEV_ID_CNP_H, MEI_ME_PCH8_CFG)}, 104 + {MEI_PCI_DEVICE(MEI_DEV_ID_CNP_H_4, MEI_ME_PCH8_CFG)}, 105 + 101 106 /* required last entry */ 102 107 {0, } 103 108 };
+2
drivers/net/ethernet/amd/xgbe/xgbe-pci.c
··· 426 426 struct net_device *netdev = pdata->netdev; 427 427 int ret = 0; 428 428 429 + XP_IOWRITE(pdata, XP_INT_EN, 0x1fffff); 430 + 429 431 pdata->lpm_ctrl &= ~MDIO_CTRL1_LPOWER; 430 432 XMDIO_WRITE(pdata, MDIO_MMD_PCS, MDIO_CTRL1, pdata->lpm_ctrl); 431 433
+10 -4
drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c
··· 226 226 goto err_ioremap; 227 227 228 228 self->aq_hw = kzalloc(sizeof(*self->aq_hw), GFP_KERNEL); 229 + if (!self->aq_hw) { 230 + err = -ENOMEM; 231 + goto err_ioremap; 232 + } 229 233 self->aq_hw->aq_nic_cfg = aq_nic_get_cfg(self); 230 234 231 235 for (bar = 0; bar < 4; ++bar) { ··· 239 235 mmio_pa = pci_resource_start(pdev, bar); 240 236 if (mmio_pa == 0U) { 241 237 err = -EIO; 242 - goto err_ioremap; 238 + goto err_free_aq_hw; 243 239 } 244 240 245 241 reg_sz = pci_resource_len(pdev, bar); 246 242 if ((reg_sz <= 24 /*ATL_REGS_SIZE*/)) { 247 243 err = -EIO; 248 - goto err_ioremap; 244 + goto err_free_aq_hw; 249 245 } 250 246 251 247 self->aq_hw->mmio = ioremap_nocache(mmio_pa, reg_sz); 252 248 if (!self->aq_hw->mmio) { 253 249 err = -EIO; 254 - goto err_ioremap; 250 + goto err_free_aq_hw; 255 251 } 256 252 break; 257 253 } ··· 259 255 260 256 if (bar == 4) { 261 257 err = -EIO; 262 - goto err_ioremap; 258 + goto err_free_aq_hw; 263 259 } 264 260 265 261 numvecs = min((u8)AQ_CFG_VECS_DEF, ··· 294 290 aq_pci_free_irq_vectors(self); 295 291 err_hwinit: 296 292 iounmap(self->aq_hw->mmio); 293 + err_free_aq_hw: 294 + kfree(self->aq_hw); 297 295 err_ioremap: 298 296 free_netdev(ndev); 299 297 err_pci_func:
+7 -16
drivers/net/ethernet/freescale/gianfar.c
··· 2934 2934 { 2935 2935 int size = lstatus & BD_LENGTH_MASK; 2936 2936 struct page *page = rxb->page; 2937 - bool last = !!(lstatus & BD_LFLAG(RXBD_LAST)); 2938 - 2939 - /* Remove the FCS from the packet length */ 2940 - if (last) 2941 - size -= ETH_FCS_LEN; 2942 2937 2943 2938 if (likely(first)) { 2944 2939 skb_put(skb, size); 2945 2940 } else { 2946 2941 /* the last fragments' length contains the full frame length */ 2947 - if (last) 2942 + if (lstatus & BD_LFLAG(RXBD_LAST)) 2948 2943 size -= skb->len; 2949 2944 2950 - /* Add the last fragment if it contains something other than 2951 - * the FCS, otherwise drop it and trim off any part of the FCS 2952 - * that was already received. 2953 - */ 2954 - if (size > 0) 2955 - skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page, 2956 - rxb->page_offset + RXBUF_ALIGNMENT, 2957 - size, GFAR_RXB_TRUESIZE); 2958 - else if (size < 0) 2959 - pskb_trim(skb, skb->len + size); 2945 + skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page, 2946 + rxb->page_offset + RXBUF_ALIGNMENT, 2947 + size, GFAR_RXB_TRUESIZE); 2960 2948 } 2961 2949 2962 2950 /* try reuse page */ ··· 3056 3068 3057 3069 if (priv->padding) 3058 3070 skb_pull(skb, priv->padding); 3071 + 3072 + /* Trim off the FCS */ 3073 + pskb_trim(skb, skb->len - ETH_FCS_LEN); 3059 3074 3060 3075 if (ndev->features & NETIF_F_RXCSUM) 3061 3076 gfar_rx_checksum(skb, fcb);
+6 -1
drivers/net/ethernet/ibm/ibmvnic.c
··· 1920 1920 dev_kfree_skb_any(rx_buff->skb); 1921 1921 remove_buff_from_pool(adapter, rx_buff); 1922 1922 continue; 1923 + } else if (!rx_buff->skb) { 1924 + /* free the entry */ 1925 + next->rx_comp.first = 0; 1926 + remove_buff_from_pool(adapter, rx_buff); 1927 + continue; 1923 1928 } 1924 1929 1925 1930 length = be32_to_cpu(next->rx_comp.len); ··· 3791 3786 3792 3787 dma_unmap_single(dev, adapter->login_buf_token, adapter->login_buf_sz, 3793 3788 DMA_BIDIRECTIONAL); 3794 - release_login_buffer(adapter); 3795 3789 dma_unmap_single(dev, adapter->login_rsp_buf_token, 3796 3790 adapter->login_rsp_buf_sz, DMA_BIDIRECTIONAL); 3797 3791 ··· 3821 3817 ibmvnic_remove(adapter->vdev); 3822 3818 return -EIO; 3823 3819 } 3820 + release_login_buffer(adapter); 3824 3821 complete(&adapter->init_done); 3825 3822 3826 3823 return 0;
+4 -4
drivers/net/ethernet/mellanox/mlx5/core/diag/fs_tracepoint.c
··· 96 96 "%pI4"); 97 97 } else if (ethertype.v == ETH_P_IPV6) { 98 98 static const struct in6_addr full_ones = { 99 - .in6_u.u6_addr32 = {htonl(0xffffffff), 100 - htonl(0xffffffff), 101 - htonl(0xffffffff), 102 - htonl(0xffffffff)}, 99 + .in6_u.u6_addr32 = {__constant_htonl(0xffffffff), 100 + __constant_htonl(0xffffffff), 101 + __constant_htonl(0xffffffff), 102 + __constant_htonl(0xffffffff)}, 103 103 }; 104 104 DECLARE_MASK_VAL(struct in6_addr, src_ipv6); 105 105 DECLARE_MASK_VAL(struct in6_addr, dst_ipv6);
+10 -4
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
··· 1768 1768 param->wq.linear = 1; 1769 1769 } 1770 1770 1771 - static void mlx5e_build_drop_rq_param(struct mlx5e_rq_param *param) 1771 + static void mlx5e_build_drop_rq_param(struct mlx5_core_dev *mdev, 1772 + struct mlx5e_rq_param *param) 1772 1773 { 1773 1774 void *rqc = param->rqc; 1774 1775 void *wq = MLX5_ADDR_OF(rqc, rqc, wq); 1775 1776 1776 1777 MLX5_SET(wq, wq, wq_type, MLX5_WQ_TYPE_LINKED_LIST); 1777 1778 MLX5_SET(wq, wq, log_wq_stride, ilog2(sizeof(struct mlx5e_rx_wqe))); 1779 + 1780 + param->wq.buf_numa_node = dev_to_node(&mdev->pdev->dev); 1778 1781 } 1779 1782 1780 1783 static void mlx5e_build_sq_param_common(struct mlx5e_priv *priv, ··· 2637 2634 struct mlx5e_cq *cq, 2638 2635 struct mlx5e_cq_param *param) 2639 2636 { 2637 + param->wq.buf_numa_node = dev_to_node(&mdev->pdev->dev); 2638 + param->wq.db_numa_node = dev_to_node(&mdev->pdev->dev); 2639 + 2640 2640 return mlx5e_alloc_cq_common(mdev, param, cq); 2641 2641 } 2642 2642 ··· 2651 2645 struct mlx5e_cq *cq = &drop_rq->cq; 2652 2646 int err; 2653 2647 2654 - mlx5e_build_drop_rq_param(&rq_param); 2648 + mlx5e_build_drop_rq_param(mdev, &rq_param); 2655 2649 2656 2650 err = mlx5e_alloc_drop_cq(mdev, cq, &cq_param); 2657 2651 if (err) ··· 3000 2994 } 3001 2995 #endif 3002 2996 3003 - int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type, 3004 - void *type_data) 2997 + static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type, 2998 + void *type_data) 3005 2999 { 3006 3000 switch (type) { 3007 3001 #ifdef CONFIG_MLX5_ESWITCH
+34 -13
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
··· 36 36 #include <linux/tcp.h> 37 37 #include <linux/bpf_trace.h> 38 38 #include <net/busy_poll.h> 39 + #include <net/ip6_checksum.h> 39 40 #include "en.h" 40 41 #include "en_tc.h" 41 42 #include "eswitch.h" ··· 548 547 return true; 549 548 } 550 549 550 + static void mlx5e_lro_update_tcp_hdr(struct mlx5_cqe64 *cqe, struct tcphdr *tcp) 551 + { 552 + u8 l4_hdr_type = get_cqe_l4_hdr_type(cqe); 553 + u8 tcp_ack = (l4_hdr_type == CQE_L4_HDR_TYPE_TCP_ACK_NO_DATA) || 554 + (l4_hdr_type == CQE_L4_HDR_TYPE_TCP_ACK_AND_DATA); 555 + 556 + tcp->check = 0; 557 + tcp->psh = get_cqe_lro_tcppsh(cqe); 558 + 559 + if (tcp_ack) { 560 + tcp->ack = 1; 561 + tcp->ack_seq = cqe->lro_ack_seq_num; 562 + tcp->window = cqe->lro_tcp_win; 563 + } 564 + } 565 + 551 566 static void mlx5e_lro_update_hdr(struct sk_buff *skb, struct mlx5_cqe64 *cqe, 552 567 u32 cqe_bcnt) 553 568 { 554 569 struct ethhdr *eth = (struct ethhdr *)(skb->data); 555 570 struct tcphdr *tcp; 556 571 int network_depth = 0; 572 + __wsum check; 557 573 __be16 proto; 558 574 u16 tot_len; 559 575 void *ip_p; 560 - 561 - u8 l4_hdr_type = get_cqe_l4_hdr_type(cqe); 562 - u8 tcp_ack = (l4_hdr_type == CQE_L4_HDR_TYPE_TCP_ACK_NO_DATA) || 563 - (l4_hdr_type == CQE_L4_HDR_TYPE_TCP_ACK_AND_DATA); 564 576 565 577 proto = __vlan_get_protocol(skb, eth->h_proto, &network_depth); 566 578 ··· 591 577 ipv4->check = 0; 592 578 ipv4->check = ip_fast_csum((unsigned char *)ipv4, 593 579 ipv4->ihl); 580 + 581 + mlx5e_lro_update_tcp_hdr(cqe, tcp); 582 + check = csum_partial(tcp, tcp->doff * 4, 583 + csum_unfold((__force __sum16)cqe->check_sum)); 584 + /* Almost done, don't forget the pseudo header */ 585 + tcp->check = csum_tcpudp_magic(ipv4->saddr, ipv4->daddr, 586 + tot_len - sizeof(struct iphdr), 587 + IPPROTO_TCP, check); 594 588 } else { 589 + u16 payload_len = tot_len - sizeof(struct ipv6hdr); 595 590 struct ipv6hdr *ipv6 = ip_p; 596 591 597 592 tcp = ip_p + sizeof(struct ipv6hdr); 598 593 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6; 599 594 600 595 ipv6->hop_limit = cqe->lro_min_ttl; 601 - ipv6->payload_len = cpu_to_be16(tot_len - 602 - sizeof(struct ipv6hdr)); 603 - } 596 + ipv6->payload_len = cpu_to_be16(payload_len); 604 597 605 - tcp->psh = get_cqe_lro_tcppsh(cqe); 606 - 607 - if (tcp_ack) { 608 - tcp->ack = 1; 609 - tcp->ack_seq = cqe->lro_ack_seq_num; 610 - tcp->window = cqe->lro_tcp_win; 598 + mlx5e_lro_update_tcp_hdr(cqe, tcp); 599 + check = csum_partial(tcp, tcp->doff * 4, 600 + csum_unfold((__force __sum16)cqe->check_sum)); 601 + /* Almost done, don't forget the pseudo header */ 602 + tcp->check = csum_ipv6_magic(&ipv6->saddr, &ipv6->daddr, payload_len, 603 + IPPROTO_TCP, check); 611 604 } 612 605 } 613 606
+2 -1
drivers/net/ethernet/mellanox/mlx5/core/en_selftest.c
··· 216 216 if (iph->protocol != IPPROTO_UDP) 217 217 goto out; 218 218 219 - udph = udp_hdr(skb); 219 + /* Don't assume skb_transport_header() was set */ 220 + udph = (struct udphdr *)((u8 *)iph + 4 * iph->ihl); 220 221 if (udph->dest != htons(9)) 221 222 goto out; 222 223
+2 -1
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
··· 2529 2529 if (tcf_vlan_action(a) == TCA_VLAN_ACT_POP) { 2530 2530 attr->action |= MLX5_FLOW_CONTEXT_ACTION_VLAN_POP; 2531 2531 } else if (tcf_vlan_action(a) == TCA_VLAN_ACT_PUSH) { 2532 - if (tcf_vlan_push_proto(a) != htons(ETH_P_8021Q)) 2532 + if (tcf_vlan_push_proto(a) != htons(ETH_P_8021Q) || 2533 + tcf_vlan_push_prio(a)) 2533 2534 return -EOPNOTSUPP; 2534 2535 2535 2536 attr->action |= MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH;
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
··· 176 176 default: 177 177 hlen = mlx5e_skb_l2_header_offset(skb); 178 178 } 179 - return min_t(u16, hlen, skb->len); 179 + return min_t(u16, hlen, skb_headlen(skb)); 180 180 } 181 181 182 182 static inline void mlx5e_tx_skb_pull_inline(unsigned char **skb_data,
+4 -4
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
··· 1529 1529 1530 1530 esw_debug(esw->dev, "Enabling VPORT(%d)\n", vport_num); 1531 1531 1532 + /* Create steering drop counters for ingress and egress ACLs */ 1533 + if (vport_num && esw->mode == SRIOV_LEGACY) 1534 + esw_vport_create_drop_counters(vport); 1535 + 1532 1536 /* Restore old vport configuration */ 1533 1537 esw_apply_vport_conf(esw, vport); 1534 1538 ··· 1548 1544 /* only PF is trusted by default */ 1549 1545 if (!vport_num) 1550 1546 vport->info.trusted = true; 1551 - 1552 - /* create steering drop counters for ingress and egress ACLs */ 1553 - if (vport_num && esw->mode == SRIOV_LEGACY) 1554 - esw_vport_create_drop_counters(vport); 1555 1547 1556 1548 esw_vport_change_handle_locked(vport); 1557 1549
+10 -3
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
··· 1429 1429 1430 1430 if (xored_actions & (MLX5_FLOW_CONTEXT_ACTION_DROP | 1431 1431 MLX5_FLOW_CONTEXT_ACTION_ENCAP | 1432 - MLX5_FLOW_CONTEXT_ACTION_DECAP)) 1432 + MLX5_FLOW_CONTEXT_ACTION_DECAP | 1433 + MLX5_FLOW_CONTEXT_ACTION_MOD_HDR)) 1433 1434 return true; 1434 1435 1435 1436 return false; ··· 1759 1758 1760 1759 /* Collect all fgs which has a matching match_criteria */ 1761 1760 err = build_match_list(&match_head, ft, spec); 1762 - if (err) 1761 + if (err) { 1762 + if (take_write) 1763 + up_write_ref_node(&ft->node); 1763 1764 return ERR_PTR(err); 1765 + } 1764 1766 1765 1767 if (!take_write) 1766 1768 up_read_ref_node(&ft->node); ··· 1772 1768 dest_num, version); 1773 1769 free_match_list(&match_head); 1774 1770 if (!IS_ERR(rule) || 1775 - (PTR_ERR(rule) != -ENOENT && PTR_ERR(rule) != -EAGAIN)) 1771 + (PTR_ERR(rule) != -ENOENT && PTR_ERR(rule) != -EAGAIN)) { 1772 + if (take_write) 1773 + up_write_ref_node(&ft->node); 1776 1774 return rule; 1775 + } 1777 1776 1778 1777 if (!take_write) { 1779 1778 nested_down_write_ref_node(&ft->node, FS_LOCK_GRANDPARENT);
+1
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
··· 34 34 #include <linux/highmem.h> 35 35 #include <rdma/mlx5-abi.h> 36 36 #include "en.h" 37 + #include "clock.h" 37 38 38 39 enum { 39 40 MLX5_CYCLES_SHIFT = 23
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/main.c
··· 551 551 MLX5_SET(cmd_hca_cap, 552 552 set_hca_cap, 553 553 cache_line_128byte, 554 - cache_line_size() == 128 ? 1 : 0); 554 + cache_line_size() >= 128 ? 1 : 0); 555 555 556 556 if (MLX5_CAP_GEN_MAX(dev, dct)) 557 557 MLX5_SET(cmd_hca_cap, set_hca_cap, dct, 1);
+1 -1
drivers/net/ethernet/smsc/Kconfig
··· 20 20 21 21 config SMC9194 22 22 tristate "SMC 9194 support" 23 - depends on (ISA || MAC && BROKEN) 23 + depends on ISA 24 24 select CRC32 25 25 ---help--- 26 26 This is support for the SMC9xxx based Ethernet cards. Choose this
+1 -1
drivers/net/macvlan.c
··· 1451 1451 /* the macvlan port may be freed by macvlan_uninit when fail to register. 1452 1452 * so we destroy the macvlan port only when it's valid. 1453 1453 */ 1454 - if (create && macvlan_port_get_rtnl(dev)) 1454 + if (create && macvlan_port_get_rtnl(lowerdev)) 1455 1455 macvlan_port_destroy(port->dev); 1456 1456 return err; 1457 1457 }
+4 -3
drivers/net/usb/smsc75xx.c
··· 954 954 /* it's racing here! */ 955 955 956 956 ret = smsc75xx_write_reg(dev, RFE_CTL, pdata->rfe_ctl); 957 - if (ret < 0) 957 + if (ret < 0) { 958 958 netdev_warn(dev->net, "Error writing RFE_CTL\n"); 959 - 960 - return ret; 959 + return ret; 960 + } 961 + return 0; 961 962 } 962 963 963 964 static int smsc75xx_wait_ready(struct usbnet *dev, int in_pm)
+34 -24
drivers/net/virtio_net.c
··· 443 443 sg_init_one(sq->sg, xdp->data, xdp->data_end - xdp->data); 444 444 445 445 err = virtqueue_add_outbuf(sq->vq, sq->sg, 1, xdp->data, GFP_ATOMIC); 446 - if (unlikely(err)) { 447 - struct page *page = virt_to_head_page(xdp->data); 448 - 449 - put_page(page); 450 - return false; 451 - } 446 + if (unlikely(err)) 447 + return false; /* Caller handle free/refcnt */ 452 448 453 449 return true; 454 450 } ··· 452 456 static int virtnet_xdp_xmit(struct net_device *dev, struct xdp_buff *xdp) 453 457 { 454 458 struct virtnet_info *vi = netdev_priv(dev); 455 - bool sent = __virtnet_xdp_xmit(vi, xdp); 459 + struct receive_queue *rq = vi->rq; 460 + struct bpf_prog *xdp_prog; 461 + bool sent; 456 462 463 + /* Only allow ndo_xdp_xmit if XDP is loaded on dev, as this 464 + * indicate XDP resources have been successfully allocated. 465 + */ 466 + xdp_prog = rcu_dereference(rq->xdp_prog); 467 + if (!xdp_prog) 468 + return -ENXIO; 469 + 470 + sent = __virtnet_xdp_xmit(vi, xdp); 457 471 if (!sent) 458 472 return -ENOSPC; 459 473 return 0; ··· 552 546 unsigned int buflen = SKB_DATA_ALIGN(GOOD_PACKET_LEN + headroom) + 553 547 SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); 554 548 struct page *page = virt_to_head_page(buf); 555 - unsigned int delta = 0, err; 549 + unsigned int delta = 0; 556 550 struct page *xdp_page; 551 + bool sent; 552 + int err; 553 + 557 554 len -= vi->hdr_len; 558 555 559 556 rcu_read_lock(); ··· 567 558 void *orig_data; 568 559 u32 act; 569 560 570 - if (unlikely(hdr->hdr.gso_type || hdr->hdr.flags)) 561 + if (unlikely(hdr->hdr.gso_type)) 571 562 goto err_xdp; 572 563 573 564 if (unlikely(xdp_headroom < virtnet_get_headroom(vi))) { ··· 605 596 delta = orig_data - xdp.data; 606 597 break; 607 598 case XDP_TX: 608 - if (unlikely(!__virtnet_xdp_xmit(vi, &xdp))) 599 + sent = __virtnet_xdp_xmit(vi, &xdp); 600 + if (unlikely(!sent)) { 609 601 trace_xdp_exception(vi->dev, xdp_prog, act); 610 - else 611 - *xdp_xmit = true; 602 + goto err_xdp; 603 + } 604 + *xdp_xmit = true; 612 605 rcu_read_unlock(); 613 606 goto xdp_xmit; 614 607 case XDP_REDIRECT: 615 608 err = xdp_do_redirect(dev, &xdp, xdp_prog); 616 - if (!err) 617 - *xdp_xmit = true; 609 + if (err) 610 + goto err_xdp; 611 + *xdp_xmit = true; 618 612 rcu_read_unlock(); 619 613 goto xdp_xmit; 620 614 default: ··· 689 677 struct bpf_prog *xdp_prog; 690 678 unsigned int truesize; 691 679 unsigned int headroom = mergeable_ctx_to_headroom(ctx); 692 - int err; 680 + bool sent; 693 681 694 682 head_skb = NULL; 695 683 ··· 758 746 } 759 747 break; 760 748 case XDP_TX: 761 - if (unlikely(!__virtnet_xdp_xmit(vi, &xdp))) 749 + sent = __virtnet_xdp_xmit(vi, &xdp); 750 + if (unlikely(!sent)) { 762 751 trace_xdp_exception(vi->dev, xdp_prog, act); 763 - else 764 - *xdp_xmit = true; 752 + if (unlikely(xdp_page != page)) 753 + put_page(xdp_page); 754 + goto err_xdp; 755 + } 756 + *xdp_xmit = true; 765 757 if (unlikely(xdp_page != page)) 766 758 goto err_xdp; 767 - rcu_read_unlock(); 768 - goto xdp_xmit; 769 - case XDP_REDIRECT: 770 - err = xdp_do_redirect(dev, &xdp, xdp_prog); 771 - if (!err) 772 - *xdp_xmit = true; 773 759 rcu_read_unlock(); 774 760 goto xdp_xmit; 775 761 default:
+1 -1
drivers/net/wireless/mac80211_hwsim.c
··· 3561 3561 3562 3562 spin_lock_init(&hwsim_radio_lock); 3563 3563 3564 - hwsim_wq = alloc_workqueue("hwsim_wq",WQ_MEM_RECLAIM,0); 3564 + hwsim_wq = alloc_workqueue("hwsim_wq", 0, 0); 3565 3565 if (!hwsim_wq) 3566 3566 return -ENOMEM; 3567 3567 rhashtable_init(&hwsim_radios_rht, &hwsim_rht_params);
+61 -77
drivers/perf/arm_pmu.c
··· 17 17 #include <linux/export.h> 18 18 #include <linux/kernel.h> 19 19 #include <linux/perf/arm_pmu.h> 20 - #include <linux/platform_device.h> 21 20 #include <linux/slab.h> 22 21 #include <linux/sched/clock.h> 23 22 #include <linux/spinlock.h> ··· 24 25 #include <linux/irqdesc.h> 25 26 26 27 #include <asm/irq_regs.h> 28 + 29 + static DEFINE_PER_CPU(struct arm_pmu *, cpu_armpmu); 30 + static DEFINE_PER_CPU(int, cpu_irq); 27 31 28 32 static int 29 33 armpmu_map_cache_event(const unsigned (*cache_map) ··· 322 320 return 0; 323 321 } 324 322 325 - static struct arm_pmu_platdata *armpmu_get_platdata(struct arm_pmu *armpmu) 326 - { 327 - struct platform_device *pdev = armpmu->plat_device; 328 - 329 - return pdev ? dev_get_platdata(&pdev->dev) : NULL; 330 - } 331 - 332 323 static irqreturn_t armpmu_dispatch_irq(int irq, void *dev) 333 324 { 334 325 struct arm_pmu *armpmu; 335 - struct arm_pmu_platdata *plat; 336 326 int ret; 337 327 u64 start_clock, finish_clock; 338 328 ··· 335 341 * dereference. 336 342 */ 337 343 armpmu = *(void **)dev; 338 - 339 - plat = armpmu_get_platdata(armpmu); 344 + if (WARN_ON_ONCE(!armpmu)) 345 + return IRQ_NONE; 340 346 341 347 start_clock = sched_clock(); 342 - if (plat && plat->handle_irq) 343 - ret = plat->handle_irq(irq, armpmu, armpmu->handle_irq); 344 - else 345 - ret = armpmu->handle_irq(irq, armpmu); 348 + ret = armpmu->handle_irq(irq, armpmu); 346 349 finish_clock = sched_clock(); 347 350 348 351 perf_sample_event_took(finish_clock - start_clock); ··· 522 531 } 523 532 EXPORT_SYMBOL_GPL(perf_num_counters); 524 533 525 - void armpmu_free_irq(struct arm_pmu *armpmu, int cpu) 534 + static int armpmu_count_irq_users(const int irq) 526 535 { 527 - struct pmu_hw_events __percpu *hw_events = armpmu->hw_events; 528 - int irq = per_cpu(hw_events->irq, cpu); 536 + int cpu, count = 0; 529 537 530 - if (!cpumask_test_and_clear_cpu(cpu, &armpmu->active_irqs)) 531 - return; 532 - 533 - if (irq_is_percpu_devid(irq)) { 534 - free_percpu_irq(irq, &hw_events->percpu_pmu); 535 - cpumask_clear(&armpmu->active_irqs); 536 - return; 538 + for_each_possible_cpu(cpu) { 539 + if (per_cpu(cpu_irq, cpu) == irq) 540 + count++; 537 541 } 538 542 539 - free_irq(irq, per_cpu_ptr(&hw_events->percpu_pmu, cpu)); 543 + return count; 540 544 } 541 545 542 - void armpmu_free_irqs(struct arm_pmu *armpmu) 546 + void armpmu_free_irq(int irq, int cpu) 543 547 { 544 - int cpu; 548 + if (per_cpu(cpu_irq, cpu) == 0) 549 + return; 550 + if (WARN_ON(irq != per_cpu(cpu_irq, cpu))) 551 + return; 545 552 546 - for_each_cpu(cpu, &armpmu->supported_cpus) 547 - armpmu_free_irq(armpmu, cpu); 553 + if (!irq_is_percpu_devid(irq)) 554 + free_irq(irq, per_cpu_ptr(&cpu_armpmu, cpu)); 555 + else if (armpmu_count_irq_users(irq) == 1) 556 + free_percpu_irq(irq, &cpu_armpmu); 557 + 558 + per_cpu(cpu_irq, cpu) = 0; 548 559 } 549 560 550 - int armpmu_request_irq(struct arm_pmu *armpmu, int cpu) 561 + int armpmu_request_irq(int irq, int cpu) 551 562 { 552 563 int err = 0; 553 - struct pmu_hw_events __percpu *hw_events = armpmu->hw_events; 554 564 const irq_handler_t handler = armpmu_dispatch_irq; 555 - int irq = per_cpu(hw_events->irq, cpu); 556 565 if (!irq) 557 566 return 0; 558 567 559 - if (irq_is_percpu_devid(irq) && cpumask_empty(&armpmu->active_irqs)) { 560 - err = request_percpu_irq(irq, handler, "arm-pmu", 561 - &hw_events->percpu_pmu); 562 - } else if (irq_is_percpu_devid(irq)) { 563 - int other_cpu = cpumask_first(&armpmu->active_irqs); 564 - int other_irq = per_cpu(hw_events->irq, other_cpu); 565 - 566 - if (irq != other_irq) { 567 - pr_warn("mismatched PPIs detected.\n"); 568 - err = -EINVAL; 569 - goto err_out; 570 - } 571 - } else { 572 - struct arm_pmu_platdata *platdata = armpmu_get_platdata(armpmu); 568 + if (!irq_is_percpu_devid(irq)) { 573 569 unsigned long irq_flags; 574 570 575 571 err = irq_force_affinity(irq, cpumask_of(cpu)); ··· 567 589 goto err_out; 568 590 } 569 591 570 - if (platdata && platdata->irq_flags) { 571 - irq_flags = platdata->irq_flags; 572 - } else { 573 - irq_flags = IRQF_PERCPU | 574 - IRQF_NOBALANCING | 575 - IRQF_NO_THREAD; 576 - } 592 + irq_flags = IRQF_PERCPU | 593 + IRQF_NOBALANCING | 594 + IRQF_NO_THREAD; 577 595 596 + irq_set_status_flags(irq, IRQ_NOAUTOEN); 578 597 err = request_irq(irq, handler, irq_flags, "arm-pmu", 579 - per_cpu_ptr(&hw_events->percpu_pmu, cpu)); 598 + per_cpu_ptr(&cpu_armpmu, cpu)); 599 + } else if (armpmu_count_irq_users(irq) == 0) { 600 + err = request_percpu_irq(irq, handler, "arm-pmu", 601 + &cpu_armpmu); 580 602 } 581 603 582 604 if (err) 583 605 goto err_out; 584 606 585 - cpumask_set_cpu(cpu, &armpmu->active_irqs); 607 + per_cpu(cpu_irq, cpu) = irq; 586 608 return 0; 587 609 588 610 err_out: 589 611 pr_err("unable to request IRQ%d for ARM PMU counters\n", irq); 590 - return err; 591 - } 592 - 593 - int armpmu_request_irqs(struct arm_pmu *armpmu) 594 - { 595 - int cpu, err; 596 - 597 - for_each_cpu(cpu, &armpmu->supported_cpus) { 598 - err = armpmu_request_irq(armpmu, cpu); 599 - if (err) 600 - break; 601 - } 602 - 603 612 return err; 604 613 } 605 614 ··· 612 647 if (pmu->reset) 613 648 pmu->reset(pmu); 614 649 650 + per_cpu(cpu_armpmu, cpu) = pmu; 651 + 615 652 irq = armpmu_get_cpu_irq(pmu, cpu); 616 653 if (irq) { 617 - if (irq_is_percpu_devid(irq)) { 654 + if (irq_is_percpu_devid(irq)) 618 655 enable_percpu_irq(irq, IRQ_TYPE_NONE); 619 - return 0; 620 - } 656 + else 657 + enable_irq(irq); 621 658 } 622 659 623 660 return 0; ··· 634 667 return 0; 635 668 636 669 irq = armpmu_get_cpu_irq(pmu, cpu); 637 - if (irq && irq_is_percpu_devid(irq)) 638 - disable_percpu_irq(irq); 670 + if (irq) { 671 + if (irq_is_percpu_devid(irq)) 672 + disable_percpu_irq(irq); 673 + else 674 + disable_irq(irq); 675 + } 676 + 677 + per_cpu(cpu_armpmu, cpu) = NULL; 639 678 640 679 return 0; 641 680 } ··· 773 800 &cpu_pmu->node); 774 801 } 775 802 776 - struct arm_pmu *armpmu_alloc(void) 803 + static struct arm_pmu *__armpmu_alloc(gfp_t flags) 777 804 { 778 805 struct arm_pmu *pmu; 779 806 int cpu; 780 807 781 - pmu = kzalloc(sizeof(*pmu), GFP_KERNEL); 808 + pmu = kzalloc(sizeof(*pmu), flags); 782 809 if (!pmu) { 783 810 pr_info("failed to allocate PMU device!\n"); 784 811 goto out; 785 812 } 786 813 787 - pmu->hw_events = alloc_percpu(struct pmu_hw_events); 814 + pmu->hw_events = alloc_percpu_gfp(struct pmu_hw_events, flags); 788 815 if (!pmu->hw_events) { 789 816 pr_info("failed to allocate per-cpu PMU data.\n"); 790 817 goto out_free_pmu; ··· 829 856 out: 830 857 return NULL; 831 858 } 859 + 860 + struct arm_pmu *armpmu_alloc(void) 861 + { 862 + return __armpmu_alloc(GFP_KERNEL); 863 + } 864 + 865 + struct arm_pmu *armpmu_alloc_atomic(void) 866 + { 867 + return __armpmu_alloc(GFP_ATOMIC); 868 + } 869 + 832 870 833 871 void armpmu_free(struct arm_pmu *pmu) 834 872 {
+44 -17
drivers/perf/arm_pmu_acpi.c
··· 11 11 #include <linux/acpi.h> 12 12 #include <linux/cpumask.h> 13 13 #include <linux/init.h> 14 + #include <linux/irq.h> 15 + #include <linux/irqdesc.h> 14 16 #include <linux/percpu.h> 15 17 #include <linux/perf/arm_pmu.h> 16 18 ··· 89 87 pr_warn("No ACPI PMU IRQ for CPU%d\n", cpu); 90 88 } 91 89 90 + /* 91 + * Log and request the IRQ so the core arm_pmu code can manage 92 + * it. We'll have to sanity-check IRQs later when we associate 93 + * them with their PMUs. 94 + */ 92 95 per_cpu(pmu_irqs, cpu) = irq; 96 + armpmu_request_irq(irq, cpu); 93 97 } 94 98 95 99 return 0; ··· 135 127 return pmu; 136 128 } 137 129 138 - pmu = armpmu_alloc(); 130 + pmu = armpmu_alloc_atomic(); 139 131 if (!pmu) { 140 132 pr_warn("Unable to allocate PMU for CPU%d\n", 141 133 smp_processor_id()); ··· 145 137 pmu->acpi_cpuid = cpuid; 146 138 147 139 return pmu; 140 + } 141 + 142 + /* 143 + * Check whether the new IRQ is compatible with those already associated with 144 + * the PMU (e.g. we don't have mismatched PPIs). 145 + */ 146 + static bool pmu_irq_matches(struct arm_pmu *pmu, int irq) 147 + { 148 + struct pmu_hw_events __percpu *hw_events = pmu->hw_events; 149 + int cpu; 150 + 151 + if (!irq) 152 + return true; 153 + 154 + for_each_cpu(cpu, &pmu->supported_cpus) { 155 + int other_irq = per_cpu(hw_events->irq, cpu); 156 + if (!other_irq) 157 + continue; 158 + 159 + if (irq == other_irq) 160 + continue; 161 + if (!irq_is_percpu_devid(irq) && !irq_is_percpu_devid(other_irq)) 162 + continue; 163 + 164 + pr_warn("mismatched PPIs detected\n"); 165 + return false; 166 + } 167 + 168 + return true; 148 169 } 149 170 150 171 /* ··· 201 164 if (!pmu) 202 165 return -ENOMEM; 203 166 204 - cpumask_set_cpu(cpu, &pmu->supported_cpus); 205 - 206 167 per_cpu(probed_pmus, cpu) = pmu; 207 168 208 - /* 209 - * Log and request the IRQ so the core arm_pmu code can manage it. In 210 - * some situations (e.g. mismatched PPIs), we may fail to request the 211 - * IRQ. However, it may be too late for us to do anything about it. 212 - * The common ARM PMU code will log a warning in this case. 213 - */ 214 - hw_events = pmu->hw_events; 215 - per_cpu(hw_events->irq, cpu) = irq; 216 - armpmu_request_irq(pmu, cpu); 169 + if (pmu_irq_matches(pmu, irq)) { 170 + hw_events = pmu->hw_events; 171 + per_cpu(hw_events->irq, cpu) = irq; 172 + } 173 + 174 + cpumask_set_cpu(cpu, &pmu->supported_cpus); 217 175 218 176 /* 219 177 * Ideally, we'd probe the PMU here when we find the first matching ··· 279 247 if (acpi_disabled) 280 248 return 0; 281 249 282 - /* 283 - * We can't request IRQs yet, since we don't know the cookie value 284 - * until we know which CPUs share the same logical PMU. We'll handle 285 - * that in arm_pmu_acpi_cpu_starting(). 286 - */ 287 250 ret = arm_pmu_acpi_parse_irqs(); 288 251 if (ret) 289 252 return ret;
+30 -7
drivers/perf/arm_pmu_platform.c
··· 127 127 pdev->dev.of_node); 128 128 } 129 129 130 - /* 131 - * Some platforms have all PMU IRQs OR'd into a single IRQ, with a 132 - * special platdata function that attempts to demux them. 133 - */ 134 - if (dev_get_platdata(&pdev->dev)) 135 - cpumask_setall(&pmu->supported_cpus); 136 - 137 130 for (i = 0; i < num_irqs; i++) { 138 131 int cpu, irq; 139 132 ··· 155 162 } 156 163 157 164 return 0; 165 + } 166 + 167 + static int armpmu_request_irqs(struct arm_pmu *armpmu) 168 + { 169 + struct pmu_hw_events __percpu *hw_events = armpmu->hw_events; 170 + int cpu, err; 171 + 172 + for_each_cpu(cpu, &armpmu->supported_cpus) { 173 + int irq = per_cpu(hw_events->irq, cpu); 174 + if (!irq) 175 + continue; 176 + 177 + err = armpmu_request_irq(irq, cpu); 178 + if (err) 179 + break; 180 + } 181 + 182 + return err; 183 + } 184 + 185 + static void armpmu_free_irqs(struct arm_pmu *armpmu) 186 + { 187 + int cpu; 188 + struct pmu_hw_events __percpu *hw_events = armpmu->hw_events; 189 + 190 + for_each_cpu(cpu, &armpmu->supported_cpus) { 191 + int irq = per_cpu(hw_events->irq, cpu); 192 + 193 + armpmu_free_irq(irq, cpu); 194 + } 158 195 } 159 196 160 197 int arm_pmu_device_probe(struct platform_device *pdev,
-1
drivers/scsi/Makefile
··· 185 185 CFLAGS_ncr53c8xx.o := $(ncr53c8xx-flags-y) $(ncr53c8xx-flags-m) 186 186 zalon7xx-objs := zalon.o ncr53c8xx.o 187 187 NCR_Q720_mod-objs := NCR_Q720.o ncr53c8xx.o 188 - oktagon_esp_mod-objs := oktagon_esp.o oktagon_io.o 189 188 190 189 # Files generated that shall be removed upon make clean 191 190 clean-files := 53c700_d.h 53c700_u.h
+3 -1
drivers/scsi/aacraid/linit.c
··· 1693 1693 * Map in the registers from the adapter. 1694 1694 */ 1695 1695 aac->base_size = AAC_MIN_FOOTPRINT_SIZE; 1696 - if ((*aac_drivers[index].init)(aac)) 1696 + if ((*aac_drivers[index].init)(aac)) { 1697 + error = -ENODEV; 1697 1698 goto out_unmap; 1699 + } 1698 1700 1699 1701 if (aac->sync_mode) { 1700 1702 if (aac_sync_mode)
-34
drivers/scsi/aic7xxx/aiclib.c
··· 1 - /* 2 - * Implementation of Utility functions for all SCSI device types. 3 - * 4 - * Copyright (c) 1997, 1998, 1999 Justin T. Gibbs. 5 - * Copyright (c) 1997, 1998 Kenneth D. Merry. 6 - * All rights reserved. 7 - * 8 - * Redistribution and use in source and binary forms, with or without 9 - * modification, are permitted provided that the following conditions 10 - * are met: 11 - * 1. Redistributions of source code must retain the above copyright 12 - * notice, this list of conditions, and the following disclaimer, 13 - * without modification, immediately at the beginning of the file. 14 - * 2. The name of the author may not be used to endorse or promote products 15 - * derived from this software without specific prior written permission. 16 - * 17 - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 21 - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 - * SUCH DAMAGE. 28 - * 29 - * $FreeBSD: src/sys/cam/scsi/scsi_all.c,v 1.38 2002/09/23 04:56:35 mjacob Exp $ 30 - * $Id$ 31 - */ 32 - 33 - #include "aiclib.h" 34 -
+1
drivers/scsi/bnx2fc/bnx2fc_io.c
··· 1889 1889 /* we will not receive ABTS response for this IO */ 1890 1890 BNX2FC_IO_DBG(io_req, "Timer context finished processing " 1891 1891 "this scsi cmd\n"); 1892 + return; 1892 1893 } 1893 1894 1894 1895 /* Cancel the timeout_work, as we received IO completion */
+1 -1
drivers/scsi/csiostor/csio_lnode.c
··· 114 114 static struct csio_lnode * 115 115 csio_ln_lookup_by_portid(struct csio_hw *hw, uint8_t portid) 116 116 { 117 - struct csio_lnode *ln = hw->rln; 117 + struct csio_lnode *ln; 118 118 struct list_head *tmp; 119 119 120 120 /* Match siblings lnode with portid */
+5
drivers/scsi/device_handler/scsi_dh_alua.c
··· 876 876 877 877 /** 878 878 * alua_rtpg_queue() - cause RTPG to be submitted asynchronously 879 + * @pg: ALUA port group associated with @sdev. 880 + * @sdev: SCSI device for which to submit an RTPG. 881 + * @qdata: Information about the callback to invoke after the RTPG. 882 + * @force: Whether or not to submit an RTPG if a work item that will submit an 883 + * RTPG already has been scheduled. 879 884 * 880 885 * Returns true if and only if alua_rtpg_work() will be called asynchronously. 881 886 * That function is responsible for calling @qdata->fn().
+1 -1
drivers/scsi/ibmvscsi/ibmvfc.h
··· 367 367 }; 368 368 369 369 struct ibmvfc_fcp_rsp_info { 370 - __be16 reserved; 370 + u8 reserved[3]; 371 371 u8 rsp_code; 372 372 u8 reserved2[4]; 373 373 }__attribute__((packed, aligned (2)));
+4 -1
drivers/scsi/mpt3sas/mpt3sas_base.c
··· 2410 2410 continue; 2411 2411 } 2412 2412 2413 - for_each_cpu(cpu, mask) 2413 + for_each_cpu_and(cpu, mask, cpu_online_mask) { 2414 + if (cpu >= ioc->cpu_msix_table_sz) 2415 + break; 2414 2416 ioc->cpu_msix_table[cpu] = reply_q->msix_index; 2417 + } 2415 2418 } 2416 2419 return; 2417 2420 }
+26 -29
drivers/scsi/qedi/qedi_main.c
··· 1724 1724 { 1725 1725 struct qedi_ctx *qedi = data; 1726 1726 struct nvm_iscsi_initiator *initiator; 1727 - char *str = buf; 1728 1727 int rc = 1; 1729 1728 u32 ipv6_en, dhcp_en, ip_len; 1730 1729 struct nvm_iscsi_block *block; ··· 1757 1758 1758 1759 switch (type) { 1759 1760 case ISCSI_BOOT_ETH_IP_ADDR: 1760 - rc = snprintf(str, ip_len, fmt, ip); 1761 + rc = snprintf(buf, ip_len, fmt, ip); 1761 1762 break; 1762 1763 case ISCSI_BOOT_ETH_SUBNET_MASK: 1763 - rc = snprintf(str, ip_len, fmt, sub); 1764 + rc = snprintf(buf, ip_len, fmt, sub); 1764 1765 break; 1765 1766 case ISCSI_BOOT_ETH_GATEWAY: 1766 - rc = snprintf(str, ip_len, fmt, gw); 1767 + rc = snprintf(buf, ip_len, fmt, gw); 1767 1768 break; 1768 1769 case ISCSI_BOOT_ETH_FLAGS: 1769 - rc = snprintf(str, 3, "%hhd\n", 1770 + rc = snprintf(buf, 3, "%hhd\n", 1770 1771 SYSFS_FLAG_FW_SEL_BOOT); 1771 1772 break; 1772 1773 case ISCSI_BOOT_ETH_INDEX: 1773 - rc = snprintf(str, 3, "0\n"); 1774 + rc = snprintf(buf, 3, "0\n"); 1774 1775 break; 1775 1776 case ISCSI_BOOT_ETH_MAC: 1776 - rc = sysfs_format_mac(str, qedi->mac, ETH_ALEN); 1777 + rc = sysfs_format_mac(buf, qedi->mac, ETH_ALEN); 1777 1778 break; 1778 1779 case ISCSI_BOOT_ETH_VLAN: 1779 - rc = snprintf(str, 12, "%d\n", 1780 + rc = snprintf(buf, 12, "%d\n", 1780 1781 GET_FIELD2(initiator->generic_cont0, 1781 1782 NVM_ISCSI_CFG_INITIATOR_VLAN)); 1782 1783 break; 1783 1784 case ISCSI_BOOT_ETH_ORIGIN: 1784 1785 if (dhcp_en) 1785 - rc = snprintf(str, 3, "3\n"); 1786 + rc = snprintf(buf, 3, "3\n"); 1786 1787 break; 1787 1788 default: 1788 1789 rc = 0; ··· 1818 1819 { 1819 1820 struct qedi_ctx *qedi = data; 1820 1821 struct nvm_iscsi_initiator *initiator; 1821 - char *str = buf; 1822 1822 int rc; 1823 1823 struct nvm_iscsi_block *block; 1824 1824 ··· 1829 1831 1830 1832 switch (type) { 1831 1833 case ISCSI_BOOT_INI_INITIATOR_NAME: 1832 - rc = snprintf(str, NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, "%s\n", 1833 - initiator->initiator_name.byte); 1834 + rc = sprintf(buf, "%.*s\n", NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, 1835 + initiator->initiator_name.byte); 1834 1836 break; 1835 1837 default: 1836 1838 rc = 0; ··· 1858 1860 qedi_show_boot_tgt_info(struct qedi_ctx *qedi, int type, 1859 1861 char *buf, enum qedi_nvm_tgts idx) 1860 1862 { 1861 - char *str = buf; 1862 1863 int rc = 1; 1863 1864 u32 ctrl_flags, ipv6_en, chap_en, mchap_en, ip_len; 1864 1865 struct nvm_iscsi_block *block; ··· 1896 1899 1897 1900 switch (type) { 1898 1901 case ISCSI_BOOT_TGT_NAME: 1899 - rc = snprintf(str, NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, "%s\n", 1900 - block->target[idx].target_name.byte); 1902 + rc = sprintf(buf, "%.*s\n", NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, 1903 + block->target[idx].target_name.byte); 1901 1904 break; 1902 1905 case ISCSI_BOOT_TGT_IP_ADDR: 1903 1906 if (ipv6_en) 1904 - rc = snprintf(str, ip_len, "%pI6\n", 1907 + rc = snprintf(buf, ip_len, "%pI6\n", 1905 1908 block->target[idx].ipv6_addr.byte); 1906 1909 else 1907 - rc = snprintf(str, ip_len, "%pI4\n", 1910 + rc = snprintf(buf, ip_len, "%pI4\n", 1908 1911 block->target[idx].ipv4_addr.byte); 1909 1912 break; 1910 1913 case ISCSI_BOOT_TGT_PORT: 1911 - rc = snprintf(str, 12, "%d\n", 1914 + rc = snprintf(buf, 12, "%d\n", 1912 1915 GET_FIELD2(block->target[idx].generic_cont0, 1913 1916 NVM_ISCSI_CFG_TARGET_TCP_PORT)); 1914 1917 break; 1915 1918 case ISCSI_BOOT_TGT_LUN: 1916 - rc = snprintf(str, 22, "%.*d\n", 1919 + rc = snprintf(buf, 22, "%.*d\n", 1917 1920 block->target[idx].lun.value[1], 1918 1921 block->target[idx].lun.value[0]); 1919 1922 break; 1920 1923 case ISCSI_BOOT_TGT_CHAP_NAME: 1921 - rc = snprintf(str, NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, "%s\n", 1922 - chap_name); 1924 + rc = sprintf(buf, "%.*s\n", NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, 1925 + chap_name); 1923 1926 break; 1924 1927 case ISCSI_BOOT_TGT_CHAP_SECRET: 1925 - rc = snprintf(str, NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN, "%s\n", 1926 - chap_secret); 1928 + rc = sprintf(buf, "%.*s\n", NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, 1929 + chap_secret); 1927 1930 break; 1928 1931 case ISCSI_BOOT_TGT_REV_CHAP_NAME: 1929 - rc = snprintf(str, NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, "%s\n", 1930 - mchap_name); 1932 + rc = sprintf(buf, "%.*s\n", NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, 1933 + mchap_name); 1931 1934 break; 1932 1935 case ISCSI_BOOT_TGT_REV_CHAP_SECRET: 1933 - rc = snprintf(str, NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN, "%s\n", 1934 - mchap_secret); 1936 + rc = sprintf(buf, "%.*s\n", NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, 1937 + mchap_secret); 1935 1938 break; 1936 1939 case ISCSI_BOOT_TGT_FLAGS: 1937 - rc = snprintf(str, 3, "%hhd\n", SYSFS_FLAG_FW_SEL_BOOT); 1940 + rc = snprintf(buf, 3, "%hhd\n", SYSFS_FLAG_FW_SEL_BOOT); 1938 1941 break; 1939 1942 case ISCSI_BOOT_TGT_NIC_ASSOC: 1940 - rc = snprintf(str, 3, "0\n"); 1943 + rc = snprintf(buf, 3, "0\n"); 1941 1944 break; 1942 1945 default: 1943 1946 rc = 0;
+3 -20
drivers/scsi/qla2xxx/qla_init.c
··· 59 59 req->outstanding_cmds[sp->handle] = NULL; 60 60 iocb = &sp->u.iocb_cmd; 61 61 iocb->timeout(sp); 62 - if (sp->type != SRB_ELS_DCMD) 63 - sp->free(sp); 64 62 spin_unlock_irqrestore(&vha->hw->hardware_lock, flags); 65 63 } 66 64 ··· 100 102 srb_t *sp = data; 101 103 fc_port_t *fcport = sp->fcport; 102 104 struct srb_iocb *lio = &sp->u.iocb_cmd; 103 - struct event_arg ea; 104 105 105 106 if (fcport) { 106 107 ql_dbg(ql_dbg_disc, fcport->vha, 0x2071, ··· 114 117 115 118 switch (sp->type) { 116 119 case SRB_LOGIN_CMD: 117 - if (!fcport) 118 - break; 119 120 /* Retry as needed. */ 120 121 lio->u.logio.data[0] = MBS_COMMAND_ERROR; 121 122 lio->u.logio.data[1] = lio->u.logio.flags & SRB_LOGIN_RETRIED ? 122 123 QLA_LOGIO_LOGIN_RETRIED : 0; 123 - memset(&ea, 0, sizeof(ea)); 124 - ea.event = FCME_PLOGI_DONE; 125 - ea.fcport = sp->fcport; 126 - ea.data[0] = lio->u.logio.data[0]; 127 - ea.data[1] = lio->u.logio.data[1]; 128 - ea.sp = sp; 129 - qla24xx_handle_plogi_done_event(fcport->vha, &ea); 124 + sp->done(sp, QLA_FUNCTION_TIMEOUT); 130 125 break; 131 126 case SRB_LOGOUT_CMD: 132 - if (!fcport) 133 - break; 134 - qlt_logo_completion_handler(fcport, QLA_FUNCTION_TIMEOUT); 135 - break; 136 127 case SRB_CT_PTHRU_CMD: 137 128 case SRB_MB_IOCB: 138 129 case SRB_NACK_PLOGI: ··· 220 235 qla2x00_async_logout_sp_done(void *ptr, int res) 221 236 { 222 237 srb_t *sp = ptr; 223 - struct srb_iocb *lio = &sp->u.iocb_cmd; 224 238 225 239 sp->fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); 226 - if (!test_bit(UNLOADING, &sp->vha->dpc_flags)) 227 - qla2x00_post_async_logout_done_work(sp->vha, sp->fcport, 228 - lio->u.logio.data); 240 + sp->fcport->login_gen++; 241 + qlt_logo_completion_handler(sp->fcport, res); 229 242 sp->free(sp); 230 243 } 231 244
+3 -4
drivers/scsi/qla2xxx/qla_iocb.c
··· 3275 3275 memset(abt_iocb, 0, sizeof(struct abort_entry_24xx)); 3276 3276 abt_iocb->entry_type = ABORT_IOCB_TYPE; 3277 3277 abt_iocb->entry_count = 1; 3278 - abt_iocb->handle = 3279 - cpu_to_le32(MAKE_HANDLE(aio->u.abt.req_que_no, 3280 - aio->u.abt.cmd_hndl)); 3278 + abt_iocb->handle = cpu_to_le32(MAKE_HANDLE(req->id, sp->handle)); 3281 3279 abt_iocb->nport_handle = cpu_to_le16(sp->fcport->loop_id); 3282 3280 abt_iocb->handle_to_abort = 3283 - cpu_to_le32(MAKE_HANDLE(req->id, aio->u.abt.cmd_hndl)); 3281 + cpu_to_le32(MAKE_HANDLE(aio->u.abt.req_que_no, 3282 + aio->u.abt.cmd_hndl)); 3284 3283 abt_iocb->port_id[0] = sp->fcport->d_id.b.al_pa; 3285 3284 abt_iocb->port_id[1] = sp->fcport->d_id.b.area; 3286 3285 abt_iocb->port_id[2] = sp->fcport->d_id.b.domain;
+4 -2
drivers/scsi/qla2xxx/qla_isr.c
··· 272 272 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 273 273 274 274 /* Read all mbox registers? */ 275 - mboxes = (1 << ha->mbx_count) - 1; 275 + WARN_ON_ONCE(ha->mbx_count > 32); 276 + mboxes = (1ULL << ha->mbx_count) - 1; 276 277 if (!ha->mcp) 277 278 ql_dbg(ql_dbg_async, vha, 0x5001, "MBX pointer ERROR.\n"); 278 279 else ··· 2881 2880 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; 2882 2881 2883 2882 /* Read all mbox registers? */ 2884 - mboxes = (1 << ha->mbx_count) - 1; 2883 + WARN_ON_ONCE(ha->mbx_count > 32); 2884 + mboxes = (1ULL << ha->mbx_count) - 1; 2885 2885 if (!ha->mcp) 2886 2886 ql_dbg(ql_dbg_async, vha, 0x504e, "MBX pointer ERROR.\n"); 2887 2887 else
+2
drivers/scsi/qla2xxx/qla_os.c
··· 3625 3625 } 3626 3626 qla2x00_wait_for_hba_ready(base_vha); 3627 3627 3628 + qla2x00_wait_for_sess_deletion(base_vha); 3629 + 3628 3630 /* 3629 3631 * if UNLOAD flag is already set, then continue unload, 3630 3632 * where it was set first.
-2
drivers/scsi/qla2xxx/qla_target.c
··· 4871 4871 sess); 4872 4872 qlt_send_term_imm_notif(vha, iocb, 1); 4873 4873 res = 0; 4874 - spin_lock_irqsave(&tgt->ha->tgt.sess_lock, 4875 - flags); 4876 4874 break; 4877 4875 } 4878 4876
+2
drivers/scsi/qla4xxx/ql4_def.h
··· 168 168 #define DEV_DB_NON_PERSISTENT 0 169 169 #define DEV_DB_PERSISTENT 1 170 170 171 + #define QL4_ISP_REG_DISCONNECT 0xffffffffU 172 + 171 173 #define COPY_ISID(dst_isid, src_isid) { \ 172 174 int i, j; \ 173 175 for (i = 0, j = ISID_SIZE - 1; i < ISID_SIZE;) \
+46
drivers/scsi/qla4xxx/ql4_os.c
··· 262 262 263 263 static struct scsi_transport_template *qla4xxx_scsi_transport; 264 264 265 + static int qla4xxx_isp_check_reg(struct scsi_qla_host *ha) 266 + { 267 + u32 reg_val = 0; 268 + int rval = QLA_SUCCESS; 269 + 270 + if (is_qla8022(ha)) 271 + reg_val = readl(&ha->qla4_82xx_reg->host_status); 272 + else if (is_qla8032(ha) || is_qla8042(ha)) 273 + reg_val = qla4_8xxx_rd_direct(ha, QLA8XXX_PEG_ALIVE_COUNTER); 274 + else 275 + reg_val = readw(&ha->reg->ctrl_status); 276 + 277 + if (reg_val == QL4_ISP_REG_DISCONNECT) 278 + rval = QLA_ERROR; 279 + 280 + return rval; 281 + } 282 + 265 283 static int qla4xxx_send_ping(struct Scsi_Host *shost, uint32_t iface_num, 266 284 uint32_t iface_type, uint32_t payload_size, 267 285 uint32_t pid, struct sockaddr *dst_addr) ··· 9204 9186 struct srb *srb = NULL; 9205 9187 int ret = SUCCESS; 9206 9188 int wait = 0; 9189 + int rval; 9207 9190 9208 9191 ql4_printk(KERN_INFO, ha, "scsi%ld:%d:%llu: Abort command issued cmd=%p, cdb=0x%x\n", 9209 9192 ha->host_no, id, lun, cmd, cmd->cmnd[0]); 9193 + 9194 + rval = qla4xxx_isp_check_reg(ha); 9195 + if (rval != QLA_SUCCESS) { 9196 + ql4_printk(KERN_INFO, ha, "PCI/Register disconnect, exiting.\n"); 9197 + return FAILED; 9198 + } 9210 9199 9211 9200 spin_lock_irqsave(&ha->hardware_lock, flags); 9212 9201 srb = (struct srb *) CMD_SP(cmd); ··· 9266 9241 struct scsi_qla_host *ha = to_qla_host(cmd->device->host); 9267 9242 struct ddb_entry *ddb_entry = cmd->device->hostdata; 9268 9243 int ret = FAILED, stat; 9244 + int rval; 9269 9245 9270 9246 if (!ddb_entry) 9271 9247 return ret; ··· 9285 9259 "dpc_flags=%lx, status=%x allowed=%d\n", ha->host_no, 9286 9260 cmd, jiffies, cmd->request->timeout / HZ, 9287 9261 ha->dpc_flags, cmd->result, cmd->allowed)); 9262 + 9263 + rval = qla4xxx_isp_check_reg(ha); 9264 + if (rval != QLA_SUCCESS) { 9265 + ql4_printk(KERN_INFO, ha, "PCI/Register disconnect, exiting.\n"); 9266 + return FAILED; 9267 + } 9288 9268 9289 9269 /* FIXME: wait for hba to go online */ 9290 9270 stat = qla4xxx_reset_lun(ha, ddb_entry, cmd->device->lun); ··· 9335 9303 struct scsi_qla_host *ha = to_qla_host(cmd->device->host); 9336 9304 struct ddb_entry *ddb_entry = cmd->device->hostdata; 9337 9305 int stat, ret; 9306 + int rval; 9338 9307 9339 9308 if (!ddb_entry) 9340 9309 return FAILED; ··· 9352 9319 "to=%x,dpc_flags=%lx, status=%x allowed=%d\n", 9353 9320 ha->host_no, cmd, jiffies, cmd->request->timeout / HZ, 9354 9321 ha->dpc_flags, cmd->result, cmd->allowed)); 9322 + 9323 + rval = qla4xxx_isp_check_reg(ha); 9324 + if (rval != QLA_SUCCESS) { 9325 + ql4_printk(KERN_INFO, ha, "PCI/Register disconnect, exiting.\n"); 9326 + return FAILED; 9327 + } 9355 9328 9356 9329 stat = qla4xxx_reset_target(ha, ddb_entry); 9357 9330 if (stat != QLA_SUCCESS) { ··· 9413 9374 { 9414 9375 int return_status = FAILED; 9415 9376 struct scsi_qla_host *ha; 9377 + int rval; 9416 9378 9417 9379 ha = to_qla_host(cmd->device->host); 9380 + 9381 + rval = qla4xxx_isp_check_reg(ha); 9382 + if (rval != QLA_SUCCESS) { 9383 + ql4_printk(KERN_INFO, ha, "PCI/Register disconnect, exiting.\n"); 9384 + return FAILED; 9385 + } 9418 9386 9419 9387 if ((is_qla8032(ha) || is_qla8042(ha)) && ql4xdontresethba) 9420 9388 qla4_83xx_set_idc_dontreset(ha);
+1 -1
drivers/scsi/storvsc_drv.c
··· 1657 1657 .eh_timed_out = storvsc_eh_timed_out, 1658 1658 .slave_alloc = storvsc_device_alloc, 1659 1659 .slave_configure = storvsc_device_configure, 1660 - .cmd_per_lun = 255, 1660 + .cmd_per_lun = 2048, 1661 1661 .this_id = -1, 1662 1662 .use_clustering = ENABLE_CLUSTERING, 1663 1663 /* Make sure we dont get a sg segment crosses a page boundary */
+1 -1
drivers/scsi/sym53c8xx_2/sym_hipd.c
··· 536 536 * Look for the greatest clock divisor that allows an 537 537 * input speed faster than the period. 538 538 */ 539 - while (div-- > 0) 539 + while (--div > 0) 540 540 if (kpc >= (div_10M[div] << 2)) break; 541 541 542 542 /*
+2
drivers/scsi/ufs/ufshcd.c
··· 4352 4352 /* REPORT SUPPORTED OPERATION CODES is not supported */ 4353 4353 sdev->no_report_opcodes = 1; 4354 4354 4355 + /* WRITE_SAME command is not supported */ 4356 + sdev->no_write_same = 1; 4355 4357 4356 4358 ufshcd_set_queue_depth(sdev); 4357 4359
+12 -9
drivers/staging/android/ashmem.c
··· 702 702 size_t pgstart, pgend; 703 703 int ret = -EINVAL; 704 704 705 - if (unlikely(!asma->file)) 706 - return -EINVAL; 705 + mutex_lock(&ashmem_mutex); 707 706 708 - if (unlikely(copy_from_user(&pin, p, sizeof(pin)))) 709 - return -EFAULT; 707 + if (unlikely(!asma->file)) 708 + goto out_unlock; 709 + 710 + if (unlikely(copy_from_user(&pin, p, sizeof(pin)))) { 711 + ret = -EFAULT; 712 + goto out_unlock; 713 + } 710 714 711 715 /* per custom, you can pass zero for len to mean "everything onward" */ 712 716 if (!pin.len) 713 717 pin.len = PAGE_ALIGN(asma->size) - pin.offset; 714 718 715 719 if (unlikely((pin.offset | pin.len) & ~PAGE_MASK)) 716 - return -EINVAL; 720 + goto out_unlock; 717 721 718 722 if (unlikely(((__u32)-1) - pin.offset < pin.len)) 719 - return -EINVAL; 723 + goto out_unlock; 720 724 721 725 if (unlikely(PAGE_ALIGN(asma->size) < pin.offset + pin.len)) 722 - return -EINVAL; 726 + goto out_unlock; 723 727 724 728 pgstart = pin.offset / PAGE_SIZE; 725 729 pgend = pgstart + (pin.len / PAGE_SIZE) - 1; 726 - 727 - mutex_lock(&ashmem_mutex); 728 730 729 731 switch (cmd) { 730 732 case ASHMEM_PIN: ··· 740 738 break; 741 739 } 742 740 741 + out_unlock: 743 742 mutex_unlock(&ashmem_mutex); 744 743 745 744 return ret;
+17
drivers/staging/android/ion/ion_cma_heap.c
··· 12 12 #include <linux/err.h> 13 13 #include <linux/cma.h> 14 14 #include <linux/scatterlist.h> 15 + #include <linux/highmem.h> 15 16 16 17 #include "ion.h" 17 18 ··· 42 41 pages = cma_alloc(cma_heap->cma, nr_pages, align, GFP_KERNEL); 43 42 if (!pages) 44 43 return -ENOMEM; 44 + 45 + if (PageHighMem(pages)) { 46 + unsigned long nr_clear_pages = nr_pages; 47 + struct page *page = pages; 48 + 49 + while (nr_clear_pages > 0) { 50 + void *vaddr = kmap_atomic(page); 51 + 52 + memset(vaddr, 0, PAGE_SIZE); 53 + kunmap_atomic(vaddr); 54 + page++; 55 + nr_clear_pages--; 56 + } 57 + } else { 58 + memset(page_address(pages), 0, size); 59 + } 45 60 46 61 table = kmalloc(sizeof(*table), GFP_KERNEL); 47 62 if (!table)
+1 -1
drivers/staging/fsl-mc/bus/Kconfig
··· 7 7 8 8 config FSL_MC_BUS 9 9 bool "QorIQ DPAA2 fsl-mc bus driver" 10 - depends on OF && (ARCH_LAYERSCAPE || (COMPILE_TEST && (ARM || ARM64 || X86 || PPC))) 10 + depends on OF && (ARCH_LAYERSCAPE || (COMPILE_TEST && (ARM || ARM64 || X86_LOCAL_APIC || PPC))) 11 11 select GENERIC_MSI_IRQ_DOMAIN 12 12 help 13 13 Driver to enable the bus infrastructure for the QorIQ DPAA2
+19 -8
drivers/staging/iio/adc/ad7192.c
··· 141 141 #define AD7192_GPOCON_P1DAT BIT(1) /* P1 state */ 142 142 #define AD7192_GPOCON_P0DAT BIT(0) /* P0 state */ 143 143 144 + #define AD7192_EXT_FREQ_MHZ_MIN 2457600 145 + #define AD7192_EXT_FREQ_MHZ_MAX 5120000 144 146 #define AD7192_INT_FREQ_MHZ 4915200 145 147 146 148 /* NOTE: ··· 220 218 ARRAY_SIZE(ad7192_calib_arr)); 221 219 } 222 220 221 + static inline bool ad7192_valid_external_frequency(u32 freq) 222 + { 223 + return (freq >= AD7192_EXT_FREQ_MHZ_MIN && 224 + freq <= AD7192_EXT_FREQ_MHZ_MAX); 225 + } 226 + 223 227 static int ad7192_setup(struct ad7192_state *st, 224 228 const struct ad7192_platform_data *pdata) 225 229 { ··· 251 243 id); 252 244 253 245 switch (pdata->clock_source_sel) { 254 - case AD7192_CLK_EXT_MCLK1_2: 255 - case AD7192_CLK_EXT_MCLK2: 256 - st->mclk = AD7192_INT_FREQ_MHZ; 257 - break; 258 246 case AD7192_CLK_INT: 259 247 case AD7192_CLK_INT_CO: 260 - if (pdata->ext_clk_hz) 261 - st->mclk = pdata->ext_clk_hz; 262 - else 263 - st->mclk = AD7192_INT_FREQ_MHZ; 248 + st->mclk = AD7192_INT_FREQ_MHZ; 264 249 break; 250 + case AD7192_CLK_EXT_MCLK1_2: 251 + case AD7192_CLK_EXT_MCLK2: 252 + if (ad7192_valid_external_frequency(pdata->ext_clk_hz)) { 253 + st->mclk = pdata->ext_clk_hz; 254 + break; 255 + } 256 + dev_err(&st->sd.spi->dev, "Invalid frequency setting %u\n", 257 + pdata->ext_clk_hz); 258 + ret = -EINVAL; 259 + goto out; 265 260 default: 266 261 ret = -EINVAL; 267 262 goto out;
+1 -3
drivers/staging/iio/impedance-analyzer/ad5933.c
··· 648 648 /* Ring buffer functions - here trigger setup related */ 649 649 indio_dev->setup_ops = &ad5933_ring_setup_ops; 650 650 651 - indio_dev->modes |= INDIO_BUFFER_HARDWARE; 652 - 653 651 return 0; 654 652 } 655 653 ··· 760 762 indio_dev->dev.parent = &client->dev; 761 763 indio_dev->info = &ad5933_info; 762 764 indio_dev->name = id->name; 763 - indio_dev->modes = INDIO_DIRECT_MODE; 765 + indio_dev->modes = (INDIO_BUFFER_SOFTWARE | INDIO_DIRECT_MODE); 764 766 indio_dev->channels = ad5933_channels; 765 767 indio_dev->num_channels = ARRAY_SIZE(ad5933_channels); 766 768
+6 -3
drivers/usb/class/cdc-acm.c
··· 174 174 wb = &acm->wb[wbn]; 175 175 if (!wb->use) { 176 176 wb->use = 1; 177 + wb->len = 0; 177 178 return wbn; 178 179 } 179 180 wbn = (wbn + 1) % ACM_NW; ··· 806 805 static void acm_tty_flush_chars(struct tty_struct *tty) 807 806 { 808 807 struct acm *acm = tty->driver_data; 809 - struct acm_wb *cur = acm->putbuffer; 808 + struct acm_wb *cur; 810 809 int err; 811 810 unsigned long flags; 812 811 812 + spin_lock_irqsave(&acm->write_lock, flags); 813 + 814 + cur = acm->putbuffer; 813 815 if (!cur) /* nothing to do */ 814 - return; 816 + goto out; 815 817 816 818 acm->putbuffer = NULL; 817 819 err = usb_autopm_get_interface_async(acm->control); 818 - spin_lock_irqsave(&acm->write_lock, flags); 819 820 if (err < 0) { 820 821 cur->use = 0; 821 822 acm->putbuffer = cur;
+3
drivers/usb/core/quirks.c
··· 226 226 { USB_DEVICE(0x1a0a, 0x0200), .driver_info = 227 227 USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL }, 228 228 229 + /* Corsair K70 RGB */ 230 + { USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT }, 231 + 229 232 /* Corsair Strafe RGB */ 230 233 { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT }, 231 234
+16 -10
drivers/usb/dwc2/gadget.c
··· 1917 1917 /* Not specific buffer needed for ep0 ZLP */ 1918 1918 dma_addr_t dma = hs_ep->desc_list_dma; 1919 1919 1920 - dwc2_gadget_set_ep0_desc_chain(hsotg, hs_ep); 1920 + if (!index) 1921 + dwc2_gadget_set_ep0_desc_chain(hsotg, hs_ep); 1922 + 1921 1923 dwc2_gadget_config_nonisoc_xfer_ddma(hs_ep, dma, 0); 1922 1924 } else { 1923 1925 dwc2_writel(DXEPTSIZ_MC(1) | DXEPTSIZ_PKTCNT(1) | ··· 2976 2974 if (ints & DXEPINT_STSPHSERCVD) { 2977 2975 dev_dbg(hsotg->dev, "%s: StsPhseRcvd\n", __func__); 2978 2976 2979 - /* Move to STATUS IN for DDMA */ 2980 - if (using_desc_dma(hsotg)) 2981 - dwc2_hsotg_ep0_zlp(hsotg, true); 2977 + /* Safety check EP0 state when STSPHSERCVD asserted */ 2978 + if (hsotg->ep0_state == DWC2_EP0_DATA_OUT) { 2979 + /* Move to STATUS IN for DDMA */ 2980 + if (using_desc_dma(hsotg)) 2981 + dwc2_hsotg_ep0_zlp(hsotg, true); 2982 + } 2983 + 2982 2984 } 2983 2985 2984 2986 if (ints & DXEPINT_BACK2BACKSETUP) ··· 3381 3375 dwc2_writel(dwc2_hsotg_ep0_mps(hsotg->eps_out[0]->ep.maxpacket) | 3382 3376 DXEPCTL_USBACTEP, hsotg->regs + DIEPCTL0); 3383 3377 3384 - dwc2_hsotg_enqueue_setup(hsotg); 3385 - 3386 - dev_dbg(hsotg->dev, "EP0: DIEPCTL0=0x%08x, DOEPCTL0=0x%08x\n", 3387 - dwc2_readl(hsotg->regs + DIEPCTL0), 3388 - dwc2_readl(hsotg->regs + DOEPCTL0)); 3389 - 3390 3378 /* clear global NAKs */ 3391 3379 val = DCTL_CGOUTNAK | DCTL_CGNPINNAK; 3392 3380 if (!is_usb_reset) ··· 3391 3391 mdelay(3); 3392 3392 3393 3393 hsotg->lx_state = DWC2_L0; 3394 + 3395 + dwc2_hsotg_enqueue_setup(hsotg); 3396 + 3397 + dev_dbg(hsotg->dev, "EP0: DIEPCTL0=0x%08x, DOEPCTL0=0x%08x\n", 3398 + dwc2_readl(hsotg->regs + DIEPCTL0), 3399 + dwc2_readl(hsotg->regs + DOEPCTL0)); 3394 3400 } 3395 3401 3396 3402 static void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg)
+63 -27
drivers/usb/dwc3/core.c
··· 100 100 reg &= ~(DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_OTG)); 101 101 reg |= DWC3_GCTL_PRTCAPDIR(mode); 102 102 dwc3_writel(dwc->regs, DWC3_GCTL, reg); 103 + 104 + dwc->current_dr_role = mode; 103 105 } 104 106 105 107 static void __dwc3_set_mode(struct work_struct *work) ··· 134 132 spin_lock_irqsave(&dwc->lock, flags); 135 133 136 134 dwc3_set_prtcap(dwc, dwc->desired_dr_role); 137 - 138 - dwc->current_dr_role = dwc->desired_dr_role; 139 135 140 136 spin_unlock_irqrestore(&dwc->lock, flags); 141 137 ··· 219 219 * XHCI driver will reset the host block. If dwc3 was configured for 220 220 * host-only mode, then we can return early. 221 221 */ 222 - if (dwc->dr_mode == USB_DR_MODE_HOST) 222 + if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST) 223 223 return 0; 224 224 225 225 reg = dwc3_readl(dwc->regs, DWC3_DCTL); ··· 233 233 234 234 udelay(1); 235 235 } while (--retries); 236 + 237 + phy_exit(dwc->usb3_generic_phy); 238 + phy_exit(dwc->usb2_generic_phy); 236 239 237 240 return -ETIMEDOUT; 238 241 } ··· 486 483 parms->hwparams8 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS8); 487 484 } 488 485 486 + static int dwc3_core_ulpi_init(struct dwc3 *dwc) 487 + { 488 + int intf; 489 + int ret = 0; 490 + 491 + intf = DWC3_GHWPARAMS3_HSPHY_IFC(dwc->hwparams.hwparams3); 492 + 493 + if (intf == DWC3_GHWPARAMS3_HSPHY_IFC_ULPI || 494 + (intf == DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI && 495 + dwc->hsphy_interface && 496 + !strncmp(dwc->hsphy_interface, "ulpi", 4))) 497 + ret = dwc3_ulpi_init(dwc); 498 + 499 + return ret; 500 + } 501 + 489 502 /** 490 503 * dwc3_phy_setup - Configure USB PHY Interface of DWC3 Core 491 504 * @dwc: Pointer to our controller context structure ··· 513 494 static int dwc3_phy_setup(struct dwc3 *dwc) 514 495 { 515 496 u32 reg; 516 - int ret; 517 497 518 498 reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); 519 499 ··· 583 565 } 584 566 /* FALLTHROUGH */ 585 567 case DWC3_GHWPARAMS3_HSPHY_IFC_ULPI: 586 - ret = dwc3_ulpi_init(dwc); 587 - if (ret) 588 - return ret; 589 568 /* FALLTHROUGH */ 590 569 default: 591 570 break; ··· 739 724 } 740 725 741 726 static int dwc3_core_get_phy(struct dwc3 *dwc); 727 + static int dwc3_core_ulpi_init(struct dwc3 *dwc); 742 728 743 729 /** 744 730 * dwc3_core_init - Low-level initialization of DWC3 Core ··· 771 755 dwc->maximum_speed = USB_SPEED_HIGH; 772 756 } 773 757 774 - ret = dwc3_core_get_phy(dwc); 775 - if (ret) 776 - goto err0; 777 - 778 - ret = dwc3_core_soft_reset(dwc); 779 - if (ret) 780 - goto err0; 781 - 782 758 ret = dwc3_phy_setup(dwc); 783 759 if (ret) 784 760 goto err0; 761 + 762 + if (!dwc->ulpi_ready) { 763 + ret = dwc3_core_ulpi_init(dwc); 764 + if (ret) 765 + goto err0; 766 + dwc->ulpi_ready = true; 767 + } 768 + 769 + if (!dwc->phys_ready) { 770 + ret = dwc3_core_get_phy(dwc); 771 + if (ret) 772 + goto err0a; 773 + dwc->phys_ready = true; 774 + } 775 + 776 + ret = dwc3_core_soft_reset(dwc); 777 + if (ret) 778 + goto err0a; 785 779 786 780 dwc3_core_setup_global_control(dwc); 787 781 dwc3_core_num_eps(dwc); ··· 863 837 usb_phy_shutdown(dwc->usb3_phy); 864 838 phy_exit(dwc->usb2_generic_phy); 865 839 phy_exit(dwc->usb3_generic_phy); 840 + 841 + err0a: 842 + dwc3_ulpi_exit(dwc); 866 843 867 844 err0: 868 845 return ret; ··· 945 916 946 917 switch (dwc->dr_mode) { 947 918 case USB_DR_MODE_PERIPHERAL: 948 - dwc->current_dr_role = DWC3_GCTL_PRTCAP_DEVICE; 949 919 dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE); 950 920 951 921 if (dwc->usb2_phy) ··· 960 932 } 961 933 break; 962 934 case USB_DR_MODE_HOST: 963 - dwc->current_dr_role = DWC3_GCTL_PRTCAP_HOST; 964 935 dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_HOST); 965 936 966 937 if (dwc->usb2_phy) ··· 1261 1234 1262 1235 err3: 1263 1236 dwc3_free_event_buffers(dwc); 1264 - dwc3_ulpi_exit(dwc); 1265 1237 1266 1238 err2: 1267 1239 pm_runtime_allow(&pdev->dev); ··· 1310 1284 } 1311 1285 1312 1286 #ifdef CONFIG_PM 1313 - static int dwc3_suspend_common(struct dwc3 *dwc) 1287 + static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg) 1314 1288 { 1315 1289 unsigned long flags; 1316 1290 ··· 1322 1296 dwc3_core_exit(dwc); 1323 1297 break; 1324 1298 case DWC3_GCTL_PRTCAP_HOST: 1299 + /* do nothing during host runtime_suspend */ 1300 + if (!PMSG_IS_AUTO(msg)) 1301 + dwc3_core_exit(dwc); 1302 + break; 1325 1303 default: 1326 1304 /* do nothing */ 1327 1305 break; ··· 1334 1304 return 0; 1335 1305 } 1336 1306 1337 - static int dwc3_resume_common(struct dwc3 *dwc) 1307 + static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg) 1338 1308 { 1339 1309 unsigned long flags; 1340 1310 int ret; ··· 1350 1320 spin_unlock_irqrestore(&dwc->lock, flags); 1351 1321 break; 1352 1322 case DWC3_GCTL_PRTCAP_HOST: 1323 + /* nothing to do on host runtime_resume */ 1324 + if (!PMSG_IS_AUTO(msg)) { 1325 + ret = dwc3_core_init(dwc); 1326 + if (ret) 1327 + return ret; 1328 + } 1329 + break; 1353 1330 default: 1354 1331 /* do nothing */ 1355 1332 break; ··· 1368 1331 static int dwc3_runtime_checks(struct dwc3 *dwc) 1369 1332 { 1370 1333 switch (dwc->current_dr_role) { 1371 - case USB_DR_MODE_PERIPHERAL: 1372 - case USB_DR_MODE_OTG: 1334 + case DWC3_GCTL_PRTCAP_DEVICE: 1373 1335 if (dwc->connected) 1374 1336 return -EBUSY; 1375 1337 break; 1376 - case USB_DR_MODE_HOST: 1338 + case DWC3_GCTL_PRTCAP_HOST: 1377 1339 default: 1378 1340 /* do nothing */ 1379 1341 break; ··· 1389 1353 if (dwc3_runtime_checks(dwc)) 1390 1354 return -EBUSY; 1391 1355 1392 - ret = dwc3_suspend_common(dwc); 1356 + ret = dwc3_suspend_common(dwc, PMSG_AUTO_SUSPEND); 1393 1357 if (ret) 1394 1358 return ret; 1395 1359 ··· 1405 1369 1406 1370 device_init_wakeup(dev, false); 1407 1371 1408 - ret = dwc3_resume_common(dwc); 1372 + ret = dwc3_resume_common(dwc, PMSG_AUTO_RESUME); 1409 1373 if (ret) 1410 1374 return ret; 1411 1375 ··· 1452 1416 struct dwc3 *dwc = dev_get_drvdata(dev); 1453 1417 int ret; 1454 1418 1455 - ret = dwc3_suspend_common(dwc); 1419 + ret = dwc3_suspend_common(dwc, PMSG_SUSPEND); 1456 1420 if (ret) 1457 1421 return ret; 1458 1422 ··· 1468 1432 1469 1433 pinctrl_pm_select_default_state(dev); 1470 1434 1471 - ret = dwc3_resume_common(dwc); 1435 + ret = dwc3_resume_common(dwc, PMSG_RESUME); 1472 1436 if (ret) 1473 1437 return ret; 1474 1438
+14 -7
drivers/usb/dwc3/core.h
··· 158 158 #define DWC3_GDBGFIFOSPACE_TYPE(n) (((n) << 5) & 0x1e0) 159 159 #define DWC3_GDBGFIFOSPACE_SPACE_AVAILABLE(n) (((n) >> 16) & 0xffff) 160 160 161 - #define DWC3_TXFIFOQ 1 162 - #define DWC3_RXFIFOQ 3 163 - #define DWC3_TXREQQ 5 164 - #define DWC3_RXREQQ 7 165 - #define DWC3_RXINFOQ 9 166 - #define DWC3_DESCFETCHQ 13 167 - #define DWC3_EVENTQ 15 161 + #define DWC3_TXFIFOQ 0 162 + #define DWC3_RXFIFOQ 1 163 + #define DWC3_TXREQQ 2 164 + #define DWC3_RXREQQ 3 165 + #define DWC3_RXINFOQ 4 166 + #define DWC3_PSTATQ 5 167 + #define DWC3_DESCFETCHQ 6 168 + #define DWC3_EVENTQ 7 169 + #define DWC3_AUXEVENTQ 8 168 170 169 171 /* Global RX Threshold Configuration Register */ 170 172 #define DWC3_GRXTHRCFG_MAXRXBURSTSIZE(n) (((n) & 0x1f) << 19) ··· 797 795 * @usb3_phy: pointer to USB3 PHY 798 796 * @usb2_generic_phy: pointer to USB2 PHY 799 797 * @usb3_generic_phy: pointer to USB3 PHY 798 + * @phys_ready: flag to indicate that PHYs are ready 800 799 * @ulpi: pointer to ulpi interface 800 + * @ulpi_ready: flag to indicate that ULPI is initialized 801 801 * @u2sel: parameter from Set SEL request. 802 802 * @u2pel: parameter from Set SEL request. 803 803 * @u1sel: parameter from Set SEL request. ··· 897 893 struct phy *usb2_generic_phy; 898 894 struct phy *usb3_generic_phy; 899 895 896 + bool phys_ready; 897 + 900 898 struct ulpi *ulpi; 899 + bool ulpi_ready; 901 900 902 901 void __iomem *regs; 903 902 size_t regs_size;
+1
drivers/usb/dwc3/dwc3-of-simple.c
··· 143 143 clk_disable_unprepare(simple->clks[i]); 144 144 clk_put(simple->clks[i]); 145 145 } 146 + simple->num_clocks = 0; 146 147 147 148 reset_control_assert(simple->resets); 148 149 reset_control_put(simple->resets);
+16
drivers/usb/dwc3/dwc3-omap.c
··· 582 582 return 0; 583 583 } 584 584 585 + static void dwc3_omap_complete(struct device *dev) 586 + { 587 + struct dwc3_omap *omap = dev_get_drvdata(dev); 588 + 589 + if (extcon_get_state(omap->edev, EXTCON_USB)) 590 + dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_VALID); 591 + else 592 + dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_OFF); 593 + 594 + if (extcon_get_state(omap->edev, EXTCON_USB_HOST)) 595 + dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND); 596 + else 597 + dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_FLOAT); 598 + } 599 + 585 600 static const struct dev_pm_ops dwc3_omap_dev_pm_ops = { 586 601 587 602 SET_SYSTEM_SLEEP_PM_OPS(dwc3_omap_suspend, dwc3_omap_resume) 603 + .complete = dwc3_omap_complete, 588 604 }; 589 605 590 606 #define DEV_PM_OPS (&dwc3_omap_dev_pm_ops)
+6 -1
drivers/usb/dwc3/ep0.c
··· 854 854 trb++; 855 855 trb->ctrl &= ~DWC3_TRB_CTRL_HWO; 856 856 trace_dwc3_complete_trb(ep0, trb); 857 - ep0->trb_enqueue = 0; 857 + 858 + if (r->direction) 859 + dwc->eps[1]->trb_enqueue = 0; 860 + else 861 + dwc->eps[0]->trb_enqueue = 0; 862 + 858 863 dwc->ep0_bounced = false; 859 864 } 860 865
+2
drivers/usb/dwc3/gadget.c
··· 2745 2745 break; 2746 2746 } 2747 2747 2748 + dwc->eps[1]->endpoint.maxpacket = dwc->gadget.ep0->maxpacket; 2749 + 2748 2750 /* Enable USB2 LPM Capability */ 2749 2751 2750 2752 if ((dwc->revision > DWC3_REVISION_194A) &&
+9 -35
drivers/usb/gadget/function/f_fs.c
··· 1855 1855 1856 1856 spin_lock_irqsave(&func->ffs->eps_lock, flags); 1857 1857 while(count--) { 1858 - struct usb_endpoint_descriptor *ds; 1859 - struct usb_ss_ep_comp_descriptor *comp_desc = NULL; 1860 - int needs_comp_desc = false; 1861 - int desc_idx; 1862 - 1863 - if (ffs->gadget->speed == USB_SPEED_SUPER) { 1864 - desc_idx = 2; 1865 - needs_comp_desc = true; 1866 - } else if (ffs->gadget->speed == USB_SPEED_HIGH) 1867 - desc_idx = 1; 1868 - else 1869 - desc_idx = 0; 1870 - 1871 - /* fall-back to lower speed if desc missing for current speed */ 1872 - do { 1873 - ds = ep->descs[desc_idx]; 1874 - } while (!ds && --desc_idx >= 0); 1875 - 1876 - if (!ds) { 1877 - ret = -EINVAL; 1878 - break; 1879 - } 1880 - 1881 1858 ep->ep->driver_data = ep; 1882 - ep->ep->desc = ds; 1883 1859 1884 - if (needs_comp_desc) { 1885 - comp_desc = (struct usb_ss_ep_comp_descriptor *)(ds + 1886 - USB_DT_ENDPOINT_SIZE); 1887 - ep->ep->maxburst = comp_desc->bMaxBurst + 1; 1888 - ep->ep->comp_desc = comp_desc; 1860 + ret = config_ep_by_speed(func->gadget, &func->function, ep->ep); 1861 + if (ret) { 1862 + pr_err("%s: config_ep_by_speed(%s) returned %d\n", 1863 + __func__, ep->ep->name, ret); 1864 + break; 1889 1865 } 1890 1866 1891 1867 ret = usb_ep_enable(ep->ep); 1892 1868 if (likely(!ret)) { 1893 1869 epfile->ep = ep; 1894 - epfile->in = usb_endpoint_dir_in(ds); 1895 - epfile->isoc = usb_endpoint_xfer_isoc(ds); 1870 + epfile->in = usb_endpoint_dir_in(ep->ep->desc); 1871 + epfile->isoc = usb_endpoint_xfer_isoc(ep->ep->desc); 1896 1872 } else { 1897 1873 break; 1898 1874 } ··· 2955 2979 struct ffs_data *ffs = func->ffs; 2956 2980 2957 2981 const int full = !!func->ffs->fs_descs_count; 2958 - const int high = gadget_is_dualspeed(func->gadget) && 2959 - func->ffs->hs_descs_count; 2960 - const int super = gadget_is_superspeed(func->gadget) && 2961 - func->ffs->ss_descs_count; 2982 + const int high = !!func->ffs->hs_descs_count; 2983 + const int super = !!func->ffs->ss_descs_count; 2962 2984 2963 2985 int fs_len, hs_len, ss_len, ret, i; 2964 2986 struct ffs_ep *eps_ptr;
+2
drivers/usb/gadget/function/f_uac2.c
··· 524 524 dev_err(dev, "%s:%d Error!\n", __func__, __LINE__); 525 525 return ret; 526 526 } 527 + iad_desc.bFirstInterface = ret; 528 + 527 529 std_ac_if_desc.bInterfaceNumber = ret; 528 530 uac2->ac_intf = ret; 529 531 uac2->ac_alt = 0;
-1
drivers/usb/gadget/udc/Kconfig
··· 274 274 tristate "Synopsys USB 2.0 Device controller" 275 275 depends on USB_GADGET && OF && HAS_DMA 276 276 depends on EXTCON || EXTCON=n 277 - select USB_GADGET_DUALSPEED 278 277 select USB_SNP_CORE 279 278 default ARCH_BCM_IPROC 280 279 help
+1
drivers/usb/gadget/udc/bdc/bdc_pci.c
··· 77 77 if (ret) { 78 78 dev_err(&pci->dev, 79 79 "couldn't add resources to bdc device\n"); 80 + platform_device_put(bdc); 80 81 return ret; 81 82 } 82 83
+1 -1
drivers/usb/gadget/udc/core.c
··· 180 180 void usb_ep_free_request(struct usb_ep *ep, 181 181 struct usb_request *req) 182 182 { 183 - ep->ops->free_request(ep, req); 184 183 trace_usb_ep_free_request(ep, req, 0); 184 + ep->ops->free_request(ep, req); 185 185 } 186 186 EXPORT_SYMBOL_GPL(usb_ep_free_request); 187 187
+2 -2
drivers/usb/gadget/udc/fsl_udc_core.c
··· 1305 1305 { 1306 1306 struct fsl_ep *ep = get_ep_by_pipe(udc, pipe); 1307 1307 1308 - if (ep->name) 1308 + if (ep->ep.name) 1309 1309 nuke(ep, -ESHUTDOWN); 1310 1310 } 1311 1311 ··· 1693 1693 curr_ep = get_ep_by_pipe(udc, i); 1694 1694 1695 1695 /* If the ep is configured */ 1696 - if (curr_ep->name == NULL) { 1696 + if (!curr_ep->ep.name) { 1697 1697 WARNING("Invalid EP?"); 1698 1698 continue; 1699 1699 }
+1 -1
drivers/usb/gadget/udc/renesas_usb3.c
··· 2410 2410 __renesas_usb3_ep_free_request(usb3->ep0_req); 2411 2411 if (usb3->phy) 2412 2412 phy_put(usb3->phy); 2413 - pm_runtime_disable(usb3_to_dev(usb3)); 2413 + pm_runtime_disable(&pdev->dev); 2414 2414 2415 2415 return 0; 2416 2416 }
+2 -2
drivers/usb/host/ehci-hub.c
··· 774 774 atomic_inc(&urb->use_count); 775 775 atomic_inc(&urb->dev->urbnum); 776 776 urb->setup_dma = dma_map_single( 777 - hcd->self.controller, 777 + hcd->self.sysdev, 778 778 urb->setup_packet, 779 779 sizeof(struct usb_ctrlrequest), 780 780 DMA_TO_DEVICE); 781 781 urb->transfer_dma = dma_map_single( 782 - hcd->self.controller, 782 + hcd->self.sysdev, 783 783 urb->transfer_buffer, 784 784 urb->transfer_buffer_length, 785 785 DMA_FROM_DEVICE);
+4 -8
drivers/usb/host/ehci-q.c
··· 1188 1188 * 15 secs after the setup 1189 1189 */ 1190 1190 if (is_setup) { 1191 - /* SETUP pid */ 1191 + /* SETUP pid, and interrupt after SETUP completion */ 1192 1192 qtd_fill(ehci, qtd, urb->setup_dma, 1193 1193 sizeof(struct usb_ctrlrequest), 1194 - token | (2 /* "setup" */ << 8), 8); 1194 + QTD_IOC | token | (2 /* "setup" */ << 8), 8); 1195 1195 1196 1196 submit_async(ehci, urb, &qtd_list, GFP_ATOMIC); 1197 1197 return 0; /*Return now; we shall come back after 15 seconds*/ ··· 1228 1228 qtd_prev->hw_next = QTD_NEXT(ehci, qtd->qtd_dma); 1229 1229 list_add_tail(&qtd->qtd_list, head); 1230 1230 1231 - /* dont fill any data in such packets */ 1232 - qtd_fill(ehci, qtd, 0, 0, token, 0); 1233 - 1234 - /* by default, enable interrupt on urb completion */ 1235 - if (likely(!(urb->transfer_flags & URB_NO_INTERRUPT))) 1236 - qtd->hw_token |= cpu_to_hc32(ehci, QTD_IOC); 1231 + /* Interrupt after STATUS completion */ 1232 + qtd_fill(ehci, qtd, 0, 0, token | QTD_IOC, 0); 1237 1233 1238 1234 submit_async(ehci, urb, &qtd_list, GFP_KERNEL); 1239 1235
+7 -3
drivers/usb/host/ohci-hcd.c
··· 74 74 75 75 #define STATECHANGE_DELAY msecs_to_jiffies(300) 76 76 #define IO_WATCHDOG_DELAY msecs_to_jiffies(275) 77 + #define IO_WATCHDOG_OFF 0xffffff00 77 78 78 79 #include "ohci.h" 79 80 #include "pci-quirks.h" ··· 232 231 } 233 232 234 233 /* Start up the I/O watchdog timer, if it's not running */ 235 - if (!timer_pending(&ohci->io_watchdog) && 234 + if (ohci->prev_frame_no == IO_WATCHDOG_OFF && 236 235 list_empty(&ohci->eds_in_use) && 237 236 !(ohci->flags & OHCI_QUIRK_QEMU)) { 238 237 ohci->prev_frame_no = ohci_frame_no(ohci); ··· 502 501 return 0; 503 502 504 503 timer_setup(&ohci->io_watchdog, io_watchdog_func, 0); 504 + ohci->prev_frame_no = IO_WATCHDOG_OFF; 505 505 506 506 ohci->hcca = dma_alloc_coherent (hcd->self.controller, 507 507 sizeof(*ohci->hcca), &ohci->hcca_dma, GFP_KERNEL); ··· 732 730 u32 head; 733 731 struct ed *ed; 734 732 struct td *td, *td_start, *td_next; 735 - unsigned frame_no; 733 + unsigned frame_no, prev_frame_no = IO_WATCHDOG_OFF; 736 734 unsigned long flags; 737 735 738 736 spin_lock_irqsave(&ohci->lock, flags); ··· 837 835 } 838 836 } 839 837 if (!list_empty(&ohci->eds_in_use)) { 840 - ohci->prev_frame_no = frame_no; 838 + prev_frame_no = frame_no; 841 839 ohci->prev_wdh_cnt = ohci->wdh_cnt; 842 840 ohci->prev_donehead = ohci_readl(ohci, 843 841 &ohci->regs->donehead); ··· 847 845 } 848 846 849 847 done: 848 + ohci->prev_frame_no = prev_frame_no; 850 849 spin_unlock_irqrestore(&ohci->lock, flags); 851 850 } 852 851 ··· 976 973 if (quirk_nec(ohci)) 977 974 flush_work(&ohci->nec_work); 978 975 del_timer_sync(&ohci->io_watchdog); 976 + ohci->prev_frame_no = IO_WATCHDOG_OFF; 979 977 980 978 ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); 981 979 ohci_usb_reset(ohci);
+3 -1
drivers/usb/host/ohci-hub.c
··· 311 311 rc = ohci_rh_suspend (ohci, 0); 312 312 spin_unlock_irq (&ohci->lock); 313 313 314 - if (rc == 0) 314 + if (rc == 0) { 315 315 del_timer_sync(&ohci->io_watchdog); 316 + ohci->prev_frame_no = IO_WATCHDOG_OFF; 317 + } 316 318 return rc; 317 319 } 318 320
+10 -7
drivers/usb/host/ohci-q.c
··· 1019 1019 * have modified this list. normally it's just prepending 1020 1020 * entries (which we'd ignore), but paranoia won't hurt. 1021 1021 */ 1022 + *last = ed->ed_next; 1023 + ed->ed_next = NULL; 1022 1024 modified = 0; 1023 1025 1024 1026 /* unlink urbs as requested, but rescan the list after ··· 1079 1077 goto rescan_this; 1080 1078 1081 1079 /* 1082 - * If no TDs are queued, take ED off the ed_rm_list. 1080 + * If no TDs are queued, ED is now idle. 1083 1081 * Otherwise, if the HC is running, reschedule. 1084 - * If not, leave it on the list for further dequeues. 1082 + * If the HC isn't running, add ED back to the 1083 + * start of the list for later processing. 1085 1084 */ 1086 1085 if (list_empty(&ed->td_list)) { 1087 - *last = ed->ed_next; 1088 - ed->ed_next = NULL; 1089 1086 ed->state = ED_IDLE; 1090 1087 list_del(&ed->in_use_list); 1091 1088 } else if (ohci->rh_state == OHCI_RH_RUNNING) { 1092 - *last = ed->ed_next; 1093 - ed->ed_next = NULL; 1094 1089 ed_schedule(ohci, ed); 1095 1090 } else { 1096 - last = &ed->ed_next; 1091 + ed->ed_next = ohci->ed_rm_list; 1092 + ohci->ed_rm_list = ed; 1093 + /* Don't loop on the same ED */ 1094 + if (last == &ohci->ed_rm_list) 1095 + last = &ed->ed_next; 1097 1096 } 1098 1097 1099 1098 if (modified)
+109
drivers/usb/host/pci-quirks.c
··· 66 66 #define AX_INDXC 0x30 67 67 #define AX_DATAC 0x34 68 68 69 + #define PT_ADDR_INDX 0xE8 70 + #define PT_READ_INDX 0xE4 71 + #define PT_SIG_1_ADDR 0xA520 72 + #define PT_SIG_2_ADDR 0xA521 73 + #define PT_SIG_3_ADDR 0xA522 74 + #define PT_SIG_4_ADDR 0xA523 75 + #define PT_SIG_1_DATA 0x78 76 + #define PT_SIG_2_DATA 0x56 77 + #define PT_SIG_3_DATA 0x34 78 + #define PT_SIG_4_DATA 0x12 79 + #define PT4_P1_REG 0xB521 80 + #define PT4_P2_REG 0xB522 81 + #define PT2_P1_REG 0xD520 82 + #define PT2_P2_REG 0xD521 83 + #define PT1_P1_REG 0xD522 84 + #define PT1_P2_REG 0xD523 85 + 69 86 #define NB_PCIE_INDX_ADDR 0xe0 70 87 #define NB_PCIE_INDX_DATA 0xe4 71 88 #define PCIE_P_CNTL 0x10040 ··· 528 511 pci_dev_put(smbus); 529 512 } 530 513 EXPORT_SYMBOL_GPL(usb_amd_dev_put); 514 + 515 + /* 516 + * Check if port is disabled in BIOS on AMD Promontory host. 517 + * BIOS Disabled ports may wake on connect/disconnect and need 518 + * driver workaround to keep them disabled. 519 + * Returns true if port is marked disabled. 520 + */ 521 + bool usb_amd_pt_check_port(struct device *device, int port) 522 + { 523 + unsigned char value, port_shift; 524 + struct pci_dev *pdev; 525 + u16 reg; 526 + 527 + pdev = to_pci_dev(device); 528 + pci_write_config_word(pdev, PT_ADDR_INDX, PT_SIG_1_ADDR); 529 + 530 + pci_read_config_byte(pdev, PT_READ_INDX, &value); 531 + if (value != PT_SIG_1_DATA) 532 + return false; 533 + 534 + pci_write_config_word(pdev, PT_ADDR_INDX, PT_SIG_2_ADDR); 535 + 536 + pci_read_config_byte(pdev, PT_READ_INDX, &value); 537 + if (value != PT_SIG_2_DATA) 538 + return false; 539 + 540 + pci_write_config_word(pdev, PT_ADDR_INDX, PT_SIG_3_ADDR); 541 + 542 + pci_read_config_byte(pdev, PT_READ_INDX, &value); 543 + if (value != PT_SIG_3_DATA) 544 + return false; 545 + 546 + pci_write_config_word(pdev, PT_ADDR_INDX, PT_SIG_4_ADDR); 547 + 548 + pci_read_config_byte(pdev, PT_READ_INDX, &value); 549 + if (value != PT_SIG_4_DATA) 550 + return false; 551 + 552 + /* Check disabled port setting, if bit is set port is enabled */ 553 + switch (pdev->device) { 554 + case 0x43b9: 555 + case 0x43ba: 556 + /* 557 + * device is AMD_PROMONTORYA_4(0x43b9) or PROMONTORYA_3(0x43ba) 558 + * PT4_P1_REG bits[7..1] represents USB2.0 ports 6 to 0 559 + * PT4_P2_REG bits[6..0] represents ports 13 to 7 560 + */ 561 + if (port > 6) { 562 + reg = PT4_P2_REG; 563 + port_shift = port - 7; 564 + } else { 565 + reg = PT4_P1_REG; 566 + port_shift = port + 1; 567 + } 568 + break; 569 + case 0x43bb: 570 + /* 571 + * device is AMD_PROMONTORYA_2(0x43bb) 572 + * PT2_P1_REG bits[7..5] represents USB2.0 ports 2 to 0 573 + * PT2_P2_REG bits[5..0] represents ports 9 to 3 574 + */ 575 + if (port > 2) { 576 + reg = PT2_P2_REG; 577 + port_shift = port - 3; 578 + } else { 579 + reg = PT2_P1_REG; 580 + port_shift = port + 5; 581 + } 582 + break; 583 + case 0x43bc: 584 + /* 585 + * device is AMD_PROMONTORYA_1(0x43bc) 586 + * PT1_P1_REG[7..4] represents USB2.0 ports 3 to 0 587 + * PT1_P2_REG[5..0] represents ports 9 to 4 588 + */ 589 + if (port > 3) { 590 + reg = PT1_P2_REG; 591 + port_shift = port - 4; 592 + } else { 593 + reg = PT1_P1_REG; 594 + port_shift = port + 4; 595 + } 596 + break; 597 + default: 598 + return false; 599 + } 600 + pci_write_config_word(pdev, PT_ADDR_INDX, reg); 601 + pci_read_config_byte(pdev, PT_READ_INDX, &value); 602 + 603 + return !(value & BIT(port_shift)); 604 + } 605 + EXPORT_SYMBOL_GPL(usb_amd_pt_check_port); 531 606 532 607 /* 533 608 * Make sure the controller is completely inactive, unable to
+5
drivers/usb/host/pci-quirks.h
··· 17 17 void usb_disable_xhci_ports(struct pci_dev *xhci_pdev); 18 18 void sb800_prefetch(struct device *dev, int on); 19 19 bool usb_xhci_needs_pci_reset(struct pci_dev *pdev); 20 + bool usb_amd_pt_check_port(struct device *device, int port); 20 21 #else 21 22 struct pci_dev; 22 23 static inline void usb_amd_quirk_pll_disable(void) {} ··· 26 25 static inline void usb_amd_dev_put(void) {} 27 26 static inline void usb_disable_xhci_ports(struct pci_dev *xhci_pdev) {} 28 27 static inline void sb800_prefetch(struct device *dev, int on) {} 28 + static inline bool usb_amd_pt_check_port(struct device *device, int port) 29 + { 30 + return false; 31 + } 29 32 #endif /* CONFIG_USB_PCI */ 30 33 31 34 #endif /* __LINUX_USB_PCI_QUIRKS_H */
+2 -2
drivers/usb/host/xhci-debugfs.c
··· 211 211 static int xhci_ring_trb_show(struct seq_file *s, void *unused) 212 212 { 213 213 int i; 214 - struct xhci_ring *ring = s->private; 214 + struct xhci_ring *ring = *(struct xhci_ring **)s->private; 215 215 struct xhci_segment *seg = ring->first_seg; 216 216 217 217 for (i = 0; i < ring->num_segs; i++) { ··· 387 387 388 388 snprintf(epriv->name, sizeof(epriv->name), "ep%02d", ep_index); 389 389 epriv->root = xhci_debugfs_create_ring_dir(xhci, 390 - &dev->eps[ep_index].new_ring, 390 + &dev->eps[ep_index].ring, 391 391 epriv->name, 392 392 spriv->root); 393 393 spriv->eps[ep_index] = epriv;
+16 -9
drivers/usb/host/xhci-hub.c
··· 1224 1224 temp = readl(port_array[wIndex]); 1225 1225 break; 1226 1226 } 1227 - 1228 - /* Software should not attempt to set 1229 - * port link state above '3' (U3) and the port 1230 - * must be enabled. 1231 - */ 1232 - if ((temp & PORT_PE) == 0 || 1233 - (link_state > USB_SS_PORT_LS_U3)) { 1234 - xhci_warn(xhci, "Cannot set link state.\n"); 1227 + /* Port must be enabled */ 1228 + if (!(temp & PORT_PE)) { 1229 + retval = -ENODEV; 1230 + break; 1231 + } 1232 + /* Can't set port link state above '3' (U3) */ 1233 + if (link_state > USB_SS_PORT_LS_U3) { 1234 + xhci_warn(xhci, "Cannot set port %d link state %d\n", 1235 + wIndex, link_state); 1235 1236 goto error; 1236 1237 } 1237 - 1238 1238 if (link_state == USB_SS_PORT_LS_U3) { 1239 1239 slot_id = xhci_find_slot_id_by_port(hcd, xhci, 1240 1240 wIndex + 1); ··· 1521 1521 } else { 1522 1522 t2 |= PORT_WKOC_E | PORT_WKCONN_E; 1523 1523 t2 &= ~PORT_WKDISC_E; 1524 + } 1525 + 1526 + if ((xhci->quirks & XHCI_U2_DISABLE_WAKE) && 1527 + (hcd->speed < HCD_USB3)) { 1528 + if (usb_amd_pt_check_port(hcd->self.controller, 1529 + port_index)) 1530 + t2 &= ~PORT_WAKE_BITS; 1524 1531 } 1525 1532 } else 1526 1533 t2 &= ~PORT_WAKE_BITS;
+11
drivers/usb/host/xhci-pci.c
··· 42 42 #define PCI_DEVICE_ID_INTEL_APL_XHCI 0x5aa8 43 43 #define PCI_DEVICE_ID_INTEL_DNV_XHCI 0x19d0 44 44 45 + #define PCI_DEVICE_ID_AMD_PROMONTORYA_4 0x43b9 46 + #define PCI_DEVICE_ID_AMD_PROMONTORYA_3 0x43ba 47 + #define PCI_DEVICE_ID_AMD_PROMONTORYA_2 0x43bb 48 + #define PCI_DEVICE_ID_AMD_PROMONTORYA_1 0x43bc 45 49 #define PCI_DEVICE_ID_ASMEDIA_1042A_XHCI 0x1142 46 50 47 51 static const char hcd_name[] = "xhci_hcd"; ··· 128 124 129 125 if (pdev->vendor == PCI_VENDOR_ID_AMD) 130 126 xhci->quirks |= XHCI_TRUST_TX_LENGTH; 127 + 128 + if ((pdev->vendor == PCI_VENDOR_ID_AMD) && 129 + ((pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_4) || 130 + (pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_3) || 131 + (pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_2) || 132 + (pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_1))) 133 + xhci->quirks |= XHCI_U2_DISABLE_WAKE; 131 134 132 135 if (pdev->vendor == PCI_VENDOR_ID_INTEL) { 133 136 xhci->quirks |= XHCI_LPM_SUPPORT;
+4 -6
drivers/usb/host/xhci.c
··· 646 646 return; 647 647 } 648 648 649 - xhci_debugfs_exit(xhci); 650 - 651 649 xhci_dbc_exit(xhci); 652 650 653 651 spin_lock_irq(&xhci->lock); ··· 678 680 679 681 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "cleaning up memory"); 680 682 xhci_mem_cleanup(xhci); 683 + xhci_debugfs_exit(xhci); 681 684 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 682 685 "xhci_stop completed - status = %x", 683 686 readl(&xhci->op_regs->status)); ··· 1013 1014 1014 1015 xhci_dbg(xhci, "cleaning up memory\n"); 1015 1016 xhci_mem_cleanup(xhci); 1017 + xhci_debugfs_exit(xhci); 1016 1018 xhci_dbg(xhci, "xhci_stop completed - status = %x\n", 1017 1019 readl(&xhci->op_regs->status)); 1018 1020 ··· 3544 3544 virt_dev->eps[i].ep_state &= ~EP_STOP_CMD_PENDING; 3545 3545 del_timer_sync(&virt_dev->eps[i].stop_cmd_timer); 3546 3546 } 3547 - 3547 + xhci_debugfs_remove_slot(xhci, udev->slot_id); 3548 3548 ret = xhci_disable_slot(xhci, udev->slot_id); 3549 - if (ret) { 3550 - xhci_debugfs_remove_slot(xhci, udev->slot_id); 3549 + if (ret) 3551 3550 xhci_free_virt_device(xhci, udev->slot_id); 3552 - } 3553 3551 } 3554 3552 3555 3553 int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id)
+1 -1
drivers/usb/host/xhci.h
··· 1822 1822 /* For controller with a broken Port Disable implementation */ 1823 1823 #define XHCI_BROKEN_PORT_PED (1 << 25) 1824 1824 #define XHCI_LIMIT_ENDPOINT_INTERVAL_7 (1 << 26) 1825 - /* Reserved. It was XHCI_U2_DISABLE_WAKE */ 1825 + #define XHCI_U2_DISABLE_WAKE (1 << 27) 1826 1826 #define XHCI_ASMEDIA_MODIFY_FLOWCONTROL (1 << 28) 1827 1827 #define XHCI_HW_LPM_DISABLE (1 << 29) 1828 1828
+6
drivers/usb/misc/ldusb.c
··· 42 42 #define USB_DEVICE_ID_LD_MICROCASSYTIME 0x1033 /* USB Product ID of Micro-CASSY Time (reserved) */ 43 43 #define USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE 0x1035 /* USB Product ID of Micro-CASSY Temperature */ 44 44 #define USB_DEVICE_ID_LD_MICROCASSYPH 0x1038 /* USB Product ID of Micro-CASSY pH */ 45 + #define USB_DEVICE_ID_LD_POWERANALYSERCASSY 0x1040 /* USB Product ID of Power Analyser CASSY */ 46 + #define USB_DEVICE_ID_LD_CONVERTERCONTROLLERCASSY 0x1042 /* USB Product ID of Converter Controller CASSY */ 47 + #define USB_DEVICE_ID_LD_MACHINETESTCASSY 0x1043 /* USB Product ID of Machine Test CASSY */ 45 48 #define USB_DEVICE_ID_LD_JWM 0x1080 /* USB Product ID of Joule and Wattmeter */ 46 49 #define USB_DEVICE_ID_LD_DMMP 0x1081 /* USB Product ID of Digital Multimeter P (reserved) */ 47 50 #define USB_DEVICE_ID_LD_UMIP 0x1090 /* USB Product ID of UMI P */ ··· 87 84 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTIME) }, 88 85 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE) }, 89 86 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYPH) }, 87 + { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERANALYSERCASSY) }, 88 + { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CONVERTERCONTROLLERCASSY) }, 89 + { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETESTCASSY) }, 90 90 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) }, 91 91 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) }, 92 92 { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) },
+2 -1
drivers/usb/musb/musb_core.c
··· 2708 2708 if ((devctl & mask) != (musb->context.devctl & mask)) 2709 2709 musb->port1_status = 0; 2710 2710 2711 - musb_start(musb); 2711 + musb_enable_interrupts(musb); 2712 + musb_platform_enable(musb); 2712 2713 2713 2714 spin_lock_irqsave(&musb->lock, flags); 2714 2715 error = musb_run_resume_work(musb);
+1 -7
drivers/usb/musb/musb_host.c
··· 391 391 } 392 392 } 393 393 394 - /* 395 - * The pipe must be broken if current urb->status is set, so don't 396 - * start next urb. 397 - * TODO: to minimize the risk of regression, only check urb->status 398 - * for RX, until we have a test case to understand the behavior of TX. 399 - */ 400 - if ((!status || !is_in) && qh && qh->is_ready) { 394 + if (qh != NULL && qh->is_ready) { 401 395 musb_dbg(musb, "... next ep%d %cX urb %p", 402 396 hw_ep->epnum, is_in ? 'R' : 'T', next_urb(qh)); 403 397 musb_start_urb(musb, is_in, qh);
+3
drivers/usb/phy/phy-mxs-usb.c
··· 602 602 void __iomem *base = phy->io_priv; 603 603 enum usb_charger_type chgr_type = UNKNOWN_TYPE; 604 604 605 + if (!regmap) 606 + return UNKNOWN_TYPE; 607 + 605 608 if (mxs_charger_data_contact_detect(mxs_phy)) 606 609 return chgr_type; 607 610
+5
drivers/usb/renesas_usbhs/fifo.c
··· 982 982 if ((uintptr_t)pkt->buf & (USBHS_USB_DMAC_XFER_SIZE - 1)) 983 983 goto usbhsf_pio_prepare_pop; 984 984 985 + /* return at this time if the pipe is running */ 986 + if (usbhs_pipe_is_running(pipe)) 987 + return 0; 988 + 985 989 usbhs_pipe_config_change_bfre(pipe, 1); 986 990 987 991 ret = usbhsf_fifo_select(pipe, fifo, 0); ··· 1176 1172 usbhsf_fifo_clear(pipe, fifo); 1177 1173 pkt->actual = usbhs_dma_calc_received_size(pkt, chan, rcv_len); 1178 1174 1175 + usbhs_pipe_running(pipe, 0); 1179 1176 usbhsf_dma_stop(pipe, fifo); 1180 1177 usbhsf_dma_unmap(pkt); 1181 1178 usbhsf_fifo_unselect(pipe, pipe->fifo);
+7
drivers/usb/serial/option.c
··· 241 241 #define QUECTEL_PRODUCT_EC21 0x0121 242 242 #define QUECTEL_PRODUCT_EC25 0x0125 243 243 #define QUECTEL_PRODUCT_BG96 0x0296 244 + #define QUECTEL_PRODUCT_EP06 0x0306 244 245 245 246 #define CMOTECH_VENDOR_ID 0x16d8 246 247 #define CMOTECH_PRODUCT_6001 0x6001 ··· 688 687 689 688 static const struct option_blacklist_info yuga_clm920_nc5_blacklist = { 690 689 .reserved = BIT(1) | BIT(4), 690 + }; 691 + 692 + static const struct option_blacklist_info quectel_ep06_blacklist = { 693 + .reserved = BIT(4) | BIT(5), 691 694 }; 692 695 693 696 static const struct usb_device_id option_ids[] = { ··· 1208 1203 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1209 1204 { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96), 1210 1205 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1206 + { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06), 1207 + .driver_info = (kernel_ulong_t)&quectel_ep06_blacklist }, 1211 1208 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) }, 1212 1209 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) }, 1213 1210 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003),
+3
drivers/usb/usbip/stub_dev.c
··· 73 73 goto err; 74 74 75 75 sdev->ud.tcp_socket = socket; 76 + sdev->ud.sockfd = sockfd; 76 77 77 78 spin_unlock_irq(&sdev->ud.lock); 78 79 ··· 173 172 if (ud->tcp_socket) { 174 173 sockfd_put(ud->tcp_socket); 175 174 ud->tcp_socket = NULL; 175 + ud->sockfd = -1; 176 176 } 177 177 178 178 /* 3. free used data */ ··· 268 266 sdev->ud.status = SDEV_ST_AVAILABLE; 269 267 spin_lock_init(&sdev->ud.lock); 270 268 sdev->ud.tcp_socket = NULL; 269 + sdev->ud.sockfd = -1; 271 270 272 271 INIT_LIST_HEAD(&sdev->priv_init); 273 272 INIT_LIST_HEAD(&sdev->priv_tx);
+2
drivers/usb/usbip/vhci_hcd.c
··· 984 984 if (vdev->ud.tcp_socket) { 985 985 sockfd_put(vdev->ud.tcp_socket); 986 986 vdev->ud.tcp_socket = NULL; 987 + vdev->ud.sockfd = -1; 987 988 } 988 989 pr_info("release socket\n"); 989 990 ··· 1031 1030 if (ud->tcp_socket) { 1032 1031 sockfd_put(ud->tcp_socket); 1033 1032 ud->tcp_socket = NULL; 1033 + ud->sockfd = -1; 1034 1034 } 1035 1035 ud->status = VDEV_ST_NULL; 1036 1036
+4
drivers/xen/tmem.c
··· 284 284 int pool = tmem_frontswap_poolid; 285 285 int ret; 286 286 287 + /* THP isn't supported */ 288 + if (PageTransHuge(page)) 289 + return -1; 290 + 287 291 if (pool < 0) 288 292 return -1; 289 293 if (ind64 != ind)
+6
fs/efivarfs/file.c
··· 8 8 */ 9 9 10 10 #include <linux/efi.h> 11 + #include <linux/delay.h> 11 12 #include <linux/fs.h> 12 13 #include <linux/slab.h> 13 14 #include <linux/mount.h> ··· 74 73 void *data; 75 74 ssize_t size = 0; 76 75 int err; 76 + 77 + while (!__ratelimit(&file->f_cred->user->ratelimit)) { 78 + if (!msleep_interruptible(50)) 79 + return -EINTR; 80 + } 77 81 78 82 err = efivar_entry_size(var, &datasize); 79 83
+12 -3
fs/signalfd.c
··· 118 118 err |= __put_user(kinfo->si_trapno, &uinfo->ssi_trapno); 119 119 #endif 120 120 #ifdef BUS_MCEERR_AO 121 - /* 121 + /* 122 122 * Other callers might not initialize the si_lsb field, 123 123 * so check explicitly for the right codes here. 124 124 */ 125 125 if (kinfo->si_signo == SIGBUS && 126 - (kinfo->si_code == BUS_MCEERR_AR || 127 - kinfo->si_code == BUS_MCEERR_AO)) 126 + kinfo->si_code == BUS_MCEERR_AO) 127 + err |= __put_user((short) kinfo->si_addr_lsb, 128 + &uinfo->ssi_addr_lsb); 129 + #endif 130 + #ifdef BUS_MCEERR_AR 131 + /* 132 + * Other callers might not initialize the si_lsb field, 133 + * so check explicitly for the right codes here. 134 + */ 135 + if (kinfo->si_signo == SIGBUS && 136 + kinfo->si_code == BUS_MCEERR_AR) 128 137 err |= __put_user((short) kinfo->si_addr_lsb, 129 138 &uinfo->ssi_addr_lsb); 130 139 #endif
+1
include/asm-generic/bug.h
··· 52 52 #ifndef HAVE_ARCH_BUG 53 53 #define BUG() do { \ 54 54 printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \ 55 + barrier_before_unreachable(); \ 55 56 panic("BUG!"); \ 56 57 } while (0) 57 58 #endif
+9
include/drm/drm_atomic.h
··· 134 134 * &drm_pending_vblank_event pointer to clean up private events. 135 135 */ 136 136 struct drm_pending_vblank_event *event; 137 + 138 + /** 139 + * @abort_completion: 140 + * 141 + * A flag that's set after drm_atomic_helper_setup_commit takes a second 142 + * reference for the completion of $drm_crtc_state.event. It's used by 143 + * the free code to remove the second reference if commit fails. 144 + */ 145 + bool abort_completion; 137 146 }; 138 147 139 148 struct __drm_planes_state {
+1
include/drm/drm_crtc_helper.h
··· 77 77 78 78 void drm_kms_helper_poll_disable(struct drm_device *dev); 79 79 void drm_kms_helper_poll_enable(struct drm_device *dev); 80 + bool drm_kms_helper_is_poll_worker(void); 80 81 81 82 #endif
+14 -1
include/linux/compiler-gcc.h
··· 208 208 #endif 209 209 210 210 /* 211 + * calling noreturn functions, __builtin_unreachable() and __builtin_trap() 212 + * confuse the stack allocation in gcc, leading to overly large stack 213 + * frames, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82365 214 + * 215 + * Adding an empty inline assembly before it works around the problem 216 + */ 217 + #define barrier_before_unreachable() asm volatile("") 218 + 219 + /* 211 220 * Mark a position in code as unreachable. This can be used to 212 221 * suppress control flow warnings after asm blocks that transfer 213 222 * control elsewhere. ··· 226 217 * unreleased. Really, we need to have autoconf for the kernel. 227 218 */ 228 219 #define unreachable() \ 229 - do { annotate_unreachable(); __builtin_unreachable(); } while (0) 220 + do { \ 221 + annotate_unreachable(); \ 222 + barrier_before_unreachable(); \ 223 + __builtin_unreachable(); \ 224 + } while (0) 230 225 231 226 /* Mark a function definition as prohibited from being cloned. */ 232 227 #define __noclone __attribute__((__noclone__, __optimize__("no-tracer")))
+5
include/linux/compiler.h
··· 86 86 # define barrier_data(ptr) barrier() 87 87 #endif 88 88 89 + /* workaround for GCC PR82365 if needed */ 90 + #ifndef barrier_before_unreachable 91 + # define barrier_before_unreachable() do { } while (0) 92 + #endif 93 + 89 94 /* Unreachable code */ 90 95 #ifdef CONFIG_STACK_VALIDATION 91 96 /*
+9
include/linux/kconfig.h
··· 4 4 5 5 #include <generated/autoconf.h> 6 6 7 + #ifdef CONFIG_CPU_BIG_ENDIAN 8 + #define __BIG_ENDIAN 4321 9 + #else 10 + #define __LITTLE_ENDIAN 1234 11 + #endif 12 + 7 13 #define __ARG_PLACEHOLDER_1 0, 8 14 #define __take_second_arg(__ignored, val, ...) val 9 15 ··· 69 63 * 0 otherwise. 70 64 */ 71 65 #define IS_ENABLED(option) __or(IS_BUILTIN(option), IS_MODULE(option)) 66 + 67 + /* Make sure we always have all types and struct attributes defined. */ 68 + #include <linux/compiler_types.h> 72 69 73 70 #endif /* __LINUX_KCONFIG_H */
+16 -8
include/linux/memcontrol.h
··· 523 523 static inline void mod_memcg_state(struct mem_cgroup *memcg, 524 524 int idx, int val) 525 525 { 526 - preempt_disable(); 526 + unsigned long flags; 527 + 528 + local_irq_save(flags); 527 529 __mod_memcg_state(memcg, idx, val); 528 - preempt_enable(); 530 + local_irq_restore(flags); 529 531 } 530 532 531 533 /** ··· 608 606 static inline void mod_lruvec_state(struct lruvec *lruvec, 609 607 enum node_stat_item idx, int val) 610 608 { 611 - preempt_disable(); 609 + unsigned long flags; 610 + 611 + local_irq_save(flags); 612 612 __mod_lruvec_state(lruvec, idx, val); 613 - preempt_enable(); 613 + local_irq_restore(flags); 614 614 } 615 615 616 616 static inline void __mod_lruvec_page_state(struct page *page, ··· 634 630 static inline void mod_lruvec_page_state(struct page *page, 635 631 enum node_stat_item idx, int val) 636 632 { 637 - preempt_disable(); 633 + unsigned long flags; 634 + 635 + local_irq_save(flags); 638 636 __mod_lruvec_page_state(page, idx, val); 639 - preempt_enable(); 637 + local_irq_restore(flags); 640 638 } 641 639 642 640 unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order, ··· 665 659 static inline void count_memcg_events(struct mem_cgroup *memcg, 666 660 int idx, unsigned long count) 667 661 { 668 - preempt_disable(); 662 + unsigned long flags; 663 + 664 + local_irq_save(flags); 669 665 __count_memcg_events(memcg, idx, count); 670 - preempt_enable(); 666 + local_irq_restore(flags); 671 667 } 672 668 673 669 /* idx can be of type enum memcg_event_item or vm_event_item */
+4 -22
include/linux/perf/arm_pmu.h
··· 14 14 15 15 #include <linux/interrupt.h> 16 16 #include <linux/perf_event.h> 17 + #include <linux/platform_device.h> 17 18 #include <linux/sysfs.h> 18 19 #include <asm/cputype.h> 19 - 20 - /* 21 - * struct arm_pmu_platdata - ARM PMU platform data 22 - * 23 - * @handle_irq: an optional handler which will be called from the 24 - * interrupt and passed the address of the low level handler, 25 - * and can be used to implement any platform specific handling 26 - * before or after calling it. 27 - * 28 - * @irq_flags: if non-zero, these flags will be passed to request_irq 29 - * when requesting interrupts for this PMU device. 30 - */ 31 - struct arm_pmu_platdata { 32 - irqreturn_t (*handle_irq)(int irq, void *dev, 33 - irq_handler_t pmu_handler); 34 - unsigned long irq_flags; 35 - }; 36 20 37 21 #ifdef CONFIG_ARM_PMU 38 22 ··· 76 92 77 93 struct arm_pmu { 78 94 struct pmu pmu; 79 - cpumask_t active_irqs; 80 95 cpumask_t supported_cpus; 81 96 char *name; 82 97 irqreturn_t (*handle_irq)(int irq_num, void *dev); ··· 157 174 158 175 /* Internal functions only for core arm_pmu code */ 159 176 struct arm_pmu *armpmu_alloc(void); 177 + struct arm_pmu *armpmu_alloc_atomic(void); 160 178 void armpmu_free(struct arm_pmu *pmu); 161 179 int armpmu_register(struct arm_pmu *pmu); 162 - int armpmu_request_irqs(struct arm_pmu *armpmu); 163 - void armpmu_free_irqs(struct arm_pmu *armpmu); 164 - int armpmu_request_irq(struct arm_pmu *armpmu, int cpu); 165 - void armpmu_free_irq(struct arm_pmu *armpmu, int cpu); 180 + int armpmu_request_irq(int irq, int cpu); 181 + void armpmu_free_irq(int irq, int cpu); 166 182 167 183 #define ARMV8_PMU_PDEV_NAME "armv8-pmu" 168 184
+12 -1
include/linux/sched/mm.h
··· 36 36 atomic_inc(&mm->mm_count); 37 37 } 38 38 39 - extern void mmdrop(struct mm_struct *mm); 39 + extern void __mmdrop(struct mm_struct *mm); 40 + 41 + static inline void mmdrop(struct mm_struct *mm) 42 + { 43 + /* 44 + * The implicit full barrier implied by atomic_dec_and_test() is 45 + * required by the membarrier system call before returning to 46 + * user-space, after storing to rq->curr. 47 + */ 48 + if (unlikely(atomic_dec_and_test(&mm->mm_count))) 49 + __mmdrop(mm); 50 + } 40 51 41 52 /** 42 53 * mmget() - Pin the address space associated with a &struct mm_struct.
+4
include/linux/sched/user.h
··· 4 4 5 5 #include <linux/uidgid.h> 6 6 #include <linux/atomic.h> 7 + #include <linux/ratelimit.h> 7 8 8 9 struct key; 9 10 ··· 42 41 defined(CONFIG_NET) 43 42 atomic_long_t locked_vm; 44 43 #endif 44 + 45 + /* Miscellaneous per-user rate limit */ 46 + struct ratelimit_state ratelimit; 45 47 }; 46 48 47 49 extern int uids_sysfs_init(void);
-2
include/linux/swap.h
··· 337 337 extern void mark_page_lazyfree(struct page *page); 338 338 extern void swap_setup(void); 339 339 340 - extern void add_page_to_unevictable_list(struct page *page); 341 - 342 340 extern void lru_cache_add_active_or_unevictable(struct page *page, 343 341 struct vm_area_struct *vma); 344 342
+1
include/linux/workqueue.h
··· 465 465 466 466 extern void workqueue_set_max_active(struct workqueue_struct *wq, 467 467 int max_active); 468 + extern struct work_struct *current_work(void); 468 469 extern bool current_is_workqueue_rescuer(void); 469 470 extern bool workqueue_congested(int cpu, struct workqueue_struct *wq); 470 471 extern unsigned int work_busy(struct work_struct *work);
+1 -1
include/net/mac80211.h
··· 4168 4168 * The TX headroom reserved by mac80211 for its own tx_status functions. 4169 4169 * This is enough for the radiotap header. 4170 4170 */ 4171 - #define IEEE80211_TX_STATUS_HEADROOM 14 4171 + #define IEEE80211_TX_STATUS_HEADROOM ALIGN(14, 4) 4172 4172 4173 4173 /** 4174 4174 * ieee80211_sta_set_buffered - inform mac80211 about driver-buffered frames
+1 -1
include/net/regulatory.h
··· 78 78 int wiphy_idx; 79 79 enum nl80211_reg_initiator initiator; 80 80 enum nl80211_user_reg_hint_type user_reg_hint_type; 81 - char alpha2[2]; 81 + char alpha2[3]; 82 82 enum nl80211_dfs_regions dfs_region; 83 83 bool intersect; 84 84 bool processed;
-4
include/rdma/restrack.h
··· 29 29 */ 30 30 RDMA_RESTRACK_QP, 31 31 /** 32 - * @RDMA_RESTRACK_XRCD: XRC domain (XRCD) 33 - */ 34 - RDMA_RESTRACK_XRCD, 35 - /** 36 32 * @RDMA_RESTRACK_MAX: Last entry, used for array dclarations 37 33 */ 38 34 RDMA_RESTRACK_MAX
+31 -12
include/rdma/uverbs_ioctl.h
··· 276 276 */ 277 277 278 278 struct uverbs_ptr_attr { 279 - union { 280 - u64 data; 281 - void __user *ptr; 282 - }; 279 + u64 data; 283 280 u16 len; 284 281 /* Combination of bits from enum UVERBS_ATTR_F_XXXX */ 285 282 u16 flags; ··· 348 351 } 349 352 350 353 static inline int uverbs_copy_to(const struct uverbs_attr_bundle *attrs_bundle, 351 - size_t idx, const void *from) 354 + size_t idx, const void *from, size_t size) 352 355 { 353 356 const struct uverbs_attr *attr = uverbs_attr_get(attrs_bundle, idx); 354 357 u16 flags; 358 + size_t min_size; 355 359 356 360 if (IS_ERR(attr)) 357 361 return PTR_ERR(attr); 358 362 363 + min_size = min_t(size_t, attr->ptr_attr.len, size); 364 + if (copy_to_user(u64_to_user_ptr(attr->ptr_attr.data), from, min_size)) 365 + return -EFAULT; 366 + 359 367 flags = attr->ptr_attr.flags | UVERBS_ATTR_F_VALID_OUTPUT; 360 - return (!copy_to_user(attr->ptr_attr.ptr, from, attr->ptr_attr.len) && 361 - !put_user(flags, &attr->uattr->flags)) ? 0 : -EFAULT; 368 + if (put_user(flags, &attr->uattr->flags)) 369 + return -EFAULT; 370 + 371 + return 0; 362 372 } 363 373 364 - static inline int _uverbs_copy_from(void *to, size_t to_size, 374 + static inline bool uverbs_attr_ptr_is_inline(const struct uverbs_attr *attr) 375 + { 376 + return attr->ptr_attr.len <= sizeof(attr->ptr_attr.data); 377 + } 378 + 379 + static inline int _uverbs_copy_from(void *to, 365 380 const struct uverbs_attr_bundle *attrs_bundle, 366 - size_t idx) 381 + size_t idx, 382 + size_t size) 367 383 { 368 384 const struct uverbs_attr *attr = uverbs_attr_get(attrs_bundle, idx); 369 385 370 386 if (IS_ERR(attr)) 371 387 return PTR_ERR(attr); 372 388 373 - if (to_size <= sizeof(((struct ib_uverbs_attr *)0)->data)) 389 + /* 390 + * Validation ensures attr->ptr_attr.len >= size. If the caller is 391 + * using UVERBS_ATTR_SPEC_F_MIN_SZ then it must call copy_from with 392 + * the right size. 393 + */ 394 + if (unlikely(size < attr->ptr_attr.len)) 395 + return -EINVAL; 396 + 397 + if (uverbs_attr_ptr_is_inline(attr)) 374 398 memcpy(to, &attr->ptr_attr.data, attr->ptr_attr.len); 375 - else if (copy_from_user(to, attr->ptr_attr.ptr, attr->ptr_attr.len)) 399 + else if (copy_from_user(to, u64_to_user_ptr(attr->ptr_attr.data), 400 + attr->ptr_attr.len)) 376 401 return -EFAULT; 377 402 378 403 return 0; 379 404 } 380 405 381 406 #define uverbs_copy_from(to, attrs_bundle, idx) \ 382 - _uverbs_copy_from(to, sizeof(*(to)), attrs_bundle, idx) 407 + _uverbs_copy_from(to, attrs_bundle, idx, sizeof(*to)) 383 408 384 409 /* ================================================= 385 410 * Definitions -> Specs infrastructure
+2 -2
include/uapi/linux/ptrace.h
··· 69 69 #define PTRACE_SECCOMP_GET_METADATA 0x420d 70 70 71 71 struct seccomp_metadata { 72 - unsigned long filter_off; /* Input: which filter */ 73 - unsigned int flags; /* Output: filter's flags */ 72 + __u64 filter_off; /* Input: which filter */ 73 + __u64 flags; /* Output: filter's flags */ 74 74 }; 75 75 76 76 /* Read signals from a shared (process wide) queue */
+2 -2
include/uapi/rdma/rdma_user_ioctl.h
··· 65 65 __u16 len; /* only for pointers */ 66 66 __u16 flags; /* combination of UVERBS_ATTR_F_XXXX */ 67 67 __u16 reserved; 68 - __u64 data; /* ptr to command, inline data or idr/fd */ 68 + __aligned_u64 data; /* ptr to command, inline data or idr/fd */ 69 69 }; 70 70 71 71 struct ib_uverbs_ioctl_hdr { ··· 73 73 __u16 object_id; 74 74 __u16 method_id; 75 75 __u16 num_attrs; 76 - __u64 reserved; 76 + __aligned_u64 reserved; 77 77 struct ib_uverbs_attr attrs[0]; 78 78 }; 79 79
+20 -13
kernel/bpf/arraymap.c
··· 26 26 { 27 27 int i; 28 28 29 - for (i = 0; i < array->map.max_entries; i++) 29 + for (i = 0; i < array->map.max_entries; i++) { 30 30 free_percpu(array->pptrs[i]); 31 + cond_resched(); 32 + } 31 33 } 32 34 33 35 static int bpf_array_alloc_percpu(struct bpf_array *array) ··· 45 43 return -ENOMEM; 46 44 } 47 45 array->pptrs[i] = ptr; 46 + cond_resched(); 48 47 } 49 48 50 49 return 0; ··· 76 73 static struct bpf_map *array_map_alloc(union bpf_attr *attr) 77 74 { 78 75 bool percpu = attr->map_type == BPF_MAP_TYPE_PERCPU_ARRAY; 79 - int numa_node = bpf_map_attr_numa_node(attr); 76 + int ret, numa_node = bpf_map_attr_numa_node(attr); 80 77 u32 elem_size, index_mask, max_entries; 81 78 bool unpriv = !capable(CAP_SYS_ADMIN); 79 + u64 cost, array_size, mask64; 82 80 struct bpf_array *array; 83 - u64 array_size, mask64; 84 81 85 82 elem_size = round_up(attr->value_size, 8); 86 83 ··· 112 109 array_size += (u64) max_entries * elem_size; 113 110 114 111 /* make sure there is no u32 overflow later in round_up() */ 115 - if (array_size >= U32_MAX - PAGE_SIZE) 112 + cost = array_size; 113 + if (cost >= U32_MAX - PAGE_SIZE) 116 114 return ERR_PTR(-ENOMEM); 115 + if (percpu) { 116 + cost += (u64)attr->max_entries * elem_size * num_possible_cpus(); 117 + if (cost >= U32_MAX - PAGE_SIZE) 118 + return ERR_PTR(-ENOMEM); 119 + } 120 + cost = round_up(cost, PAGE_SIZE) >> PAGE_SHIFT; 121 + 122 + ret = bpf_map_precharge_memlock(cost); 123 + if (ret < 0) 124 + return ERR_PTR(ret); 117 125 118 126 /* allocate all map elements and zero-initialize them */ 119 127 array = bpf_map_area_alloc(array_size, numa_node); ··· 135 121 136 122 /* copy mandatory map attributes */ 137 123 bpf_map_init_from_attr(&array->map, attr); 124 + array->map.pages = cost; 138 125 array->elem_size = elem_size; 139 126 140 - if (!percpu) 141 - goto out; 142 - 143 - array_size += (u64) attr->max_entries * elem_size * num_possible_cpus(); 144 - 145 - if (array_size >= U32_MAX - PAGE_SIZE || 146 - bpf_array_alloc_percpu(array)) { 127 + if (percpu && bpf_array_alloc_percpu(array)) { 147 128 bpf_map_area_free(array); 148 129 return ERR_PTR(-ENOMEM); 149 130 } 150 - out: 151 - array->map.pages = round_up(array_size, PAGE_SIZE) >> PAGE_SHIFT; 152 131 153 132 return &array->map; 154 133 }
+1 -1
kernel/bpf/core.c
··· 1590 1590 * so always copy 'cnt' prog_ids to the user. 1591 1591 * In a rare race the user will see zero prog_ids 1592 1592 */ 1593 - ids = kcalloc(cnt, sizeof(u32), GFP_USER); 1593 + ids = kcalloc(cnt, sizeof(u32), GFP_USER | __GFP_NOWARN); 1594 1594 if (!ids) 1595 1595 return -ENOMEM; 1596 1596 rcu_read_lock();
+1 -1
kernel/bpf/cpumap.c
··· 334 334 static struct bpf_cpu_map_entry *__cpu_map_entry_alloc(u32 qsize, u32 cpu, 335 335 int map_id) 336 336 { 337 - gfp_t gfp = GFP_ATOMIC|__GFP_NOWARN; 337 + gfp_t gfp = GFP_KERNEL | __GFP_NOWARN; 338 338 struct bpf_cpu_map_entry *rcpu; 339 339 int numa, err; 340 340
+8 -6
kernel/bpf/lpm_trie.c
··· 555 555 struct lpm_trie_node __rcu **slot; 556 556 struct lpm_trie_node *node; 557 557 558 - raw_spin_lock(&trie->lock); 558 + /* Wait for outstanding programs to complete 559 + * update/lookup/delete/get_next_key and free the trie. 560 + */ 561 + synchronize_rcu(); 559 562 560 563 /* Always start at the root and walk down to a node that has no 561 564 * children. Then free that node, nullify its reference in the parent ··· 569 566 slot = &trie->root; 570 567 571 568 for (;;) { 572 - node = rcu_dereference_protected(*slot, 573 - lockdep_is_held(&trie->lock)); 569 + node = rcu_dereference_protected(*slot, 1); 574 570 if (!node) 575 - goto unlock; 571 + goto out; 576 572 577 573 if (rcu_access_pointer(node->child[0])) { 578 574 slot = &node->child[0]; ··· 589 587 } 590 588 } 591 589 592 - unlock: 593 - raw_spin_unlock(&trie->lock); 590 + out: 591 + kfree(trie); 594 592 } 595 593 596 594 static int trie_get_next_key(struct bpf_map *map, void *_key, void *_next_key)
+2 -1
kernel/bpf/sockmap.c
··· 521 521 static struct bpf_map *sock_map_alloc(union bpf_attr *attr) 522 522 { 523 523 struct bpf_stab *stab; 524 - int err = -EINVAL; 525 524 u64 cost; 525 + int err; 526 526 527 527 if (!capable(CAP_NET_ADMIN)) 528 528 return ERR_PTR(-EPERM); ··· 547 547 548 548 /* make sure page count doesn't overflow */ 549 549 cost = (u64) stab->map.max_entries * sizeof(struct sock *); 550 + err = -EINVAL; 550 551 if (cost >= U32_MAX - PAGE_SIZE) 551 552 goto free_stab; 552 553
+2 -13
kernel/fork.c
··· 592 592 * is dropped: either by a lazy thread or by 593 593 * mmput. Free the page directory and the mm. 594 594 */ 595 - static void __mmdrop(struct mm_struct *mm) 595 + void __mmdrop(struct mm_struct *mm) 596 596 { 597 597 BUG_ON(mm == &init_mm); 598 598 mm_free_pgd(mm); ··· 603 603 put_user_ns(mm->user_ns); 604 604 free_mm(mm); 605 605 } 606 - 607 - void mmdrop(struct mm_struct *mm) 608 - { 609 - /* 610 - * The implicit full barrier implied by atomic_dec_and_test() is 611 - * required by the membarrier system call before returning to 612 - * user-space, after storing to rq->curr. 613 - */ 614 - if (unlikely(atomic_dec_and_test(&mm->mm_count))) 615 - __mmdrop(mm); 616 - } 617 - EXPORT_SYMBOL_GPL(mmdrop); 606 + EXPORT_SYMBOL_GPL(__mmdrop); 618 607 619 608 static void mmdrop_async_fn(struct work_struct *work) 620 609 {
+1 -1
kernel/relay.c
··· 163 163 { 164 164 struct rchan_buf *buf; 165 165 166 - if (chan->n_subbufs > UINT_MAX / sizeof(size_t *)) 166 + if (chan->n_subbufs > KMALLOC_MAX_SIZE / sizeof(size_t *)) 167 167 return NULL; 168 168 169 169 buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL);
+4 -2
kernel/seccomp.c
··· 1076 1076 1077 1077 size = min_t(unsigned long, size, sizeof(kmd)); 1078 1078 1079 - if (copy_from_user(&kmd, data, size)) 1079 + if (size < sizeof(kmd.filter_off)) 1080 + return -EINVAL; 1081 + 1082 + if (copy_from_user(&kmd.filter_off, data, sizeof(kmd.filter_off))) 1080 1083 return -EFAULT; 1081 1084 1082 1085 filter = get_nth_filter(task, kmd.filter_off); 1083 1086 if (IS_ERR(filter)) 1084 1087 return PTR_ERR(filter); 1085 1088 1086 - memset(&kmd, 0, sizeof(kmd)); 1087 1089 if (filter->log) 1088 1090 kmd.flags |= SECCOMP_FILTER_FLAG_LOG; 1089 1091
+2
kernel/trace/bpf_trace.c
··· 872 872 return -EINVAL; 873 873 if (copy_from_user(&query, uquery, sizeof(query))) 874 874 return -EFAULT; 875 + if (query.ids_len > BPF_TRACE_MAX_PROGS) 876 + return -E2BIG; 875 877 876 878 mutex_lock(&bpf_event_mutex); 877 879 ret = bpf_prog_array_copy_info(event->tp_event->prog_array,
+3
kernel/user.c
··· 101 101 .sigpending = ATOMIC_INIT(0), 102 102 .locked_shm = 0, 103 103 .uid = GLOBAL_ROOT_UID, 104 + .ratelimit = RATELIMIT_STATE_INIT(root_user.ratelimit, 0, 0), 104 105 }; 105 106 106 107 /* ··· 192 191 193 192 new->uid = uid; 194 193 atomic_set(&new->__count, 1); 194 + ratelimit_state_init(&new->ratelimit, HZ, 100); 195 + ratelimit_set_flags(&new->ratelimit, RATELIMIT_MSG_ON_RELEASE); 195 196 196 197 /* 197 198 * Before adding this, check whether we raced
+16
kernel/workqueue.c
··· 4180 4180 EXPORT_SYMBOL_GPL(workqueue_set_max_active); 4181 4181 4182 4182 /** 4183 + * current_work - retrieve %current task's work struct 4184 + * 4185 + * Determine if %current task is a workqueue worker and what it's working on. 4186 + * Useful to find out the context that the %current task is running in. 4187 + * 4188 + * Return: work struct if %current task is a workqueue worker, %NULL otherwise. 4189 + */ 4190 + struct work_struct *current_work(void) 4191 + { 4192 + struct worker *worker = current_wq_worker(); 4193 + 4194 + return worker ? worker->current_work : NULL; 4195 + } 4196 + EXPORT_SYMBOL(current_work); 4197 + 4198 + /** 4183 4199 * current_is_workqueue_rescuer - is %current workqueue rescuer? 4184 4200 * 4185 4201 * Determine whether %current is a workqueue rescuer. Can be used from
+1
lib/Kconfig.debug
··· 1642 1642 1643 1643 menuconfig RUNTIME_TESTING_MENU 1644 1644 bool "Runtime Testing" 1645 + def_bool y 1645 1646 1646 1647 if RUNTIME_TESTING_MENU 1647 1648
-2
lib/idr.c
··· 431 431 bitmap = this_cpu_xchg(ida_bitmap, NULL); 432 432 if (!bitmap) 433 433 return -EAGAIN; 434 - memset(bitmap, 0, sizeof(*bitmap)); 435 434 bitmap->bitmap[0] = tmp >> RADIX_TREE_EXCEPTIONAL_SHIFT; 436 435 rcu_assign_pointer(*slot, bitmap); 437 436 } ··· 463 464 bitmap = this_cpu_xchg(ida_bitmap, NULL); 464 465 if (!bitmap) 465 466 return -EAGAIN; 466 - memset(bitmap, 0, sizeof(*bitmap)); 467 467 __set_bit(bit, bitmap->bitmap); 468 468 radix_tree_iter_replace(root, &iter, slot, bitmap); 469 469 }
+1 -1
lib/radix-tree.c
··· 2125 2125 preempt_enable(); 2126 2126 2127 2127 if (!this_cpu_read(ida_bitmap)) { 2128 - struct ida_bitmap *bitmap = kmalloc(sizeof(*bitmap), gfp); 2128 + struct ida_bitmap *bitmap = kzalloc(sizeof(*bitmap), gfp); 2129 2129 if (!bitmap) 2130 2130 return 0; 2131 2131 if (this_cpu_cmpxchg(ida_bitmap, NULL, bitmap))
+1 -1
lib/vsprintf.c
··· 1849 1849 { 1850 1850 const int default_width = 2 * sizeof(void *); 1851 1851 1852 - if (!ptr && *fmt != 'K') { 1852 + if (!ptr && *fmt != 'K' && *fmt != 'x') { 1853 1853 /* 1854 1854 * Print (null) with the same width as a pointer so it makes 1855 1855 * tabular output look nice.
+6
mm/mlock.c
··· 64 64 mod_zone_page_state(page_zone(page), NR_MLOCK, 65 65 -hpage_nr_pages(page)); 66 66 count_vm_event(UNEVICTABLE_PGCLEARED); 67 + /* 68 + * The previous TestClearPageMlocked() corresponds to the smp_mb() 69 + * in __pagevec_lru_add_fn(). 70 + * 71 + * See __pagevec_lru_add_fn for more explanation. 72 + */ 67 73 if (!isolate_lru_page(page)) { 68 74 putback_lru_page(page); 69 75 } else {
+4
mm/page_alloc.c
··· 46 46 #include <linux/stop_machine.h> 47 47 #include <linux/sort.h> 48 48 #include <linux/pfn.h> 49 + #include <xen/xen.h> 49 50 #include <linux/backing-dev.h> 50 51 #include <linux/fault-inject.h> 51 52 #include <linux/page-isolation.h> ··· 347 346 { 348 347 /* Always populate low zones for address-constrained allocations */ 349 348 if (zone_end < pgdat_end_pfn(pgdat)) 349 + return true; 350 + /* Xen PV domains need page structures early */ 351 + if (xen_pv_domain()) 350 352 return true; 351 353 (*nr_initialised)++; 352 354 if ((*nr_initialised > pgdat->static_init_pgcnt) &&
+48 -36
mm/swap.c
··· 446 446 } 447 447 448 448 /** 449 - * add_page_to_unevictable_list - add a page to the unevictable list 450 - * @page: the page to be added to the unevictable list 451 - * 452 - * Add page directly to its zone's unevictable list. To avoid races with 453 - * tasks that might be making the page evictable, through eg. munlock, 454 - * munmap or exit, while it's not on the lru, we want to add the page 455 - * while it's locked or otherwise "invisible" to other tasks. This is 456 - * difficult to do when using the pagevec cache, so bypass that. 457 - */ 458 - void add_page_to_unevictable_list(struct page *page) 459 - { 460 - struct pglist_data *pgdat = page_pgdat(page); 461 - struct lruvec *lruvec; 462 - 463 - spin_lock_irq(&pgdat->lru_lock); 464 - lruvec = mem_cgroup_page_lruvec(page, pgdat); 465 - ClearPageActive(page); 466 - SetPageUnevictable(page); 467 - SetPageLRU(page); 468 - add_page_to_lru_list(page, lruvec, LRU_UNEVICTABLE); 469 - spin_unlock_irq(&pgdat->lru_lock); 470 - } 471 - 472 - /** 473 449 * lru_cache_add_active_or_unevictable 474 450 * @page: the page to be added to LRU 475 451 * @vma: vma in which page is mapped for determining reclaimability ··· 460 484 { 461 485 VM_BUG_ON_PAGE(PageLRU(page), page); 462 486 463 - if (likely((vma->vm_flags & (VM_LOCKED | VM_SPECIAL)) != VM_LOCKED)) { 487 + if (likely((vma->vm_flags & (VM_LOCKED | VM_SPECIAL)) != VM_LOCKED)) 464 488 SetPageActive(page); 465 - lru_cache_add(page); 466 - return; 467 - } 468 - 469 - if (!TestSetPageMlocked(page)) { 489 + else if (!TestSetPageMlocked(page)) { 470 490 /* 471 491 * We use the irq-unsafe __mod_zone_page_stat because this 472 492 * counter is not modified from interrupt context, and the pte ··· 472 500 hpage_nr_pages(page)); 473 501 count_vm_event(UNEVICTABLE_PGMLOCKED); 474 502 } 475 - add_page_to_unevictable_list(page); 503 + lru_cache_add(page); 476 504 } 477 505 478 506 /* ··· 858 886 static void __pagevec_lru_add_fn(struct page *page, struct lruvec *lruvec, 859 887 void *arg) 860 888 { 861 - int file = page_is_file_cache(page); 862 - int active = PageActive(page); 863 - enum lru_list lru = page_lru(page); 889 + enum lru_list lru; 890 + int was_unevictable = TestClearPageUnevictable(page); 864 891 865 892 VM_BUG_ON_PAGE(PageLRU(page), page); 866 893 867 894 SetPageLRU(page); 895 + /* 896 + * Page becomes evictable in two ways: 897 + * 1) Within LRU lock [munlock_vma_pages() and __munlock_pagevec()]. 898 + * 2) Before acquiring LRU lock to put the page to correct LRU and then 899 + * a) do PageLRU check with lock [check_move_unevictable_pages] 900 + * b) do PageLRU check before lock [clear_page_mlock] 901 + * 902 + * (1) & (2a) are ok as LRU lock will serialize them. For (2b), we need 903 + * following strict ordering: 904 + * 905 + * #0: __pagevec_lru_add_fn #1: clear_page_mlock 906 + * 907 + * SetPageLRU() TestClearPageMlocked() 908 + * smp_mb() // explicit ordering // above provides strict 909 + * // ordering 910 + * PageMlocked() PageLRU() 911 + * 912 + * 913 + * if '#1' does not observe setting of PG_lru by '#0' and fails 914 + * isolation, the explicit barrier will make sure that page_evictable 915 + * check will put the page in correct LRU. Without smp_mb(), SetPageLRU 916 + * can be reordered after PageMlocked check and can make '#1' to fail 917 + * the isolation of the page whose Mlocked bit is cleared (#0 is also 918 + * looking at the same page) and the evictable page will be stranded 919 + * in an unevictable LRU. 920 + */ 921 + smp_mb(); 922 + 923 + if (page_evictable(page)) { 924 + lru = page_lru(page); 925 + update_page_reclaim_stat(lruvec, page_is_file_cache(page), 926 + PageActive(page)); 927 + if (was_unevictable) 928 + count_vm_event(UNEVICTABLE_PGRESCUED); 929 + } else { 930 + lru = LRU_UNEVICTABLE; 931 + ClearPageActive(page); 932 + SetPageUnevictable(page); 933 + if (!was_unevictable) 934 + count_vm_event(UNEVICTABLE_PGCULLED); 935 + } 936 + 868 937 add_page_to_lru_list(page, lruvec, lru); 869 - update_page_reclaim_stat(lruvec, file, active); 870 938 trace_mm_lru_insertion(page, lru); 871 939 } 872 940 ··· 925 913 * @pvec: Where the resulting entries are placed 926 914 * @mapping: The address_space to search 927 915 * @start: The starting entry index 928 - * @nr_pages: The maximum number of pages 916 + * @nr_entries: The maximum number of pages 929 917 * @indices: The cache indices corresponding to the entries in @pvec 930 918 * 931 919 * pagevec_lookup_entries() will search for and return a group of up
+7 -3
mm/vmalloc.c
··· 1943 1943 } 1944 1944 1945 1945 #if defined(CONFIG_64BIT) && defined(CONFIG_ZONE_DMA32) 1946 - #define GFP_VMALLOC32 GFP_DMA32 | GFP_KERNEL 1946 + #define GFP_VMALLOC32 (GFP_DMA32 | GFP_KERNEL) 1947 1947 #elif defined(CONFIG_64BIT) && defined(CONFIG_ZONE_DMA) 1948 - #define GFP_VMALLOC32 GFP_DMA | GFP_KERNEL 1948 + #define GFP_VMALLOC32 (GFP_DMA | GFP_KERNEL) 1949 1949 #else 1950 - #define GFP_VMALLOC32 GFP_KERNEL 1950 + /* 1951 + * 64b systems should always have either DMA or DMA32 zones. For others 1952 + * GFP_DMA32 should do the right thing and use the normal zone. 1953 + */ 1954 + #define GFP_VMALLOC32 GFP_DMA32 | GFP_KERNEL 1951 1955 #endif 1952 1956 1953 1957 /**
+1 -58
mm/vmscan.c
··· 769 769 */ 770 770 void putback_lru_page(struct page *page) 771 771 { 772 - bool is_unevictable; 773 - int was_unevictable = PageUnevictable(page); 774 - 775 - VM_BUG_ON_PAGE(PageLRU(page), page); 776 - 777 - redo: 778 - ClearPageUnevictable(page); 779 - 780 - if (page_evictable(page)) { 781 - /* 782 - * For evictable pages, we can use the cache. 783 - * In event of a race, worst case is we end up with an 784 - * unevictable page on [in]active list. 785 - * We know how to handle that. 786 - */ 787 - is_unevictable = false; 788 - lru_cache_add(page); 789 - } else { 790 - /* 791 - * Put unevictable pages directly on zone's unevictable 792 - * list. 793 - */ 794 - is_unevictable = true; 795 - add_page_to_unevictable_list(page); 796 - /* 797 - * When racing with an mlock or AS_UNEVICTABLE clearing 798 - * (page is unlocked) make sure that if the other thread 799 - * does not observe our setting of PG_lru and fails 800 - * isolation/check_move_unevictable_pages, 801 - * we see PG_mlocked/AS_UNEVICTABLE cleared below and move 802 - * the page back to the evictable list. 803 - * 804 - * The other side is TestClearPageMlocked() or shmem_lock(). 805 - */ 806 - smp_mb(); 807 - } 808 - 809 - /* 810 - * page's status can change while we move it among lru. If an evictable 811 - * page is on unevictable list, it never be freed. To avoid that, 812 - * check after we added it to the list, again. 813 - */ 814 - if (is_unevictable && page_evictable(page)) { 815 - if (!isolate_lru_page(page)) { 816 - put_page(page); 817 - goto redo; 818 - } 819 - /* This means someone else dropped this page from LRU 820 - * So, it will be freed or putback to LRU again. There is 821 - * nothing to do here. 822 - */ 823 - } 824 - 825 - if (was_unevictable && !is_unevictable) 826 - count_vm_event(UNEVICTABLE_PGRESCUED); 827 - else if (!was_unevictable && is_unevictable) 828 - count_vm_event(UNEVICTABLE_PGCULLED); 829 - 772 + lru_cache_add(page); 830 773 put_page(page); /* drop ref from isolate */ 831 774 } 832 775
+1 -1
mm/zpool.c
··· 360 360 361 361 /** 362 362 * zpool_evictable() - Test if zpool is potentially evictable 363 - * @pool The zpool to test 363 + * @zpool: The zpool to test 364 364 * 365 365 * Zpool is only potentially evictable when it's created with struct 366 366 * zpool_ops.evict and its driver implements struct zpool_driver.shrink.
+6
mm/zswap.c
··· 1007 1007 u8 *src, *dst; 1008 1008 struct zswap_header zhdr = { .swpentry = swp_entry(type, offset) }; 1009 1009 1010 + /* THP isn't supported */ 1011 + if (PageTransHuge(page)) { 1012 + ret = -EINVAL; 1013 + goto reject; 1014 + } 1015 + 1010 1016 if (!zswap_enabled || !tree) { 1011 1017 ret = -ENODEV; 1012 1018 goto reject;
+5 -5
net/bridge/netfilter/ebt_among.c
··· 187 187 expected_length += ebt_mac_wormhash_size(wh_src); 188 188 189 189 if (em->match_size != EBT_ALIGN(expected_length)) { 190 - pr_info("wrong size: %d against expected %d, rounded to %zd\n", 191 - em->match_size, expected_length, 192 - EBT_ALIGN(expected_length)); 190 + pr_err_ratelimited("wrong size: %d against expected %d, rounded to %zd\n", 191 + em->match_size, expected_length, 192 + EBT_ALIGN(expected_length)); 193 193 return -EINVAL; 194 194 } 195 195 if (wh_dst && (err = ebt_mac_wormhash_check_integrity(wh_dst))) { 196 - pr_info("dst integrity fail: %x\n", -err); 196 + pr_err_ratelimited("dst integrity fail: %x\n", -err); 197 197 return -EINVAL; 198 198 } 199 199 if (wh_src && (err = ebt_mac_wormhash_check_integrity(wh_src))) { 200 - pr_info("src integrity fail: %x\n", -err); 200 + pr_err_ratelimited("src integrity fail: %x\n", -err); 201 201 return -EINVAL; 202 202 } 203 203 return 0;
+2 -2
net/bridge/netfilter/ebt_limit.c
··· 72 72 /* Check for overflow. */ 73 73 if (info->burst == 0 || 74 74 user2credits(info->avg * info->burst) < user2credits(info->avg)) { 75 - pr_info("overflow, try lower: %u/%u\n", 76 - info->avg, info->burst); 75 + pr_info_ratelimited("overflow, try lower: %u/%u\n", 76 + info->avg, info->burst); 77 77 return -EINVAL; 78 78 } 79 79
+1 -5
net/core/filter.c
··· 3381 3381 struct sock *sk = bpf_sock->sk; 3382 3382 int val = argval & BPF_SOCK_OPS_ALL_CB_FLAGS; 3383 3383 3384 - if (!sk_fullsock(sk)) 3384 + if (!IS_ENABLED(CONFIG_INET) || !sk_fullsock(sk)) 3385 3385 return -EINVAL; 3386 3386 3387 - #ifdef CONFIG_INET 3388 3387 if (val) 3389 3388 tcp_sk(sk)->bpf_sock_ops_cb_flags = val; 3390 3389 3391 3390 return argval & (~BPF_SOCK_OPS_ALL_CB_FLAGS); 3392 - #else 3393 - return -EINVAL; 3394 - #endif 3395 3391 } 3396 3392 3397 3393 static const struct bpf_func_proto bpf_sock_ops_cb_flags_set_proto = {
+1
net/core/gen_estimator.c
··· 66 66 static void est_fetch_counters(struct net_rate_estimator *e, 67 67 struct gnet_stats_basic_packed *b) 68 68 { 69 + memset(b, 0, sizeof(*b)); 69 70 if (e->stats_lock) 70 71 spin_lock(e->stats_lock); 71 72
+1 -6
net/ipv4/ip_sockglue.c
··· 1569 1569 if (get_user(len, optlen)) 1570 1570 return -EFAULT; 1571 1571 1572 - lock_sock(sk); 1573 - err = nf_getsockopt(sk, PF_INET, optname, optval, 1574 - &len); 1575 - release_sock(sk); 1572 + err = nf_getsockopt(sk, PF_INET, optname, optval, &len); 1576 1573 if (err >= 0) 1577 1574 err = put_user(len, optlen); 1578 1575 return err; ··· 1601 1604 if (get_user(len, optlen)) 1602 1605 return -EFAULT; 1603 1606 1604 - lock_sock(sk); 1605 1607 err = compat_nf_getsockopt(sk, PF_INET, optname, optval, &len); 1606 - release_sock(sk); 1607 1608 if (err >= 0) 1608 1609 err = put_user(len, optlen); 1609 1610 return err;
+4
net/ipv4/netfilter/arp_tables.c
··· 252 252 } 253 253 if (table_base + v 254 254 != arpt_next_entry(e)) { 255 + if (unlikely(stackidx >= private->stacksize)) { 256 + verdict = NF_DROP; 257 + break; 258 + } 255 259 jumpstack[stackidx++] = e; 256 260 } 257 261
+6 -1
net/ipv4/netfilter/ip_tables.c
··· 330 330 continue; 331 331 } 332 332 if (table_base + v != ipt_next_entry(e) && 333 - !(e->ip.flags & IPT_F_GOTO)) 333 + !(e->ip.flags & IPT_F_GOTO)) { 334 + if (unlikely(stackidx >= private->stacksize)) { 335 + verdict = NF_DROP; 336 + break; 337 + } 334 338 jumpstack[stackidx++] = e; 339 + } 335 340 336 341 e = get_entry(table_base, v); 337 342 continue;
+12 -8
net/ipv4/netfilter/ipt_CLUSTERIP.c
··· 107 107 108 108 local_bh_disable(); 109 109 if (refcount_dec_and_lock(&c->entries, &cn->lock)) { 110 - list_del_rcu(&c->list); 111 - spin_unlock(&cn->lock); 112 - local_bh_enable(); 113 - 114 - unregister_netdevice_notifier(&c->notifier); 115 - 116 110 /* In case anyone still accesses the file, the open/close 117 111 * functions are also incrementing the refcount on their own, 118 112 * so it's safe to remove the entry even if it's in use. */ ··· 114 120 if (cn->procdir) 115 121 proc_remove(c->pde); 116 122 #endif 123 + list_del_rcu(&c->list); 124 + spin_unlock(&cn->lock); 125 + local_bh_enable(); 126 + 127 + unregister_netdevice_notifier(&c->notifier); 128 + 117 129 return; 118 130 } 119 131 local_bh_enable(); ··· 154 154 #endif 155 155 if (unlikely(!refcount_inc_not_zero(&c->refcount))) 156 156 c = NULL; 157 - else if (entry) 158 - refcount_inc(&c->entries); 157 + else if (entry) { 158 + if (unlikely(!refcount_inc_not_zero(&c->entries))) { 159 + clusterip_config_put(c); 160 + c = NULL; 161 + } 162 + } 159 163 } 160 164 rcu_read_unlock_bh(); 161 165
+5 -7
net/ipv4/netfilter/ipt_ECN.c
··· 98 98 const struct ipt_ECN_info *einfo = par->targinfo; 99 99 const struct ipt_entry *e = par->entryinfo; 100 100 101 - if (einfo->operation & IPT_ECN_OP_MASK) { 102 - pr_info("unsupported ECN operation %x\n", einfo->operation); 101 + if (einfo->operation & IPT_ECN_OP_MASK) 103 102 return -EINVAL; 104 - } 105 - if (einfo->ip_ect & ~IPT_ECN_IP_MASK) { 106 - pr_info("new ECT codepoint %x out of mask\n", einfo->ip_ect); 103 + 104 + if (einfo->ip_ect & ~IPT_ECN_IP_MASK) 107 105 return -EINVAL; 108 - } 106 + 109 107 if ((einfo->operation & (IPT_ECN_OP_SET_ECE|IPT_ECN_OP_SET_CWR)) && 110 108 (e->ip.proto != IPPROTO_TCP || (e->ip.invflags & XT_INV_PROTO))) { 111 - pr_info("cannot use TCP operations on a non-tcp rule\n"); 109 + pr_info_ratelimited("cannot use operation on non-tcp rule\n"); 112 110 return -EINVAL; 113 111 } 114 112 return 0;
+2 -2
net/ipv4/netfilter/ipt_REJECT.c
··· 74 74 const struct ipt_entry *e = par->entryinfo; 75 75 76 76 if (rejinfo->with == IPT_ICMP_ECHOREPLY) { 77 - pr_info("ECHOREPLY no longer supported.\n"); 77 + pr_info_ratelimited("ECHOREPLY no longer supported.\n"); 78 78 return -EINVAL; 79 79 } else if (rejinfo->with == IPT_TCP_RESET) { 80 80 /* Must specify that it's a TCP packet */ 81 81 if (e->ip.proto != IPPROTO_TCP || 82 82 (e->ip.invflags & XT_INV_PROTO)) { 83 - pr_info("TCP_RESET invalid for non-tcp\n"); 83 + pr_info_ratelimited("TCP_RESET invalid for non-tcp\n"); 84 84 return -EINVAL; 85 85 } 86 86 }
+3 -3
net/ipv4/netfilter/ipt_rpfilter.c
··· 105 105 const struct xt_rpfilter_info *info = par->matchinfo; 106 106 unsigned int options = ~XT_RPFILTER_OPTION_MASK; 107 107 if (info->flags & options) { 108 - pr_info("unknown options encountered"); 108 + pr_info_ratelimited("unknown options\n"); 109 109 return -EINVAL; 110 110 } 111 111 112 112 if (strcmp(par->table, "mangle") != 0 && 113 113 strcmp(par->table, "raw") != 0) { 114 - pr_info("match only valid in the \'raw\' " 115 - "or \'mangle\' tables, not \'%s\'.\n", par->table); 114 + pr_info_ratelimited("only valid in \'raw\' or \'mangle\' table, not \'%s\'\n", 115 + par->table); 116 116 return -EINVAL; 117 117 } 118 118
+2
net/ipv4/route.c
··· 1811 1811 return skb_get_hash_raw(skb) >> 1; 1812 1812 memset(&hash_keys, 0, sizeof(hash_keys)); 1813 1813 skb_flow_dissect_flow_keys(skb, &keys, flag); 1814 + 1815 + hash_keys.control.addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS; 1814 1816 hash_keys.addrs.v4addrs.src = keys.addrs.v4addrs.src; 1815 1817 hash_keys.addrs.v4addrs.dst = keys.addrs.v4addrs.dst; 1816 1818 hash_keys.ports.src = keys.ports.src;
+5 -4
net/ipv4/tcp_output.c
··· 1718 1718 */ 1719 1719 segs = max_t(u32, bytes / mss_now, min_tso_segs); 1720 1720 1721 - return min_t(u32, segs, sk->sk_gso_max_segs); 1721 + return segs; 1722 1722 } 1723 1723 EXPORT_SYMBOL(tcp_tso_autosize); 1724 1724 ··· 1730 1730 const struct tcp_congestion_ops *ca_ops = inet_csk(sk)->icsk_ca_ops; 1731 1731 u32 tso_segs = ca_ops->tso_segs_goal ? ca_ops->tso_segs_goal(sk) : 0; 1732 1732 1733 - return tso_segs ? : 1734 - tcp_tso_autosize(sk, mss_now, 1735 - sock_net(sk)->ipv4.sysctl_tcp_min_tso_segs); 1733 + if (!tso_segs) 1734 + tso_segs = tcp_tso_autosize(sk, mss_now, 1735 + sock_net(sk)->ipv4.sysctl_tcp_min_tso_segs); 1736 + return min_t(u32, tso_segs, sk->sk_gso_max_segs); 1736 1737 } 1737 1738 1738 1739 /* Returns the portion of skb which can be sent right away */
+2 -8
net/ipv6/ipv6_sockglue.c
··· 1367 1367 if (get_user(len, optlen)) 1368 1368 return -EFAULT; 1369 1369 1370 - lock_sock(sk); 1371 - err = nf_getsockopt(sk, PF_INET6, optname, optval, 1372 - &len); 1373 - release_sock(sk); 1370 + err = nf_getsockopt(sk, PF_INET6, optname, optval, &len); 1374 1371 if (err >= 0) 1375 1372 err = put_user(len, optlen); 1376 1373 } ··· 1406 1409 if (get_user(len, optlen)) 1407 1410 return -EFAULT; 1408 1411 1409 - lock_sock(sk); 1410 - err = compat_nf_getsockopt(sk, PF_INET6, 1411 - optname, optval, &len); 1412 - release_sock(sk); 1412 + err = compat_nf_getsockopt(sk, PF_INET6, optname, optval, &len); 1413 1413 if (err >= 0) 1414 1414 err = put_user(len, optlen); 1415 1415 }
+4
net/ipv6/netfilter/ip6_tables.c
··· 352 352 } 353 353 if (table_base + v != ip6t_next_entry(e) && 354 354 !(e->ipv6.flags & IP6T_F_GOTO)) { 355 + if (unlikely(stackidx >= private->stacksize)) { 356 + verdict = NF_DROP; 357 + break; 358 + } 355 359 jumpstack[stackidx++] = e; 356 360 } 357 361
+2 -2
net/ipv6/netfilter/ip6t_REJECT.c
··· 85 85 const struct ip6t_entry *e = par->entryinfo; 86 86 87 87 if (rejinfo->with == IP6T_ICMP6_ECHOREPLY) { 88 - pr_info("ECHOREPLY is not supported.\n"); 88 + pr_info_ratelimited("ECHOREPLY is not supported\n"); 89 89 return -EINVAL; 90 90 } else if (rejinfo->with == IP6T_TCP_RESET) { 91 91 /* Must specify that it's a TCP packet */ 92 92 if (!(e->ipv6.flags & IP6T_F_PROTO) || 93 93 e->ipv6.proto != IPPROTO_TCP || 94 94 (e->ipv6.invflags & XT_INV_PROTO)) { 95 - pr_info("TCP_RESET illegal for non-tcp\n"); 95 + pr_info_ratelimited("TCP_RESET illegal for non-tcp\n"); 96 96 return -EINVAL; 97 97 } 98 98 }
+3 -3
net/ipv6/netfilter/ip6t_rpfilter.c
··· 103 103 unsigned int options = ~XT_RPFILTER_OPTION_MASK; 104 104 105 105 if (info->flags & options) { 106 - pr_info("unknown options encountered"); 106 + pr_info_ratelimited("unknown options\n"); 107 107 return -EINVAL; 108 108 } 109 109 110 110 if (strcmp(par->table, "mangle") != 0 && 111 111 strcmp(par->table, "raw") != 0) { 112 - pr_info("match only valid in the \'raw\' " 113 - "or \'mangle\' tables, not \'%s\'.\n", par->table); 112 + pr_info_ratelimited("only valid in \'raw\' or \'mangle\' table, not \'%s\'\n", 113 + par->table); 114 114 return -EINVAL; 115 115 } 116 116
+4 -2
net/ipv6/netfilter/ip6t_srh.c
··· 122 122 const struct ip6t_srh *srhinfo = par->matchinfo; 123 123 124 124 if (srhinfo->mt_flags & ~IP6T_SRH_MASK) { 125 - pr_err("unknown srh match flags %X\n", srhinfo->mt_flags); 125 + pr_info_ratelimited("unknown srh match flags %X\n", 126 + srhinfo->mt_flags); 126 127 return -EINVAL; 127 128 } 128 129 129 130 if (srhinfo->mt_invflags & ~IP6T_SRH_INV_MASK) { 130 - pr_err("unknown srh invflags %X\n", srhinfo->mt_invflags); 131 + pr_info_ratelimited("unknown srh invflags %X\n", 132 + srhinfo->mt_invflags); 131 133 return -EINVAL; 132 134 } 133 135
+1 -1
net/ipv6/sit.c
··· 182 182 #ifdef CONFIG_IPV6_SIT_6RD 183 183 struct ip_tunnel *t = netdev_priv(dev); 184 184 185 - if (t->dev == sitn->fb_tunnel_dev) { 185 + if (dev == sitn->fb_tunnel_dev) { 186 186 ipv6_addr_set(&t->ip6rd.prefix, htonl(0x20020000), 0, 0, 0); 187 187 t->ip6rd.relay_prefix = 0; 188 188 t->ip6rd.prefixlen = 16;
+1 -3
net/mac80211/agg-rx.c
··· 8 8 * Copyright 2007, Michael Wu <flamingice@sourmilk.net> 9 9 * Copyright 2007-2010, Intel Corporation 10 10 * Copyright(c) 2015-2017 Intel Deutschland GmbH 11 + * Copyright (C) 2018 Intel Corporation 11 12 * 12 13 * This program is free software; you can redistribute it and/or modify 13 14 * it under the terms of the GNU General Public License version 2 as ··· 305 304 * driver so reject the timeout update. 306 305 */ 307 306 status = WLAN_STATUS_REQUEST_DECLINED; 308 - ieee80211_send_addba_resp(sta->sdata, sta->sta.addr, 309 - tid, dialog_token, status, 310 - 1, buf_size, timeout); 311 307 goto end; 312 308 } 313 309
+1 -1
net/mac80211/cfg.c
··· 2892 2892 } 2893 2893 if (beacon->probe_resp_len) { 2894 2894 new_beacon->probe_resp_len = beacon->probe_resp_len; 2895 - beacon->probe_resp = pos; 2895 + new_beacon->probe_resp = pos; 2896 2896 memcpy(pos, beacon->probe_resp, beacon->probe_resp_len); 2897 2897 pos += beacon->probe_resp_len; 2898 2898 }
+1 -1
net/mac80211/ieee80211_i.h
··· 1467 1467 const struct ieee80211_timeout_interval_ie *timeout_int; 1468 1468 const u8 *opmode_notif; 1469 1469 const struct ieee80211_sec_chan_offs_ie *sec_chan_offs; 1470 - const struct ieee80211_mesh_chansw_params_ie *mesh_chansw_params_ie; 1470 + struct ieee80211_mesh_chansw_params_ie *mesh_chansw_params_ie; 1471 1471 const struct ieee80211_bss_max_idle_period_ie *max_idle_period_ie; 1472 1472 1473 1473 /* length of them, respectively */
+6 -11
net/mac80211/mesh.c
··· 1255 1255 } 1256 1256 1257 1257 static int mesh_fwd_csa_frame(struct ieee80211_sub_if_data *sdata, 1258 - struct ieee80211_mgmt *mgmt, size_t len) 1258 + struct ieee80211_mgmt *mgmt, size_t len, 1259 + struct ieee802_11_elems *elems) 1259 1260 { 1260 1261 struct ieee80211_mgmt *mgmt_fwd; 1261 1262 struct sk_buff *skb; 1262 1263 struct ieee80211_local *local = sdata->local; 1263 - u8 *pos = mgmt->u.action.u.chan_switch.variable; 1264 - size_t offset_ttl; 1265 1264 1266 1265 skb = dev_alloc_skb(local->tx_headroom + len); 1267 1266 if (!skb) ··· 1268 1269 skb_reserve(skb, local->tx_headroom); 1269 1270 mgmt_fwd = skb_put(skb, len); 1270 1271 1271 - /* offset_ttl is based on whether the secondary channel 1272 - * offset is available or not. Subtract 1 from the mesh TTL 1273 - * and disable the initiator flag before forwarding. 1274 - */ 1275 - offset_ttl = (len < 42) ? 7 : 10; 1276 - *(pos + offset_ttl) -= 1; 1277 - *(pos + offset_ttl + 1) &= ~WLAN_EID_CHAN_SWITCH_PARAM_INITIATOR; 1272 + elems->mesh_chansw_params_ie->mesh_ttl--; 1273 + elems->mesh_chansw_params_ie->mesh_flags &= 1274 + ~WLAN_EID_CHAN_SWITCH_PARAM_INITIATOR; 1278 1275 1279 1276 memcpy(mgmt_fwd, mgmt, len); 1280 1277 eth_broadcast_addr(mgmt_fwd->da); ··· 1318 1323 1319 1324 /* forward or re-broadcast the CSA frame */ 1320 1325 if (fwd_csa) { 1321 - if (mesh_fwd_csa_frame(sdata, mgmt, len) < 0) 1326 + if (mesh_fwd_csa_frame(sdata, mgmt, len, &elems) < 0) 1322 1327 mcsa_dbg(sdata, "Failed to forward the CSA frame"); 1323 1328 } 1324 1329 }
+3 -4
net/mac80211/spectmgmt.c
··· 8 8 * Copyright 2007, Michael Wu <flamingice@sourmilk.net> 9 9 * Copyright 2007-2008, Intel Corporation 10 10 * Copyright 2008, Johannes Berg <johannes@sipsolutions.net> 11 + * Copyright (C) 2018 Intel Corporation 11 12 * 12 13 * This program is free software; you can redistribute it and/or modify 13 14 * it under the terms of the GNU General Public License version 2 as ··· 28 27 u32 sta_flags, u8 *bssid, 29 28 struct ieee80211_csa_ie *csa_ie) 30 29 { 31 - enum nl80211_band new_band; 30 + enum nl80211_band new_band = current_band; 32 31 int new_freq; 33 32 u8 new_chan_no; 34 33 struct ieee80211_channel *new_chan; ··· 56 55 elems->ext_chansw_ie->new_operating_class, 57 56 &new_band)) { 58 57 sdata_info(sdata, 59 - "cannot understand ECSA IE operating class %d, disconnecting\n", 58 + "cannot understand ECSA IE operating class, %d, ignoring\n", 60 59 elems->ext_chansw_ie->new_operating_class); 61 - return -EINVAL; 62 60 } 63 61 new_chan_no = elems->ext_chansw_ie->new_ch_num; 64 62 csa_ie->count = elems->ext_chansw_ie->count; 65 63 csa_ie->mode = elems->ext_chansw_ie->mode; 66 64 } else if (elems->ch_switch_ie) { 67 - new_band = current_band; 68 65 new_chan_no = elems->ch_switch_ie->new_ch_num; 69 66 csa_ie->count = elems->ch_switch_ie->count; 70 67 csa_ie->mode = elems->ch_switch_ie->mode;
+2 -1
net/mac80211/sta_info.c
··· 314 314 315 315 if (ieee80211_hw_check(hw, USES_RSS)) { 316 316 sta->pcpu_rx_stats = 317 - alloc_percpu(struct ieee80211_sta_rx_stats); 317 + alloc_percpu_gfp(struct ieee80211_sta_rx_stats, gfp); 318 318 if (!sta->pcpu_rx_stats) 319 319 goto free; 320 320 } ··· 433 433 if (sta->sta.txq[0]) 434 434 kfree(to_txq_info(sta->sta.txq[0])); 435 435 free: 436 + free_percpu(sta->pcpu_rx_stats); 436 437 #ifdef CONFIG_MAC80211_MESH 437 438 kfree(sta->mesh); 438 439 #endif
+5 -2
net/netfilter/nf_nat_proto_common.c
··· 41 41 const struct nf_conn *ct, 42 42 u16 *rover) 43 43 { 44 - unsigned int range_size, min, i; 44 + unsigned int range_size, min, max, i; 45 45 __be16 *portptr; 46 46 u_int16_t off; 47 47 ··· 71 71 } 72 72 } else { 73 73 min = ntohs(range->min_proto.all); 74 - range_size = ntohs(range->max_proto.all) - min + 1; 74 + max = ntohs(range->max_proto.all); 75 + if (unlikely(max < min)) 76 + swap(max, min); 77 + range_size = max - min + 1; 75 78 } 76 79 77 80 if (range->flags & NF_NAT_RANGE_PROTO_RANDOM) {
+34 -40
net/netfilter/x_tables.c
··· 434 434 * ebt_among is exempt from centralized matchsize checking 435 435 * because it uses a dynamic-size data set. 436 436 */ 437 - pr_err("%s_tables: %s.%u match: invalid size " 438 - "%u (kernel) != (user) %u\n", 439 - xt_prefix[par->family], par->match->name, 440 - par->match->revision, 441 - XT_ALIGN(par->match->matchsize), size); 437 + pr_err_ratelimited("%s_tables: %s.%u match: invalid size %u (kernel) != (user) %u\n", 438 + xt_prefix[par->family], par->match->name, 439 + par->match->revision, 440 + XT_ALIGN(par->match->matchsize), size); 442 441 return -EINVAL; 443 442 } 444 443 if (par->match->table != NULL && 445 444 strcmp(par->match->table, par->table) != 0) { 446 - pr_err("%s_tables: %s match: only valid in %s table, not %s\n", 447 - xt_prefix[par->family], par->match->name, 448 - par->match->table, par->table); 445 + pr_info_ratelimited("%s_tables: %s match: only valid in %s table, not %s\n", 446 + xt_prefix[par->family], par->match->name, 447 + par->match->table, par->table); 449 448 return -EINVAL; 450 449 } 451 450 if (par->match->hooks && (par->hook_mask & ~par->match->hooks) != 0) { 452 451 char used[64], allow[64]; 453 452 454 - pr_err("%s_tables: %s match: used from hooks %s, but only " 455 - "valid from %s\n", 456 - xt_prefix[par->family], par->match->name, 457 - textify_hooks(used, sizeof(used), par->hook_mask, 458 - par->family), 459 - textify_hooks(allow, sizeof(allow), par->match->hooks, 460 - par->family)); 453 + pr_info_ratelimited("%s_tables: %s match: used from hooks %s, but only valid from %s\n", 454 + xt_prefix[par->family], par->match->name, 455 + textify_hooks(used, sizeof(used), 456 + par->hook_mask, par->family), 457 + textify_hooks(allow, sizeof(allow), 458 + par->match->hooks, 459 + par->family)); 461 460 return -EINVAL; 462 461 } 463 462 if (par->match->proto && (par->match->proto != proto || inv_proto)) { 464 - pr_err("%s_tables: %s match: only valid for protocol %u\n", 465 - xt_prefix[par->family], par->match->name, 466 - par->match->proto); 463 + pr_info_ratelimited("%s_tables: %s match: only valid for protocol %u\n", 464 + xt_prefix[par->family], par->match->name, 465 + par->match->proto); 467 466 return -EINVAL; 468 467 } 469 468 if (par->match->checkentry != NULL) { ··· 813 814 int ret; 814 815 815 816 if (XT_ALIGN(par->target->targetsize) != size) { 816 - pr_err("%s_tables: %s.%u target: invalid size " 817 - "%u (kernel) != (user) %u\n", 818 - xt_prefix[par->family], par->target->name, 819 - par->target->revision, 820 - XT_ALIGN(par->target->targetsize), size); 817 + pr_err_ratelimited("%s_tables: %s.%u target: invalid size %u (kernel) != (user) %u\n", 818 + xt_prefix[par->family], par->target->name, 819 + par->target->revision, 820 + XT_ALIGN(par->target->targetsize), size); 821 821 return -EINVAL; 822 822 } 823 823 if (par->target->table != NULL && 824 824 strcmp(par->target->table, par->table) != 0) { 825 - pr_err("%s_tables: %s target: only valid in %s table, not %s\n", 826 - xt_prefix[par->family], par->target->name, 827 - par->target->table, par->table); 825 + pr_info_ratelimited("%s_tables: %s target: only valid in %s table, not %s\n", 826 + xt_prefix[par->family], par->target->name, 827 + par->target->table, par->table); 828 828 return -EINVAL; 829 829 } 830 830 if (par->target->hooks && (par->hook_mask & ~par->target->hooks) != 0) { 831 831 char used[64], allow[64]; 832 832 833 - pr_err("%s_tables: %s target: used from hooks %s, but only " 834 - "usable from %s\n", 835 - xt_prefix[par->family], par->target->name, 836 - textify_hooks(used, sizeof(used), par->hook_mask, 837 - par->family), 838 - textify_hooks(allow, sizeof(allow), par->target->hooks, 839 - par->family)); 833 + pr_info_ratelimited("%s_tables: %s target: used from hooks %s, but only usable from %s\n", 834 + xt_prefix[par->family], par->target->name, 835 + textify_hooks(used, sizeof(used), 836 + par->hook_mask, par->family), 837 + textify_hooks(allow, sizeof(allow), 838 + par->target->hooks, 839 + par->family)); 840 840 return -EINVAL; 841 841 } 842 842 if (par->target->proto && (par->target->proto != proto || inv_proto)) { 843 - pr_err("%s_tables: %s target: only valid for protocol %u\n", 844 - xt_prefix[par->family], par->target->name, 845 - par->target->proto); 843 + pr_info_ratelimited("%s_tables: %s target: only valid for protocol %u\n", 844 + xt_prefix[par->family], par->target->name, 845 + par->target->proto); 846 846 return -EINVAL; 847 847 } 848 848 if (par->target->checkentry != NULL) { ··· 1000 1002 size_t sz = sizeof(*info) + size; 1001 1003 1002 1004 if (sz < sizeof(*info)) 1003 - return NULL; 1004 - 1005 - /* Pedantry: prevent them from hitting BUG() in vmalloc.c --RR */ 1006 - if ((size >> PAGE_SHIFT) + 2 > totalram_pages) 1007 1005 return NULL; 1008 1006 1009 1007 /* __GFP_NORETRY is not fully supported by kvmalloc but it should
+2 -2
net/netfilter/xt_AUDIT.c
··· 120 120 const struct xt_audit_info *info = par->targinfo; 121 121 122 122 if (info->type > XT_AUDIT_TYPE_MAX) { 123 - pr_info("Audit type out of range (valid range: 0..%hhu)\n", 124 - XT_AUDIT_TYPE_MAX); 123 + pr_info_ratelimited("Audit type out of range (valid range: 0..%hhu)\n", 124 + XT_AUDIT_TYPE_MAX); 125 125 return -ERANGE; 126 126 } 127 127
+4 -4
net/netfilter/xt_CHECKSUM.c
··· 36 36 const struct xt_CHECKSUM_info *einfo = par->targinfo; 37 37 38 38 if (einfo->operation & ~XT_CHECKSUM_OP_FILL) { 39 - pr_info("unsupported CHECKSUM operation %x\n", einfo->operation); 39 + pr_info_ratelimited("unsupported CHECKSUM operation %x\n", 40 + einfo->operation); 40 41 return -EINVAL; 41 42 } 42 - if (!einfo->operation) { 43 - pr_info("no CHECKSUM operation enabled\n"); 43 + if (!einfo->operation) 44 44 return -EINVAL; 45 - } 45 + 46 46 return 0; 47 47 } 48 48
+5 -5
net/netfilter/xt_CONNSECMARK.c
··· 91 91 92 92 if (strcmp(par->table, "mangle") != 0 && 93 93 strcmp(par->table, "security") != 0) { 94 - pr_info("target only valid in the \'mangle\' " 95 - "or \'security\' tables, not \'%s\'.\n", par->table); 94 + pr_info_ratelimited("only valid in \'mangle\' or \'security\' table, not \'%s\'\n", 95 + par->table); 96 96 return -EINVAL; 97 97 } 98 98 ··· 102 102 break; 103 103 104 104 default: 105 - pr_info("invalid mode: %hu\n", info->mode); 105 + pr_info_ratelimited("invalid mode: %hu\n", info->mode); 106 106 return -EINVAL; 107 107 } 108 108 109 109 ret = nf_ct_netns_get(par->net, par->family); 110 110 if (ret < 0) 111 - pr_info("cannot load conntrack support for proto=%u\n", 112 - par->family); 111 + pr_info_ratelimited("cannot load conntrack support for proto=%u\n", 112 + par->family); 113 113 return ret; 114 114 } 115 115
+13 -12
net/netfilter/xt_CT.c
··· 82 82 83 83 proto = xt_ct_find_proto(par); 84 84 if (!proto) { 85 - pr_info("You must specify a L4 protocol, and not use " 86 - "inversions on it.\n"); 85 + pr_info_ratelimited("You must specify a L4 protocol and not use inversions on it\n"); 87 86 return -ENOENT; 88 87 } 89 88 90 89 helper = nf_conntrack_helper_try_module_get(helper_name, par->family, 91 90 proto); 92 91 if (helper == NULL) { 93 - pr_info("No such helper \"%s\"\n", helper_name); 92 + pr_info_ratelimited("No such helper \"%s\"\n", helper_name); 94 93 return -ENOENT; 95 94 } 96 95 ··· 123 124 const struct nf_conntrack_l4proto *l4proto; 124 125 struct ctnl_timeout *timeout; 125 126 struct nf_conn_timeout *timeout_ext; 127 + const char *errmsg = NULL; 126 128 int ret = 0; 127 129 u8 proto; 128 130 ··· 131 131 timeout_find_get = rcu_dereference(nf_ct_timeout_find_get_hook); 132 132 if (timeout_find_get == NULL) { 133 133 ret = -ENOENT; 134 - pr_info("Timeout policy base is empty\n"); 134 + errmsg = "Timeout policy base is empty"; 135 135 goto out; 136 136 } 137 137 138 138 proto = xt_ct_find_proto(par); 139 139 if (!proto) { 140 140 ret = -EINVAL; 141 - pr_info("You must specify a L4 protocol, and not use " 142 - "inversions on it.\n"); 141 + errmsg = "You must specify a L4 protocol and not use inversions on it"; 143 142 goto out; 144 143 } 145 144 146 145 timeout = timeout_find_get(par->net, timeout_name); 147 146 if (timeout == NULL) { 148 147 ret = -ENOENT; 149 - pr_info("No such timeout policy \"%s\"\n", timeout_name); 148 + pr_info_ratelimited("No such timeout policy \"%s\"\n", 149 + timeout_name); 150 150 goto out; 151 151 } 152 152 153 153 if (timeout->l3num != par->family) { 154 154 ret = -EINVAL; 155 - pr_info("Timeout policy `%s' can only be used by L3 protocol " 156 - "number %d\n", timeout_name, timeout->l3num); 155 + pr_info_ratelimited("Timeout policy `%s' can only be used by L%d protocol number %d\n", 156 + timeout_name, 3, timeout->l3num); 157 157 goto err_put_timeout; 158 158 } 159 159 /* Make sure the timeout policy matches any existing protocol tracker, ··· 162 162 l4proto = __nf_ct_l4proto_find(par->family, proto); 163 163 if (timeout->l4proto->l4proto != l4proto->l4proto) { 164 164 ret = -EINVAL; 165 - pr_info("Timeout policy `%s' can only be used by L4 protocol " 166 - "number %d\n", 167 - timeout_name, timeout->l4proto->l4proto); 165 + pr_info_ratelimited("Timeout policy `%s' can only be used by L%d protocol number %d\n", 166 + timeout_name, 4, timeout->l4proto->l4proto); 168 167 goto err_put_timeout; 169 168 } 170 169 timeout_ext = nf_ct_timeout_ext_add(ct, timeout, GFP_ATOMIC); ··· 179 180 __xt_ct_tg_timeout_put(timeout); 180 181 out: 181 182 rcu_read_unlock(); 183 + if (errmsg) 184 + pr_info_ratelimited("%s\n", errmsg); 182 185 return ret; 183 186 #else 184 187 return -EOPNOTSUPP;
+1 -3
net/netfilter/xt_DSCP.c
··· 66 66 { 67 67 const struct xt_DSCP_info *info = par->targinfo; 68 68 69 - if (info->dscp > XT_DSCP_MAX) { 70 - pr_info("dscp %x out of range\n", info->dscp); 69 + if (info->dscp > XT_DSCP_MAX) 71 70 return -EDOM; 72 - } 73 71 return 0; 74 72 } 75 73
+3 -10
net/netfilter/xt_HL.c
··· 105 105 { 106 106 const struct ipt_TTL_info *info = par->targinfo; 107 107 108 - if (info->mode > IPT_TTL_MAXMODE) { 109 - pr_info("TTL: invalid or unknown mode %u\n", info->mode); 108 + if (info->mode > IPT_TTL_MAXMODE) 110 109 return -EINVAL; 111 - } 112 110 if (info->mode != IPT_TTL_SET && info->ttl == 0) 113 111 return -EINVAL; 114 112 return 0; ··· 116 118 { 117 119 const struct ip6t_HL_info *info = par->targinfo; 118 120 119 - if (info->mode > IP6T_HL_MAXMODE) { 120 - pr_info("invalid or unknown mode %u\n", info->mode); 121 + if (info->mode > IP6T_HL_MAXMODE) 121 122 return -EINVAL; 122 - } 123 - if (info->mode != IP6T_HL_SET && info->hop_limit == 0) { 124 - pr_info("increment/decrement does not " 125 - "make sense with value 0\n"); 123 + if (info->mode != IP6T_HL_SET && info->hop_limit == 0) 126 124 return -EINVAL; 127 - } 128 125 return 0; 129 126 } 130 127
+15 -12
net/netfilter/xt_HMARK.c
··· 9 9 * the Free Software Foundation. 10 10 */ 11 11 12 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 13 + 12 14 #include <linux/module.h> 13 15 #include <linux/skbuff.h> 14 16 #include <linux/icmp.h> ··· 314 312 static int hmark_tg_check(const struct xt_tgchk_param *par) 315 313 { 316 314 const struct xt_hmark_info *info = par->targinfo; 315 + const char *errmsg = "proto mask must be zero with L3 mode"; 317 316 318 - if (!info->hmodulus) { 319 - pr_info("xt_HMARK: hash modulus can't be zero\n"); 317 + if (!info->hmodulus) 320 318 return -EINVAL; 321 - } 319 + 322 320 if (info->proto_mask && 323 - (info->flags & XT_HMARK_FLAG(XT_HMARK_METHOD_L3))) { 324 - pr_info("xt_HMARK: proto mask must be zero with L3 mode\n"); 325 - return -EINVAL; 326 - } 321 + (info->flags & XT_HMARK_FLAG(XT_HMARK_METHOD_L3))) 322 + goto err; 323 + 327 324 if (info->flags & XT_HMARK_FLAG(XT_HMARK_SPI_MASK) && 328 325 (info->flags & (XT_HMARK_FLAG(XT_HMARK_SPORT_MASK) | 329 - XT_HMARK_FLAG(XT_HMARK_DPORT_MASK)))) { 330 - pr_info("xt_HMARK: spi-mask and port-mask can't be combined\n"); 326 + XT_HMARK_FLAG(XT_HMARK_DPORT_MASK)))) 331 327 return -EINVAL; 332 - } 328 + 333 329 if (info->flags & XT_HMARK_FLAG(XT_HMARK_SPI) && 334 330 (info->flags & (XT_HMARK_FLAG(XT_HMARK_SPORT) | 335 331 XT_HMARK_FLAG(XT_HMARK_DPORT)))) { 336 - pr_info("xt_HMARK: spi-set and port-set can't be combined\n"); 337 - return -EINVAL; 332 + errmsg = "spi-set and port-set can't be combined"; 333 + goto err; 338 334 } 339 335 return 0; 336 + err: 337 + pr_info_ratelimited("%s\n", errmsg); 338 + return -EINVAL; 340 339 } 341 340 342 341 static struct xt_target hmark_tg_reg[] __read_mostly = {
+6 -3
net/netfilter/xt_IDLETIMER.c
··· 146 146 timer_setup(&info->timer->timer, idletimer_tg_expired, 0); 147 147 info->timer->refcnt = 1; 148 148 149 + INIT_WORK(&info->timer->work, idletimer_tg_work); 150 + 149 151 mod_timer(&info->timer->timer, 150 152 msecs_to_jiffies(info->timeout * 1000) + jiffies); 151 - 152 - INIT_WORK(&info->timer->work, idletimer_tg_work); 153 153 154 154 return 0; 155 155 ··· 191 191 pr_debug("timeout value is zero\n"); 192 192 return -EINVAL; 193 193 } 194 - 194 + if (info->timeout >= INT_MAX / 1000) { 195 + pr_debug("timeout value is too big\n"); 196 + return -EINVAL; 197 + } 195 198 if (info->label[0] == '\0' || 196 199 strnlen(info->label, 197 200 MAX_IDLETIMER_LABEL_SIZE) == MAX_IDLETIMER_LABEL_SIZE) {
+7 -9
net/netfilter/xt_LED.c
··· 111 111 struct xt_led_info_internal *ledinternal; 112 112 int err; 113 113 114 - if (ledinfo->id[0] == '\0') { 115 - pr_info("No 'id' parameter given.\n"); 114 + if (ledinfo->id[0] == '\0') 116 115 return -EINVAL; 117 - } 118 116 119 117 mutex_lock(&xt_led_mutex); 120 118 ··· 136 138 137 139 err = led_trigger_register(&ledinternal->netfilter_led_trigger); 138 140 if (err) { 139 - pr_err("Trigger name is already in use.\n"); 141 + pr_info_ratelimited("Trigger name is already in use.\n"); 140 142 goto exit_alloc; 141 143 } 142 144 143 - /* See if we need to set up a timer */ 144 - if (ledinfo->delay > 0) 145 - timer_setup(&ledinternal->timer, led_timeout_callback, 0); 145 + /* Since the letinternal timer can be shared between multiple targets, 146 + * always set it up, even if the current target does not need it 147 + */ 148 + timer_setup(&ledinternal->timer, led_timeout_callback, 0); 146 149 147 150 list_add_tail(&ledinternal->list, &xt_led_triggers); 148 151 ··· 180 181 181 182 list_del(&ledinternal->list); 182 183 183 - if (ledinfo->delay > 0) 184 - del_timer_sync(&ledinternal->timer); 184 + del_timer_sync(&ledinternal->timer); 185 185 186 186 led_trigger_unregister(&ledinternal->netfilter_led_trigger); 187 187
+5 -3
net/netfilter/xt_NFQUEUE.c
··· 8 8 * 9 9 */ 10 10 11 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 12 + 11 13 #include <linux/module.h> 12 14 #include <linux/skbuff.h> 13 15 ··· 69 67 init_hashrandom(&jhash_initval); 70 68 71 69 if (info->queues_total == 0) { 72 - pr_err("NFQUEUE: number of total queues is 0\n"); 70 + pr_info_ratelimited("number of total queues is 0\n"); 73 71 return -EINVAL; 74 72 } 75 73 maxid = info->queues_total - 1 + info->queuenum; 76 74 if (maxid > 0xffff) { 77 - pr_err("NFQUEUE: number of queues (%u) out of range (got %u)\n", 78 - info->queues_total, maxid); 75 + pr_info_ratelimited("number of queues (%u) out of range (got %u)\n", 76 + info->queues_total, maxid); 79 77 return -ERANGE; 80 78 } 81 79 if (par->target->revision == 2 && info->flags > 1)
+10 -8
net/netfilter/xt_SECMARK.c
··· 60 60 &info->secid); 61 61 if (err) { 62 62 if (err == -EINVAL) 63 - pr_info("invalid security context \'%s\'\n", info->secctx); 63 + pr_info_ratelimited("invalid security context \'%s\'\n", 64 + info->secctx); 64 65 return err; 65 66 } 66 67 67 68 if (!info->secid) { 68 - pr_info("unable to map security context \'%s\'\n", info->secctx); 69 + pr_info_ratelimited("unable to map security context \'%s\'\n", 70 + info->secctx); 69 71 return -ENOENT; 70 72 } 71 73 72 74 err = security_secmark_relabel_packet(info->secid); 73 75 if (err) { 74 - pr_info("unable to obtain relabeling permission\n"); 76 + pr_info_ratelimited("unable to obtain relabeling permission\n"); 75 77 return err; 76 78 } 77 79 ··· 88 86 89 87 if (strcmp(par->table, "mangle") != 0 && 90 88 strcmp(par->table, "security") != 0) { 91 - pr_info("target only valid in the \'mangle\' " 92 - "or \'security\' tables, not \'%s\'.\n", par->table); 89 + pr_info_ratelimited("only valid in \'mangle\' or \'security\' table, not \'%s\'\n", 90 + par->table); 93 91 return -EINVAL; 94 92 } 95 93 96 94 if (mode && mode != info->mode) { 97 - pr_info("mode already set to %hu cannot mix with " 98 - "rules for mode %hu\n", mode, info->mode); 95 + pr_info_ratelimited("mode already set to %hu cannot mix with rules for mode %hu\n", 96 + mode, info->mode); 99 97 return -EINVAL; 100 98 } 101 99 ··· 103 101 case SECMARK_MODE_SEL: 104 102 break; 105 103 default: 106 - pr_info("invalid mode: %hu\n", info->mode); 104 + pr_info_ratelimited("invalid mode: %hu\n", info->mode); 107 105 return -EINVAL; 108 106 } 109 107
+4 -6
net/netfilter/xt_TCPMSS.c
··· 273 273 (par->hook_mask & ~((1 << NF_INET_FORWARD) | 274 274 (1 << NF_INET_LOCAL_OUT) | 275 275 (1 << NF_INET_POST_ROUTING))) != 0) { 276 - pr_info("path-MTU clamping only supported in " 277 - "FORWARD, OUTPUT and POSTROUTING hooks\n"); 276 + pr_info_ratelimited("path-MTU clamping only supported in FORWARD, OUTPUT and POSTROUTING hooks\n"); 278 277 return -EINVAL; 279 278 } 280 279 if (par->nft_compat) ··· 282 283 xt_ematch_foreach(ematch, e) 283 284 if (find_syn_match(ematch)) 284 285 return 0; 285 - pr_info("Only works on TCP SYN packets\n"); 286 + pr_info_ratelimited("Only works on TCP SYN packets\n"); 286 287 return -EINVAL; 287 288 } 288 289 ··· 297 298 (par->hook_mask & ~((1 << NF_INET_FORWARD) | 298 299 (1 << NF_INET_LOCAL_OUT) | 299 300 (1 << NF_INET_POST_ROUTING))) != 0) { 300 - pr_info("path-MTU clamping only supported in " 301 - "FORWARD, OUTPUT and POSTROUTING hooks\n"); 301 + pr_info_ratelimited("path-MTU clamping only supported in FORWARD, OUTPUT and POSTROUTING hooks\n"); 302 302 return -EINVAL; 303 303 } 304 304 if (par->nft_compat) ··· 306 308 xt_ematch_foreach(ematch, e) 307 309 if (find_syn_match(ematch)) 308 310 return 0; 309 - pr_info("Only works on TCP SYN packets\n"); 311 + pr_info_ratelimited("Only works on TCP SYN packets\n"); 310 312 return -EINVAL; 311 313 } 312 314 #endif
+2 -4
net/netfilter/xt_TPROXY.c
··· 540 540 !(i->invflags & IP6T_INV_PROTO)) 541 541 return 0; 542 542 543 - pr_info("Can be used only in combination with " 544 - "either -p tcp or -p udp\n"); 543 + pr_info_ratelimited("Can be used only with -p tcp or -p udp\n"); 545 544 return -EINVAL; 546 545 } 547 546 #endif ··· 558 559 && !(i->invflags & IPT_INV_PROTO)) 559 560 return 0; 560 561 561 - pr_info("Can be used only in combination with " 562 - "either -p tcp or -p udp\n"); 562 + pr_info_ratelimited("Can be used only with -p tcp or -p udp\n"); 563 563 return -EINVAL; 564 564 } 565 565
+16 -17
net/netfilter/xt_addrtype.c
··· 164 164 165 165 static int addrtype_mt_checkentry_v1(const struct xt_mtchk_param *par) 166 166 { 167 + const char *errmsg = "both incoming and outgoing interface limitation cannot be selected"; 167 168 struct xt_addrtype_info_v1 *info = par->matchinfo; 168 169 169 170 if (info->flags & XT_ADDRTYPE_LIMIT_IFACE_IN && 170 - info->flags & XT_ADDRTYPE_LIMIT_IFACE_OUT) { 171 - pr_info("both incoming and outgoing " 172 - "interface limitation cannot be selected\n"); 173 - return -EINVAL; 174 - } 171 + info->flags & XT_ADDRTYPE_LIMIT_IFACE_OUT) 172 + goto err; 175 173 176 174 if (par->hook_mask & ((1 << NF_INET_PRE_ROUTING) | 177 175 (1 << NF_INET_LOCAL_IN)) && 178 176 info->flags & XT_ADDRTYPE_LIMIT_IFACE_OUT) { 179 - pr_info("output interface limitation " 180 - "not valid in PREROUTING and INPUT\n"); 181 - return -EINVAL; 177 + errmsg = "output interface limitation not valid in PREROUTING and INPUT"; 178 + goto err; 182 179 } 183 180 184 181 if (par->hook_mask & ((1 << NF_INET_POST_ROUTING) | 185 182 (1 << NF_INET_LOCAL_OUT)) && 186 183 info->flags & XT_ADDRTYPE_LIMIT_IFACE_IN) { 187 - pr_info("input interface limitation " 188 - "not valid in POSTROUTING and OUTPUT\n"); 189 - return -EINVAL; 184 + errmsg = "input interface limitation not valid in POSTROUTING and OUTPUT"; 185 + goto err; 190 186 } 191 187 192 188 #if IS_ENABLED(CONFIG_IP6_NF_IPTABLES) 193 189 if (par->family == NFPROTO_IPV6) { 194 190 if ((info->source | info->dest) & XT_ADDRTYPE_BLACKHOLE) { 195 - pr_err("ipv6 BLACKHOLE matching not supported\n"); 196 - return -EINVAL; 191 + errmsg = "ipv6 BLACKHOLE matching not supported"; 192 + goto err; 197 193 } 198 194 if ((info->source | info->dest) >= XT_ADDRTYPE_PROHIBIT) { 199 - pr_err("ipv6 PROHIBIT (THROW, NAT ..) matching not supported\n"); 200 - return -EINVAL; 195 + errmsg = "ipv6 PROHIBIT (THROW, NAT ..) matching not supported"; 196 + goto err; 201 197 } 202 198 if ((info->source | info->dest) & XT_ADDRTYPE_BROADCAST) { 203 - pr_err("ipv6 does not support BROADCAST matching\n"); 204 - return -EINVAL; 199 + errmsg = "ipv6 does not support BROADCAST matching"; 200 + goto err; 205 201 } 206 202 } 207 203 #endif 208 204 return 0; 205 + err: 206 + pr_info_ratelimited("%s\n", errmsg); 207 + return -EINVAL; 209 208 } 210 209 211 210 static struct xt_match addrtype_mt_reg[] __read_mostly = {
+3 -1
net/netfilter/xt_bpf.c
··· 7 7 * published by the Free Software Foundation. 8 8 */ 9 9 10 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 11 + 10 12 #include <linux/module.h> 11 13 #include <linux/syscalls.h> 12 14 #include <linux/skbuff.h> ··· 36 34 program.filter = insns; 37 35 38 36 if (bpf_prog_create(ret, &program)) { 39 - pr_info("bpf: check failed: parse error\n"); 37 + pr_info_ratelimited("check failed: parse error\n"); 40 38 return -EINVAL; 41 39 } 42 40
+5 -3
net/netfilter/xt_cgroup.c
··· 12 12 * published by the Free Software Foundation. 13 13 */ 14 14 15 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 16 + 15 17 #include <linux/skbuff.h> 16 18 #include <linux/module.h> 17 19 #include <linux/netfilter/x_tables.h> ··· 50 48 } 51 49 52 50 if (info->has_path && info->has_classid) { 53 - pr_info("xt_cgroup: both path and classid specified\n"); 51 + pr_info_ratelimited("path and classid specified\n"); 54 52 return -EINVAL; 55 53 } 56 54 ··· 58 56 if (info->has_path) { 59 57 cgrp = cgroup_get_from_path(info->path); 60 58 if (IS_ERR(cgrp)) { 61 - pr_info("xt_cgroup: invalid path, errno=%ld\n", 62 - PTR_ERR(cgrp)); 59 + pr_info_ratelimited("invalid path, errno=%ld\n", 60 + PTR_ERR(cgrp)); 63 61 return -EINVAL; 64 62 } 65 63 info->priv = cgrp;
+3 -5
net/netfilter/xt_cluster.c
··· 135 135 struct xt_cluster_match_info *info = par->matchinfo; 136 136 137 137 if (info->total_nodes > XT_CLUSTER_NODES_MAX) { 138 - pr_info("you have exceeded the maximum " 139 - "number of cluster nodes (%u > %u)\n", 140 - info->total_nodes, XT_CLUSTER_NODES_MAX); 138 + pr_info_ratelimited("you have exceeded the maximum number of cluster nodes (%u > %u)\n", 139 + info->total_nodes, XT_CLUSTER_NODES_MAX); 141 140 return -EINVAL; 142 141 } 143 142 if (info->node_mask >= (1ULL << info->total_nodes)) { 144 - pr_info("this node mask cannot be " 145 - "higher than the total number of nodes\n"); 143 + pr_info_ratelimited("node mask cannot exceed total number of nodes\n"); 146 144 return -EDOM; 147 145 } 148 146 return 0;
+2 -2
net/netfilter/xt_connbytes.c
··· 112 112 113 113 ret = nf_ct_netns_get(par->net, par->family); 114 114 if (ret < 0) 115 - pr_info("cannot load conntrack support for proto=%u\n", 116 - par->family); 115 + pr_info_ratelimited("cannot load conntrack support for proto=%u\n", 116 + par->family); 117 117 118 118 /* 119 119 * This filter cannot function correctly unless connection tracking
+4 -3
net/netfilter/xt_connlabel.c
··· 57 57 int ret; 58 58 59 59 if (info->options & ~options) { 60 - pr_err("Unknown options in mask %x\n", info->options); 60 + pr_info_ratelimited("Unknown options in mask %x\n", 61 + info->options); 61 62 return -EINVAL; 62 63 } 63 64 64 65 ret = nf_ct_netns_get(par->net, par->family); 65 66 if (ret < 0) { 66 - pr_info("cannot load conntrack support for proto=%u\n", 67 - par->family); 67 + pr_info_ratelimited("cannot load conntrack support for proto=%u\n", 68 + par->family); 68 69 return ret; 69 70 } 70 71
+4 -4
net/netfilter/xt_connmark.c
··· 79 79 80 80 ret = nf_ct_netns_get(par->net, par->family); 81 81 if (ret < 0) 82 - pr_info("cannot load conntrack support for proto=%u\n", 83 - par->family); 82 + pr_info_ratelimited("cannot load conntrack support for proto=%u\n", 83 + par->family); 84 84 return ret; 85 85 } 86 86 ··· 109 109 110 110 ret = nf_ct_netns_get(par->net, par->family); 111 111 if (ret < 0) 112 - pr_info("cannot load conntrack support for proto=%u\n", 113 - par->family); 112 + pr_info_ratelimited("cannot load conntrack support for proto=%u\n", 113 + par->family); 114 114 return ret; 115 115 } 116 116
+2 -2
net/netfilter/xt_conntrack.c
··· 272 272 273 273 ret = nf_ct_netns_get(par->net, par->family); 274 274 if (ret < 0) 275 - pr_info("cannot load conntrack support for proto=%u\n", 276 - par->family); 275 + pr_info_ratelimited("cannot load conntrack support for proto=%u\n", 276 + par->family); 277 277 return ret; 278 278 } 279 279
+1 -3
net/netfilter/xt_dscp.c
··· 46 46 { 47 47 const struct xt_dscp_info *info = par->matchinfo; 48 48 49 - if (info->dscp > XT_DSCP_MAX) { 50 - pr_info("dscp %x out of range\n", info->dscp); 49 + if (info->dscp > XT_DSCP_MAX) 51 50 return -EDOM; 52 - } 53 51 54 52 return 0; 55 53 }
+2 -2
net/netfilter/xt_ecn.c
··· 97 97 98 98 if (info->operation & (XT_ECN_OP_MATCH_ECE | XT_ECN_OP_MATCH_CWR) && 99 99 (ip->proto != IPPROTO_TCP || ip->invflags & IPT_INV_PROTO)) { 100 - pr_info("cannot match TCP bits in rule for non-tcp packets\n"); 100 + pr_info_ratelimited("cannot match TCP bits for non-tcp packets\n"); 101 101 return -EINVAL; 102 102 } 103 103 ··· 139 139 140 140 if (info->operation & (XT_ECN_OP_MATCH_ECE | XT_ECN_OP_MATCH_CWR) && 141 141 (ip->proto != IPPROTO_TCP || ip->invflags & IP6T_INV_PROTO)) { 142 - pr_info("cannot match TCP bits in rule for non-tcp packets\n"); 142 + pr_info_ratelimited("cannot match TCP bits for non-tcp packets\n"); 143 143 return -EINVAL; 144 144 } 145 145
+14 -12
net/netfilter/xt_hashlimit.c
··· 523 523 if (user != 0) { 524 524 return div64_u64(XT_HASHLIMIT_SCALE_v2, user); 525 525 } else { 526 - pr_warn("invalid rate from userspace: %llu\n", user); 526 + pr_info_ratelimited("invalid rate from userspace: %llu\n", 527 + user); 527 528 return 0; 528 529 } 529 530 } ··· 775 774 if (!dh->rateinfo.prev_window && 776 775 (dh->rateinfo.current_rate <= dh->rateinfo.burst)) { 777 776 spin_unlock(&dh->lock); 778 - rcu_read_unlock_bh(); 777 + local_bh_enable(); 779 778 return !(cfg->mode & XT_HASHLIMIT_INVERT); 780 779 } else { 781 780 goto overlimit; ··· 866 865 } 867 866 868 867 if (cfg->mode & ~XT_HASHLIMIT_ALL) { 869 - pr_info("Unknown mode mask %X, kernel too old?\n", 870 - cfg->mode); 868 + pr_info_ratelimited("Unknown mode mask %X, kernel too old?\n", 869 + cfg->mode); 871 870 return -EINVAL; 872 871 } 873 872 874 873 /* Check for overflow. */ 875 874 if (revision >= 3 && cfg->mode & XT_HASHLIMIT_RATE_MATCH) { 876 875 if (cfg->avg == 0 || cfg->avg > U32_MAX) { 877 - pr_info("hashlimit invalid rate\n"); 876 + pr_info_ratelimited("invalid rate\n"); 878 877 return -ERANGE; 879 878 } 880 879 881 880 if (cfg->interval == 0) { 882 - pr_info("hashlimit invalid interval\n"); 881 + pr_info_ratelimited("invalid interval\n"); 883 882 return -EINVAL; 884 883 } 885 884 } else if (cfg->mode & XT_HASHLIMIT_BYTES) { 886 885 if (user2credits_byte(cfg->avg) == 0) { 887 - pr_info("overflow, rate too high: %llu\n", cfg->avg); 886 + pr_info_ratelimited("overflow, rate too high: %llu\n", 887 + cfg->avg); 888 888 return -EINVAL; 889 889 } 890 890 } else if (cfg->burst == 0 || 891 - user2credits(cfg->avg * cfg->burst, revision) < 892 - user2credits(cfg->avg, revision)) { 893 - pr_info("overflow, try lower: %llu/%llu\n", 894 - cfg->avg, cfg->burst); 895 - return -ERANGE; 891 + user2credits(cfg->avg * cfg->burst, revision) < 892 + user2credits(cfg->avg, revision)) { 893 + pr_info_ratelimited("overflow, try lower: %llu/%llu\n", 894 + cfg->avg, cfg->burst); 895 + return -ERANGE; 896 896 } 897 897 898 898 mutex_lock(&hashlimit_mutex);
+2 -2
net/netfilter/xt_helper.c
··· 61 61 62 62 ret = nf_ct_netns_get(par->net, par->family); 63 63 if (ret < 0) { 64 - pr_info("cannot load conntrack support for proto=%u\n", 65 - par->family); 64 + pr_info_ratelimited("cannot load conntrack support for proto=%u\n", 65 + par->family); 66 66 return ret; 67 67 } 68 68 info->name[sizeof(info->name) - 1] = '\0';
+1 -1
net/netfilter/xt_ipcomp.c
··· 72 72 73 73 /* Must specify no unknown invflags */ 74 74 if (compinfo->invflags & ~XT_IPCOMP_INV_MASK) { 75 - pr_err("unknown flags %X\n", compinfo->invflags); 75 + pr_info_ratelimited("unknown flags %X\n", compinfo->invflags); 76 76 return -EINVAL; 77 77 } 78 78 return 0;
+2 -1
net/netfilter/xt_ipvs.c
··· 158 158 && par->family != NFPROTO_IPV6 159 159 #endif 160 160 ) { 161 - pr_info("protocol family %u not supported\n", par->family); 161 + pr_info_ratelimited("protocol family %u not supported\n", 162 + par->family); 162 163 return -EINVAL; 163 164 } 164 165
+13 -9
net/netfilter/xt_l2tp.c
··· 216 216 /* Check for invalid flags */ 217 217 if (info->flags & ~(XT_L2TP_TID | XT_L2TP_SID | XT_L2TP_VERSION | 218 218 XT_L2TP_TYPE)) { 219 - pr_info("unknown flags: %x\n", info->flags); 219 + pr_info_ratelimited("unknown flags: %x\n", info->flags); 220 220 return -EINVAL; 221 221 } 222 222 ··· 225 225 (!(info->flags & XT_L2TP_SID)) && 226 226 ((!(info->flags & XT_L2TP_TYPE)) || 227 227 (info->type != XT_L2TP_TYPE_CONTROL))) { 228 - pr_info("invalid flags combination: %x\n", info->flags); 228 + pr_info_ratelimited("invalid flags combination: %x\n", 229 + info->flags); 229 230 return -EINVAL; 230 231 } 231 232 ··· 235 234 */ 236 235 if (info->flags & XT_L2TP_VERSION) { 237 236 if ((info->version < 2) || (info->version > 3)) { 238 - pr_info("wrong L2TP version: %u\n", info->version); 237 + pr_info_ratelimited("wrong L2TP version: %u\n", 238 + info->version); 239 239 return -EINVAL; 240 240 } 241 241 242 242 if (info->version == 2) { 243 243 if ((info->flags & XT_L2TP_TID) && 244 244 (info->tid > 0xffff)) { 245 - pr_info("v2 tid > 0xffff: %u\n", info->tid); 245 + pr_info_ratelimited("v2 tid > 0xffff: %u\n", 246 + info->tid); 246 247 return -EINVAL; 247 248 } 248 249 if ((info->flags & XT_L2TP_SID) && 249 250 (info->sid > 0xffff)) { 250 - pr_info("v2 sid > 0xffff: %u\n", info->sid); 251 + pr_info_ratelimited("v2 sid > 0xffff: %u\n", 252 + info->sid); 251 253 return -EINVAL; 252 254 } 253 255 } ··· 272 268 273 269 if ((ip->proto != IPPROTO_UDP) && 274 270 (ip->proto != IPPROTO_L2TP)) { 275 - pr_info("missing protocol rule (udp|l2tpip)\n"); 271 + pr_info_ratelimited("missing protocol rule (udp|l2tpip)\n"); 276 272 return -EINVAL; 277 273 } 278 274 279 275 if ((ip->proto == IPPROTO_L2TP) && 280 276 (info->version == 2)) { 281 - pr_info("v2 doesn't support IP mode\n"); 277 + pr_info_ratelimited("v2 doesn't support IP mode\n"); 282 278 return -EINVAL; 283 279 } 284 280 ··· 299 295 300 296 if ((ip->proto != IPPROTO_UDP) && 301 297 (ip->proto != IPPROTO_L2TP)) { 302 - pr_info("missing protocol rule (udp|l2tpip)\n"); 298 + pr_info_ratelimited("missing protocol rule (udp|l2tpip)\n"); 303 299 return -EINVAL; 304 300 } 305 301 306 302 if ((ip->proto == IPPROTO_L2TP) && 307 303 (info->version == 2)) { 308 - pr_info("v2 doesn't support IP mode\n"); 304 + pr_info_ratelimited("v2 doesn't support IP mode\n"); 309 305 return -EINVAL; 310 306 } 311 307
+2 -2
net/netfilter/xt_limit.c
··· 106 106 /* Check for overflow. */ 107 107 if (r->burst == 0 108 108 || user2credits(r->avg * r->burst) < user2credits(r->avg)) { 109 - pr_info("Overflow, try lower: %u/%u\n", 110 - r->avg, r->burst); 109 + pr_info_ratelimited("Overflow, try lower: %u/%u\n", 110 + r->avg, r->burst); 111 111 return -ERANGE; 112 112 } 113 113
+3 -2
net/netfilter/xt_nat.c
··· 8 8 * published by the Free Software Foundation. 9 9 */ 10 10 11 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 12 + 11 13 #include <linux/module.h> 12 14 #include <linux/skbuff.h> 13 15 #include <linux/netfilter.h> ··· 21 19 const struct nf_nat_ipv4_multi_range_compat *mr = par->targinfo; 22 20 23 21 if (mr->rangesize != 1) { 24 - pr_info("%s: multiple ranges no longer supported\n", 25 - par->target->name); 22 + pr_info_ratelimited("multiple ranges no longer supported\n"); 26 23 return -EINVAL; 27 24 } 28 25 return nf_ct_netns_get(par->net, par->family);
+4 -2
net/netfilter/xt_nfacct.c
··· 6 6 * it under the terms of the GNU General Public License version 2 (or any 7 7 * later at your option) as published by the Free Software Foundation. 8 8 */ 9 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 10 + 9 11 #include <linux/module.h> 10 12 #include <linux/skbuff.h> 11 13 ··· 41 39 42 40 nfacct = nfnl_acct_find_get(par->net, info->name); 43 41 if (nfacct == NULL) { 44 - pr_info("xt_nfacct: accounting object with name `%s' " 45 - "does not exists\n", info->name); 42 + pr_info_ratelimited("accounting object `%s' does not exists\n", 43 + info->name); 46 44 return -ENOENT; 47 45 } 48 46 info->nfacct = nfacct;
+1 -3
net/netfilter/xt_physdev.c
··· 107 107 info->invert & XT_PHYSDEV_OP_BRIDGED) && 108 108 par->hook_mask & ((1 << NF_INET_LOCAL_OUT) | 109 109 (1 << NF_INET_FORWARD) | (1 << NF_INET_POST_ROUTING))) { 110 - pr_info("using --physdev-out and --physdev-is-out are only " 111 - "supported in the FORWARD and POSTROUTING chains with " 112 - "bridged traffic.\n"); 110 + pr_info_ratelimited("--physdev-out and --physdev-is-out only supported in the FORWARD and POSTROUTING chains with bridged traffic\n"); 113 111 if (par->hook_mask & (1 << NF_INET_LOCAL_OUT)) 114 112 return -EINVAL; 115 113 }
+13 -10
net/netfilter/xt_policy.c
··· 132 132 static int policy_mt_check(const struct xt_mtchk_param *par) 133 133 { 134 134 const struct xt_policy_info *info = par->matchinfo; 135 + const char *errmsg = "neither incoming nor outgoing policy selected"; 135 136 136 - if (!(info->flags & (XT_POLICY_MATCH_IN|XT_POLICY_MATCH_OUT))) { 137 - pr_info("neither incoming nor outgoing policy selected\n"); 138 - return -EINVAL; 139 - } 137 + if (!(info->flags & (XT_POLICY_MATCH_IN|XT_POLICY_MATCH_OUT))) 138 + goto err; 139 + 140 140 if (par->hook_mask & ((1 << NF_INET_PRE_ROUTING) | 141 141 (1 << NF_INET_LOCAL_IN)) && info->flags & XT_POLICY_MATCH_OUT) { 142 - pr_info("output policy not valid in PREROUTING and INPUT\n"); 143 - return -EINVAL; 142 + errmsg = "output policy not valid in PREROUTING and INPUT"; 143 + goto err; 144 144 } 145 145 if (par->hook_mask & ((1 << NF_INET_POST_ROUTING) | 146 146 (1 << NF_INET_LOCAL_OUT)) && info->flags & XT_POLICY_MATCH_IN) { 147 - pr_info("input policy not valid in POSTROUTING and OUTPUT\n"); 148 - return -EINVAL; 147 + errmsg = "input policy not valid in POSTROUTING and OUTPUT"; 148 + goto err; 149 149 } 150 150 if (info->len > XT_POLICY_MAX_ELEM) { 151 - pr_info("too many policy elements\n"); 152 - return -EINVAL; 151 + errmsg = "too many policy elements"; 152 + goto err; 153 153 } 154 154 return 0; 155 + err: 156 + pr_info_ratelimited("%s\n", errmsg); 157 + return -EINVAL; 155 158 } 156 159 157 160 static struct xt_match policy_mt_reg[] __read_mostly = {
+6 -8
net/netfilter/xt_recent.c
··· 342 342 net_get_random_once(&hash_rnd, sizeof(hash_rnd)); 343 343 344 344 if (info->check_set & ~XT_RECENT_VALID_FLAGS) { 345 - pr_info("Unsupported user space flags (%08x)\n", 346 - info->check_set); 345 + pr_info_ratelimited("Unsupported userspace flags (%08x)\n", 346 + info->check_set); 347 347 return -EINVAL; 348 348 } 349 349 if (hweight8(info->check_set & ··· 357 357 if ((info->check_set & XT_RECENT_REAP) && !info->seconds) 358 358 return -EINVAL; 359 359 if (info->hit_count >= XT_RECENT_MAX_NSTAMPS) { 360 - pr_info("hitcount (%u) is larger than allowed maximum (%u)\n", 361 - info->hit_count, XT_RECENT_MAX_NSTAMPS - 1); 360 + pr_info_ratelimited("hitcount (%u) is larger than allowed maximum (%u)\n", 361 + info->hit_count, XT_RECENT_MAX_NSTAMPS - 1); 362 362 return -EINVAL; 363 363 } 364 364 if (info->name[0] == '\0' || ··· 587 587 add = true; 588 588 break; 589 589 default: 590 - pr_info("Need \"+ip\", \"-ip\" or \"/\"\n"); 590 + pr_info_ratelimited("Need \"+ip\", \"-ip\" or \"/\"\n"); 591 591 return -EINVAL; 592 592 } 593 593 ··· 601 601 succ = in4_pton(c, size, (void *)&addr, '\n', NULL); 602 602 } 603 603 604 - if (!succ) { 605 - pr_info("illegal address written to procfs\n"); 604 + if (!succ) 606 605 return -EINVAL; 607 - } 608 606 609 607 spin_lock_bh(&recent_lock); 610 608 e = recent_entry_lookup(t, &addr, family, 0);
+25 -25
net/netfilter/xt_set.c
··· 92 92 index = ip_set_nfnl_get_byindex(par->net, info->match_set.index); 93 93 94 94 if (index == IPSET_INVALID_ID) { 95 - pr_warn("Cannot find set identified by id %u to match\n", 96 - info->match_set.index); 95 + pr_info_ratelimited("Cannot find set identified by id %u to match\n", 96 + info->match_set.index); 97 97 return -ENOENT; 98 98 } 99 99 if (info->match_set.u.flags[IPSET_DIM_MAX - 1] != 0) { 100 - pr_warn("Protocol error: set match dimension is over the limit!\n"); 100 + pr_info_ratelimited("set match dimension is over the limit!\n"); 101 101 ip_set_nfnl_put(par->net, info->match_set.index); 102 102 return -ERANGE; 103 103 } ··· 143 143 index = ip_set_nfnl_get_byindex(par->net, info->match_set.index); 144 144 145 145 if (index == IPSET_INVALID_ID) { 146 - pr_warn("Cannot find set identified by id %u to match\n", 147 - info->match_set.index); 146 + pr_info_ratelimited("Cannot find set identified by id %u to match\n", 147 + info->match_set.index); 148 148 return -ENOENT; 149 149 } 150 150 if (info->match_set.dim > IPSET_DIM_MAX) { 151 - pr_warn("Protocol error: set match dimension is over the limit!\n"); 151 + pr_info_ratelimited("set match dimension is over the limit!\n"); 152 152 ip_set_nfnl_put(par->net, info->match_set.index); 153 153 return -ERANGE; 154 154 } ··· 241 241 if (info->add_set.index != IPSET_INVALID_ID) { 242 242 index = ip_set_nfnl_get_byindex(par->net, info->add_set.index); 243 243 if (index == IPSET_INVALID_ID) { 244 - pr_warn("Cannot find add_set index %u as target\n", 245 - info->add_set.index); 244 + pr_info_ratelimited("Cannot find add_set index %u as target\n", 245 + info->add_set.index); 246 246 return -ENOENT; 247 247 } 248 248 } ··· 250 250 if (info->del_set.index != IPSET_INVALID_ID) { 251 251 index = ip_set_nfnl_get_byindex(par->net, info->del_set.index); 252 252 if (index == IPSET_INVALID_ID) { 253 - pr_warn("Cannot find del_set index %u as target\n", 254 - info->del_set.index); 253 + pr_info_ratelimited("Cannot find del_set index %u as target\n", 254 + info->del_set.index); 255 255 if (info->add_set.index != IPSET_INVALID_ID) 256 256 ip_set_nfnl_put(par->net, info->add_set.index); 257 257 return -ENOENT; ··· 259 259 } 260 260 if (info->add_set.u.flags[IPSET_DIM_MAX - 1] != 0 || 261 261 info->del_set.u.flags[IPSET_DIM_MAX - 1] != 0) { 262 - pr_warn("Protocol error: SET target dimension is over the limit!\n"); 262 + pr_info_ratelimited("SET target dimension over the limit!\n"); 263 263 if (info->add_set.index != IPSET_INVALID_ID) 264 264 ip_set_nfnl_put(par->net, info->add_set.index); 265 265 if (info->del_set.index != IPSET_INVALID_ID) ··· 316 316 if (info->add_set.index != IPSET_INVALID_ID) { 317 317 index = ip_set_nfnl_get_byindex(par->net, info->add_set.index); 318 318 if (index == IPSET_INVALID_ID) { 319 - pr_warn("Cannot find add_set index %u as target\n", 320 - info->add_set.index); 319 + pr_info_ratelimited("Cannot find add_set index %u as target\n", 320 + info->add_set.index); 321 321 return -ENOENT; 322 322 } 323 323 } ··· 325 325 if (info->del_set.index != IPSET_INVALID_ID) { 326 326 index = ip_set_nfnl_get_byindex(par->net, info->del_set.index); 327 327 if (index == IPSET_INVALID_ID) { 328 - pr_warn("Cannot find del_set index %u as target\n", 329 - info->del_set.index); 328 + pr_info_ratelimited("Cannot find del_set index %u as target\n", 329 + info->del_set.index); 330 330 if (info->add_set.index != IPSET_INVALID_ID) 331 331 ip_set_nfnl_put(par->net, info->add_set.index); 332 332 return -ENOENT; ··· 334 334 } 335 335 if (info->add_set.dim > IPSET_DIM_MAX || 336 336 info->del_set.dim > IPSET_DIM_MAX) { 337 - pr_warn("Protocol error: SET target dimension is over the limit!\n"); 337 + pr_info_ratelimited("SET target dimension over the limit!\n"); 338 338 if (info->add_set.index != IPSET_INVALID_ID) 339 339 ip_set_nfnl_put(par->net, info->add_set.index); 340 340 if (info->del_set.index != IPSET_INVALID_ID) ··· 444 444 index = ip_set_nfnl_get_byindex(par->net, 445 445 info->add_set.index); 446 446 if (index == IPSET_INVALID_ID) { 447 - pr_warn("Cannot find add_set index %u as target\n", 448 - info->add_set.index); 447 + pr_info_ratelimited("Cannot find add_set index %u as target\n", 448 + info->add_set.index); 449 449 return -ENOENT; 450 450 } 451 451 } ··· 454 454 index = ip_set_nfnl_get_byindex(par->net, 455 455 info->del_set.index); 456 456 if (index == IPSET_INVALID_ID) { 457 - pr_warn("Cannot find del_set index %u as target\n", 458 - info->del_set.index); 457 + pr_info_ratelimited("Cannot find del_set index %u as target\n", 458 + info->del_set.index); 459 459 if (info->add_set.index != IPSET_INVALID_ID) 460 460 ip_set_nfnl_put(par->net, 461 461 info->add_set.index); ··· 465 465 466 466 if (info->map_set.index != IPSET_INVALID_ID) { 467 467 if (strncmp(par->table, "mangle", 7)) { 468 - pr_warn("--map-set only usable from mangle table\n"); 468 + pr_info_ratelimited("--map-set only usable from mangle table\n"); 469 469 return -EINVAL; 470 470 } 471 471 if (((info->flags & IPSET_FLAG_MAP_SKBPRIO) | ··· 473 473 !(par->hook_mask & (1 << NF_INET_FORWARD | 474 474 1 << NF_INET_LOCAL_OUT | 475 475 1 << NF_INET_POST_ROUTING))) { 476 - pr_warn("mapping of prio or/and queue is allowed only from OUTPUT/FORWARD/POSTROUTING chains\n"); 476 + pr_info_ratelimited("mapping of prio or/and queue is allowed only from OUTPUT/FORWARD/POSTROUTING chains\n"); 477 477 return -EINVAL; 478 478 } 479 479 index = ip_set_nfnl_get_byindex(par->net, 480 480 info->map_set.index); 481 481 if (index == IPSET_INVALID_ID) { 482 - pr_warn("Cannot find map_set index %u as target\n", 483 - info->map_set.index); 482 + pr_info_ratelimited("Cannot find map_set index %u as target\n", 483 + info->map_set.index); 484 484 if (info->add_set.index != IPSET_INVALID_ID) 485 485 ip_set_nfnl_put(par->net, 486 486 info->add_set.index); ··· 494 494 if (info->add_set.dim > IPSET_DIM_MAX || 495 495 info->del_set.dim > IPSET_DIM_MAX || 496 496 info->map_set.dim > IPSET_DIM_MAX) { 497 - pr_warn("Protocol error: SET target dimension is over the limit!\n"); 497 + pr_info_ratelimited("SET target dimension over the limit!\n"); 498 498 if (info->add_set.index != IPSET_INVALID_ID) 499 499 ip_set_nfnl_put(par->net, info->add_set.index); 500 500 if (info->del_set.index != IPSET_INVALID_ID)
+6 -4
net/netfilter/xt_socket.c
··· 171 171 return err; 172 172 173 173 if (info->flags & ~XT_SOCKET_FLAGS_V1) { 174 - pr_info("unknown flags 0x%x\n", info->flags & ~XT_SOCKET_FLAGS_V1); 174 + pr_info_ratelimited("unknown flags 0x%x\n", 175 + info->flags & ~XT_SOCKET_FLAGS_V1); 175 176 return -EINVAL; 176 177 } 177 178 return 0; ··· 188 187 return err; 189 188 190 189 if (info->flags & ~XT_SOCKET_FLAGS_V2) { 191 - pr_info("unknown flags 0x%x\n", info->flags & ~XT_SOCKET_FLAGS_V2); 190 + pr_info_ratelimited("unknown flags 0x%x\n", 191 + info->flags & ~XT_SOCKET_FLAGS_V2); 192 192 return -EINVAL; 193 193 } 194 194 return 0; ··· 205 203 if (err) 206 204 return err; 207 205 if (info->flags & ~XT_SOCKET_FLAGS_V3) { 208 - pr_info("unknown flags 0x%x\n", 209 - info->flags & ~XT_SOCKET_FLAGS_V3); 206 + pr_info_ratelimited("unknown flags 0x%x\n", 207 + info->flags & ~XT_SOCKET_FLAGS_V3); 210 208 return -EINVAL; 211 209 } 212 210 return 0;
+2 -2
net/netfilter/xt_state.c
··· 44 44 45 45 ret = nf_ct_netns_get(par->net, par->family); 46 46 if (ret < 0) 47 - pr_info("cannot load conntrack support for proto=%u\n", 48 - par->family); 47 + pr_info_ratelimited("cannot load conntrack support for proto=%u\n", 48 + par->family); 49 49 return ret; 50 50 } 51 51
+3 -3
net/netfilter/xt_time.c
··· 235 235 236 236 if (info->daytime_start > XT_TIME_MAX_DAYTIME || 237 237 info->daytime_stop > XT_TIME_MAX_DAYTIME) { 238 - pr_info("invalid argument - start or " 239 - "stop time greater than 23:59:59\n"); 238 + pr_info_ratelimited("invalid argument - start or stop time greater than 23:59:59\n"); 240 239 return -EDOM; 241 240 } 242 241 243 242 if (info->flags & ~XT_TIME_ALL_FLAGS) { 244 - pr_info("unknown flags 0x%x\n", info->flags & ~XT_TIME_ALL_FLAGS); 243 + pr_info_ratelimited("unknown flags 0x%x\n", 244 + info->flags & ~XT_TIME_ALL_FLAGS); 245 245 return -EINVAL; 246 246 } 247 247
+3 -1
net/netlink/af_netlink.c
··· 2308 2308 if (cb->start) { 2309 2309 ret = cb->start(cb); 2310 2310 if (ret) 2311 - goto error_unlock; 2311 + goto error_put; 2312 2312 } 2313 2313 2314 2314 nlk->cb_running = true; ··· 2328 2328 */ 2329 2329 return -EINTR; 2330 2330 2331 + error_put: 2332 + module_put(control->module); 2331 2333 error_unlock: 2332 2334 sock_put(sk); 2333 2335 mutex_unlock(nlk->cb_mutex);
+1 -1
net/rxrpc/output.c
··· 445 445 (char *)&opt, sizeof(opt)); 446 446 if (ret == 0) { 447 447 ret = kernel_sendmsg(conn->params.local->socket, &msg, 448 - iov, 1, iov[0].iov_len); 448 + iov, 2, len); 449 449 450 450 opt = IPV6_PMTUDISC_DO; 451 451 kernel_setsockopt(conn->params.local->socket,
+6 -1
net/sched/cls_api.c
··· 1397 1397 nla_get_u32(tca[TCA_CHAIN]) != chain->index) 1398 1398 continue; 1399 1399 if (!tcf_chain_dump(chain, q, parent, skb, cb, 1400 - index_start, &index)) 1400 + index_start, &index)) { 1401 + err = -EMSGSIZE; 1401 1402 break; 1403 + } 1402 1404 } 1403 1405 1404 1406 cb->args[0] = index; 1405 1407 1406 1408 out: 1409 + /* If we did no progress, the error (EMSGSIZE) is real */ 1410 + if (skb->len == 0 && err) 1411 + return err; 1407 1412 return skb->len; 1408 1413 } 1409 1414
+22 -3
net/wireless/mesh.c
··· 170 170 enum nl80211_bss_scan_width scan_width; 171 171 struct ieee80211_supported_band *sband = 172 172 rdev->wiphy.bands[setup->chandef.chan->band]; 173 - scan_width = cfg80211_chandef_to_scan_width(&setup->chandef); 174 - setup->basic_rates = ieee80211_mandatory_rates(sband, 175 - scan_width); 173 + 174 + if (setup->chandef.chan->band == NL80211_BAND_2GHZ) { 175 + int i; 176 + 177 + /* 178 + * Older versions selected the mandatory rates for 179 + * 2.4 GHz as well, but were broken in that only 180 + * 1 Mbps was regarded as a mandatory rate. Keep 181 + * using just 1 Mbps as the default basic rate for 182 + * mesh to be interoperable with older versions. 183 + */ 184 + for (i = 0; i < sband->n_bitrates; i++) { 185 + if (sband->bitrates[i].bitrate == 10) { 186 + setup->basic_rates = BIT(i); 187 + break; 188 + } 189 + } 190 + } else { 191 + scan_width = cfg80211_chandef_to_scan_width(&setup->chandef); 192 + setup->basic_rates = ieee80211_mandatory_rates(sband, 193 + scan_width); 194 + } 176 195 } 177 196 178 197 err = cfg80211_chandef_dfs_required(&rdev->wiphy,
+2
net/wireless/sme.c
··· 1032 1032 wdev->current_bss = NULL; 1033 1033 wdev->ssid_len = 0; 1034 1034 wdev->conn_owner_nlportid = 0; 1035 + kzfree(wdev->connect_keys); 1036 + wdev->connect_keys = NULL; 1035 1037 1036 1038 nl80211_send_disconnected(rdev, dev, reason, ie, ie_len, from_ap); 1037 1039
+1
security/integrity/digsig.c
··· 18 18 #include <linux/cred.h> 19 19 #include <linux/key-type.h> 20 20 #include <linux/digsig.h> 21 + #include <linux/vmalloc.h> 21 22 #include <crypto/public_key.h> 22 23 #include <keys/system_keyring.h> 23 24
+87 -23
security/keys/big_key.c
··· 22 22 #include <keys/big_key-type.h> 23 23 #include <crypto/aead.h> 24 24 25 + struct big_key_buf { 26 + unsigned int nr_pages; 27 + void *virt; 28 + struct scatterlist *sg; 29 + struct page *pages[]; 30 + }; 31 + 25 32 /* 26 33 * Layout of key payload words. 27 34 */ ··· 98 91 /* 99 92 * Encrypt/decrypt big_key data 100 93 */ 101 - static int big_key_crypt(enum big_key_op op, u8 *data, size_t datalen, u8 *key) 94 + static int big_key_crypt(enum big_key_op op, struct big_key_buf *buf, size_t datalen, u8 *key) 102 95 { 103 96 int ret; 104 - struct scatterlist sgio; 105 97 struct aead_request *aead_req; 106 98 /* We always use a zero nonce. The reason we can get away with this is 107 99 * because we're using a different randomly generated key for every ··· 115 109 return -ENOMEM; 116 110 117 111 memset(zero_nonce, 0, sizeof(zero_nonce)); 118 - sg_init_one(&sgio, data, datalen + (op == BIG_KEY_ENC ? ENC_AUTHTAG_SIZE : 0)); 119 - aead_request_set_crypt(aead_req, &sgio, &sgio, datalen, zero_nonce); 112 + aead_request_set_crypt(aead_req, buf->sg, buf->sg, datalen, zero_nonce); 120 113 aead_request_set_callback(aead_req, CRYPTO_TFM_REQ_MAY_SLEEP, NULL, NULL); 121 114 aead_request_set_ad(aead_req, 0); 122 115 ··· 135 130 } 136 131 137 132 /* 133 + * Free up the buffer. 134 + */ 135 + static void big_key_free_buffer(struct big_key_buf *buf) 136 + { 137 + unsigned int i; 138 + 139 + if (buf->virt) { 140 + memset(buf->virt, 0, buf->nr_pages * PAGE_SIZE); 141 + vunmap(buf->virt); 142 + } 143 + 144 + for (i = 0; i < buf->nr_pages; i++) 145 + if (buf->pages[i]) 146 + __free_page(buf->pages[i]); 147 + 148 + kfree(buf); 149 + } 150 + 151 + /* 152 + * Allocate a buffer consisting of a set of pages with a virtual mapping 153 + * applied over them. 154 + */ 155 + static void *big_key_alloc_buffer(size_t len) 156 + { 157 + struct big_key_buf *buf; 158 + unsigned int npg = (len + PAGE_SIZE - 1) >> PAGE_SHIFT; 159 + unsigned int i, l; 160 + 161 + buf = kzalloc(sizeof(struct big_key_buf) + 162 + sizeof(struct page) * npg + 163 + sizeof(struct scatterlist) * npg, 164 + GFP_KERNEL); 165 + if (!buf) 166 + return NULL; 167 + 168 + buf->nr_pages = npg; 169 + buf->sg = (void *)(buf->pages + npg); 170 + sg_init_table(buf->sg, npg); 171 + 172 + for (i = 0; i < buf->nr_pages; i++) { 173 + buf->pages[i] = alloc_page(GFP_KERNEL); 174 + if (!buf->pages[i]) 175 + goto nomem; 176 + 177 + l = min_t(size_t, len, PAGE_SIZE); 178 + sg_set_page(&buf->sg[i], buf->pages[i], l, 0); 179 + len -= l; 180 + } 181 + 182 + buf->virt = vmap(buf->pages, buf->nr_pages, VM_MAP, PAGE_KERNEL); 183 + if (!buf->virt) 184 + goto nomem; 185 + 186 + return buf; 187 + 188 + nomem: 189 + big_key_free_buffer(buf); 190 + return NULL; 191 + } 192 + 193 + /* 138 194 * Preparse a big key 139 195 */ 140 196 int big_key_preparse(struct key_preparsed_payload *prep) 141 197 { 198 + struct big_key_buf *buf; 142 199 struct path *path = (struct path *)&prep->payload.data[big_key_path]; 143 200 struct file *file; 144 201 u8 *enckey; 145 - u8 *data = NULL; 146 202 ssize_t written; 147 - size_t datalen = prep->datalen; 203 + size_t datalen = prep->datalen, enclen = datalen + ENC_AUTHTAG_SIZE; 148 204 int ret; 149 205 150 - ret = -EINVAL; 151 206 if (datalen <= 0 || datalen > 1024 * 1024 || !prep->data) 152 - goto error; 207 + return -EINVAL; 153 208 154 209 /* Set an arbitrary quota */ 155 210 prep->quotalen = 16; ··· 222 157 * 223 158 * File content is stored encrypted with randomly generated key. 224 159 */ 225 - size_t enclen = datalen + ENC_AUTHTAG_SIZE; 226 160 loff_t pos = 0; 227 161 228 - data = kmalloc(enclen, GFP_KERNEL); 229 - if (!data) 162 + buf = big_key_alloc_buffer(enclen); 163 + if (!buf) 230 164 return -ENOMEM; 231 - memcpy(data, prep->data, datalen); 165 + memcpy(buf->virt, prep->data, datalen); 232 166 233 167 /* generate random key */ 234 168 enckey = kmalloc(ENC_KEY_SIZE, GFP_KERNEL); ··· 240 176 goto err_enckey; 241 177 242 178 /* encrypt aligned data */ 243 - ret = big_key_crypt(BIG_KEY_ENC, data, datalen, enckey); 179 + ret = big_key_crypt(BIG_KEY_ENC, buf, datalen, enckey); 244 180 if (ret) 245 181 goto err_enckey; 246 182 ··· 251 187 goto err_enckey; 252 188 } 253 189 254 - written = kernel_write(file, data, enclen, &pos); 190 + written = kernel_write(file, buf->virt, enclen, &pos); 255 191 if (written != enclen) { 256 192 ret = written; 257 193 if (written >= 0) ··· 266 202 *path = file->f_path; 267 203 path_get(path); 268 204 fput(file); 269 - kzfree(data); 205 + big_key_free_buffer(buf); 270 206 } else { 271 207 /* Just store the data in a buffer */ 272 208 void *data = kmalloc(datalen, GFP_KERNEL); ··· 284 220 err_enckey: 285 221 kzfree(enckey); 286 222 error: 287 - kzfree(data); 223 + big_key_free_buffer(buf); 288 224 return ret; 289 225 } 290 226 ··· 362 298 return datalen; 363 299 364 300 if (datalen > BIG_KEY_FILE_THRESHOLD) { 301 + struct big_key_buf *buf; 365 302 struct path *path = (struct path *)&key->payload.data[big_key_path]; 366 303 struct file *file; 367 - u8 *data; 368 304 u8 *enckey = (u8 *)key->payload.data[big_key_data]; 369 305 size_t enclen = datalen + ENC_AUTHTAG_SIZE; 370 306 loff_t pos = 0; 371 307 372 - data = kmalloc(enclen, GFP_KERNEL); 373 - if (!data) 308 + buf = big_key_alloc_buffer(enclen); 309 + if (!buf) 374 310 return -ENOMEM; 375 311 376 312 file = dentry_open(path, O_RDONLY, current_cred()); ··· 380 316 } 381 317 382 318 /* read file to kernel and decrypt */ 383 - ret = kernel_read(file, data, enclen, &pos); 319 + ret = kernel_read(file, buf->virt, enclen, &pos); 384 320 if (ret >= 0 && ret != enclen) { 385 321 ret = -EIO; 386 322 goto err_fput; 387 323 } 388 324 389 - ret = big_key_crypt(BIG_KEY_DEC, data, enclen, enckey); 325 + ret = big_key_crypt(BIG_KEY_DEC, buf, enclen, enckey); 390 326 if (ret) 391 327 goto err_fput; 392 328 393 329 ret = datalen; 394 330 395 331 /* copy decrypted data to user */ 396 - if (copy_to_user(buffer, data, datalen) != 0) 332 + if (copy_to_user(buffer, buf->virt, datalen) != 0) 397 333 ret = -EFAULT; 398 334 399 335 err_fput: 400 336 fput(file); 401 337 error: 402 - kzfree(data); 338 + big_key_free_buffer(buf); 403 339 } else { 404 340 ret = datalen; 405 341 if (copy_to_user(buffer, key->payload.data[big_key_data],
+1 -1
tools/bpf/bpftool/main.c
··· 244 244 } 245 245 246 246 if (errno && errno != ENOENT) { 247 - perror("reading batch file failed"); 247 + p_err("reading batch file failed: %s", strerror(errno)); 248 248 err = -1; 249 249 } else { 250 250 p_info("processed %d lines", lines);
+3
tools/bpf/bpftool/prog.c
··· 774 774 n < 0 ? strerror(errno) : "short write"); 775 775 goto err_free; 776 776 } 777 + 778 + if (json_output) 779 + jsonw_null(json_wtr); 777 780 } else { 778 781 if (member_len == &info.jited_prog_len) { 779 782 const char *name = NULL;
-1
tools/cgroup/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 # Makefile for cgroup tools 3 3 4 - CC = $(CROSS_COMPILE)gcc 5 4 CFLAGS = -Wall -Wextra 6 5 7 6 all: cgroup_event_listener
-2
tools/gpio/Makefile
··· 12 12 # (this improves performance and avoids hard-to-debug behaviour); 13 13 MAKEFLAGS += -r 14 14 15 - CC = $(CROSS_COMPILE)gcc 16 - LD = $(CROSS_COMPILE)ld 17 15 CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include 18 16 19 17 ALL_TARGETS := lsgpio gpio-hammer gpio-event-mon
-1
tools/hv/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 # Makefile for Hyper-V tools 3 3 4 - CC = $(CROSS_COMPILE)gcc 5 4 WARNINGS = -Wall -Wextra 6 5 CFLAGS = $(WARNINGS) -g $(shell getconf LFS_CFLAGS) 7 6
-2
tools/iio/Makefile
··· 12 12 # (this improves performance and avoids hard-to-debug behaviour); 13 13 MAKEFLAGS += -r 14 14 15 - CC = $(CROSS_COMPILE)gcc 16 - LD = $(CROSS_COMPILE)ld 17 15 CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include 18 16 19 17 ALL_TARGETS := iio_event_monitor lsiio iio_generic_buffer
-1
tools/laptop/freefall/Makefile
··· 2 2 PREFIX ?= /usr 3 3 SBINDIR ?= sbin 4 4 INSTALL ?= install 5 - CC = $(CROSS_COMPILE)gcc 6 5 7 6 TARGET = freefall 8 7
-1
tools/leds/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 # Makefile for LEDs tools 3 3 4 - CC = $(CROSS_COMPILE)gcc 5 4 CFLAGS = -Wall -Wextra -g -I../../include/uapi 6 5 7 6 all: uledmon led_hw_brightness_mon
+3 -2
tools/lib/bpf/libbpf.c
··· 1060 1060 prog->insns = new_insn; 1061 1061 prog->main_prog_cnt = prog->insns_cnt; 1062 1062 prog->insns_cnt = new_cnt; 1063 + pr_debug("added %zd insn from %s to prog %s\n", 1064 + text->insns_cnt, text->section_name, 1065 + prog->section_name); 1063 1066 } 1064 1067 insn = &prog->insns[relo->insn_idx]; 1065 1068 insn->imm += prog->main_prog_cnt - relo->insn_idx; 1066 - pr_debug("added %zd insn from %s to prog %s\n", 1067 - text->insns_cnt, text->section_name, prog->section_name); 1068 1069 return 0; 1069 1070 } 1070 1071
-6
tools/perf/Makefile.perf
··· 146 146 $(eval $(1) = $(2))) 147 147 endef 148 148 149 - # Allow setting CC and AR and LD, or setting CROSS_COMPILE as a prefix. 150 - $(call allow-override,CC,$(CROSS_COMPILE)gcc) 151 - $(call allow-override,AR,$(CROSS_COMPILE)ar) 152 - $(call allow-override,LD,$(CROSS_COMPILE)ld) 153 - $(call allow-override,CXX,$(CROSS_COMPILE)g++) 154 - 155 149 LD += $(EXTRA_LDFLAGS) 156 150 157 151 HOSTCC ?= gcc
-3
tools/power/acpi/Makefile.config
··· 56 56 # to compile vs uClibc, that can be done here as well. 57 57 CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc- 58 58 CROSS_COMPILE ?= $(CROSS) 59 - CC = $(CROSS_COMPILE)gcc 60 - LD = $(CROSS_COMPILE)gcc 61 - STRIP = $(CROSS_COMPILE)strip 62 59 HOSTCC = gcc 63 60 64 61 # check if compiler option is supported
+18
tools/scripts/Makefile.include
··· 42 42 43 43 CC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?) 44 44 45 + # Makefiles suck: This macro sets a default value of $(2) for the 46 + # variable named by $(1), unless the variable has been set by 47 + # environment or command line. This is necessary for CC and AR 48 + # because make sets default values, so the simpler ?= approach 49 + # won't work as expected. 50 + define allow-override 51 + $(if $(or $(findstring environment,$(origin $(1))),\ 52 + $(findstring command line,$(origin $(1)))),,\ 53 + $(eval $(1) = $(2))) 54 + endef 55 + 56 + # Allow setting various cross-compile vars or setting CROSS_COMPILE as a prefix. 57 + $(call allow-override,CC,$(CROSS_COMPILE)gcc) 58 + $(call allow-override,AR,$(CROSS_COMPILE)ar) 59 + $(call allow-override,LD,$(CROSS_COMPILE)ld) 60 + $(call allow-override,CXX,$(CROSS_COMPILE)g++) 61 + $(call allow-override,STRIP,$(CROSS_COMPILE)strip) 62 + 45 63 ifeq ($(CC_NO_CLANG), 1) 46 64 EXTRA_WARNINGS += -Wstrict-aliasing=3 47 65 endif
-2
tools/spi/Makefile
··· 11 11 # (this improves performance and avoids hard-to-debug behaviour); 12 12 MAKEFLAGS += -r 13 13 14 - CC = $(CROSS_COMPILE)gcc 15 - LD = $(CROSS_COMPILE)ld 16 14 CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include 17 15 18 16 ALL_TARGETS := spidev_test spidev_fdx
+1
tools/testing/selftests/bpf/.gitignore
··· 11 11 test_tcpbpf_user 12 12 test_verifier_log 13 13 feature 14 + test_libbpf_open
+2
tools/testing/selftests/bpf/test_maps.c
··· 126 126 fd = bpf_create_map(BPF_MAP_TYPE_HASH, i, j, 127 127 2, map_flags); 128 128 if (fd < 0) { 129 + if (errno == ENOMEM) 130 + return; 129 131 printf("Failed to create hashmap key=%d value=%d '%s'\n", 130 132 i, j, strerror(errno)); 131 133 exit(1);
-1
tools/testing/selftests/bpf/test_tcpbpf_kern.c
··· 5 5 #include <linux/if_ether.h> 6 6 #include <linux/if_packet.h> 7 7 #include <linux/ip.h> 8 - #include <linux/in6.h> 9 8 #include <linux/types.h> 10 9 #include <linux/socket.h> 11 10 #include <linux/tcp.h>
+26
tools/testing/selftests/bpf/test_verifier.c
··· 2587 2587 .result = ACCEPT, 2588 2588 }, 2589 2589 { 2590 + "runtime/jit: pass negative index to tail_call", 2591 + .insns = { 2592 + BPF_MOV64_IMM(BPF_REG_3, -1), 2593 + BPF_LD_MAP_FD(BPF_REG_2, 0), 2594 + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, 2595 + BPF_FUNC_tail_call), 2596 + BPF_MOV64_IMM(BPF_REG_0, 0), 2597 + BPF_EXIT_INSN(), 2598 + }, 2599 + .fixup_prog = { 1 }, 2600 + .result = ACCEPT, 2601 + }, 2602 + { 2603 + "runtime/jit: pass > 32bit index to tail_call", 2604 + .insns = { 2605 + BPF_LD_IMM64(BPF_REG_3, 0x100000000ULL), 2606 + BPF_LD_MAP_FD(BPF_REG_2, 0), 2607 + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, 2608 + BPF_FUNC_tail_call), 2609 + BPF_MOV64_IMM(BPF_REG_0, 0), 2610 + BPF_EXIT_INSN(), 2611 + }, 2612 + .fixup_prog = { 2 }, 2613 + .result = ACCEPT, 2614 + }, 2615 + { 2590 2616 "stack pointer arithmetic", 2591 2617 .insns = { 2592 2618 BPF_MOV64_IMM(BPF_REG_1, 4),
+1
tools/testing/selftests/memfd/Makefile
··· 5 5 CFLAGS += -I../../../../usr/include/ 6 6 7 7 TEST_PROGS := run_tests.sh 8 + TEST_FILES := run_fuse_test.sh 8 9 TEST_GEN_FILES := memfd_test fuse_mnt fuse_test 9 10 10 11 fuse_mnt.o: CFLAGS += $(shell pkg-config fuse --cflags)
+61
tools/testing/selftests/seccomp/seccomp_bpf.c
··· 141 141 #define SECCOMP_FILTER_FLAG_LOG 2 142 142 #endif 143 143 144 + #ifndef PTRACE_SECCOMP_GET_METADATA 145 + #define PTRACE_SECCOMP_GET_METADATA 0x420d 146 + 147 + struct seccomp_metadata { 148 + __u64 filter_off; /* Input: which filter */ 149 + __u64 flags; /* Output: filter's flags */ 150 + }; 151 + #endif 152 + 144 153 #ifndef seccomp 145 154 int seccomp(unsigned int op, unsigned int flags, void *args) 146 155 { ··· 2852 2843 ret = seccomp(SECCOMP_GET_ACTION_AVAIL, 0, &unknown_action); 2853 2844 EXPECT_EQ(ret, -1); 2854 2845 EXPECT_EQ(errno, EOPNOTSUPP); 2846 + } 2847 + 2848 + TEST(get_metadata) 2849 + { 2850 + pid_t pid; 2851 + int pipefd[2]; 2852 + char buf; 2853 + struct seccomp_metadata md; 2854 + 2855 + ASSERT_EQ(0, pipe(pipefd)); 2856 + 2857 + pid = fork(); 2858 + ASSERT_GE(pid, 0); 2859 + if (pid == 0) { 2860 + struct sock_filter filter[] = { 2861 + BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW), 2862 + }; 2863 + struct sock_fprog prog = { 2864 + .len = (unsigned short)ARRAY_SIZE(filter), 2865 + .filter = filter, 2866 + }; 2867 + 2868 + /* one with log, one without */ 2869 + ASSERT_EQ(0, seccomp(SECCOMP_SET_MODE_FILTER, 2870 + SECCOMP_FILTER_FLAG_LOG, &prog)); 2871 + ASSERT_EQ(0, seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog)); 2872 + 2873 + ASSERT_EQ(0, close(pipefd[0])); 2874 + ASSERT_EQ(1, write(pipefd[1], "1", 1)); 2875 + ASSERT_EQ(0, close(pipefd[1])); 2876 + 2877 + while (1) 2878 + sleep(100); 2879 + } 2880 + 2881 + ASSERT_EQ(0, close(pipefd[1])); 2882 + ASSERT_EQ(1, read(pipefd[0], &buf, 1)); 2883 + 2884 + ASSERT_EQ(0, ptrace(PTRACE_ATTACH, pid)); 2885 + ASSERT_EQ(pid, waitpid(pid, NULL, 0)); 2886 + 2887 + md.filter_off = 0; 2888 + ASSERT_EQ(sizeof(md), ptrace(PTRACE_SECCOMP_GET_METADATA, pid, sizeof(md), &md)); 2889 + EXPECT_EQ(md.flags, SECCOMP_FILTER_FLAG_LOG); 2890 + EXPECT_EQ(md.filter_off, 0); 2891 + 2892 + md.filter_off = 1; 2893 + ASSERT_EQ(sizeof(md), ptrace(PTRACE_SECCOMP_GET_METADATA, pid, sizeof(md), &md)); 2894 + EXPECT_EQ(md.flags, 0); 2895 + EXPECT_EQ(md.filter_off, 1); 2896 + 2897 + ASSERT_EQ(0, kill(pid, SIGKILL)); 2855 2898 } 2856 2899 2857 2900 /*
-1
tools/usb/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 # Makefile for USB tools 3 3 4 - CC = $(CROSS_COMPILE)gcc 5 4 PTHREAD_LIBS = -lpthread 6 5 WARNINGS = -Wall -Wextra 7 6 CFLAGS = $(WARNINGS) -g -I../include
-1
tools/vm/Makefile
··· 6 6 LIB_DIR = ../lib/api 7 7 LIBS = $(LIB_DIR)/libapi.a 8 8 9 - CC = $(CROSS_COMPILE)gcc 10 9 CFLAGS = -Wall -Wextra -I../lib/ 11 10 LDFLAGS = $(LIBS) 12 11
-1
tools/wmi/Makefile
··· 2 2 SBINDIR ?= sbin 3 3 INSTALL ?= install 4 4 CFLAGS += -D__EXPORTED_HEADERS__ -I../../include/uapi -I../../include 5 - CC = $(CROSS_COMPILE)gcc 6 5 7 6 TARGET = dell-smbios-example 8 7