aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/networking/bonding.txt2
-rw-r--r--MAINTAINERS6
-rw-r--r--arch/Kconfig3
-rw-r--r--arch/powerpc/kernel/exceptions-64s.S24
-rw-r--r--arch/powerpc/kernel/signal_64.c13
-rw-r--r--arch/powerpc/kernel/trace/ftrace_64_mprofile.S45
-rw-r--r--arch/powerpc/lib/sstep.c6
-rw-r--r--arch/powerpc/mm/numa.c1
-rw-r--r--arch/powerpc/perf/imc-pmu.c39
-rw-r--r--arch/sparc/Kconfig1
-rw-r--r--arch/x86/kvm/mmu.c15
-rw-r--r--arch/x86/kvm/paging_tmpl.h3
-rw-r--r--arch/x86/kvm/vmx.c2
-rw-r--r--arch/x86/xen/enlighten.c4
-rw-r--r--block/bio.c26
-rw-r--r--crypto/shash.c10
-rw-r--r--crypto/skcipher.c17
-rw-r--r--crypto/xts.c6
-rw-r--r--drivers/acpi/property.c29
-rw-r--r--drivers/base/property.c19
-rw-r--r--drivers/crypto/axis/artpec6_crypto.c4
-rw-r--r--drivers/crypto/stm32/stm32-hash.c15
-rw-r--r--drivers/gpio/Kconfig3
-rw-r--r--drivers/gpio/gpio-omap.c24
-rw-r--r--drivers/gpio/gpiolib-acpi.c2
-rw-r--r--drivers/hid/Kconfig1
-rw-r--r--drivers/hid/hid-core.c2
-rw-r--r--drivers/hid/hid-elecom.c13
-rw-r--r--drivers/hid/hid-ids.h2
-rw-r--r--drivers/hid/usbhid/hid-core.c12
-rw-r--r--drivers/net/ethernet/cavium/thunder/nicvf_main.c2
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c22
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_common.c19
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c16
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c6
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c14
-rw-r--r--drivers/net/ppp/ppp_generic.c20
-rw-r--r--drivers/net/usb/cdc_ether.c13
-rw-r--r--drivers/pinctrl/Kconfig1
-rw-r--r--drivers/pinctrl/bcm/pinctrl-bcm2835.c4
-rw-r--r--drivers/pinctrl/intel/pinctrl-cherryview.c14
-rw-r--r--drivers/remoteproc/Kconfig2
-rw-r--r--drivers/remoteproc/imx_rproc.c9
-rw-r--r--drivers/rpmsg/qcom_glink_native.c14
-rw-r--r--fs/9p/vfs_addr.c10
-rw-r--r--fs/direct-io.c3
-rw-r--r--fs/f2fs/f2fs.h2
-rw-r--r--fs/f2fs/segment.c6
-rw-r--r--fs/f2fs/super.c2
-rw-r--r--fs/nfs/client.c2
-rw-r--r--fs/nfs/filelayout/filelayout.c3
-rw-r--r--fs/nfs/nfs4idmap.c2
-rw-r--r--fs/nfs/nfs4proc.c3
-rw-r--r--fs/nfs/nfs4xdr.c4
-rw-r--r--fs/nfsd/nfs4proc.c9
-rw-r--r--fs/quota/dquot.c27
-rw-r--r--fs/xfs/libxfs/xfs_alloc.c8
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c4
-rw-r--r--fs/xfs/libxfs/xfs_ialloc.c4
-rw-r--r--fs/xfs/libxfs/xfs_log_format.h27
-rw-r--r--fs/xfs/xfs_acl.c22
-rw-r--r--fs/xfs/xfs_attr_inactive.c2
-rw-r--r--fs/xfs/xfs_bmap_util.c2
-rw-r--r--fs/xfs/xfs_bmap_util.h13
-rw-r--r--fs/xfs/xfs_file.c4
-rw-r--r--fs/xfs/xfs_fsmap.c12
-rw-r--r--fs/xfs/xfs_inode_item.c79
-rw-r--r--fs/xfs/xfs_log.c2
-rw-r--r--fs/xfs/xfs_mount.c2
-rw-r--r--fs/xfs/xfs_ondisk.h2
-rw-r--r--include/linux/bpf.h5
-rw-r--r--include/linux/netfilter_bridge/ebtables.h7
-rw-r--r--include/sound/seq_virmidi.h1
-rw-r--r--include/uapi/linux/netfilter/xt_bpf.h1
-rw-r--r--kernel/bpf/inode.c1
-rw-r--r--kernel/bpf/verifier.c5
-rw-r--r--kernel/exit.c6
-rw-r--r--kernel/livepatch/core.c60
-rw-r--r--kernel/seccomp.c2
-rw-r--r--net/bridge/netfilter/ebtable_broute.c4
-rw-r--r--net/bridge/netfilter/ebtable_filter.c4
-rw-r--r--net/bridge/netfilter/ebtable_nat.c4
-rw-r--r--net/bridge/netfilter/ebtables.c17
-rw-r--r--net/ipv4/gre_offload.c2
-rw-r--r--net/ipv4/netfilter/ipt_SYNPROXY.c3
-rw-r--r--net/ipv4/route.c2
-rw-r--r--net/ipv4/udp.c14
-rw-r--r--net/ipv4/udp_offload.c2
-rw-r--r--net/ipv6/addrconf.c4
-rw-r--r--net/ipv6/ip6_offload.c2
-rw-r--r--net/ipv6/netfilter/ip6t_SYNPROXY.c2
-rw-r--r--net/ipv6/route.c2
-rw-r--r--net/netfilter/ipset/ip_set_core.c29
-rw-r--r--net/netfilter/ipset/ip_set_hash_ip.c22
-rw-r--r--net/netfilter/ipset/ip_set_hash_ipmark.c2
-rw-r--r--net/netfilter/ipset/ip_set_hash_ipport.c2
-rw-r--r--net/netfilter/ipset/ip_set_hash_ipportip.c2
-rw-r--r--net/netfilter/ipset/ip_set_hash_ipportnet.c4
-rw-r--r--net/netfilter/ipset/ip_set_hash_net.c2
-rw-r--r--net/netfilter/ipset/ip_set_hash_netiface.c2
-rw-r--r--net/netfilter/ipset/ip_set_hash_netnet.c4
-rw-r--r--net/netfilter/ipset/ip_set_hash_netport.c2
-rw-r--r--net/netfilter/ipset/ip_set_hash_netportnet.c4
-rw-r--r--net/netfilter/ipvs/ip_vs_xmit.c8
-rw-r--r--net/netfilter/nf_tables_api.c10
-rw-r--r--net/netfilter/x_tables.c4
-rw-r--r--net/netfilter/xt_bpf.c22
-rw-r--r--net/netfilter/xt_socket.c4
-rw-r--r--net/netlink/af_netlink.c13
-rw-r--r--net/sunrpc/xprtsock.c2
-rw-r--r--net/tipc/bcast.c4
-rw-r--r--net/tipc/msg.c8
-rw-r--r--net/wireless/nl80211.c14
-rw-r--r--net/xfrm/xfrm_device.c1
-rw-r--r--net/xfrm/xfrm_input.c6
-rw-r--r--net/xfrm/xfrm_state.c4
-rw-r--r--net/xfrm/xfrm_user.c1
-rwxr-xr-xscripts/faddr2line5
-rw-r--r--sound/core/seq/seq_clientmgr.c6
-rw-r--r--sound/core/seq/seq_ports.c7
-rw-r--r--sound/core/seq/seq_virmidi.c27
-rw-r--r--sound/usb/caiaq/device.c12
-rw-r--r--sound/usb/line6/driver.c7
-rw-r--r--sound/usb/line6/podhd.c8
-rw-r--r--sound/usb/mixer.c12
-rw-r--r--sound/usb/mixer.h2
-rw-r--r--sound/usb/quirks.c1
-rw-r--r--tools/testing/selftests/mqueue/Makefile4
-rw-r--r--tools/testing/selftests/networking/timestamping/rxtimestamp.c2
-rw-r--r--tools/testing/selftests/x86/Makefile2
130 files changed, 734 insertions, 448 deletions
diff --git a/Documentation/networking/bonding.txt b/Documentation/networking/bonding.txt
index 57f52cdce32e..9ba04c0bab8d 100644
--- a/Documentation/networking/bonding.txt
+++ b/Documentation/networking/bonding.txt
@@ -2387,7 +2387,7 @@ broadcast: Like active-backup, there is not much advantage to this
2387 and packet type ID), so in a "gatewayed" configuration, all 2387 and packet type ID), so in a "gatewayed" configuration, all
2388 outgoing traffic will generally use the same device. Incoming 2388 outgoing traffic will generally use the same device. Incoming
2389 traffic may also end up on a single device, but that is 2389 traffic may also end up on a single device, but that is
2390 dependent upon the balancing policy of the peer's 8023.ad 2390 dependent upon the balancing policy of the peer's 802.3ad
2391 implementation. In a "local" configuration, traffic will be 2391 implementation. In a "local" configuration, traffic will be
2392 distributed across the devices in the bond. 2392 distributed across the devices in the bond.
2393 2393
diff --git a/MAINTAINERS b/MAINTAINERS
index 2d3d750b19c0..a74227ad082e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5346,9 +5346,7 @@ M: "J. Bruce Fields" <bfields@fieldses.org>
5346L: linux-fsdevel@vger.kernel.org 5346L: linux-fsdevel@vger.kernel.org
5347S: Maintained 5347S: Maintained
5348F: include/linux/fcntl.h 5348F: include/linux/fcntl.h
5349F: include/linux/fs.h
5350F: include/uapi/linux/fcntl.h 5349F: include/uapi/linux/fcntl.h
5351F: include/uapi/linux/fs.h
5352F: fs/fcntl.c 5350F: fs/fcntl.c
5353F: fs/locks.c 5351F: fs/locks.c
5354 5352
@@ -5357,6 +5355,8 @@ M: Alexander Viro <viro@zeniv.linux.org.uk>
5357L: linux-fsdevel@vger.kernel.org 5355L: linux-fsdevel@vger.kernel.org
5358S: Maintained 5356S: Maintained
5359F: fs/* 5357F: fs/*
5358F: include/linux/fs.h
5359F: include/uapi/linux/fs.h
5360 5360
5361FINTEK F75375S HARDWARE MONITOR AND FAN CONTROLLER DRIVER 5361FINTEK F75375S HARDWARE MONITOR AND FAN CONTROLLER DRIVER
5362M: Riku Voipio <riku.voipio@iki.fi> 5362M: Riku Voipio <riku.voipio@iki.fi>
@@ -7571,7 +7571,7 @@ F: arch/mips/include/asm/kvm*
7571F: arch/mips/kvm/ 7571F: arch/mips/kvm/
7572 7572
7573KERNEL VIRTUAL MACHINE FOR POWERPC (KVM/powerpc) 7573KERNEL VIRTUAL MACHINE FOR POWERPC (KVM/powerpc)
7574M: Alexander Graf <agraf@suse.com> 7574M: Paul Mackerras <paulus@ozlabs.org>
7575L: kvm-ppc@vger.kernel.org 7575L: kvm-ppc@vger.kernel.org
7576W: http://www.linux-kvm.org/ 7576W: http://www.linux-kvm.org/
7577T: git git://github.com/agraf/linux-2.6.git 7577T: git git://github.com/agraf/linux-2.6.git
diff --git a/arch/Kconfig b/arch/Kconfig
index 1aafb4efbb51..d789a89cb32c 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -937,9 +937,6 @@ config STRICT_MODULE_RWX
937 and non-text memory will be made non-executable. This provides 937 and non-text memory will be made non-executable. This provides
938 protection against certain security exploits (e.g. writing to text) 938 protection against certain security exploits (e.g. writing to text)
939 939
940config ARCH_WANT_RELAX_ORDER
941 bool
942
943config ARCH_HAS_REFCOUNT 940config ARCH_HAS_REFCOUNT
944 bool 941 bool
945 help 942 help
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 48da0f5d2f7f..b82586c53560 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -734,7 +734,29 @@ EXC_REAL(program_check, 0x700, 0x100)
734EXC_VIRT(program_check, 0x4700, 0x100, 0x700) 734EXC_VIRT(program_check, 0x4700, 0x100, 0x700)
735TRAMP_KVM(PACA_EXGEN, 0x700) 735TRAMP_KVM(PACA_EXGEN, 0x700)
736EXC_COMMON_BEGIN(program_check_common) 736EXC_COMMON_BEGIN(program_check_common)
737 EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN) 737 /*
738 * It's possible to receive a TM Bad Thing type program check with
739 * userspace register values (in particular r1), but with SRR1 reporting
740 * that we came from the kernel. Normally that would confuse the bad
741 * stack logic, and we would report a bad kernel stack pointer. Instead
742 * we switch to the emergency stack if we're taking a TM Bad Thing from
743 * the kernel.
744 */
745 li r10,MSR_PR /* Build a mask of MSR_PR .. */
746 oris r10,r10,0x200000@h /* .. and SRR1_PROGTM */
747 and r10,r10,r12 /* Mask SRR1 with that. */
748 srdi r10,r10,8 /* Shift it so we can compare */
749 cmpldi r10,(0x200000 >> 8) /* .. with an immediate. */
750 bne 1f /* If != go to normal path. */
751
752 /* SRR1 had PR=0 and SRR1_PROGTM=1, so use the emergency stack */
753 andi. r10,r12,MSR_PR; /* Set CR0 correctly for label */
754 /* 3 in EXCEPTION_PROLOG_COMMON */
755 mr r10,r1 /* Save r1 */
756 ld r1,PACAEMERGSP(r13) /* Use emergency stack */
757 subi r1,r1,INT_FRAME_SIZE /* alloc stack frame */
758 b 3f /* Jump into the macro !! */
7591: EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN)
738 bl save_nvgprs 760 bl save_nvgprs
739 RECONCILE_IRQ_STATE(r10, r11) 761 RECONCILE_IRQ_STATE(r10, r11)
740 addi r3,r1,STACK_FRAME_OVERHEAD 762 addi r3,r1,STACK_FRAME_OVERHEAD
diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
index c83c115858c1..b2c002993d78 100644
--- a/arch/powerpc/kernel/signal_64.c
+++ b/arch/powerpc/kernel/signal_64.c
@@ -452,9 +452,20 @@ static long restore_tm_sigcontexts(struct task_struct *tsk,
452 if (MSR_TM_RESV(msr)) 452 if (MSR_TM_RESV(msr))
453 return -EINVAL; 453 return -EINVAL;
454 454
455 /* pull in MSR TM from user context */ 455 /* pull in MSR TS bits from user context */
456 regs->msr = (regs->msr & ~MSR_TS_MASK) | (msr & MSR_TS_MASK); 456 regs->msr = (regs->msr & ~MSR_TS_MASK) | (msr & MSR_TS_MASK);
457 457
458 /*
459 * Ensure that TM is enabled in regs->msr before we leave the signal
460 * handler. It could be the case that (a) user disabled the TM bit
461 * through the manipulation of the MSR bits in uc_mcontext or (b) the
462 * TM bit was disabled because a sufficient number of context switches
463 * happened whilst in the signal handler and load_tm overflowed,
464 * disabling the TM bit. In either case we can end up with an illegal
465 * TM state leading to a TM Bad Thing when we return to userspace.
466 */
467 regs->msr |= MSR_TM;
468
458 /* pull in MSR LE from user context */ 469 /* pull in MSR LE from user context */
459 regs->msr = (regs->msr & ~MSR_LE) | (msr & MSR_LE); 470 regs->msr = (regs->msr & ~MSR_LE) | (msr & MSR_LE);
460 471
diff --git a/arch/powerpc/kernel/trace/ftrace_64_mprofile.S b/arch/powerpc/kernel/trace/ftrace_64_mprofile.S
index c98e90b4ea7b..b4e2b7165f79 100644
--- a/arch/powerpc/kernel/trace/ftrace_64_mprofile.S
+++ b/arch/powerpc/kernel/trace/ftrace_64_mprofile.S
@@ -181,34 +181,25 @@ _GLOBAL(ftrace_stub)
181 * - we have no stack frame and can not allocate one 181 * - we have no stack frame and can not allocate one
182 * - LR points back to the original caller (in A) 182 * - LR points back to the original caller (in A)
183 * - CTR holds the new NIP in C 183 * - CTR holds the new NIP in C
184 * - r0 & r12 are free 184 * - r0, r11 & r12 are free
185 *
186 * r0 can't be used as the base register for a DS-form load or store, so
187 * we temporarily shuffle r1 (stack pointer) into r0 and then put it back.
188 */ 185 */
189livepatch_handler: 186livepatch_handler:
190 CURRENT_THREAD_INFO(r12, r1) 187 CURRENT_THREAD_INFO(r12, r1)
191 188
192 /* Save stack pointer into r0 */
193 mr r0, r1
194
195 /* Allocate 3 x 8 bytes */ 189 /* Allocate 3 x 8 bytes */
196 ld r1, TI_livepatch_sp(r12) 190 ld r11, TI_livepatch_sp(r12)
197 addi r1, r1, 24 191 addi r11, r11, 24
198 std r1, TI_livepatch_sp(r12) 192 std r11, TI_livepatch_sp(r12)
199 193
200 /* Save toc & real LR on livepatch stack */ 194 /* Save toc & real LR on livepatch stack */
201 std r2, -24(r1) 195 std r2, -24(r11)
202 mflr r12 196 mflr r12
203 std r12, -16(r1) 197 std r12, -16(r11)
204 198
205 /* Store stack end marker */ 199 /* Store stack end marker */
206 lis r12, STACK_END_MAGIC@h 200 lis r12, STACK_END_MAGIC@h
207 ori r12, r12, STACK_END_MAGIC@l 201 ori r12, r12, STACK_END_MAGIC@l
208 std r12, -8(r1) 202 std r12, -8(r11)
209
210 /* Restore real stack pointer */
211 mr r1, r0
212 203
213 /* Put ctr in r12 for global entry and branch there */ 204 /* Put ctr in r12 for global entry and branch there */
214 mfctr r12 205 mfctr r12
@@ -216,36 +207,30 @@ livepatch_handler:
216 207
217 /* 208 /*
218 * Now we are returning from the patched function to the original 209 * Now we are returning from the patched function to the original
219 * caller A. We are free to use r0 and r12, and we can use r2 until we 210 * caller A. We are free to use r11, r12 and we can use r2 until we
220 * restore it. 211 * restore it.
221 */ 212 */
222 213
223 CURRENT_THREAD_INFO(r12, r1) 214 CURRENT_THREAD_INFO(r12, r1)
224 215
225 /* Save stack pointer into r0 */ 216 ld r11, TI_livepatch_sp(r12)
226 mr r0, r1
227
228 ld r1, TI_livepatch_sp(r12)
229 217
230 /* Check stack marker hasn't been trashed */ 218 /* Check stack marker hasn't been trashed */
231 lis r2, STACK_END_MAGIC@h 219 lis r2, STACK_END_MAGIC@h
232 ori r2, r2, STACK_END_MAGIC@l 220 ori r2, r2, STACK_END_MAGIC@l
233 ld r12, -8(r1) 221 ld r12, -8(r11)
2341: tdne r12, r2 2221: tdne r12, r2
235 EMIT_BUG_ENTRY 1b, __FILE__, __LINE__ - 1, 0 223 EMIT_BUG_ENTRY 1b, __FILE__, __LINE__ - 1, 0
236 224
237 /* Restore LR & toc from livepatch stack */ 225 /* Restore LR & toc from livepatch stack */
238 ld r12, -16(r1) 226 ld r12, -16(r11)
239 mtlr r12 227 mtlr r12
240 ld r2, -24(r1) 228 ld r2, -24(r11)
241 229
242 /* Pop livepatch stack frame */ 230 /* Pop livepatch stack frame */
243 CURRENT_THREAD_INFO(r12, r0) 231 CURRENT_THREAD_INFO(r12, r1)
244 subi r1, r1, 24 232 subi r11, r11, 24
245 std r1, TI_livepatch_sp(r12) 233 std r11, TI_livepatch_sp(r12)
246
247 /* Restore real stack pointer */
248 mr r1, r0
249 234
250 /* Return to original caller of live patched function */ 235 /* Return to original caller of live patched function */
251 blr 236 blr
diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index 5e8418c28bd8..f208f560aecd 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -1684,11 +1684,13 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
1684 * Logical instructions 1684 * Logical instructions
1685 */ 1685 */
1686 case 26: /* cntlzw */ 1686 case 26: /* cntlzw */
1687 op->val = __builtin_clz((unsigned int) regs->gpr[rd]); 1687 val = (unsigned int) regs->gpr[rd];
1688 op->val = ( val ? __builtin_clz(val) : 32 );
1688 goto logical_done; 1689 goto logical_done;
1689#ifdef __powerpc64__ 1690#ifdef __powerpc64__
1690 case 58: /* cntlzd */ 1691 case 58: /* cntlzd */
1691 op->val = __builtin_clzl(regs->gpr[rd]); 1692 val = regs->gpr[rd];
1693 op->val = ( val ? __builtin_clzl(val) : 64 );
1692 goto logical_done; 1694 goto logical_done;
1693#endif 1695#endif
1694 case 28: /* and */ 1696 case 28: /* and */
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index b95c584ce19d..a51df9ef529d 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -1438,7 +1438,6 @@ out:
1438 1438
1439int arch_update_cpu_topology(void) 1439int arch_update_cpu_topology(void)
1440{ 1440{
1441 lockdep_assert_cpus_held();
1442 return numa_update_cpu_topology(true); 1441 return numa_update_cpu_topology(true);
1443} 1442}
1444 1443
diff --git a/arch/powerpc/perf/imc-pmu.c b/arch/powerpc/perf/imc-pmu.c
index 9ccac86f3463..88126245881b 100644
--- a/arch/powerpc/perf/imc-pmu.c
+++ b/arch/powerpc/perf/imc-pmu.c
@@ -399,6 +399,20 @@ static void nest_imc_counters_release(struct perf_event *event)
399 399
400 /* Take the mutex lock for this node and then decrement the reference count */ 400 /* Take the mutex lock for this node and then decrement the reference count */
401 mutex_lock(&ref->lock); 401 mutex_lock(&ref->lock);
402 if (ref->refc == 0) {
403 /*
404 * The scenario where this is true is, when perf session is
405 * started, followed by offlining of all cpus in a given node.
406 *
407 * In the cpuhotplug offline path, ppc_nest_imc_cpu_offline()
408 * function set the ref->count to zero, if the cpu which is
409 * about to offline is the last cpu in a given node and make
410 * an OPAL call to disable the engine in that node.
411 *
412 */
413 mutex_unlock(&ref->lock);
414 return;
415 }
402 ref->refc--; 416 ref->refc--;
403 if (ref->refc == 0) { 417 if (ref->refc == 0) {
404 rc = opal_imc_counters_stop(OPAL_IMC_COUNTERS_NEST, 418 rc = opal_imc_counters_stop(OPAL_IMC_COUNTERS_NEST,
@@ -523,8 +537,8 @@ static int core_imc_mem_init(int cpu, int size)
523 537
524 /* We need only vbase for core counters */ 538 /* We need only vbase for core counters */
525 mem_info->vbase = page_address(alloc_pages_node(phys_id, 539 mem_info->vbase = page_address(alloc_pages_node(phys_id,
526 GFP_KERNEL | __GFP_ZERO | __GFP_THISNODE, 540 GFP_KERNEL | __GFP_ZERO | __GFP_THISNODE |
527 get_order(size))); 541 __GFP_NOWARN, get_order(size)));
528 if (!mem_info->vbase) 542 if (!mem_info->vbase)
529 return -ENOMEM; 543 return -ENOMEM;
530 544
@@ -646,6 +660,20 @@ static void core_imc_counters_release(struct perf_event *event)
646 return; 660 return;
647 661
648 mutex_lock(&ref->lock); 662 mutex_lock(&ref->lock);
663 if (ref->refc == 0) {
664 /*
665 * The scenario where this is true is, when perf session is
666 * started, followed by offlining of all cpus in a given core.
667 *
668 * In the cpuhotplug offline path, ppc_core_imc_cpu_offline()
669 * function set the ref->count to zero, if the cpu which is
670 * about to offline is the last cpu in a given core and make
671 * an OPAL call to disable the engine in that core.
672 *
673 */
674 mutex_unlock(&ref->lock);
675 return;
676 }
649 ref->refc--; 677 ref->refc--;
650 if (ref->refc == 0) { 678 if (ref->refc == 0) {
651 rc = opal_imc_counters_stop(OPAL_IMC_COUNTERS_CORE, 679 rc = opal_imc_counters_stop(OPAL_IMC_COUNTERS_CORE,
@@ -763,8 +791,8 @@ static int thread_imc_mem_alloc(int cpu_id, int size)
763 * free the memory in cpu offline path. 791 * free the memory in cpu offline path.
764 */ 792 */
765 local_mem = page_address(alloc_pages_node(phys_id, 793 local_mem = page_address(alloc_pages_node(phys_id,
766 GFP_KERNEL | __GFP_ZERO | __GFP_THISNODE, 794 GFP_KERNEL | __GFP_ZERO | __GFP_THISNODE |
767 get_order(size))); 795 __GFP_NOWARN, get_order(size)));
768 if (!local_mem) 796 if (!local_mem)
769 return -ENOMEM; 797 return -ENOMEM;
770 798
@@ -1148,7 +1176,8 @@ static void imc_common_cpuhp_mem_free(struct imc_pmu *pmu_ptr)
1148 } 1176 }
1149 1177
1150 /* Only free the attr_groups which are dynamically allocated */ 1178 /* Only free the attr_groups which are dynamically allocated */
1151 kfree(pmu_ptr->attr_groups[IMC_EVENT_ATTR]->attrs); 1179 if (pmu_ptr->attr_groups[IMC_EVENT_ATTR])
1180 kfree(pmu_ptr->attr_groups[IMC_EVENT_ATTR]->attrs);
1152 kfree(pmu_ptr->attr_groups[IMC_EVENT_ATTR]); 1181 kfree(pmu_ptr->attr_groups[IMC_EVENT_ATTR]);
1153 kfree(pmu_ptr); 1182 kfree(pmu_ptr);
1154 return; 1183 return;
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 0be3828752e5..4e83f950713e 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -44,7 +44,6 @@ config SPARC
44 select ARCH_HAS_SG_CHAIN 44 select ARCH_HAS_SG_CHAIN
45 select CPU_NO_EFFICIENT_FFS 45 select CPU_NO_EFFICIENT_FFS
46 select LOCKDEP_SMALL if LOCKDEP 46 select LOCKDEP_SMALL if LOCKDEP
47 select ARCH_WANT_RELAX_ORDER
48 47
49config SPARC32 48config SPARC32
50 def_bool !64BIT 49 def_bool !64BIT
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 106d4a029a8a..7a69cf053711 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -3974,19 +3974,19 @@ static inline bool is_last_gpte(struct kvm_mmu *mmu,
3974 unsigned level, unsigned gpte) 3974 unsigned level, unsigned gpte)
3975{ 3975{
3976 /* 3976 /*
3977 * PT_PAGE_TABLE_LEVEL always terminates. The RHS has bit 7 set
3978 * iff level <= PT_PAGE_TABLE_LEVEL, which for our purpose means
3979 * level == PT_PAGE_TABLE_LEVEL; set PT_PAGE_SIZE_MASK in gpte then.
3980 */
3981 gpte |= level - PT_PAGE_TABLE_LEVEL - 1;
3982
3983 /*
3984 * The RHS has bit 7 set iff level < mmu->last_nonleaf_level. 3977 * The RHS has bit 7 set iff level < mmu->last_nonleaf_level.
3985 * If it is clear, there are no large pages at this level, so clear 3978 * If it is clear, there are no large pages at this level, so clear
3986 * PT_PAGE_SIZE_MASK in gpte if that is the case. 3979 * PT_PAGE_SIZE_MASK in gpte if that is the case.
3987 */ 3980 */
3988 gpte &= level - mmu->last_nonleaf_level; 3981 gpte &= level - mmu->last_nonleaf_level;
3989 3982
3983 /*
3984 * PT_PAGE_TABLE_LEVEL always terminates. The RHS has bit 7 set
3985 * iff level <= PT_PAGE_TABLE_LEVEL, which for our purpose means
3986 * level == PT_PAGE_TABLE_LEVEL; set PT_PAGE_SIZE_MASK in gpte then.
3987 */
3988 gpte |= level - PT_PAGE_TABLE_LEVEL - 1;
3989
3990 return gpte & PT_PAGE_SIZE_MASK; 3990 return gpte & PT_PAGE_SIZE_MASK;
3991} 3991}
3992 3992
@@ -4555,6 +4555,7 @@ void kvm_init_shadow_ept_mmu(struct kvm_vcpu *vcpu, bool execonly,
4555 4555
4556 update_permission_bitmask(vcpu, context, true); 4556 update_permission_bitmask(vcpu, context, true);
4557 update_pkru_bitmask(vcpu, context, true); 4557 update_pkru_bitmask(vcpu, context, true);
4558 update_last_nonleaf_level(vcpu, context);
4558 reset_rsvds_bits_mask_ept(vcpu, context, execonly); 4559 reset_rsvds_bits_mask_ept(vcpu, context, execonly);
4559 reset_ept_shadow_zero_bits_mask(vcpu, context, execonly); 4560 reset_ept_shadow_zero_bits_mask(vcpu, context, execonly);
4560} 4561}
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index 86b68dc5a649..f18d1f8d332b 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -334,10 +334,11 @@ retry_walk:
334 --walker->level; 334 --walker->level;
335 335
336 index = PT_INDEX(addr, walker->level); 336 index = PT_INDEX(addr, walker->level);
337
338 table_gfn = gpte_to_gfn(pte); 337 table_gfn = gpte_to_gfn(pte);
339 offset = index * sizeof(pt_element_t); 338 offset = index * sizeof(pt_element_t);
340 pte_gpa = gfn_to_gpa(table_gfn) + offset; 339 pte_gpa = gfn_to_gpa(table_gfn) + offset;
340
341 BUG_ON(walker->level < 1);
341 walker->table_gfn[walker->level - 1] = table_gfn; 342 walker->table_gfn[walker->level - 1] = table_gfn;
342 walker->pte_gpa[walker->level - 1] = pte_gpa; 343 walker->pte_gpa[walker->level - 1] = pte_gpa;
343 344
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index a2b804e10c95..95a01609d7ee 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -11297,7 +11297,7 @@ static void load_vmcs12_host_state(struct kvm_vcpu *vcpu,
11297 11297
11298 /* Same as above - no reason to call set_cr4_guest_host_mask(). */ 11298 /* Same as above - no reason to call set_cr4_guest_host_mask(). */
11299 vcpu->arch.cr4_guest_owned_bits = ~vmcs_readl(CR4_GUEST_HOST_MASK); 11299 vcpu->arch.cr4_guest_owned_bits = ~vmcs_readl(CR4_GUEST_HOST_MASK);
11300 kvm_set_cr4(vcpu, vmcs12->host_cr4); 11300 vmx_set_cr4(vcpu, vmcs12->host_cr4);
11301 11301
11302 nested_ept_uninit_mmu_context(vcpu); 11302 nested_ept_uninit_mmu_context(vcpu);
11303 11303
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 0e7ef69e8531..d669e9d89001 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -93,11 +93,11 @@ int xen_cpuhp_setup(int (*cpu_up_prepare_cb)(unsigned int),
93 int rc; 93 int rc;
94 94
95 rc = cpuhp_setup_state_nocalls(CPUHP_XEN_PREPARE, 95 rc = cpuhp_setup_state_nocalls(CPUHP_XEN_PREPARE,
96 "x86/xen/hvm_guest:prepare", 96 "x86/xen/guest:prepare",
97 cpu_up_prepare_cb, cpu_dead_cb); 97 cpu_up_prepare_cb, cpu_dead_cb);
98 if (rc >= 0) { 98 if (rc >= 0) {
99 rc = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, 99 rc = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
100 "x86/xen/hvm_guest:online", 100 "x86/xen/guest:online",
101 xen_cpu_up_online, NULL); 101 xen_cpu_up_online, NULL);
102 if (rc < 0) 102 if (rc < 0)
103 cpuhp_remove_state_nocalls(CPUHP_XEN_PREPARE); 103 cpuhp_remove_state_nocalls(CPUHP_XEN_PREPARE);
diff --git a/block/bio.c b/block/bio.c
index b38e962fa83e..101c2a9b5481 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1239,8 +1239,8 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
1239 */ 1239 */
1240 bmd->is_our_pages = map_data ? 0 : 1; 1240 bmd->is_our_pages = map_data ? 0 : 1;
1241 memcpy(bmd->iov, iter->iov, sizeof(struct iovec) * iter->nr_segs); 1241 memcpy(bmd->iov, iter->iov, sizeof(struct iovec) * iter->nr_segs);
1242 iov_iter_init(&bmd->iter, iter->type, bmd->iov, 1242 bmd->iter = *iter;
1243 iter->nr_segs, iter->count); 1243 bmd->iter.iov = bmd->iov;
1244 1244
1245 ret = -ENOMEM; 1245 ret = -ENOMEM;
1246 bio = bio_kmalloc(gfp_mask, nr_pages); 1246 bio = bio_kmalloc(gfp_mask, nr_pages);
@@ -1331,6 +1331,7 @@ struct bio *bio_map_user_iov(struct request_queue *q,
1331 int ret, offset; 1331 int ret, offset;
1332 struct iov_iter i; 1332 struct iov_iter i;
1333 struct iovec iov; 1333 struct iovec iov;
1334 struct bio_vec *bvec;
1334 1335
1335 iov_for_each(iov, i, *iter) { 1336 iov_for_each(iov, i, *iter) {
1336 unsigned long uaddr = (unsigned long) iov.iov_base; 1337 unsigned long uaddr = (unsigned long) iov.iov_base;
@@ -1375,7 +1376,12 @@ struct bio *bio_map_user_iov(struct request_queue *q,
1375 ret = get_user_pages_fast(uaddr, local_nr_pages, 1376 ret = get_user_pages_fast(uaddr, local_nr_pages,
1376 (iter->type & WRITE) != WRITE, 1377 (iter->type & WRITE) != WRITE,
1377 &pages[cur_page]); 1378 &pages[cur_page]);
1378 if (ret < local_nr_pages) { 1379 if (unlikely(ret < local_nr_pages)) {
1380 for (j = cur_page; j < page_limit; j++) {
1381 if (!pages[j])
1382 break;
1383 put_page(pages[j]);
1384 }
1379 ret = -EFAULT; 1385 ret = -EFAULT;
1380 goto out_unmap; 1386 goto out_unmap;
1381 } 1387 }
@@ -1383,6 +1389,7 @@ struct bio *bio_map_user_iov(struct request_queue *q,
1383 offset = offset_in_page(uaddr); 1389 offset = offset_in_page(uaddr);
1384 for (j = cur_page; j < page_limit; j++) { 1390 for (j = cur_page; j < page_limit; j++) {
1385 unsigned int bytes = PAGE_SIZE - offset; 1391 unsigned int bytes = PAGE_SIZE - offset;
1392 unsigned short prev_bi_vcnt = bio->bi_vcnt;
1386 1393
1387 if (len <= 0) 1394 if (len <= 0)
1388 break; 1395 break;
@@ -1397,6 +1404,13 @@ struct bio *bio_map_user_iov(struct request_queue *q,
1397 bytes) 1404 bytes)
1398 break; 1405 break;
1399 1406
1407 /*
1408 * check if vector was merged with previous
1409 * drop page reference if needed
1410 */
1411 if (bio->bi_vcnt == prev_bi_vcnt)
1412 put_page(pages[j]);
1413
1400 len -= bytes; 1414 len -= bytes;
1401 offset = 0; 1415 offset = 0;
1402 } 1416 }
@@ -1423,10 +1437,8 @@ struct bio *bio_map_user_iov(struct request_queue *q,
1423 return bio; 1437 return bio;
1424 1438
1425 out_unmap: 1439 out_unmap:
1426 for (j = 0; j < nr_pages; j++) { 1440 bio_for_each_segment_all(bvec, bio, j) {
1427 if (!pages[j]) 1441 put_page(bvec->bv_page);
1428 break;
1429 put_page(pages[j]);
1430 } 1442 }
1431 out: 1443 out:
1432 kfree(pages); 1444 kfree(pages);
diff --git a/crypto/shash.c b/crypto/shash.c
index 5e31c8d776df..325a14da5827 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -41,7 +41,7 @@ static int shash_setkey_unaligned(struct crypto_shash *tfm, const u8 *key,
41 int err; 41 int err;
42 42
43 absize = keylen + (alignmask & ~(crypto_tfm_ctx_alignment() - 1)); 43 absize = keylen + (alignmask & ~(crypto_tfm_ctx_alignment() - 1));
44 buffer = kmalloc(absize, GFP_KERNEL); 44 buffer = kmalloc(absize, GFP_ATOMIC);
45 if (!buffer) 45 if (!buffer)
46 return -ENOMEM; 46 return -ENOMEM;
47 47
@@ -275,12 +275,14 @@ static int shash_async_finup(struct ahash_request *req)
275 275
276int shash_ahash_digest(struct ahash_request *req, struct shash_desc *desc) 276int shash_ahash_digest(struct ahash_request *req, struct shash_desc *desc)
277{ 277{
278 struct scatterlist *sg = req->src;
279 unsigned int offset = sg->offset;
280 unsigned int nbytes = req->nbytes; 278 unsigned int nbytes = req->nbytes;
279 struct scatterlist *sg;
280 unsigned int offset;
281 int err; 281 int err;
282 282
283 if (nbytes < min(sg->length, ((unsigned int)(PAGE_SIZE)) - offset)) { 283 if (nbytes &&
284 (sg = req->src, offset = sg->offset,
285 nbytes < min(sg->length, ((unsigned int)(PAGE_SIZE)) - offset))) {
284 void *data; 286 void *data;
285 287
286 data = kmap_atomic(sg_page(sg)); 288 data = kmap_atomic(sg_page(sg));
diff --git a/crypto/skcipher.c b/crypto/skcipher.c
index 4faa0fd53b0c..d5692e35fab1 100644
--- a/crypto/skcipher.c
+++ b/crypto/skcipher.c
@@ -426,14 +426,9 @@ static int skcipher_copy_iv(struct skcipher_walk *walk)
426 426
427static int skcipher_walk_first(struct skcipher_walk *walk) 427static int skcipher_walk_first(struct skcipher_walk *walk)
428{ 428{
429 walk->nbytes = 0;
430
431 if (WARN_ON_ONCE(in_irq())) 429 if (WARN_ON_ONCE(in_irq()))
432 return -EDEADLK; 430 return -EDEADLK;
433 431
434 if (unlikely(!walk->total))
435 return 0;
436
437 walk->buffer = NULL; 432 walk->buffer = NULL;
438 if (unlikely(((unsigned long)walk->iv & walk->alignmask))) { 433 if (unlikely(((unsigned long)walk->iv & walk->alignmask))) {
439 int err = skcipher_copy_iv(walk); 434 int err = skcipher_copy_iv(walk);
@@ -452,10 +447,15 @@ static int skcipher_walk_skcipher(struct skcipher_walk *walk,
452{ 447{
453 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); 448 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
454 449
450 walk->total = req->cryptlen;
451 walk->nbytes = 0;
452
453 if (unlikely(!walk->total))
454 return 0;
455
455 scatterwalk_start(&walk->in, req->src); 456 scatterwalk_start(&walk->in, req->src);
456 scatterwalk_start(&walk->out, req->dst); 457 scatterwalk_start(&walk->out, req->dst);
457 458
458 walk->total = req->cryptlen;
459 walk->iv = req->iv; 459 walk->iv = req->iv;
460 walk->oiv = req->iv; 460 walk->oiv = req->iv;
461 461
@@ -509,6 +509,11 @@ static int skcipher_walk_aead_common(struct skcipher_walk *walk,
509 struct crypto_aead *tfm = crypto_aead_reqtfm(req); 509 struct crypto_aead *tfm = crypto_aead_reqtfm(req);
510 int err; 510 int err;
511 511
512 walk->nbytes = 0;
513
514 if (unlikely(!walk->total))
515 return 0;
516
512 walk->flags &= ~SKCIPHER_WALK_PHYS; 517 walk->flags &= ~SKCIPHER_WALK_PHYS;
513 518
514 scatterwalk_start(&walk->in, req->src); 519 scatterwalk_start(&walk->in, req->src);
diff --git a/crypto/xts.c b/crypto/xts.c
index d86c11a8c882..e31828ed0046 100644
--- a/crypto/xts.c
+++ b/crypto/xts.c
@@ -554,8 +554,10 @@ static int create(struct crypto_template *tmpl, struct rtattr **tb)
554 ctx->name[len - 1] = 0; 554 ctx->name[len - 1] = 0;
555 555
556 if (snprintf(inst->alg.base.cra_name, CRYPTO_MAX_ALG_NAME, 556 if (snprintf(inst->alg.base.cra_name, CRYPTO_MAX_ALG_NAME,
557 "xts(%s)", ctx->name) >= CRYPTO_MAX_ALG_NAME) 557 "xts(%s)", ctx->name) >= CRYPTO_MAX_ALG_NAME) {
558 return -ENAMETOOLONG; 558 err = -ENAMETOOLONG;
559 goto err_drop_spawn;
560 }
559 } else 561 } else
560 goto err_drop_spawn; 562 goto err_drop_spawn;
561 563
diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index 3fb8ff513461..e26ea209b63e 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -571,10 +571,9 @@ static int acpi_data_get_property_array(const struct acpi_device_data *data,
571 * } 571 * }
572 * } 572 * }
573 * 573 *
574 * Calling this function with index %2 return %-ENOENT and with index %3 574 * Calling this function with index %2 or index %3 return %-ENOENT. If the
575 * returns the last entry. If the property does not contain any more values 575 * property does not contain any more values %-ENOENT is returned. The NULL
576 * %-ENODATA is returned. The NULL entry must be single integer and 576 * entry must be single integer and preferably contain value %0.
577 * preferably contain value %0.
578 * 577 *
579 * Return: %0 on success, negative error code on failure. 578 * Return: %0 on success, negative error code on failure.
580 */ 579 */
@@ -590,11 +589,11 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
590 589
591 data = acpi_device_data_of_node(fwnode); 590 data = acpi_device_data_of_node(fwnode);
592 if (!data) 591 if (!data)
593 return -EINVAL; 592 return -ENOENT;
594 593
595 ret = acpi_data_get_property(data, propname, ACPI_TYPE_ANY, &obj); 594 ret = acpi_data_get_property(data, propname, ACPI_TYPE_ANY, &obj);
596 if (ret) 595 if (ret)
597 return ret; 596 return ret == -EINVAL ? -ENOENT : -EINVAL;
598 597
599 /* 598 /*
600 * The simplest case is when the value is a single reference. Just 599 * The simplest case is when the value is a single reference. Just
@@ -606,7 +605,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
606 605
607 ret = acpi_bus_get_device(obj->reference.handle, &device); 606 ret = acpi_bus_get_device(obj->reference.handle, &device);
608 if (ret) 607 if (ret)
609 return ret; 608 return ret == -ENODEV ? -EINVAL : ret;
610 609
611 args->adev = device; 610 args->adev = device;
612 args->nargs = 0; 611 args->nargs = 0;
@@ -622,8 +621,10 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
622 * The index argument is then used to determine which reference 621 * The index argument is then used to determine which reference
623 * the caller wants (along with the arguments). 622 * the caller wants (along with the arguments).
624 */ 623 */
625 if (obj->type != ACPI_TYPE_PACKAGE || index >= obj->package.count) 624 if (obj->type != ACPI_TYPE_PACKAGE)
626 return -EPROTO; 625 return -EINVAL;
626 if (index >= obj->package.count)
627 return -ENOENT;
627 628
628 element = obj->package.elements; 629 element = obj->package.elements;
629 end = element + obj->package.count; 630 end = element + obj->package.count;
@@ -635,7 +636,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
635 ret = acpi_bus_get_device(element->reference.handle, 636 ret = acpi_bus_get_device(element->reference.handle,
636 &device); 637 &device);
637 if (ret) 638 if (ret)
638 return -ENODEV; 639 return -EINVAL;
639 640
640 nargs = 0; 641 nargs = 0;
641 element++; 642 element++;
@@ -649,11 +650,11 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
649 else if (type == ACPI_TYPE_LOCAL_REFERENCE) 650 else if (type == ACPI_TYPE_LOCAL_REFERENCE)
650 break; 651 break;
651 else 652 else
652 return -EPROTO; 653 return -EINVAL;
653 } 654 }
654 655
655 if (nargs > MAX_ACPI_REFERENCE_ARGS) 656 if (nargs > MAX_ACPI_REFERENCE_ARGS)
656 return -EPROTO; 657 return -EINVAL;
657 658
658 if (idx == index) { 659 if (idx == index) {
659 args->adev = device; 660 args->adev = device;
@@ -670,13 +671,13 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
670 return -ENOENT; 671 return -ENOENT;
671 element++; 672 element++;
672 } else { 673 } else {
673 return -EPROTO; 674 return -EINVAL;
674 } 675 }
675 676
676 idx++; 677 idx++;
677 } 678 }
678 679
679 return -ENODATA; 680 return -ENOENT;
680} 681}
681EXPORT_SYMBOL_GPL(__acpi_node_get_property_reference); 682EXPORT_SYMBOL_GPL(__acpi_node_get_property_reference);
682 683
diff --git a/drivers/base/property.c b/drivers/base/property.c
index d0b65bbe7e15..7ed99c1b2a8b 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -21,6 +21,7 @@
21#include <linux/phy.h> 21#include <linux/phy.h>
22 22
23struct property_set { 23struct property_set {
24 struct device *dev;
24 struct fwnode_handle fwnode; 25 struct fwnode_handle fwnode;
25 const struct property_entry *properties; 26 const struct property_entry *properties;
26}; 27};
@@ -682,6 +683,10 @@ EXPORT_SYMBOL_GPL(fwnode_property_match_string);
682 * Caller is responsible to call fwnode_handle_put() on the returned 683 * Caller is responsible to call fwnode_handle_put() on the returned
683 * args->fwnode pointer. 684 * args->fwnode pointer.
684 * 685 *
686 * Returns: %0 on success
687 * %-ENOENT when the index is out of bounds, the index has an empty
688 * reference or the property was not found
689 * %-EINVAL on parse error
685 */ 690 */
686int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode, 691int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
687 const char *prop, const char *nargs_prop, 692 const char *prop, const char *nargs_prop,
@@ -891,6 +896,7 @@ static struct property_set *pset_copy_set(const struct property_set *pset)
891void device_remove_properties(struct device *dev) 896void device_remove_properties(struct device *dev)
892{ 897{
893 struct fwnode_handle *fwnode; 898 struct fwnode_handle *fwnode;
899 struct property_set *pset;
894 900
895 fwnode = dev_fwnode(dev); 901 fwnode = dev_fwnode(dev);
896 if (!fwnode) 902 if (!fwnode)
@@ -900,16 +906,16 @@ void device_remove_properties(struct device *dev)
900 * the pset. If there is no real firmware node (ACPI/DT) primary 906 * the pset. If there is no real firmware node (ACPI/DT) primary
901 * will hold the pset. 907 * will hold the pset.
902 */ 908 */
903 if (is_pset_node(fwnode)) { 909 pset = to_pset_node(fwnode);
910 if (pset) {
904 set_primary_fwnode(dev, NULL); 911 set_primary_fwnode(dev, NULL);
905 pset_free_set(to_pset_node(fwnode));
906 } else { 912 } else {
907 fwnode = fwnode->secondary; 913 pset = to_pset_node(fwnode->secondary);
908 if (!IS_ERR(fwnode) && is_pset_node(fwnode)) { 914 if (pset && dev == pset->dev)
909 set_secondary_fwnode(dev, NULL); 915 set_secondary_fwnode(dev, NULL);
910 pset_free_set(to_pset_node(fwnode));
911 }
912 } 916 }
917 if (pset && dev == pset->dev)
918 pset_free_set(pset);
913} 919}
914EXPORT_SYMBOL_GPL(device_remove_properties); 920EXPORT_SYMBOL_GPL(device_remove_properties);
915 921
@@ -938,6 +944,7 @@ int device_add_properties(struct device *dev,
938 944
939 p->fwnode.ops = &pset_fwnode_ops; 945 p->fwnode.ops = &pset_fwnode_ops;
940 set_secondary_fwnode(dev, &p->fwnode); 946 set_secondary_fwnode(dev, &p->fwnode);
947 p->dev = dev;
941 return 0; 948 return 0;
942} 949}
943EXPORT_SYMBOL_GPL(device_add_properties); 950EXPORT_SYMBOL_GPL(device_add_properties);
diff --git a/drivers/crypto/axis/artpec6_crypto.c b/drivers/crypto/axis/artpec6_crypto.c
index d9fbbf01062b..0f9754e07719 100644
--- a/drivers/crypto/axis/artpec6_crypto.c
+++ b/drivers/crypto/axis/artpec6_crypto.c
@@ -349,8 +349,6 @@ struct artpec6_crypto_aead_req_ctx {
349/* The crypto framework makes it hard to avoid this global. */ 349/* The crypto framework makes it hard to avoid this global. */
350static struct device *artpec6_crypto_dev; 350static struct device *artpec6_crypto_dev;
351 351
352static struct dentry *dbgfs_root;
353
354#ifdef CONFIG_FAULT_INJECTION 352#ifdef CONFIG_FAULT_INJECTION
355static DECLARE_FAULT_ATTR(artpec6_crypto_fail_status_read); 353static DECLARE_FAULT_ATTR(artpec6_crypto_fail_status_read);
356static DECLARE_FAULT_ATTR(artpec6_crypto_fail_dma_array_full); 354static DECLARE_FAULT_ATTR(artpec6_crypto_fail_dma_array_full);
@@ -2984,6 +2982,8 @@ struct dbgfs_u32 {
2984 char *desc; 2982 char *desc;
2985}; 2983};
2986 2984
2985static struct dentry *dbgfs_root;
2986
2987static void artpec6_crypto_init_debugfs(void) 2987static void artpec6_crypto_init_debugfs(void)
2988{ 2988{
2989 dbgfs_root = debugfs_create_dir("artpec6_crypto", NULL); 2989 dbgfs_root = debugfs_create_dir("artpec6_crypto", NULL);
diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c
index b585ce54a802..4835dd4a9e50 100644
--- a/drivers/crypto/stm32/stm32-hash.c
+++ b/drivers/crypto/stm32/stm32-hash.c
@@ -553,9 +553,9 @@ static int stm32_hash_dma_send(struct stm32_hash_dev *hdev)
553{ 553{
554 struct stm32_hash_request_ctx *rctx = ahash_request_ctx(hdev->req); 554 struct stm32_hash_request_ctx *rctx = ahash_request_ctx(hdev->req);
555 struct scatterlist sg[1], *tsg; 555 struct scatterlist sg[1], *tsg;
556 int err = 0, len = 0, reg, ncp; 556 int err = 0, len = 0, reg, ncp = 0;
557 unsigned int i; 557 unsigned int i;
558 const u32 *buffer = (const u32 *)rctx->buffer; 558 u32 *buffer = (void *)rctx->buffer;
559 559
560 rctx->sg = hdev->req->src; 560 rctx->sg = hdev->req->src;
561 rctx->total = hdev->req->nbytes; 561 rctx->total = hdev->req->nbytes;
@@ -620,10 +620,13 @@ static int stm32_hash_dma_send(struct stm32_hash_dev *hdev)
620 reg |= HASH_CR_DMAA; 620 reg |= HASH_CR_DMAA;
621 stm32_hash_write(hdev, HASH_CR, reg); 621 stm32_hash_write(hdev, HASH_CR, reg);
622 622
623 for (i = 0; i < DIV_ROUND_UP(ncp, sizeof(u32)); i++) 623 if (ncp) {
624 stm32_hash_write(hdev, HASH_DIN, buffer[i]); 624 memset(buffer + ncp, 0,
625 625 DIV_ROUND_UP(ncp, sizeof(u32)) - ncp);
626 stm32_hash_set_nblw(hdev, ncp); 626 writesl(hdev->io_base + HASH_DIN, buffer,
627 DIV_ROUND_UP(ncp, sizeof(u32)));
628 }
629 stm32_hash_set_nblw(hdev, DIV_ROUND_UP(ncp, sizeof(u32)));
627 reg = stm32_hash_read(hdev, HASH_STR); 630 reg = stm32_hash_read(hdev, HASH_STR);
628 reg |= HASH_STR_DCAL; 631 reg |= HASH_STR_DCAL;
629 stm32_hash_write(hdev, HASH_STR, reg); 632 stm32_hash_write(hdev, HASH_STR, reg);
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 3388d54ba114..3f80f167ed56 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -453,7 +453,8 @@ config GPIO_TS4800
453config GPIO_THUNDERX 453config GPIO_THUNDERX
454 tristate "Cavium ThunderX/OCTEON-TX GPIO" 454 tristate "Cavium ThunderX/OCTEON-TX GPIO"
455 depends on ARCH_THUNDER || (64BIT && COMPILE_TEST) 455 depends on ARCH_THUNDER || (64BIT && COMPILE_TEST)
456 depends on PCI_MSI && IRQ_DOMAIN_HIERARCHY 456 depends on PCI_MSI
457 select IRQ_DOMAIN_HIERARCHY
457 select IRQ_FASTEOI_HIERARCHY_HANDLERS 458 select IRQ_FASTEOI_HIERARCHY_HANDLERS
458 help 459 help
459 Say yes here to support the on-chip GPIO lines on the ThunderX 460 Say yes here to support the on-chip GPIO lines on the ThunderX
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index dbf869fb63ce..3233b72b6828 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -518,7 +518,13 @@ static int omap_gpio_irq_type(struct irq_data *d, unsigned type)
518 if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH)) 518 if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH))
519 irq_set_handler_locked(d, handle_level_irq); 519 irq_set_handler_locked(d, handle_level_irq);
520 else if (type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)) 520 else if (type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING))
521 irq_set_handler_locked(d, handle_edge_irq); 521 /*
522 * Edge IRQs are already cleared/acked in irq_handler and
523 * not need to be masked, as result handle_edge_irq()
524 * logic is excessed here and may cause lose of interrupts.
525 * So just use handle_simple_irq.
526 */
527 irq_set_handler_locked(d, handle_simple_irq);
522 528
523 return 0; 529 return 0;
524 530
@@ -678,7 +684,7 @@ static void omap_gpio_free(struct gpio_chip *chip, unsigned offset)
678static irqreturn_t omap_gpio_irq_handler(int irq, void *gpiobank) 684static irqreturn_t omap_gpio_irq_handler(int irq, void *gpiobank)
679{ 685{
680 void __iomem *isr_reg = NULL; 686 void __iomem *isr_reg = NULL;
681 u32 isr; 687 u32 enabled, isr, level_mask;
682 unsigned int bit; 688 unsigned int bit;
683 struct gpio_bank *bank = gpiobank; 689 struct gpio_bank *bank = gpiobank;
684 unsigned long wa_lock_flags; 690 unsigned long wa_lock_flags;
@@ -691,23 +697,21 @@ static irqreturn_t omap_gpio_irq_handler(int irq, void *gpiobank)
691 pm_runtime_get_sync(bank->chip.parent); 697 pm_runtime_get_sync(bank->chip.parent);
692 698
693 while (1) { 699 while (1) {
694 u32 isr_saved, level_mask = 0;
695 u32 enabled;
696
697 raw_spin_lock_irqsave(&bank->lock, lock_flags); 700 raw_spin_lock_irqsave(&bank->lock, lock_flags);
698 701
699 enabled = omap_get_gpio_irqbank_mask(bank); 702 enabled = omap_get_gpio_irqbank_mask(bank);
700 isr_saved = isr = readl_relaxed(isr_reg) & enabled; 703 isr = readl_relaxed(isr_reg) & enabled;
701 704
702 if (bank->level_mask) 705 if (bank->level_mask)
703 level_mask = bank->level_mask & enabled; 706 level_mask = bank->level_mask & enabled;
707 else
708 level_mask = 0;
704 709
705 /* clear edge sensitive interrupts before handler(s) are 710 /* clear edge sensitive interrupts before handler(s) are
706 called so that we don't miss any interrupt occurred while 711 called so that we don't miss any interrupt occurred while
707 executing them */ 712 executing them */
708 omap_disable_gpio_irqbank(bank, isr_saved & ~level_mask); 713 if (isr & ~level_mask)
709 omap_clear_gpio_irqbank(bank, isr_saved & ~level_mask); 714 omap_clear_gpio_irqbank(bank, isr & ~level_mask);
710 omap_enable_gpio_irqbank(bank, isr_saved & ~level_mask);
711 715
712 raw_spin_unlock_irqrestore(&bank->lock, lock_flags); 716 raw_spin_unlock_irqrestore(&bank->lock, lock_flags);
713 717
@@ -1010,7 +1014,7 @@ static void omap_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
1010 1014
1011/*---------------------------------------------------------------------*/ 1015/*---------------------------------------------------------------------*/
1012 1016
1013static void __init omap_gpio_show_rev(struct gpio_bank *bank) 1017static void omap_gpio_show_rev(struct gpio_bank *bank)
1014{ 1018{
1015 static bool called; 1019 static bool called;
1016 u32 rev; 1020 u32 rev;
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 4d2113530735..eb4528c87c0b 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -203,7 +203,7 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares,
203 203
204 if (pin <= 255) { 204 if (pin <= 255) {
205 char ev_name[5]; 205 char ev_name[5];
206 sprintf(ev_name, "_%c%02X", 206 sprintf(ev_name, "_%c%02hhX",
207 agpio->triggering == ACPI_EDGE_SENSITIVE ? 'E' : 'L', 207 agpio->triggering == ACPI_EDGE_SENSITIVE ? 'E' : 'L',
208 pin); 208 pin);
209 if (ACPI_SUCCESS(acpi_get_handle(handle, ev_name, &evt_handle))) 209 if (ACPI_SUCCESS(acpi_get_handle(handle, ev_name, &evt_handle)))
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 0a3117cc29e7..374301fcbc86 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -281,6 +281,7 @@ config HID_ELECOM
281 Support for ELECOM devices: 281 Support for ELECOM devices:
282 - BM084 Bluetooth Mouse 282 - BM084 Bluetooth Mouse
283 - DEFT Trackball (Wired and wireless) 283 - DEFT Trackball (Wired and wireless)
284 - HUGE Trackball (Wired and wireless)
284 285
285config HID_ELO 286config HID_ELO
286 tristate "ELO USB 4000/4500 touchscreen" 287 tristate "ELO USB 4000/4500 touchscreen"
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 9bc91160819b..330ca983828b 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -2032,6 +2032,8 @@ static const struct hid_device_id hid_have_special_driver[] = {
2032 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) }, 2032 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) },
2033 { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRED) }, 2033 { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRED) },
2034 { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRELESS) }, 2034 { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRELESS) },
2035 { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_HUGE_WIRED) },
2036 { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_HUGE_WIRELESS) },
2035#endif 2037#endif
2036#if IS_ENABLED(CONFIG_HID_ELO) 2038#if IS_ENABLED(CONFIG_HID_ELO)
2037 { HID_USB_DEVICE(USB_VENDOR_ID_ELO, 0x0009) }, 2039 { HID_USB_DEVICE(USB_VENDOR_ID_ELO, 0x0009) },
diff --git a/drivers/hid/hid-elecom.c b/drivers/hid/hid-elecom.c
index e2c7465df69f..54aeea57d209 100644
--- a/drivers/hid/hid-elecom.c
+++ b/drivers/hid/hid-elecom.c
@@ -3,6 +3,7 @@
3 * Copyright (c) 2010 Richard Nauber <Richard.Nauber@gmail.com> 3 * Copyright (c) 2010 Richard Nauber <Richard.Nauber@gmail.com>
4 * Copyright (c) 2016 Yuxuan Shui <yshuiv7@gmail.com> 4 * Copyright (c) 2016 Yuxuan Shui <yshuiv7@gmail.com>
5 * Copyright (c) 2017 Diego Elio Pettenò <flameeyes@flameeyes.eu> 5 * Copyright (c) 2017 Diego Elio Pettenò <flameeyes@flameeyes.eu>
6 * Copyright (c) 2017 Alex Manoussakis <amanou@gnu.org>
6 */ 7 */
7 8
8/* 9/*
@@ -32,9 +33,11 @@ static __u8 *elecom_report_fixup(struct hid_device *hdev, __u8 *rdesc,
32 break; 33 break;
33 case USB_DEVICE_ID_ELECOM_DEFT_WIRED: 34 case USB_DEVICE_ID_ELECOM_DEFT_WIRED:
34 case USB_DEVICE_ID_ELECOM_DEFT_WIRELESS: 35 case USB_DEVICE_ID_ELECOM_DEFT_WIRELESS:
35 /* The DEFT trackball has eight buttons, but its descriptor only 36 case USB_DEVICE_ID_ELECOM_HUGE_WIRED:
36 * reports five, disabling the three Fn buttons on the top of 37 case USB_DEVICE_ID_ELECOM_HUGE_WIRELESS:
37 * the mouse. 38 /* The DEFT/HUGE trackball has eight buttons, but its descriptor
39 * only reports five, disabling the three Fn buttons on the top
40 * of the mouse.
38 * 41 *
39 * Apply the following diff to the descriptor: 42 * Apply the following diff to the descriptor:
40 * 43 *
@@ -62,7 +65,7 @@ static __u8 *elecom_report_fixup(struct hid_device *hdev, __u8 *rdesc,
62 * End Collection, End Collection, 65 * End Collection, End Collection,
63 */ 66 */
64 if (*rsize == 213 && rdesc[13] == 5 && rdesc[21] == 5) { 67 if (*rsize == 213 && rdesc[13] == 5 && rdesc[21] == 5) {
65 hid_info(hdev, "Fixing up Elecom DEFT Fn buttons\n"); 68 hid_info(hdev, "Fixing up Elecom DEFT/HUGE Fn buttons\n");
66 rdesc[13] = 8; /* Button/Variable Report Count */ 69 rdesc[13] = 8; /* Button/Variable Report Count */
67 rdesc[21] = 8; /* Button/Variable Usage Maximum */ 70 rdesc[21] = 8; /* Button/Variable Usage Maximum */
68 rdesc[29] = 0; /* Button/Constant Report Count */ 71 rdesc[29] = 0; /* Button/Constant Report Count */
@@ -76,6 +79,8 @@ static const struct hid_device_id elecom_devices[] = {
76 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) }, 79 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) },
77 { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRED) }, 80 { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRED) },
78 { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRELESS) }, 81 { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRELESS) },
82 { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_HUGE_WIRED) },
83 { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_HUGE_WIRELESS) },
79 { } 84 { }
80}; 85};
81MODULE_DEVICE_TABLE(hid, elecom_devices); 86MODULE_DEVICE_TABLE(hid, elecom_devices);
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index a98919199858..be2e005c3c51 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -368,6 +368,8 @@
368#define USB_DEVICE_ID_ELECOM_BM084 0x0061 368#define USB_DEVICE_ID_ELECOM_BM084 0x0061
369#define USB_DEVICE_ID_ELECOM_DEFT_WIRED 0x00fe 369#define USB_DEVICE_ID_ELECOM_DEFT_WIRED 0x00fe
370#define USB_DEVICE_ID_ELECOM_DEFT_WIRELESS 0x00ff 370#define USB_DEVICE_ID_ELECOM_DEFT_WIRELESS 0x00ff
371#define USB_DEVICE_ID_ELECOM_HUGE_WIRED 0x010c
372#define USB_DEVICE_ID_ELECOM_HUGE_WIRELESS 0x010d
371 373
372#define USB_VENDOR_ID_DREAM_CHEEKY 0x1d34 374#define USB_VENDOR_ID_DREAM_CHEEKY 0x1d34
373#define USB_DEVICE_ID_DREAM_CHEEKY_WN 0x0004 375#define USB_DEVICE_ID_DREAM_CHEEKY_WN 0x0004
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 089bad8a9a21..045b5da9b992 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -975,6 +975,8 @@ static int usbhid_parse(struct hid_device *hid)
975 unsigned int rsize = 0; 975 unsigned int rsize = 0;
976 char *rdesc; 976 char *rdesc;
977 int ret, n; 977 int ret, n;
978 int num_descriptors;
979 size_t offset = offsetof(struct hid_descriptor, desc);
978 980
979 quirks = usbhid_lookup_quirk(le16_to_cpu(dev->descriptor.idVendor), 981 quirks = usbhid_lookup_quirk(le16_to_cpu(dev->descriptor.idVendor),
980 le16_to_cpu(dev->descriptor.idProduct)); 982 le16_to_cpu(dev->descriptor.idProduct));
@@ -997,10 +999,18 @@ static int usbhid_parse(struct hid_device *hid)
997 return -ENODEV; 999 return -ENODEV;
998 } 1000 }
999 1001
1002 if (hdesc->bLength < sizeof(struct hid_descriptor)) {
1003 dbg_hid("hid descriptor is too short\n");
1004 return -EINVAL;
1005 }
1006
1000 hid->version = le16_to_cpu(hdesc->bcdHID); 1007 hid->version = le16_to_cpu(hdesc->bcdHID);
1001 hid->country = hdesc->bCountryCode; 1008 hid->country = hdesc->bCountryCode;
1002 1009
1003 for (n = 0; n < hdesc->bNumDescriptors; n++) 1010 num_descriptors = min_t(int, hdesc->bNumDescriptors,
1011 (hdesc->bLength - offset) / sizeof(struct hid_class_descriptor));
1012
1013 for (n = 0; n < num_descriptors; n++)
1004 if (hdesc->desc[n].bDescriptorType == HID_DT_REPORT) 1014 if (hdesc->desc[n].bDescriptorType == HID_DT_REPORT)
1005 rsize = le16_to_cpu(hdesc->desc[n].wDescriptorLength); 1015 rsize = le16_to_cpu(hdesc->desc[n].wDescriptorLength);
1006 1016
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
index 49b80da51ba7..805ab45e9b5a 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
@@ -565,8 +565,10 @@ static inline bool nicvf_xdp_rx(struct nicvf *nic, struct bpf_prog *prog,
565 return true; 565 return true;
566 default: 566 default:
567 bpf_warn_invalid_xdp_action(action); 567 bpf_warn_invalid_xdp_action(action);
568 /* fall through */
568 case XDP_ABORTED: 569 case XDP_ABORTED:
569 trace_xdp_exception(nic->netdev, prog, action); 570 trace_xdp_exception(nic->netdev, prog, action);
571 /* fall through */
570 case XDP_DROP: 572 case XDP_DROP:
571 /* Check if it's a recycled page, if not 573 /* Check if it's a recycled page, if not
572 * unmap the DMA mapping. 574 * unmap the DMA mapping.
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c
index 523f9d05a810..8a32eb7d47b9 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c
@@ -175,31 +175,9 @@ static s32 ixgbe_init_phy_ops_82598(struct ixgbe_hw *hw)
175 **/ 175 **/
176static s32 ixgbe_start_hw_82598(struct ixgbe_hw *hw) 176static s32 ixgbe_start_hw_82598(struct ixgbe_hw *hw)
177{ 177{
178#ifndef CONFIG_SPARC
179 u32 regval;
180 u32 i;
181#endif
182 s32 ret_val; 178 s32 ret_val;
183 179
184 ret_val = ixgbe_start_hw_generic(hw); 180 ret_val = ixgbe_start_hw_generic(hw);
185
186#ifndef CONFIG_SPARC
187 /* Disable relaxed ordering */
188 for (i = 0; ((i < hw->mac.max_tx_queues) &&
189 (i < IXGBE_DCA_MAX_QUEUES_82598)); i++) {
190 regval = IXGBE_READ_REG(hw, IXGBE_DCA_TXCTRL(i));
191 regval &= ~IXGBE_DCA_TXCTRL_DESC_WRO_EN;
192 IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL(i), regval);
193 }
194
195 for (i = 0; ((i < hw->mac.max_rx_queues) &&
196 (i < IXGBE_DCA_MAX_QUEUES_82598)); i++) {
197 regval = IXGBE_READ_REG(hw, IXGBE_DCA_RXCTRL(i));
198 regval &= ~(IXGBE_DCA_RXCTRL_DATA_WRO_EN |
199 IXGBE_DCA_RXCTRL_HEAD_WRO_EN);
200 IXGBE_WRITE_REG(hw, IXGBE_DCA_RXCTRL(i), regval);
201 }
202#endif
203 if (ret_val) 181 if (ret_val)
204 return ret_val; 182 return ret_val;
205 183
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
index 2c19070d2a0b..6e6ab6f6875e 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
@@ -366,25 +366,6 @@ s32 ixgbe_start_hw_gen2(struct ixgbe_hw *hw)
366 } 366 }
367 IXGBE_WRITE_FLUSH(hw); 367 IXGBE_WRITE_FLUSH(hw);
368 368
369#ifndef CONFIG_ARCH_WANT_RELAX_ORDER
370 /* Disable relaxed ordering */
371 for (i = 0; i < hw->mac.max_tx_queues; i++) {
372 u32 regval;
373
374 regval = IXGBE_READ_REG(hw, IXGBE_DCA_TXCTRL_82599(i));
375 regval &= ~IXGBE_DCA_TXCTRL_DESC_WRO_EN;
376 IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL_82599(i), regval);
377 }
378
379 for (i = 0; i < hw->mac.max_rx_queues; i++) {
380 u32 regval;
381
382 regval = IXGBE_READ_REG(hw, IXGBE_DCA_RXCTRL(i));
383 regval &= ~(IXGBE_DCA_RXCTRL_DATA_WRO_EN |
384 IXGBE_DCA_RXCTRL_HEAD_WRO_EN);
385 IXGBE_WRITE_REG(hw, IXGBE_DCA_RXCTRL(i), regval);
386 }
387#endif
388 return 0; 369 return 0;
389} 370}
390 371
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index 72c565712a5f..c3e7a8191128 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -1048,7 +1048,7 @@ static int ixgbe_set_ringparam(struct net_device *netdev,
1048{ 1048{
1049 struct ixgbe_adapter *adapter = netdev_priv(netdev); 1049 struct ixgbe_adapter *adapter = netdev_priv(netdev);
1050 struct ixgbe_ring *temp_ring; 1050 struct ixgbe_ring *temp_ring;
1051 int i, err = 0; 1051 int i, j, err = 0;
1052 u32 new_rx_count, new_tx_count; 1052 u32 new_rx_count, new_tx_count;
1053 1053
1054 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) 1054 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
@@ -1085,8 +1085,8 @@ static int ixgbe_set_ringparam(struct net_device *netdev,
1085 } 1085 }
1086 1086
1087 /* allocate temporary buffer to store rings in */ 1087 /* allocate temporary buffer to store rings in */
1088 i = max_t(int, adapter->num_tx_queues, adapter->num_rx_queues); 1088 i = max_t(int, adapter->num_tx_queues + adapter->num_xdp_queues,
1089 i = max_t(int, i, adapter->num_xdp_queues); 1089 adapter->num_rx_queues);
1090 temp_ring = vmalloc(i * sizeof(struct ixgbe_ring)); 1090 temp_ring = vmalloc(i * sizeof(struct ixgbe_ring));
1091 1091
1092 if (!temp_ring) { 1092 if (!temp_ring) {
@@ -1118,8 +1118,8 @@ static int ixgbe_set_ringparam(struct net_device *netdev,
1118 } 1118 }
1119 } 1119 }
1120 1120
1121 for (i = 0; i < adapter->num_xdp_queues; i++) { 1121 for (j = 0; j < adapter->num_xdp_queues; j++, i++) {
1122 memcpy(&temp_ring[i], adapter->xdp_ring[i], 1122 memcpy(&temp_ring[i], adapter->xdp_ring[j],
1123 sizeof(struct ixgbe_ring)); 1123 sizeof(struct ixgbe_ring));
1124 1124
1125 temp_ring[i].count = new_tx_count; 1125 temp_ring[i].count = new_tx_count;
@@ -1139,10 +1139,10 @@ static int ixgbe_set_ringparam(struct net_device *netdev,
1139 memcpy(adapter->tx_ring[i], &temp_ring[i], 1139 memcpy(adapter->tx_ring[i], &temp_ring[i],
1140 sizeof(struct ixgbe_ring)); 1140 sizeof(struct ixgbe_ring));
1141 } 1141 }
1142 for (i = 0; i < adapter->num_xdp_queues; i++) { 1142 for (j = 0; j < adapter->num_xdp_queues; j++, i++) {
1143 ixgbe_free_tx_resources(adapter->xdp_ring[i]); 1143 ixgbe_free_tx_resources(adapter->xdp_ring[j]);
1144 1144
1145 memcpy(adapter->xdp_ring[i], &temp_ring[i], 1145 memcpy(adapter->xdp_ring[j], &temp_ring[i],
1146 sizeof(struct ixgbe_ring)); 1146 sizeof(struct ixgbe_ring));
1147 } 1147 }
1148 1148
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index d962368d08d0..4d76afd13868 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -4881,7 +4881,7 @@ static void ixgbe_clear_udp_tunnel_port(struct ixgbe_adapter *adapter, u32 mask)
4881 IXGBE_FLAG_GENEVE_OFFLOAD_CAPABLE))) 4881 IXGBE_FLAG_GENEVE_OFFLOAD_CAPABLE)))
4882 return; 4882 return;
4883 4883
4884 vxlanctrl = IXGBE_READ_REG(hw, IXGBE_VXLANCTRL) && ~mask; 4884 vxlanctrl = IXGBE_READ_REG(hw, IXGBE_VXLANCTRL) & ~mask;
4885 IXGBE_WRITE_REG(hw, IXGBE_VXLANCTRL, vxlanctrl); 4885 IXGBE_WRITE_REG(hw, IXGBE_VXLANCTRL, vxlanctrl);
4886 4886
4887 if (mask & IXGBE_VXLANCTRL_VXLAN_UDPPORT_MASK) 4887 if (mask & IXGBE_VXLANCTRL_VXLAN_UDPPORT_MASK)
@@ -8529,6 +8529,10 @@ static int ixgbe_ioctl(struct net_device *netdev, struct ifreq *req, int cmd)
8529 return ixgbe_ptp_set_ts_config(adapter, req); 8529 return ixgbe_ptp_set_ts_config(adapter, req);
8530 case SIOCGHWTSTAMP: 8530 case SIOCGHWTSTAMP:
8531 return ixgbe_ptp_get_ts_config(adapter, req); 8531 return ixgbe_ptp_get_ts_config(adapter, req);
8532 case SIOCGMIIPHY:
8533 if (!adapter->hw.phy.ops.read_reg)
8534 return -EOPNOTSUPP;
8535 /* fall through */
8532 default: 8536 default:
8533 return mdio_mii_ioctl(&adapter->hw.phy.mdio, if_mii(req), cmd); 8537 return mdio_mii_ioctl(&adapter->hw.phy.mdio, if_mii(req), cmd);
8534 } 8538 }
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index 032089efc1a0..c16718d296d3 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -3505,20 +3505,6 @@ static int mlxsw_sp_fib_lpm_tree_link(struct mlxsw_sp *mlxsw_sp,
3505static void mlxsw_sp_fib_lpm_tree_unlink(struct mlxsw_sp *mlxsw_sp, 3505static void mlxsw_sp_fib_lpm_tree_unlink(struct mlxsw_sp *mlxsw_sp,
3506 struct mlxsw_sp_fib *fib) 3506 struct mlxsw_sp_fib *fib)
3507{ 3507{
3508 struct mlxsw_sp_prefix_usage req_prefix_usage = {{ 0 } };
3509 struct mlxsw_sp_lpm_tree *lpm_tree;
3510
3511 /* Aggregate prefix lengths across all virtual routers to make
3512 * sure we only have used prefix lengths in the LPM tree.
3513 */
3514 mlxsw_sp_vrs_prefixes(mlxsw_sp, fib->proto, &req_prefix_usage);
3515 lpm_tree = mlxsw_sp_lpm_tree_get(mlxsw_sp, &req_prefix_usage,
3516 fib->proto);
3517 if (IS_ERR(lpm_tree))
3518 goto err_tree_get;
3519 mlxsw_sp_vrs_lpm_tree_replace(mlxsw_sp, fib, lpm_tree);
3520
3521err_tree_get:
3522 if (!mlxsw_sp_prefix_usage_none(&fib->prefix_usage)) 3508 if (!mlxsw_sp_prefix_usage_none(&fib->prefix_usage))
3523 return; 3509 return;
3524 mlxsw_sp_vr_lpm_tree_unbind(mlxsw_sp, fib); 3510 mlxsw_sp_vr_lpm_tree_unbind(mlxsw_sp, fib);
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index c3f77e3b7819..e365866600ba 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -1339,7 +1339,17 @@ ppp_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats64)
1339 1339
1340static int ppp_dev_init(struct net_device *dev) 1340static int ppp_dev_init(struct net_device *dev)
1341{ 1341{
1342 struct ppp *ppp;
1343
1342 netdev_lockdep_set_classes(dev); 1344 netdev_lockdep_set_classes(dev);
1345
1346 ppp = netdev_priv(dev);
1347 /* Let the netdevice take a reference on the ppp file. This ensures
1348 * that ppp_destroy_interface() won't run before the device gets
1349 * unregistered.
1350 */
1351 atomic_inc(&ppp->file.refcnt);
1352
1343 return 0; 1353 return 0;
1344} 1354}
1345 1355
@@ -1362,6 +1372,15 @@ static void ppp_dev_uninit(struct net_device *dev)
1362 wake_up_interruptible(&ppp->file.rwait); 1372 wake_up_interruptible(&ppp->file.rwait);
1363} 1373}
1364 1374
1375static void ppp_dev_priv_destructor(struct net_device *dev)
1376{
1377 struct ppp *ppp;
1378
1379 ppp = netdev_priv(dev);
1380 if (atomic_dec_and_test(&ppp->file.refcnt))
1381 ppp_destroy_interface(ppp);
1382}
1383
1365static const struct net_device_ops ppp_netdev_ops = { 1384static const struct net_device_ops ppp_netdev_ops = {
1366 .ndo_init = ppp_dev_init, 1385 .ndo_init = ppp_dev_init,
1367 .ndo_uninit = ppp_dev_uninit, 1386 .ndo_uninit = ppp_dev_uninit,
@@ -1387,6 +1406,7 @@ static void ppp_setup(struct net_device *dev)
1387 dev->tx_queue_len = 3; 1406 dev->tx_queue_len = 3;
1388 dev->type = ARPHRD_PPP; 1407 dev->type = ARPHRD_PPP;
1389 dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST; 1408 dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
1409 dev->priv_destructor = ppp_dev_priv_destructor;
1390 netif_keep_dst(dev); 1410 netif_keep_dst(dev);
1391} 1411}
1392 1412
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index 29c7e2ec0dcb..52ea80bcd639 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -560,6 +560,7 @@ static const struct driver_info wwan_info = {
560#define NVIDIA_VENDOR_ID 0x0955 560#define NVIDIA_VENDOR_ID 0x0955
561#define HP_VENDOR_ID 0x03f0 561#define HP_VENDOR_ID 0x03f0
562#define MICROSOFT_VENDOR_ID 0x045e 562#define MICROSOFT_VENDOR_ID 0x045e
563#define UBLOX_VENDOR_ID 0x1546
563 564
564static const struct usb_device_id products[] = { 565static const struct usb_device_id products[] = {
565/* BLACKLIST !! 566/* BLACKLIST !!
@@ -869,6 +870,18 @@ static const struct usb_device_id products[] = {
869 USB_CDC_PROTO_NONE), 870 USB_CDC_PROTO_NONE),
870 .driver_info = (unsigned long)&zte_cdc_info, 871 .driver_info = (unsigned long)&zte_cdc_info,
871}, { 872}, {
873 /* U-blox TOBY-L2 */
874 USB_DEVICE_AND_INTERFACE_INFO(UBLOX_VENDOR_ID, 0x1143, USB_CLASS_COMM,
875 USB_CDC_SUBCLASS_ETHERNET,
876 USB_CDC_PROTO_NONE),
877 .driver_info = (unsigned long)&wwan_info,
878}, {
879 /* U-blox SARA-U2 */
880 USB_DEVICE_AND_INTERFACE_INFO(UBLOX_VENDOR_ID, 0x1104, USB_CLASS_COMM,
881 USB_CDC_SUBCLASS_ETHERNET,
882 USB_CDC_PROTO_NONE),
883 .driver_info = (unsigned long)&wwan_info,
884}, {
872 USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET, 885 USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET,
873 USB_CDC_PROTO_NONE), 886 USB_CDC_PROTO_NONE),
874 .driver_info = (unsigned long) &cdc_info, 887 .driver_info = (unsigned long) &cdc_info,
diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index 1778cf4f81c7..82cd8b08d71f 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -100,6 +100,7 @@ config PINCTRL_AMD
100 tristate "AMD GPIO pin control" 100 tristate "AMD GPIO pin control"
101 depends on GPIOLIB 101 depends on GPIOLIB
102 select GPIOLIB_IRQCHIP 102 select GPIOLIB_IRQCHIP
103 select PINMUX
103 select PINCONF 104 select PINCONF
104 select GENERIC_PINCONF 105 select GENERIC_PINCONF
105 help 106 help
diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
index 0944310225db..ff782445dfb7 100644
--- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c
+++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
@@ -373,16 +373,12 @@ static void bcm2835_gpio_irq_handle_bank(struct bcm2835_pinctrl *pc,
373 unsigned long events; 373 unsigned long events;
374 unsigned offset; 374 unsigned offset;
375 unsigned gpio; 375 unsigned gpio;
376 unsigned int type;
377 376
378 events = bcm2835_gpio_rd(pc, GPEDS0 + bank * 4); 377 events = bcm2835_gpio_rd(pc, GPEDS0 + bank * 4);
379 events &= mask; 378 events &= mask;
380 events &= pc->enabled_irq_map[bank]; 379 events &= pc->enabled_irq_map[bank];
381 for_each_set_bit(offset, &events, 32) { 380 for_each_set_bit(offset, &events, 32) {
382 gpio = (32 * bank) + offset; 381 gpio = (32 * bank) + offset;
383 /* FIXME: no clue why the code looks up the type here */
384 type = pc->irq_type[gpio];
385
386 generic_handle_irq(irq_linear_revmap(pc->gpio_chip.irqdomain, 382 generic_handle_irq(irq_linear_revmap(pc->gpio_chip.irqdomain,
387 gpio)); 383 gpio));
388 } 384 }
diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c b/drivers/pinctrl/intel/pinctrl-cherryview.c
index 04e929fd0ffe..fadbca907c7c 100644
--- a/drivers/pinctrl/intel/pinctrl-cherryview.c
+++ b/drivers/pinctrl/intel/pinctrl-cherryview.c
@@ -1577,6 +1577,7 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq)
1577 struct gpio_chip *chip = &pctrl->chip; 1577 struct gpio_chip *chip = &pctrl->chip;
1578 bool need_valid_mask = !dmi_check_system(chv_no_valid_mask); 1578 bool need_valid_mask = !dmi_check_system(chv_no_valid_mask);
1579 int ret, i, offset; 1579 int ret, i, offset;
1580 int irq_base;
1580 1581
1581 *chip = chv_gpio_chip; 1582 *chip = chv_gpio_chip;
1582 1583
@@ -1622,7 +1623,18 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq)
1622 /* Clear all interrupts */ 1623 /* Clear all interrupts */
1623 chv_writel(0xffff, pctrl->regs + CHV_INTSTAT); 1624 chv_writel(0xffff, pctrl->regs + CHV_INTSTAT);
1624 1625
1625 ret = gpiochip_irqchip_add(chip, &chv_gpio_irqchip, 0, 1626 if (!need_valid_mask) {
1627 irq_base = devm_irq_alloc_descs(pctrl->dev, -1, 0,
1628 chip->ngpio, NUMA_NO_NODE);
1629 if (irq_base < 0) {
1630 dev_err(pctrl->dev, "Failed to allocate IRQ numbers\n");
1631 return irq_base;
1632 }
1633 } else {
1634 irq_base = 0;
1635 }
1636
1637 ret = gpiochip_irqchip_add(chip, &chv_gpio_irqchip, irq_base,
1626 handle_bad_irq, IRQ_TYPE_NONE); 1638 handle_bad_irq, IRQ_TYPE_NONE);
1627 if (ret) { 1639 if (ret) {
1628 dev_err(pctrl->dev, "failed to add IRQ chip\n"); 1640 dev_err(pctrl->dev, "failed to add IRQ chip\n");
diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index df63e44526ac..bf04479456a0 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -109,6 +109,7 @@ config QCOM_Q6V5_PIL
109 depends on OF && ARCH_QCOM 109 depends on OF && ARCH_QCOM
110 depends on QCOM_SMEM 110 depends on QCOM_SMEM
111 depends on RPMSG_QCOM_SMD || (COMPILE_TEST && RPMSG_QCOM_SMD=n) 111 depends on RPMSG_QCOM_SMD || (COMPILE_TEST && RPMSG_QCOM_SMD=n)
112 depends on RPMSG_QCOM_GLINK_SMEM || RPMSG_QCOM_GLINK_SMEM=n
112 select MFD_SYSCON 113 select MFD_SYSCON
113 select QCOM_RPROC_COMMON 114 select QCOM_RPROC_COMMON
114 select QCOM_SCM 115 select QCOM_SCM
@@ -120,6 +121,7 @@ config QCOM_WCNSS_PIL
120 tristate "Qualcomm WCNSS Peripheral Image Loader" 121 tristate "Qualcomm WCNSS Peripheral Image Loader"
121 depends on OF && ARCH_QCOM 122 depends on OF && ARCH_QCOM
122 depends on RPMSG_QCOM_SMD || (COMPILE_TEST && RPMSG_QCOM_SMD=n) 123 depends on RPMSG_QCOM_SMD || (COMPILE_TEST && RPMSG_QCOM_SMD=n)
124 depends on RPMSG_QCOM_GLINK_SMEM || RPMSG_QCOM_GLINK_SMEM=n
123 depends on QCOM_SMEM 125 depends on QCOM_SMEM
124 select QCOM_MDT_LOADER 126 select QCOM_MDT_LOADER
125 select QCOM_RPROC_COMMON 127 select QCOM_RPROC_COMMON
diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 612d91403341..633268e9d550 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -264,15 +264,14 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
264 if (!(att->flags & ATT_OWN)) 264 if (!(att->flags & ATT_OWN))
265 continue; 265 continue;
266 266
267 if (b > IMX7D_RPROC_MEM_MAX) 267 if (b >= IMX7D_RPROC_MEM_MAX)
268 break; 268 break;
269 269
270 priv->mem[b].cpu_addr = devm_ioremap(&pdev->dev, 270 priv->mem[b].cpu_addr = devm_ioremap(&pdev->dev,
271 att->sa, att->size); 271 att->sa, att->size);
272 if (IS_ERR(priv->mem[b].cpu_addr)) { 272 if (!priv->mem[b].cpu_addr) {
273 dev_err(dev, "devm_ioremap_resource failed\n"); 273 dev_err(dev, "devm_ioremap_resource failed\n");
274 err = PTR_ERR(priv->mem[b].cpu_addr); 274 return -ENOMEM;
275 return err;
276 } 275 }
277 priv->mem[b].sys_addr = att->sa; 276 priv->mem[b].sys_addr = att->sa;
278 priv->mem[b].size = att->size; 277 priv->mem[b].size = att->size;
@@ -296,7 +295,7 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
296 return err; 295 return err;
297 } 296 }
298 297
299 if (b > IMX7D_RPROC_MEM_MAX) 298 if (b >= IMX7D_RPROC_MEM_MAX)
300 break; 299 break;
301 300
302 priv->mem[b].cpu_addr = devm_ioremap_resource(&pdev->dev, &res); 301 priv->mem[b].cpu_addr = devm_ioremap_resource(&pdev->dev, &res);
diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
index 5a5e927ea50f..5dcc9bf1c5bc 100644
--- a/drivers/rpmsg/qcom_glink_native.c
+++ b/drivers/rpmsg/qcom_glink_native.c
@@ -635,19 +635,18 @@ qcom_glink_alloc_intent(struct qcom_glink *glink,
635 unsigned long flags; 635 unsigned long flags;
636 636
637 intent = kzalloc(sizeof(*intent), GFP_KERNEL); 637 intent = kzalloc(sizeof(*intent), GFP_KERNEL);
638
639 if (!intent) 638 if (!intent)
640 return NULL; 639 return NULL;
641 640
642 intent->data = kzalloc(size, GFP_KERNEL); 641 intent->data = kzalloc(size, GFP_KERNEL);
643 if (!intent->data) 642 if (!intent->data)
644 return NULL; 643 goto free_intent;
645 644
646 spin_lock_irqsave(&channel->intent_lock, flags); 645 spin_lock_irqsave(&channel->intent_lock, flags);
647 ret = idr_alloc_cyclic(&channel->liids, intent, 1, -1, GFP_ATOMIC); 646 ret = idr_alloc_cyclic(&channel->liids, intent, 1, -1, GFP_ATOMIC);
648 if (ret < 0) { 647 if (ret < 0) {
649 spin_unlock_irqrestore(&channel->intent_lock, flags); 648 spin_unlock_irqrestore(&channel->intent_lock, flags);
650 return NULL; 649 goto free_data;
651 } 650 }
652 spin_unlock_irqrestore(&channel->intent_lock, flags); 651 spin_unlock_irqrestore(&channel->intent_lock, flags);
653 652
@@ -656,6 +655,12 @@ qcom_glink_alloc_intent(struct qcom_glink *glink,
656 intent->reuse = reuseable; 655 intent->reuse = reuseable;
657 656
658 return intent; 657 return intent;
658
659free_data:
660 kfree(intent->data);
661free_intent:
662 kfree(intent);
663 return NULL;
659} 664}
660 665
661static void qcom_glink_handle_rx_done(struct qcom_glink *glink, 666static void qcom_glink_handle_rx_done(struct qcom_glink *glink,
@@ -1197,7 +1202,7 @@ static int qcom_glink_request_intent(struct qcom_glink *glink,
1197 1202
1198 ret = qcom_glink_tx(glink, &cmd, sizeof(cmd), NULL, 0, true); 1203 ret = qcom_glink_tx(glink, &cmd, sizeof(cmd), NULL, 0, true);
1199 if (ret) 1204 if (ret)
1200 return ret; 1205 goto unlock;
1201 1206
1202 ret = wait_for_completion_timeout(&channel->intent_req_comp, 10 * HZ); 1207 ret = wait_for_completion_timeout(&channel->intent_req_comp, 10 * HZ);
1203 if (!ret) { 1208 if (!ret) {
@@ -1207,6 +1212,7 @@ static int qcom_glink_request_intent(struct qcom_glink *glink,
1207 ret = channel->intent_req_result ? 0 : -ECANCELED; 1212 ret = channel->intent_req_result ? 0 : -ECANCELED;
1208 } 1213 }
1209 1214
1215unlock:
1210 mutex_unlock(&channel->intent_req_lock); 1216 mutex_unlock(&channel->intent_req_lock);
1211 return ret; 1217 return ret;
1212} 1218}
diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
index adaf6f6dd858..e1cbdfdb7c68 100644
--- a/fs/9p/vfs_addr.c
+++ b/fs/9p/vfs_addr.c
@@ -310,9 +310,13 @@ static int v9fs_write_end(struct file *filp, struct address_space *mapping,
310 310
311 p9_debug(P9_DEBUG_VFS, "filp %p, mapping %p\n", filp, mapping); 311 p9_debug(P9_DEBUG_VFS, "filp %p, mapping %p\n", filp, mapping);
312 312
313 if (unlikely(copied < len && !PageUptodate(page))) { 313 if (!PageUptodate(page)) {
314 copied = 0; 314 if (unlikely(copied < len)) {
315 goto out; 315 copied = 0;
316 goto out;
317 } else if (len == PAGE_SIZE) {
318 SetPageUptodate(page);
319 }
316 } 320 }
317 /* 321 /*
318 * No need to use i_size_read() here, the i_size 322 * No need to use i_size_read() here, the i_size
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 62cf812ed0e5..96415c65bbdc 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -866,7 +866,8 @@ out:
866 */ 866 */
867 if (sdio->boundary) { 867 if (sdio->boundary) {
868 ret = dio_send_cur_page(dio, sdio, map_bh); 868 ret = dio_send_cur_page(dio, sdio, map_bh);
869 dio_bio_submit(dio, sdio); 869 if (sdio->bio)
870 dio_bio_submit(dio, sdio);
870 put_page(sdio->cur_page); 871 put_page(sdio->cur_page);
871 sdio->cur_page = NULL; 872 sdio->cur_page = NULL;
872 } 873 }
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 9a7c90386947..4b4a72f392be 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -2525,7 +2525,7 @@ void invalidate_blocks(struct f2fs_sb_info *sbi, block_t addr);
2525bool is_checkpointed_data(struct f2fs_sb_info *sbi, block_t blkaddr); 2525bool is_checkpointed_data(struct f2fs_sb_info *sbi, block_t blkaddr);
2526void refresh_sit_entry(struct f2fs_sb_info *sbi, block_t old, block_t new); 2526void refresh_sit_entry(struct f2fs_sb_info *sbi, block_t old, block_t new);
2527void stop_discard_thread(struct f2fs_sb_info *sbi); 2527void stop_discard_thread(struct f2fs_sb_info *sbi);
2528void f2fs_wait_discard_bios(struct f2fs_sb_info *sbi); 2528void f2fs_wait_discard_bios(struct f2fs_sb_info *sbi, bool umount);
2529void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc); 2529void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc);
2530void release_discard_addrs(struct f2fs_sb_info *sbi); 2530void release_discard_addrs(struct f2fs_sb_info *sbi);
2531int npages_for_summary_flush(struct f2fs_sb_info *sbi, bool for_ra); 2531int npages_for_summary_flush(struct f2fs_sb_info *sbi, bool for_ra);
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 621b9b3d320b..c695ff462ee6 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1210,11 +1210,11 @@ void stop_discard_thread(struct f2fs_sb_info *sbi)
1210} 1210}
1211 1211
1212/* This comes from f2fs_put_super and f2fs_trim_fs */ 1212/* This comes from f2fs_put_super and f2fs_trim_fs */
1213void f2fs_wait_discard_bios(struct f2fs_sb_info *sbi) 1213void f2fs_wait_discard_bios(struct f2fs_sb_info *sbi, bool umount)
1214{ 1214{
1215 __issue_discard_cmd(sbi, false); 1215 __issue_discard_cmd(sbi, false);
1216 __drop_discard_cmd(sbi); 1216 __drop_discard_cmd(sbi);
1217 __wait_discard_cmd(sbi, false); 1217 __wait_discard_cmd(sbi, !umount);
1218} 1218}
1219 1219
1220static void mark_discard_range_all(struct f2fs_sb_info *sbi) 1220static void mark_discard_range_all(struct f2fs_sb_info *sbi)
@@ -2244,7 +2244,7 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
2244 } 2244 }
2245 /* It's time to issue all the filed discards */ 2245 /* It's time to issue all the filed discards */
2246 mark_discard_range_all(sbi); 2246 mark_discard_range_all(sbi);
2247 f2fs_wait_discard_bios(sbi); 2247 f2fs_wait_discard_bios(sbi, false);
2248out: 2248out:
2249 range->len = F2FS_BLK_TO_BYTES(cpc.trimmed); 2249 range->len = F2FS_BLK_TO_BYTES(cpc.trimmed);
2250 return err; 2250 return err;
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 89f61eb3d167..933c3d529e65 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -801,7 +801,7 @@ static void f2fs_put_super(struct super_block *sb)
801 } 801 }
802 802
803 /* be sure to wait for any on-going discard commands */ 803 /* be sure to wait for any on-going discard commands */
804 f2fs_wait_discard_bios(sbi); 804 f2fs_wait_discard_bios(sbi, true);
805 805
806 if (f2fs_discard_en(sbi) && !sbi->discard_blks) { 806 if (f2fs_discard_en(sbi) && !sbi->discard_blks) {
807 struct cp_control cpc = { 807 struct cp_control cpc = {
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index efebe6cf4378..22880ef6d8dd 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -218,7 +218,6 @@ static void nfs_cb_idr_remove_locked(struct nfs_client *clp)
218static void pnfs_init_server(struct nfs_server *server) 218static void pnfs_init_server(struct nfs_server *server)
219{ 219{
220 rpc_init_wait_queue(&server->roc_rpcwaitq, "pNFS ROC"); 220 rpc_init_wait_queue(&server->roc_rpcwaitq, "pNFS ROC");
221 rpc_init_wait_queue(&server->uoc_rpcwaitq, "NFS UOC");
222} 221}
223 222
224#else 223#else
@@ -888,6 +887,7 @@ struct nfs_server *nfs_alloc_server(void)
888 ida_init(&server->openowner_id); 887 ida_init(&server->openowner_id);
889 ida_init(&server->lockowner_id); 888 ida_init(&server->lockowner_id);
890 pnfs_init_server(server); 889 pnfs_init_server(server);
890 rpc_init_wait_queue(&server->uoc_rpcwaitq, "NFS UOC");
891 891
892 return server; 892 return server;
893} 893}
diff --git a/fs/nfs/filelayout/filelayout.c b/fs/nfs/filelayout/filelayout.c
index 44c638b7876c..508126eb49f9 100644
--- a/fs/nfs/filelayout/filelayout.c
+++ b/fs/nfs/filelayout/filelayout.c
@@ -745,7 +745,8 @@ filelayout_free_lseg(struct pnfs_layout_segment *lseg)
745 struct nfs4_filelayout_segment *fl = FILELAYOUT_LSEG(lseg); 745 struct nfs4_filelayout_segment *fl = FILELAYOUT_LSEG(lseg);
746 746
747 dprintk("--> %s\n", __func__); 747 dprintk("--> %s\n", __func__);
748 nfs4_fl_put_deviceid(fl->dsaddr); 748 if (fl->dsaddr != NULL)
749 nfs4_fl_put_deviceid(fl->dsaddr);
749 /* This assumes a single RW lseg */ 750 /* This assumes a single RW lseg */
750 if (lseg->pls_range.iomode == IOMODE_RW) { 751 if (lseg->pls_range.iomode == IOMODE_RW) {
751 struct nfs4_filelayout *flo; 752 struct nfs4_filelayout *flo;
diff --git a/fs/nfs/nfs4idmap.c b/fs/nfs/nfs4idmap.c
index dd5d27da8c0c..30426c1a1bbd 100644
--- a/fs/nfs/nfs4idmap.c
+++ b/fs/nfs/nfs4idmap.c
@@ -274,7 +274,7 @@ static struct key *nfs_idmap_request_key(const char *name, size_t namelen,
274 ssize_t ret; 274 ssize_t ret;
275 275
276 ret = nfs_idmap_get_desc(name, namelen, type, strlen(type), &desc); 276 ret = nfs_idmap_get_desc(name, namelen, type, strlen(type), &desc);
277 if (ret <= 0) 277 if (ret < 0)
278 return ERR_PTR(ret); 278 return ERR_PTR(ret);
279 279
280 rkey = request_key(&key_type_id_resolver, desc, ""); 280 rkey = request_key(&key_type_id_resolver, desc, "");
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 6c61e2b99635..f90090e8c959 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -8399,8 +8399,7 @@ nfs4_layoutget_handle_exception(struct rpc_task *task,
8399 lo = NFS_I(inode)->layout; 8399 lo = NFS_I(inode)->layout;
8400 /* If the open stateid was bad, then recover it. */ 8400 /* If the open stateid was bad, then recover it. */
8401 if (!lo || test_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags) || 8401 if (!lo || test_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags) ||
8402 nfs4_stateid_match_other(&lgp->args.stateid, 8402 !nfs4_stateid_match_other(&lgp->args.stateid, &lo->plh_stateid)) {
8403 &lgp->args.ctx->state->stateid)) {
8404 spin_unlock(&inode->i_lock); 8403 spin_unlock(&inode->i_lock);
8405 exception->state = lgp->args.ctx->state; 8404 exception->state = lgp->args.ctx->state;
8406 exception->stateid = &lgp->args.stateid; 8405 exception->stateid = &lgp->args.stateid;
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 37c8af003275..14ed9791ec9c 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -1842,8 +1842,8 @@ static void encode_create_session(struct xdr_stream *xdr,
1842 * Assumes OPEN is the biggest non-idempotent compound. 1842 * Assumes OPEN is the biggest non-idempotent compound.
1843 * 2 is the verifier. 1843 * 2 is the verifier.
1844 */ 1844 */
1845 max_resp_sz_cached = (NFS4_dec_open_sz + RPC_REPHDRSIZE + 1845 max_resp_sz_cached = (NFS4_dec_open_sz + RPC_REPHDRSIZE + 2)
1846 RPC_MAX_AUTH_SIZE + 2) * XDR_UNIT; 1846 * XDR_UNIT + RPC_MAX_AUTH_SIZE;
1847 1847
1848 encode_op_hdr(xdr, OP_CREATE_SESSION, decode_create_session_maxsz, hdr); 1848 encode_op_hdr(xdr, OP_CREATE_SESSION, decode_create_session_maxsz, hdr);
1849 p = reserve_space(xdr, 16 + 2*28 + 20 + clnt->cl_nodelen + 12); 1849 p = reserve_space(xdr, 16 + 2*28 + 20 + clnt->cl_nodelen + 12);
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 3c69db7d4905..8487486ec496 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -927,6 +927,13 @@ nfsd4_secinfo_release(union nfsd4_op_u *u)
927 exp_put(u->secinfo.si_exp); 927 exp_put(u->secinfo.si_exp);
928} 928}
929 929
930static void
931nfsd4_secinfo_no_name_release(union nfsd4_op_u *u)
932{
933 if (u->secinfo_no_name.sin_exp)
934 exp_put(u->secinfo_no_name.sin_exp);
935}
936
930static __be32 937static __be32
931nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, 938nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
932 union nfsd4_op_u *u) 939 union nfsd4_op_u *u)
@@ -2375,7 +2382,7 @@ static const struct nfsd4_operation nfsd4_ops[] = {
2375 }, 2382 },
2376 [OP_SECINFO_NO_NAME] = { 2383 [OP_SECINFO_NO_NAME] = {
2377 .op_func = nfsd4_secinfo_no_name, 2384 .op_func = nfsd4_secinfo_no_name,
2378 .op_release = nfsd4_secinfo_release, 2385 .op_release = nfsd4_secinfo_no_name_release,
2379 .op_flags = OP_HANDLES_WRONGSEC, 2386 .op_flags = OP_HANDLES_WRONGSEC,
2380 .op_name = "OP_SECINFO_NO_NAME", 2387 .op_name = "OP_SECINFO_NO_NAME",
2381 .op_rsize_bop = nfsd4_secinfo_rsize, 2388 .op_rsize_bop = nfsd4_secinfo_rsize,
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 50b0556a124f..52ad15192e72 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -1297,21 +1297,18 @@ static int dquot_add_space(struct dquot *dquot, qsize_t space,
1297 spin_lock(&dquot->dq_dqb_lock); 1297 spin_lock(&dquot->dq_dqb_lock);
1298 if (!sb_has_quota_limits_enabled(sb, dquot->dq_id.type) || 1298 if (!sb_has_quota_limits_enabled(sb, dquot->dq_id.type) ||
1299 test_bit(DQ_FAKE_B, &dquot->dq_flags)) 1299 test_bit(DQ_FAKE_B, &dquot->dq_flags))
1300 goto add; 1300 goto finish;
1301 1301
1302 tspace = dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace 1302 tspace = dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace
1303 + space + rsv_space; 1303 + space + rsv_space;
1304 1304
1305 if (flags & DQUOT_SPACE_NOFAIL)
1306 goto add;
1307
1308 if (dquot->dq_dqb.dqb_bhardlimit && 1305 if (dquot->dq_dqb.dqb_bhardlimit &&
1309 tspace > dquot->dq_dqb.dqb_bhardlimit && 1306 tspace > dquot->dq_dqb.dqb_bhardlimit &&
1310 !ignore_hardlimit(dquot)) { 1307 !ignore_hardlimit(dquot)) {
1311 if (flags & DQUOT_SPACE_WARN) 1308 if (flags & DQUOT_SPACE_WARN)
1312 prepare_warning(warn, dquot, QUOTA_NL_BHARDWARN); 1309 prepare_warning(warn, dquot, QUOTA_NL_BHARDWARN);
1313 ret = -EDQUOT; 1310 ret = -EDQUOT;
1314 goto out; 1311 goto finish;
1315 } 1312 }
1316 1313
1317 if (dquot->dq_dqb.dqb_bsoftlimit && 1314 if (dquot->dq_dqb.dqb_bsoftlimit &&
@@ -1322,7 +1319,7 @@ static int dquot_add_space(struct dquot *dquot, qsize_t space,
1322 if (flags & DQUOT_SPACE_WARN) 1319 if (flags & DQUOT_SPACE_WARN)
1323 prepare_warning(warn, dquot, QUOTA_NL_BSOFTLONGWARN); 1320 prepare_warning(warn, dquot, QUOTA_NL_BSOFTLONGWARN);
1324 ret = -EDQUOT; 1321 ret = -EDQUOT;
1325 goto out; 1322 goto finish;
1326 } 1323 }
1327 1324
1328 if (dquot->dq_dqb.dqb_bsoftlimit && 1325 if (dquot->dq_dqb.dqb_bsoftlimit &&
@@ -1338,13 +1335,21 @@ static int dquot_add_space(struct dquot *dquot, qsize_t space,
1338 * be always printed 1335 * be always printed
1339 */ 1336 */
1340 ret = -EDQUOT; 1337 ret = -EDQUOT;
1341 goto out; 1338 goto finish;
1342 } 1339 }
1343 } 1340 }
1344add: 1341finish:
1345 dquot->dq_dqb.dqb_rsvspace += rsv_space; 1342 /*
1346 dquot->dq_dqb.dqb_curspace += space; 1343 * We have to be careful and go through warning generation & grace time
1347out: 1344 * setting even if DQUOT_SPACE_NOFAIL is set. That's why we check it
1345 * only here...
1346 */
1347 if (flags & DQUOT_SPACE_NOFAIL)
1348 ret = 0;
1349 if (!ret) {
1350 dquot->dq_dqb.dqb_rsvspace += rsv_space;
1351 dquot->dq_dqb.dqb_curspace += space;
1352 }
1348 spin_unlock(&dquot->dq_dqb_lock); 1353 spin_unlock(&dquot->dq_dqb_lock);
1349 return ret; 1354 return ret;
1350} 1355}
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index 744dcaec34cc..f965ce832bc0 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -1584,6 +1584,10 @@ xfs_alloc_ag_vextent_small(
1584 1584
1585 bp = xfs_btree_get_bufs(args->mp, args->tp, 1585 bp = xfs_btree_get_bufs(args->mp, args->tp,
1586 args->agno, fbno, 0); 1586 args->agno, fbno, 0);
1587 if (!bp) {
1588 error = -EFSCORRUPTED;
1589 goto error0;
1590 }
1587 xfs_trans_binval(args->tp, bp); 1591 xfs_trans_binval(args->tp, bp);
1588 } 1592 }
1589 args->len = 1; 1593 args->len = 1;
@@ -2141,6 +2145,10 @@ xfs_alloc_fix_freelist(
2141 if (error) 2145 if (error)
2142 goto out_agbp_relse; 2146 goto out_agbp_relse;
2143 bp = xfs_btree_get_bufs(mp, tp, args->agno, bno, 0); 2147 bp = xfs_btree_get_bufs(mp, tp, args->agno, bno, 0);
2148 if (!bp) {
2149 error = -EFSCORRUPTED;
2150 goto out_agbp_relse;
2151 }
2144 xfs_trans_binval(tp, bp); 2152 xfs_trans_binval(tp, bp);
2145 } 2153 }
2146 2154
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 044a363119be..def32fa1c225 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -1477,14 +1477,14 @@ xfs_bmap_isaeof(
1477 int is_empty; 1477 int is_empty;
1478 int error; 1478 int error;
1479 1479
1480 bma->aeof = 0; 1480 bma->aeof = false;
1481 error = xfs_bmap_last_extent(NULL, bma->ip, whichfork, &rec, 1481 error = xfs_bmap_last_extent(NULL, bma->ip, whichfork, &rec,
1482 &is_empty); 1482 &is_empty);
1483 if (error) 1483 if (error)
1484 return error; 1484 return error;
1485 1485
1486 if (is_empty) { 1486 if (is_empty) {
1487 bma->aeof = 1; 1487 bma->aeof = true;
1488 return 0; 1488 return 0;
1489 } 1489 }
1490 1490
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index 988bb3f31446..dfd643909f85 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -1962,7 +1962,7 @@ xfs_difree_inobt(
1962 if (!(mp->m_flags & XFS_MOUNT_IKEEP) && 1962 if (!(mp->m_flags & XFS_MOUNT_IKEEP) &&
1963 rec.ir_free == XFS_INOBT_ALL_FREE && 1963 rec.ir_free == XFS_INOBT_ALL_FREE &&
1964 mp->m_sb.sb_inopblock <= XFS_INODES_PER_CHUNK) { 1964 mp->m_sb.sb_inopblock <= XFS_INODES_PER_CHUNK) {
1965 xic->deleted = 1; 1965 xic->deleted = true;
1966 xic->first_ino = XFS_AGINO_TO_INO(mp, agno, rec.ir_startino); 1966 xic->first_ino = XFS_AGINO_TO_INO(mp, agno, rec.ir_startino);
1967 xic->alloc = xfs_inobt_irec_to_allocmask(&rec); 1967 xic->alloc = xfs_inobt_irec_to_allocmask(&rec);
1968 1968
@@ -1989,7 +1989,7 @@ xfs_difree_inobt(
1989 1989
1990 xfs_difree_inode_chunk(mp, agno, &rec, dfops); 1990 xfs_difree_inode_chunk(mp, agno, &rec, dfops);
1991 } else { 1991 } else {
1992 xic->deleted = 0; 1992 xic->deleted = false;
1993 1993
1994 error = xfs_inobt_update(cur, &rec); 1994 error = xfs_inobt_update(cur, &rec);
1995 if (error) { 1995 if (error) {
diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h
index 8372e9bcd7b6..71de185735e0 100644
--- a/fs/xfs/libxfs/xfs_log_format.h
+++ b/fs/xfs/libxfs/xfs_log_format.h
@@ -270,6 +270,7 @@ typedef struct xfs_inode_log_format {
270 uint32_t ilf_fields; /* flags for fields logged */ 270 uint32_t ilf_fields; /* flags for fields logged */
271 uint16_t ilf_asize; /* size of attr d/ext/root */ 271 uint16_t ilf_asize; /* size of attr d/ext/root */
272 uint16_t ilf_dsize; /* size of data/ext/root */ 272 uint16_t ilf_dsize; /* size of data/ext/root */
273 uint32_t ilf_pad; /* pad for 64 bit boundary */
273 uint64_t ilf_ino; /* inode number */ 274 uint64_t ilf_ino; /* inode number */
274 union { 275 union {
275 uint32_t ilfu_rdev; /* rdev value for dev inode*/ 276 uint32_t ilfu_rdev; /* rdev value for dev inode*/
@@ -280,29 +281,17 @@ typedef struct xfs_inode_log_format {
280 int32_t ilf_boffset; /* off of inode in buffer */ 281 int32_t ilf_boffset; /* off of inode in buffer */
281} xfs_inode_log_format_t; 282} xfs_inode_log_format_t;
282 283
283typedef struct xfs_inode_log_format_32 { 284/*
284 uint16_t ilf_type; /* inode log item type */ 285 * Old 32 bit systems will log in this format without the 64 bit
285 uint16_t ilf_size; /* size of this item */ 286 * alignment padding. Recovery will detect this and convert it to the
286 uint32_t ilf_fields; /* flags for fields logged */ 287 * correct format.
287 uint16_t ilf_asize; /* size of attr d/ext/root */ 288 */
288 uint16_t ilf_dsize; /* size of data/ext/root */ 289struct xfs_inode_log_format_32 {
289 uint64_t ilf_ino; /* inode number */
290 union {
291 uint32_t ilfu_rdev; /* rdev value for dev inode*/
292 uuid_t ilfu_uuid; /* mount point value */
293 } ilf_u;
294 int64_t ilf_blkno; /* blkno of inode buffer */
295 int32_t ilf_len; /* len of inode buffer */
296 int32_t ilf_boffset; /* off of inode in buffer */
297} __attribute__((packed)) xfs_inode_log_format_32_t;
298
299typedef struct xfs_inode_log_format_64 {
300 uint16_t ilf_type; /* inode log item type */ 290 uint16_t ilf_type; /* inode log item type */
301 uint16_t ilf_size; /* size of this item */ 291 uint16_t ilf_size; /* size of this item */
302 uint32_t ilf_fields; /* flags for fields logged */ 292 uint32_t ilf_fields; /* flags for fields logged */
303 uint16_t ilf_asize; /* size of attr d/ext/root */ 293 uint16_t ilf_asize; /* size of attr d/ext/root */
304 uint16_t ilf_dsize; /* size of data/ext/root */ 294 uint16_t ilf_dsize; /* size of data/ext/root */
305 uint32_t ilf_pad; /* pad for 64 bit boundary */
306 uint64_t ilf_ino; /* inode number */ 295 uint64_t ilf_ino; /* inode number */
307 union { 296 union {
308 uint32_t ilfu_rdev; /* rdev value for dev inode*/ 297 uint32_t ilfu_rdev; /* rdev value for dev inode*/
@@ -311,7 +300,7 @@ typedef struct xfs_inode_log_format_64 {
311 int64_t ilf_blkno; /* blkno of inode buffer */ 300 int64_t ilf_blkno; /* blkno of inode buffer */
312 int32_t ilf_len; /* len of inode buffer */ 301 int32_t ilf_len; /* len of inode buffer */
313 int32_t ilf_boffset; /* off of inode in buffer */ 302 int32_t ilf_boffset; /* off of inode in buffer */
314} xfs_inode_log_format_64_t; 303} __attribute__((packed));
315 304
316 305
317/* 306/*
diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c
index 7034e17535de..3354140de07e 100644
--- a/fs/xfs/xfs_acl.c
+++ b/fs/xfs/xfs_acl.c
@@ -247,6 +247,8 @@ xfs_set_mode(struct inode *inode, umode_t mode)
247int 247int
248xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) 248xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
249{ 249{
250 umode_t mode;
251 bool set_mode = false;
250 int error = 0; 252 int error = 0;
251 253
252 if (!acl) 254 if (!acl)
@@ -257,16 +259,24 @@ xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
257 return error; 259 return error;
258 260
259 if (type == ACL_TYPE_ACCESS) { 261 if (type == ACL_TYPE_ACCESS) {
260 umode_t mode;
261
262 error = posix_acl_update_mode(inode, &mode, &acl); 262 error = posix_acl_update_mode(inode, &mode, &acl);
263 if (error) 263 if (error)
264 return error; 264 return error;
265 error = xfs_set_mode(inode, mode); 265 set_mode = true;
266 if (error)
267 return error;
268 } 266 }
269 267
270 set_acl: 268 set_acl:
271 return __xfs_set_acl(inode, acl, type); 269 error = __xfs_set_acl(inode, acl, type);
270 if (error)
271 return error;
272
273 /*
274 * We set the mode after successfully updating the ACL xattr because the
275 * xattr update can fail at ENOSPC and we don't want to change the mode
276 * if the ACL update hasn't been applied.
277 */
278 if (set_mode)
279 error = xfs_set_mode(inode, mode);
280
281 return error;
272} 282}
diff --git a/fs/xfs/xfs_attr_inactive.c b/fs/xfs/xfs_attr_inactive.c
index ebd66b19fbfc..e3a950ed35a8 100644
--- a/fs/xfs/xfs_attr_inactive.c
+++ b/fs/xfs/xfs_attr_inactive.c
@@ -302,6 +302,8 @@ xfs_attr3_node_inactive(
302 &bp, XFS_ATTR_FORK); 302 &bp, XFS_ATTR_FORK);
303 if (error) 303 if (error)
304 return error; 304 return error;
305 node = bp->b_addr;
306 btree = dp->d_ops->node_tree_p(node);
305 child_fsb = be32_to_cpu(btree[i + 1].before); 307 child_fsb = be32_to_cpu(btree[i + 1].before);
306 xfs_trans_brelse(*trans, bp); 308 xfs_trans_brelse(*trans, bp);
307 } 309 }
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index e9db7fc95b70..6503cfa44262 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -84,6 +84,7 @@ xfs_zero_extent(
84 GFP_NOFS, 0); 84 GFP_NOFS, 0);
85} 85}
86 86
87#ifdef CONFIG_XFS_RT
87int 88int
88xfs_bmap_rtalloc( 89xfs_bmap_rtalloc(
89 struct xfs_bmalloca *ap) /* bmap alloc argument struct */ 90 struct xfs_bmalloca *ap) /* bmap alloc argument struct */
@@ -190,6 +191,7 @@ xfs_bmap_rtalloc(
190 } 191 }
191 return 0; 192 return 0;
192} 193}
194#endif /* CONFIG_XFS_RT */
193 195
194/* 196/*
195 * Check if the endoff is outside the last extent. If so the caller will grow 197 * Check if the endoff is outside the last extent. If so the caller will grow
diff --git a/fs/xfs/xfs_bmap_util.h b/fs/xfs/xfs_bmap_util.h
index 0eaa81dc49be..7d330b3c77c3 100644
--- a/fs/xfs/xfs_bmap_util.h
+++ b/fs/xfs/xfs_bmap_util.h
@@ -28,7 +28,20 @@ struct xfs_mount;
28struct xfs_trans; 28struct xfs_trans;
29struct xfs_bmalloca; 29struct xfs_bmalloca;
30 30
31#ifdef CONFIG_XFS_RT
31int xfs_bmap_rtalloc(struct xfs_bmalloca *ap); 32int xfs_bmap_rtalloc(struct xfs_bmalloca *ap);
33#else /* !CONFIG_XFS_RT */
34/*
35 * Attempts to allocate RT extents when RT is disable indicates corruption and
36 * should trigger a shutdown.
37 */
38static inline int
39xfs_bmap_rtalloc(struct xfs_bmalloca *ap)
40{
41 return -EFSCORRUPTED;
42}
43#endif /* CONFIG_XFS_RT */
44
32int xfs_bmap_eof(struct xfs_inode *ip, xfs_fileoff_t endoff, 45int xfs_bmap_eof(struct xfs_inode *ip, xfs_fileoff_t endoff,
33 int whichfork, int *eof); 46 int whichfork, int *eof);
34int xfs_bmap_punch_delalloc_range(struct xfs_inode *ip, 47int xfs_bmap_punch_delalloc_range(struct xfs_inode *ip,
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 309e26c9dddb..56d0e526870c 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -764,7 +764,7 @@ xfs_file_fallocate(
764 enum xfs_prealloc_flags flags = 0; 764 enum xfs_prealloc_flags flags = 0;
765 uint iolock = XFS_IOLOCK_EXCL; 765 uint iolock = XFS_IOLOCK_EXCL;
766 loff_t new_size = 0; 766 loff_t new_size = 0;
767 bool do_file_insert = 0; 767 bool do_file_insert = false;
768 768
769 if (!S_ISREG(inode->i_mode)) 769 if (!S_ISREG(inode->i_mode))
770 return -EINVAL; 770 return -EINVAL;
@@ -825,7 +825,7 @@ xfs_file_fallocate(
825 error = -EINVAL; 825 error = -EINVAL;
826 goto out_unlock; 826 goto out_unlock;
827 } 827 }
828 do_file_insert = 1; 828 do_file_insert = true;
829 } else { 829 } else {
830 flags |= XFS_PREALLOC_SET; 830 flags |= XFS_PREALLOC_SET;
831 831
diff --git a/fs/xfs/xfs_fsmap.c b/fs/xfs/xfs_fsmap.c
index 814ed729881d..560e0b40ac1b 100644
--- a/fs/xfs/xfs_fsmap.c
+++ b/fs/xfs/xfs_fsmap.c
@@ -521,6 +521,7 @@ __xfs_getfsmap_rtdev(
521 return query_fn(tp, info); 521 return query_fn(tp, info);
522} 522}
523 523
524#ifdef CONFIG_XFS_RT
524/* Actually query the realtime bitmap. */ 525/* Actually query the realtime bitmap. */
525STATIC int 526STATIC int
526xfs_getfsmap_rtdev_rtbitmap_query( 527xfs_getfsmap_rtdev_rtbitmap_query(
@@ -561,6 +562,7 @@ xfs_getfsmap_rtdev_rtbitmap(
561 return __xfs_getfsmap_rtdev(tp, keys, xfs_getfsmap_rtdev_rtbitmap_query, 562 return __xfs_getfsmap_rtdev(tp, keys, xfs_getfsmap_rtdev_rtbitmap_query,
562 info); 563 info);
563} 564}
565#endif /* CONFIG_XFS_RT */
564 566
565/* Execute a getfsmap query against the regular data device. */ 567/* Execute a getfsmap query against the regular data device. */
566STATIC int 568STATIC int
@@ -795,7 +797,15 @@ xfs_getfsmap_check_keys(
795 return false; 797 return false;
796} 798}
797 799
800/*
801 * There are only two devices if we didn't configure RT devices at build time.
802 */
803#ifdef CONFIG_XFS_RT
798#define XFS_GETFSMAP_DEVS 3 804#define XFS_GETFSMAP_DEVS 3
805#else
806#define XFS_GETFSMAP_DEVS 2
807#endif /* CONFIG_XFS_RT */
808
799/* 809/*
800 * Get filesystem's extents as described in head, and format for 810 * Get filesystem's extents as described in head, and format for
801 * output. Calls formatter to fill the user's buffer until all 811 * output. Calls formatter to fill the user's buffer until all
@@ -853,10 +863,12 @@ xfs_getfsmap(
853 handlers[1].dev = new_encode_dev(mp->m_logdev_targp->bt_dev); 863 handlers[1].dev = new_encode_dev(mp->m_logdev_targp->bt_dev);
854 handlers[1].fn = xfs_getfsmap_logdev; 864 handlers[1].fn = xfs_getfsmap_logdev;
855 } 865 }
866#ifdef CONFIG_XFS_RT
856 if (mp->m_rtdev_targp) { 867 if (mp->m_rtdev_targp) {
857 handlers[2].dev = new_encode_dev(mp->m_rtdev_targp->bt_dev); 868 handlers[2].dev = new_encode_dev(mp->m_rtdev_targp->bt_dev);
858 handlers[2].fn = xfs_getfsmap_rtdev_rtbitmap; 869 handlers[2].fn = xfs_getfsmap_rtdev_rtbitmap;
859 } 870 }
871#endif /* CONFIG_XFS_RT */
860 872
861 xfs_sort(handlers, XFS_GETFSMAP_DEVS, sizeof(struct xfs_getfsmap_dev), 873 xfs_sort(handlers, XFS_GETFSMAP_DEVS, sizeof(struct xfs_getfsmap_dev),
862 xfs_getfsmap_dev_compare); 874 xfs_getfsmap_dev_compare);
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index a705f34b58fa..9bbc2d7cc8cb 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -364,6 +364,9 @@ xfs_inode_to_log_dinode(
364 to->di_dmstate = from->di_dmstate; 364 to->di_dmstate = from->di_dmstate;
365 to->di_flags = from->di_flags; 365 to->di_flags = from->di_flags;
366 366
367 /* log a dummy value to ensure log structure is fully initialised */
368 to->di_next_unlinked = NULLAGINO;
369
367 if (from->di_version == 3) { 370 if (from->di_version == 3) {
368 to->di_changecount = inode->i_version; 371 to->di_changecount = inode->i_version;
369 to->di_crtime.t_sec = from->di_crtime.t_sec; 372 to->di_crtime.t_sec = from->di_crtime.t_sec;
@@ -404,6 +407,11 @@ xfs_inode_item_format_core(
404 * the second with the on-disk inode structure, and a possible third and/or 407 * the second with the on-disk inode structure, and a possible third and/or
405 * fourth with the inode data/extents/b-tree root and inode attributes 408 * fourth with the inode data/extents/b-tree root and inode attributes
406 * data/extents/b-tree root. 409 * data/extents/b-tree root.
410 *
411 * Note: Always use the 64 bit inode log format structure so we don't
412 * leave an uninitialised hole in the format item on 64 bit systems. Log
413 * recovery on 32 bit systems handles this just fine, so there's no reason
414 * for not using an initialising the properly padded structure all the time.
407 */ 415 */
408STATIC void 416STATIC void
409xfs_inode_item_format( 417xfs_inode_item_format(
@@ -412,8 +420,8 @@ xfs_inode_item_format(
412{ 420{
413 struct xfs_inode_log_item *iip = INODE_ITEM(lip); 421 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
414 struct xfs_inode *ip = iip->ili_inode; 422 struct xfs_inode *ip = iip->ili_inode;
415 struct xfs_inode_log_format *ilf;
416 struct xfs_log_iovec *vecp = NULL; 423 struct xfs_log_iovec *vecp = NULL;
424 struct xfs_inode_log_format *ilf;
417 425
418 ASSERT(ip->i_d.di_version > 1); 426 ASSERT(ip->i_d.di_version > 1);
419 427
@@ -425,7 +433,17 @@ xfs_inode_item_format(
425 ilf->ilf_boffset = ip->i_imap.im_boffset; 433 ilf->ilf_boffset = ip->i_imap.im_boffset;
426 ilf->ilf_fields = XFS_ILOG_CORE; 434 ilf->ilf_fields = XFS_ILOG_CORE;
427 ilf->ilf_size = 2; /* format + core */ 435 ilf->ilf_size = 2; /* format + core */
428 xlog_finish_iovec(lv, vecp, sizeof(struct xfs_inode_log_format)); 436
437 /*
438 * make sure we don't leak uninitialised data into the log in the case
439 * when we don't log every field in the inode.
440 */
441 ilf->ilf_dsize = 0;
442 ilf->ilf_asize = 0;
443 ilf->ilf_pad = 0;
444 uuid_copy(&ilf->ilf_u.ilfu_uuid, &uuid_null);
445
446 xlog_finish_iovec(lv, vecp, sizeof(*ilf));
429 447
430 xfs_inode_item_format_core(ip, lv, &vecp); 448 xfs_inode_item_format_core(ip, lv, &vecp);
431 xfs_inode_item_format_data_fork(iip, ilf, lv, &vecp); 449 xfs_inode_item_format_data_fork(iip, ilf, lv, &vecp);
@@ -855,44 +873,29 @@ xfs_istale_done(
855} 873}
856 874
857/* 875/*
858 * convert an xfs_inode_log_format struct from either 32 or 64 bit versions 876 * convert an xfs_inode_log_format struct from the old 32 bit version
859 * (which can have different field alignments) to the native version 877 * (which can have different field alignments) to the native 64 bit version
860 */ 878 */
861int 879int
862xfs_inode_item_format_convert( 880xfs_inode_item_format_convert(
863 xfs_log_iovec_t *buf, 881 struct xfs_log_iovec *buf,
864 xfs_inode_log_format_t *in_f) 882 struct xfs_inode_log_format *in_f)
865{ 883{
866 if (buf->i_len == sizeof(xfs_inode_log_format_32_t)) { 884 struct xfs_inode_log_format_32 *in_f32 = buf->i_addr;
867 xfs_inode_log_format_32_t *in_f32 = buf->i_addr; 885
868 886 if (buf->i_len != sizeof(*in_f32))
869 in_f->ilf_type = in_f32->ilf_type; 887 return -EFSCORRUPTED;
870 in_f->ilf_size = in_f32->ilf_size; 888
871 in_f->ilf_fields = in_f32->ilf_fields; 889 in_f->ilf_type = in_f32->ilf_type;
872 in_f->ilf_asize = in_f32->ilf_asize; 890 in_f->ilf_size = in_f32->ilf_size;
873 in_f->ilf_dsize = in_f32->ilf_dsize; 891 in_f->ilf_fields = in_f32->ilf_fields;
874 in_f->ilf_ino = in_f32->ilf_ino; 892 in_f->ilf_asize = in_f32->ilf_asize;
875 /* copy biggest field of ilf_u */ 893 in_f->ilf_dsize = in_f32->ilf_dsize;
876 uuid_copy(&in_f->ilf_u.ilfu_uuid, &in_f32->ilf_u.ilfu_uuid); 894 in_f->ilf_ino = in_f32->ilf_ino;
877 in_f->ilf_blkno = in_f32->ilf_blkno; 895 /* copy biggest field of ilf_u */
878 in_f->ilf_len = in_f32->ilf_len; 896 uuid_copy(&in_f->ilf_u.ilfu_uuid, &in_f32->ilf_u.ilfu_uuid);
879 in_f->ilf_boffset = in_f32->ilf_boffset; 897 in_f->ilf_blkno = in_f32->ilf_blkno;
880 return 0; 898 in_f->ilf_len = in_f32->ilf_len;
881 } else if (buf->i_len == sizeof(xfs_inode_log_format_64_t)){ 899 in_f->ilf_boffset = in_f32->ilf_boffset;
882 xfs_inode_log_format_64_t *in_f64 = buf->i_addr; 900 return 0;
883
884 in_f->ilf_type = in_f64->ilf_type;
885 in_f->ilf_size = in_f64->ilf_size;
886 in_f->ilf_fields = in_f64->ilf_fields;
887 in_f->ilf_asize = in_f64->ilf_asize;
888 in_f->ilf_dsize = in_f64->ilf_dsize;
889 in_f->ilf_ino = in_f64->ilf_ino;
890 /* copy biggest field of ilf_u */
891 uuid_copy(&in_f->ilf_u.ilfu_uuid, &in_f64->ilf_u.ilfu_uuid);
892 in_f->ilf_blkno = in_f64->ilf_blkno;
893 in_f->ilf_len = in_f64->ilf_len;
894 in_f->ilf_boffset = in_f64->ilf_boffset;
895 return 0;
896 }
897 return -EFSCORRUPTED;
898} 901}
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index c5107c7bc4bf..dc95a49d62e7 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -2515,7 +2515,7 @@ next_lv:
2515 if (lv) 2515 if (lv)
2516 vecp = lv->lv_iovecp; 2516 vecp = lv->lv_iovecp;
2517 } 2517 }
2518 if (record_cnt == 0 && ordered == false) { 2518 if (record_cnt == 0 && !ordered) {
2519 if (!lv) 2519 if (!lv)
2520 return 0; 2520 return 0;
2521 break; 2521 break;
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index ea7d4b4e50d0..e9727d0a541a 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -704,7 +704,7 @@ xfs_mountfs(
704 xfs_set_maxicount(mp); 704 xfs_set_maxicount(mp);
705 705
706 /* enable fail_at_unmount as default */ 706 /* enable fail_at_unmount as default */
707 mp->m_fail_unmount = 1; 707 mp->m_fail_unmount = true;
708 708
709 error = xfs_sysfs_init(&mp->m_kobj, &xfs_mp_ktype, NULL, mp->m_fsname); 709 error = xfs_sysfs_init(&mp->m_kobj, &xfs_mp_ktype, NULL, mp->m_fsname);
710 if (error) 710 if (error)
diff --git a/fs/xfs/xfs_ondisk.h b/fs/xfs/xfs_ondisk.h
index 0c381d71b242..0492436a053f 100644
--- a/fs/xfs/xfs_ondisk.h
+++ b/fs/xfs/xfs_ondisk.h
@@ -134,7 +134,7 @@ xfs_check_ondisk_structs(void)
134 XFS_CHECK_STRUCT_SIZE(struct xfs_icreate_log, 28); 134 XFS_CHECK_STRUCT_SIZE(struct xfs_icreate_log, 28);
135 XFS_CHECK_STRUCT_SIZE(struct xfs_ictimestamp, 8); 135 XFS_CHECK_STRUCT_SIZE(struct xfs_ictimestamp, 8);
136 XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format_32, 52); 136 XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format_32, 52);
137 XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format_64, 56); 137 XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format, 56);
138 XFS_CHECK_STRUCT_SIZE(struct xfs_qoff_logformat, 20); 138 XFS_CHECK_STRUCT_SIZE(struct xfs_qoff_logformat, 20);
139 XFS_CHECK_STRUCT_SIZE(struct xfs_trans_header, 16); 139 XFS_CHECK_STRUCT_SIZE(struct xfs_trans_header, 16);
140} 140}
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 8390859e79e7..f1af7d63d678 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -368,6 +368,11 @@ static inline void __bpf_prog_uncharge(struct user_struct *user, u32 pages)
368{ 368{
369} 369}
370 370
371static inline int bpf_obj_get_user(const char __user *pathname)
372{
373 return -EOPNOTSUPP;
374}
375
371static inline struct net_device *__dev_map_lookup_elem(struct bpf_map *map, 376static inline struct net_device *__dev_map_lookup_elem(struct bpf_map *map,
372 u32 key) 377 u32 key)
373{ 378{
diff --git a/include/linux/netfilter_bridge/ebtables.h b/include/linux/netfilter_bridge/ebtables.h
index 2c2a5514b0df..528b24c78308 100644
--- a/include/linux/netfilter_bridge/ebtables.h
+++ b/include/linux/netfilter_bridge/ebtables.h
@@ -108,9 +108,10 @@ struct ebt_table {
108 108
109#define EBT_ALIGN(s) (((s) + (__alignof__(struct _xt_align)-1)) & \ 109#define EBT_ALIGN(s) (((s) + (__alignof__(struct _xt_align)-1)) & \
110 ~(__alignof__(struct _xt_align)-1)) 110 ~(__alignof__(struct _xt_align)-1))
111extern struct ebt_table *ebt_register_table(struct net *net, 111extern int ebt_register_table(struct net *net,
112 const struct ebt_table *table, 112 const struct ebt_table *table,
113 const struct nf_hook_ops *); 113 const struct nf_hook_ops *ops,
114 struct ebt_table **res);
114extern void ebt_unregister_table(struct net *net, struct ebt_table *table, 115extern void ebt_unregister_table(struct net *net, struct ebt_table *table,
115 const struct nf_hook_ops *); 116 const struct nf_hook_ops *);
116extern unsigned int ebt_do_table(struct sk_buff *skb, 117extern unsigned int ebt_do_table(struct sk_buff *skb,
diff --git a/include/sound/seq_virmidi.h b/include/sound/seq_virmidi.h
index a03acd0d398a..695257ae64ac 100644
--- a/include/sound/seq_virmidi.h
+++ b/include/sound/seq_virmidi.h
@@ -60,6 +60,7 @@ struct snd_virmidi_dev {
60 int port; /* created/attached port */ 60 int port; /* created/attached port */
61 unsigned int flags; /* SNDRV_VIRMIDI_* */ 61 unsigned int flags; /* SNDRV_VIRMIDI_* */
62 rwlock_t filelist_lock; 62 rwlock_t filelist_lock;
63 struct rw_semaphore filelist_sem;
63 struct list_head filelist; 64 struct list_head filelist;
64}; 65};
65 66
diff --git a/include/uapi/linux/netfilter/xt_bpf.h b/include/uapi/linux/netfilter/xt_bpf.h
index b97725af2ac0..da161b56c79e 100644
--- a/include/uapi/linux/netfilter/xt_bpf.h
+++ b/include/uapi/linux/netfilter/xt_bpf.h
@@ -23,6 +23,7 @@ enum xt_bpf_modes {
23 XT_BPF_MODE_FD_PINNED, 23 XT_BPF_MODE_FD_PINNED,
24 XT_BPF_MODE_FD_ELF, 24 XT_BPF_MODE_FD_ELF,
25}; 25};
26#define XT_BPF_MODE_PATH_PINNED XT_BPF_MODE_FD_PINNED
26 27
27struct xt_bpf_info_v1 { 28struct xt_bpf_info_v1 {
28 __u16 mode; 29 __u16 mode;
diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index e833ed914358..be1dde967208 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -363,6 +363,7 @@ out:
363 putname(pname); 363 putname(pname);
364 return ret; 364 return ret;
365} 365}
366EXPORT_SYMBOL_GPL(bpf_obj_get_user);
366 367
367static void bpf_evict_inode(struct inode *inode) 368static void bpf_evict_inode(struct inode *inode)
368{ 369{
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index b914fbe1383e..8b8d6ba39e23 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -653,6 +653,10 @@ static void mark_reg_read(const struct bpf_verifier_state *state, u32 regno)
653{ 653{
654 struct bpf_verifier_state *parent = state->parent; 654 struct bpf_verifier_state *parent = state->parent;
655 655
656 if (regno == BPF_REG_FP)
657 /* We don't need to worry about FP liveness because it's read-only */
658 return;
659
656 while (parent) { 660 while (parent) {
657 /* if read wasn't screened by an earlier write ... */ 661 /* if read wasn't screened by an earlier write ... */
658 if (state->regs[regno].live & REG_LIVE_WRITTEN) 662 if (state->regs[regno].live & REG_LIVE_WRITTEN)
@@ -2345,6 +2349,7 @@ static int check_alu_op(struct bpf_verifier_env *env, struct bpf_insn *insn)
2345 * copy register state to dest reg 2349 * copy register state to dest reg
2346 */ 2350 */
2347 regs[insn->dst_reg] = regs[insn->src_reg]; 2351 regs[insn->dst_reg] = regs[insn->src_reg];
2352 regs[insn->dst_reg].live |= REG_LIVE_WRITTEN;
2348 } else { 2353 } else {
2349 /* R1 = (u32) R2 */ 2354 /* R1 = (u32) R2 */
2350 if (is_pointer_value(env, insn->src_reg)) { 2355 if (is_pointer_value(env, insn->src_reg)) {
diff --git a/kernel/exit.c b/kernel/exit.c
index f2cd53e92147..cf28528842bc 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -1610,6 +1610,9 @@ SYSCALL_DEFINE5(waitid, int, which, pid_t, upid, struct siginfo __user *,
1610 if (!infop) 1610 if (!infop)
1611 return err; 1611 return err;
1612 1612
1613 if (!access_ok(VERIFY_WRITE, infop, sizeof(*infop)))
1614 goto Efault;
1615
1613 user_access_begin(); 1616 user_access_begin();
1614 unsafe_put_user(signo, &infop->si_signo, Efault); 1617 unsafe_put_user(signo, &infop->si_signo, Efault);
1615 unsafe_put_user(0, &infop->si_errno, Efault); 1618 unsafe_put_user(0, &infop->si_errno, Efault);
@@ -1735,6 +1738,9 @@ COMPAT_SYSCALL_DEFINE5(waitid,
1735 if (!infop) 1738 if (!infop)
1736 return err; 1739 return err;
1737 1740
1741 if (!access_ok(VERIFY_WRITE, infop, sizeof(*infop)))
1742 goto Efault;
1743
1738 user_access_begin(); 1744 user_access_begin();
1739 unsafe_put_user(signo, &infop->si_signo, Efault); 1745 unsafe_put_user(signo, &infop->si_signo, Efault);
1740 unsafe_put_user(0, &infop->si_errno, Efault); 1746 unsafe_put_user(0, &infop->si_errno, Efault);
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index b9628e43c78f..bf8c8fd72589 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -830,6 +830,41 @@ int klp_register_patch(struct klp_patch *patch)
830} 830}
831EXPORT_SYMBOL_GPL(klp_register_patch); 831EXPORT_SYMBOL_GPL(klp_register_patch);
832 832
833/*
834 * Remove parts of patches that touch a given kernel module. The list of
835 * patches processed might be limited. When limit is NULL, all patches
836 * will be handled.
837 */
838static void klp_cleanup_module_patches_limited(struct module *mod,
839 struct klp_patch *limit)
840{
841 struct klp_patch *patch;
842 struct klp_object *obj;
843
844 list_for_each_entry(patch, &klp_patches, list) {
845 if (patch == limit)
846 break;
847
848 klp_for_each_object(patch, obj) {
849 if (!klp_is_module(obj) || strcmp(obj->name, mod->name))
850 continue;
851
852 /*
853 * Only unpatch the module if the patch is enabled or
854 * is in transition.
855 */
856 if (patch->enabled || patch == klp_transition_patch) {
857 pr_notice("reverting patch '%s' on unloading module '%s'\n",
858 patch->mod->name, obj->mod->name);
859 klp_unpatch_object(obj);
860 }
861
862 klp_free_object_loaded(obj);
863 break;
864 }
865 }
866}
867
833int klp_module_coming(struct module *mod) 868int klp_module_coming(struct module *mod)
834{ 869{
835 int ret; 870 int ret;
@@ -894,7 +929,7 @@ err:
894 pr_warn("patch '%s' failed for module '%s', refusing to load module '%s'\n", 929 pr_warn("patch '%s' failed for module '%s', refusing to load module '%s'\n",
895 patch->mod->name, obj->mod->name, obj->mod->name); 930 patch->mod->name, obj->mod->name, obj->mod->name);
896 mod->klp_alive = false; 931 mod->klp_alive = false;
897 klp_free_object_loaded(obj); 932 klp_cleanup_module_patches_limited(mod, patch);
898 mutex_unlock(&klp_mutex); 933 mutex_unlock(&klp_mutex);
899 934
900 return ret; 935 return ret;
@@ -902,9 +937,6 @@ err:
902 937
903void klp_module_going(struct module *mod) 938void klp_module_going(struct module *mod)
904{ 939{
905 struct klp_patch *patch;
906 struct klp_object *obj;
907
908 if (WARN_ON(mod->state != MODULE_STATE_GOING && 940 if (WARN_ON(mod->state != MODULE_STATE_GOING &&
909 mod->state != MODULE_STATE_COMING)) 941 mod->state != MODULE_STATE_COMING))
910 return; 942 return;
@@ -917,25 +949,7 @@ void klp_module_going(struct module *mod)
917 */ 949 */
918 mod->klp_alive = false; 950 mod->klp_alive = false;
919 951
920 list_for_each_entry(patch, &klp_patches, list) { 952 klp_cleanup_module_patches_limited(mod, NULL);
921 klp_for_each_object(patch, obj) {
922 if (!klp_is_module(obj) || strcmp(obj->name, mod->name))
923 continue;
924
925 /*
926 * Only unpatch the module if the patch is enabled or
927 * is in transition.
928 */
929 if (patch->enabled || patch == klp_transition_patch) {
930 pr_notice("reverting patch '%s' on unloading module '%s'\n",
931 patch->mod->name, obj->mod->name);
932 klp_unpatch_object(obj);
933 }
934
935 klp_free_object_loaded(obj);
936 break;
937 }
938 }
939 953
940 mutex_unlock(&klp_mutex); 954 mutex_unlock(&klp_mutex);
941} 955}
diff --git a/kernel/seccomp.c b/kernel/seccomp.c
index bb3a38005b9c..0ae832e13b97 100644
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -473,7 +473,7 @@ static long seccomp_attach_filter(unsigned int flags,
473 return 0; 473 return 0;
474} 474}
475 475
476void __get_seccomp_filter(struct seccomp_filter *filter) 476static void __get_seccomp_filter(struct seccomp_filter *filter)
477{ 477{
478 /* Reference count is bounded by the number of total processes. */ 478 /* Reference count is bounded by the number of total processes. */
479 refcount_inc(&filter->usage); 479 refcount_inc(&filter->usage);
diff --git a/net/bridge/netfilter/ebtable_broute.c b/net/bridge/netfilter/ebtable_broute.c
index 2585b100ebbb..276b60262981 100644
--- a/net/bridge/netfilter/ebtable_broute.c
+++ b/net/bridge/netfilter/ebtable_broute.c
@@ -65,8 +65,8 @@ static int ebt_broute(struct sk_buff *skb)
65 65
66static int __net_init broute_net_init(struct net *net) 66static int __net_init broute_net_init(struct net *net)
67{ 67{
68 net->xt.broute_table = ebt_register_table(net, &broute_table, NULL); 68 return ebt_register_table(net, &broute_table, NULL,
69 return PTR_ERR_OR_ZERO(net->xt.broute_table); 69 &net->xt.broute_table);
70} 70}
71 71
72static void __net_exit broute_net_exit(struct net *net) 72static void __net_exit broute_net_exit(struct net *net)
diff --git a/net/bridge/netfilter/ebtable_filter.c b/net/bridge/netfilter/ebtable_filter.c
index 45a00dbdbcad..c41da5fac84f 100644
--- a/net/bridge/netfilter/ebtable_filter.c
+++ b/net/bridge/netfilter/ebtable_filter.c
@@ -93,8 +93,8 @@ static const struct nf_hook_ops ebt_ops_filter[] = {
93 93
94static int __net_init frame_filter_net_init(struct net *net) 94static int __net_init frame_filter_net_init(struct net *net)
95{ 95{
96 net->xt.frame_filter = ebt_register_table(net, &frame_filter, ebt_ops_filter); 96 return ebt_register_table(net, &frame_filter, ebt_ops_filter,
97 return PTR_ERR_OR_ZERO(net->xt.frame_filter); 97 &net->xt.frame_filter);
98} 98}
99 99
100static void __net_exit frame_filter_net_exit(struct net *net) 100static void __net_exit frame_filter_net_exit(struct net *net)
diff --git a/net/bridge/netfilter/ebtable_nat.c b/net/bridge/netfilter/ebtable_nat.c
index 57cd5bb154e7..08df7406ecb3 100644
--- a/net/bridge/netfilter/ebtable_nat.c
+++ b/net/bridge/netfilter/ebtable_nat.c
@@ -93,8 +93,8 @@ static const struct nf_hook_ops ebt_ops_nat[] = {
93 93
94static int __net_init frame_nat_net_init(struct net *net) 94static int __net_init frame_nat_net_init(struct net *net)
95{ 95{
96 net->xt.frame_nat = ebt_register_table(net, &frame_nat, ebt_ops_nat); 96 return ebt_register_table(net, &frame_nat, ebt_ops_nat,
97 return PTR_ERR_OR_ZERO(net->xt.frame_nat); 97 &net->xt.frame_nat);
98} 98}
99 99
100static void __net_exit frame_nat_net_exit(struct net *net) 100static void __net_exit frame_nat_net_exit(struct net *net)
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 83951f978445..3b3dcf719e07 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -1169,9 +1169,8 @@ static void __ebt_unregister_table(struct net *net, struct ebt_table *table)
1169 kfree(table); 1169 kfree(table);
1170} 1170}
1171 1171
1172struct ebt_table * 1172int ebt_register_table(struct net *net, const struct ebt_table *input_table,
1173ebt_register_table(struct net *net, const struct ebt_table *input_table, 1173 const struct nf_hook_ops *ops, struct ebt_table **res)
1174 const struct nf_hook_ops *ops)
1175{ 1174{
1176 struct ebt_table_info *newinfo; 1175 struct ebt_table_info *newinfo;
1177 struct ebt_table *t, *table; 1176 struct ebt_table *t, *table;
@@ -1183,7 +1182,7 @@ ebt_register_table(struct net *net, const struct ebt_table *input_table,
1183 repl->entries == NULL || repl->entries_size == 0 || 1182 repl->entries == NULL || repl->entries_size == 0 ||
1184 repl->counters != NULL || input_table->private != NULL) { 1183 repl->counters != NULL || input_table->private != NULL) {
1185 BUGPRINT("Bad table data for ebt_register_table!!!\n"); 1184 BUGPRINT("Bad table data for ebt_register_table!!!\n");
1186 return ERR_PTR(-EINVAL); 1185 return -EINVAL;
1187 } 1186 }
1188 1187
1189 /* Don't add one table to multiple lists. */ 1188 /* Don't add one table to multiple lists. */
@@ -1252,16 +1251,18 @@ ebt_register_table(struct net *net, const struct ebt_table *input_table,
1252 list_add(&table->list, &net->xt.tables[NFPROTO_BRIDGE]); 1251 list_add(&table->list, &net->xt.tables[NFPROTO_BRIDGE]);
1253 mutex_unlock(&ebt_mutex); 1252 mutex_unlock(&ebt_mutex);
1254 1253
1254 WRITE_ONCE(*res, table);
1255
1255 if (!ops) 1256 if (!ops)
1256 return table; 1257 return 0;
1257 1258
1258 ret = nf_register_net_hooks(net, ops, hweight32(table->valid_hooks)); 1259 ret = nf_register_net_hooks(net, ops, hweight32(table->valid_hooks));
1259 if (ret) { 1260 if (ret) {
1260 __ebt_unregister_table(net, table); 1261 __ebt_unregister_table(net, table);
1261 return ERR_PTR(ret); 1262 *res = NULL;
1262 } 1263 }
1263 1264
1264 return table; 1265 return ret;
1265free_unlock: 1266free_unlock:
1266 mutex_unlock(&ebt_mutex); 1267 mutex_unlock(&ebt_mutex);
1267free_chainstack: 1268free_chainstack:
@@ -1276,7 +1277,7 @@ free_newinfo:
1276free_table: 1277free_table:
1277 kfree(table); 1278 kfree(table);
1278out: 1279out:
1279 return ERR_PTR(ret); 1280 return ret;
1280} 1281}
1281 1282
1282void ebt_unregister_table(struct net *net, struct ebt_table *table, 1283void ebt_unregister_table(struct net *net, struct ebt_table *table,
diff --git a/net/ipv4/gre_offload.c b/net/ipv4/gre_offload.c
index 416bb304a281..1859c473b21a 100644
--- a/net/ipv4/gre_offload.c
+++ b/net/ipv4/gre_offload.c
@@ -86,7 +86,7 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
86 greh = (struct gre_base_hdr *)skb_transport_header(skb); 86 greh = (struct gre_base_hdr *)skb_transport_header(skb);
87 pcsum = (__sum16 *)(greh + 1); 87 pcsum = (__sum16 *)(greh + 1);
88 88
89 if (gso_partial) { 89 if (gso_partial && skb_is_gso(skb)) {
90 unsigned int partial_adj; 90 unsigned int partial_adj;
91 91
92 /* Adjust checksum to account for the fact that 92 /* Adjust checksum to account for the fact that
diff --git a/net/ipv4/netfilter/ipt_SYNPROXY.c b/net/ipv4/netfilter/ipt_SYNPROXY.c
index 811689e523c3..f75fc6b53115 100644
--- a/net/ipv4/netfilter/ipt_SYNPROXY.c
+++ b/net/ipv4/netfilter/ipt_SYNPROXY.c
@@ -330,7 +330,8 @@ static unsigned int ipv4_synproxy_hook(void *priv,
330 if (synproxy == NULL) 330 if (synproxy == NULL)
331 return NF_ACCEPT; 331 return NF_ACCEPT;
332 332
333 if (nf_is_loopback_packet(skb)) 333 if (nf_is_loopback_packet(skb) ||
334 ip_hdr(skb)->protocol != IPPROTO_TCP)
334 return NF_ACCEPT; 335 return NF_ACCEPT;
335 336
336 thoff = ip_hdrlen(skb); 337 thoff = ip_hdrlen(skb);
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index ac6fde5d45f1..3d9f1c2f81c5 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2513,7 +2513,7 @@ struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_or
2513 struct rtable *ort = (struct rtable *) dst_orig; 2513 struct rtable *ort = (struct rtable *) dst_orig;
2514 struct rtable *rt; 2514 struct rtable *rt;
2515 2515
2516 rt = dst_alloc(&ipv4_dst_blackhole_ops, NULL, 1, DST_OBSOLETE_NONE, 0); 2516 rt = dst_alloc(&ipv4_dst_blackhole_ops, NULL, 1, DST_OBSOLETE_DEAD, 0);
2517 if (rt) { 2517 if (rt) {
2518 struct dst_entry *new = &rt->dst; 2518 struct dst_entry *new = &rt->dst;
2519 2519
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 5676237d2b0f..e45177ceb0ee 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -2240,20 +2240,16 @@ int udp_v4_early_demux(struct sk_buff *skb)
2240 iph = ip_hdr(skb); 2240 iph = ip_hdr(skb);
2241 uh = udp_hdr(skb); 2241 uh = udp_hdr(skb);
2242 2242
2243 if (skb->pkt_type == PACKET_BROADCAST || 2243 if (skb->pkt_type == PACKET_MULTICAST) {
2244 skb->pkt_type == PACKET_MULTICAST) {
2245 in_dev = __in_dev_get_rcu(skb->dev); 2244 in_dev = __in_dev_get_rcu(skb->dev);
2246 2245
2247 if (!in_dev) 2246 if (!in_dev)
2248 return 0; 2247 return 0;
2249 2248
2250 /* we are supposed to accept bcast packets */ 2249 ours = ip_check_mc_rcu(in_dev, iph->daddr, iph->saddr,
2251 if (skb->pkt_type == PACKET_MULTICAST) { 2250 iph->protocol);
2252 ours = ip_check_mc_rcu(in_dev, iph->daddr, iph->saddr, 2251 if (!ours)
2253 iph->protocol); 2252 return 0;
2254 if (!ours)
2255 return 0;
2256 }
2257 2253
2258 sk = __udp4_lib_mcast_demux_lookup(net, uh->dest, iph->daddr, 2254 sk = __udp4_lib_mcast_demux_lookup(net, uh->dest, iph->daddr,
2259 uh->source, iph->saddr, 2255 uh->source, iph->saddr,
diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index 97658bfc1b58..e360d55be555 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -120,7 +120,7 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
120 * will be using a length value equal to only one MSS sized 120 * will be using a length value equal to only one MSS sized
121 * segment instead of the entire frame. 121 * segment instead of the entire frame.
122 */ 122 */
123 if (gso_partial) { 123 if (gso_partial && skb_is_gso(skb)) {
124 uh->len = htons(skb_shinfo(skb)->gso_size + 124 uh->len = htons(skb_shinfo(skb)->gso_size +
125 SKB_GSO_CB(skb)->data_offset + 125 SKB_GSO_CB(skb)->data_offset +
126 skb->head - (unsigned char *)uh); 126 skb->head - (unsigned char *)uh);
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 96861c702c06..4a96ebbf8eda 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -3820,8 +3820,8 @@ static void addrconf_dad_begin(struct inet6_ifaddr *ifp)
3820 goto out; 3820 goto out;
3821 3821
3822 if (dev->flags&(IFF_NOARP|IFF_LOOPBACK) || 3822 if (dev->flags&(IFF_NOARP|IFF_LOOPBACK) ||
3823 dev_net(dev)->ipv6.devconf_all->accept_dad < 1 || 3823 (dev_net(dev)->ipv6.devconf_all->accept_dad < 1 &&
3824 idev->cnf.accept_dad < 1 || 3824 idev->cnf.accept_dad < 1) ||
3825 !(ifp->flags&IFA_F_TENTATIVE) || 3825 !(ifp->flags&IFA_F_TENTATIVE) ||
3826 ifp->flags & IFA_F_NODAD) { 3826 ifp->flags & IFA_F_NODAD) {
3827 bump_id = ifp->flags & IFA_F_TENTATIVE; 3827 bump_id = ifp->flags & IFA_F_TENTATIVE;
diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c
index cdb3728faca7..4a87f9428ca5 100644
--- a/net/ipv6/ip6_offload.c
+++ b/net/ipv6/ip6_offload.c
@@ -105,7 +105,7 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,
105 105
106 for (skb = segs; skb; skb = skb->next) { 106 for (skb = segs; skb; skb = skb->next) {
107 ipv6h = (struct ipv6hdr *)(skb_mac_header(skb) + nhoff); 107 ipv6h = (struct ipv6hdr *)(skb_mac_header(skb) + nhoff);
108 if (gso_partial) 108 if (gso_partial && skb_is_gso(skb))
109 payload_len = skb_shinfo(skb)->gso_size + 109 payload_len = skb_shinfo(skb)->gso_size +
110 SKB_GSO_CB(skb)->data_offset + 110 SKB_GSO_CB(skb)->data_offset +
111 skb->head - (unsigned char *)(ipv6h + 1); 111 skb->head - (unsigned char *)(ipv6h + 1);
diff --git a/net/ipv6/netfilter/ip6t_SYNPROXY.c b/net/ipv6/netfilter/ip6t_SYNPROXY.c
index a5cd43d75393..437af8c95277 100644
--- a/net/ipv6/netfilter/ip6t_SYNPROXY.c
+++ b/net/ipv6/netfilter/ip6t_SYNPROXY.c
@@ -353,7 +353,7 @@ static unsigned int ipv6_synproxy_hook(void *priv,
353 nexthdr = ipv6_hdr(skb)->nexthdr; 353 nexthdr = ipv6_hdr(skb)->nexthdr;
354 thoff = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &nexthdr, 354 thoff = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &nexthdr,
355 &frag_off); 355 &frag_off);
356 if (thoff < 0) 356 if (thoff < 0 || nexthdr != IPPROTO_TCP)
357 return NF_ACCEPT; 357 return NF_ACCEPT;
358 358
359 th = skb_header_pointer(skb, thoff, sizeof(_th), &_th); 359 th = skb_header_pointer(skb, thoff, sizeof(_th), &_th);
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 26cc9f483b6d..a96d5b385d8f 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1325,7 +1325,7 @@ struct dst_entry *ip6_blackhole_route(struct net *net, struct dst_entry *dst_ori
1325 struct dst_entry *new = NULL; 1325 struct dst_entry *new = NULL;
1326 1326
1327 rt = dst_alloc(&ip6_dst_blackhole_ops, loopback_dev, 1, 1327 rt = dst_alloc(&ip6_dst_blackhole_ops, loopback_dev, 1,
1328 DST_OBSOLETE_NONE, 0); 1328 DST_OBSOLETE_DEAD, 0);
1329 if (rt) { 1329 if (rt) {
1330 rt6_info_init(rt); 1330 rt6_info_init(rt);
1331 1331
diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
index e495b5e484b1..cf84f7b37cd9 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -1191,14 +1191,17 @@ static int ip_set_swap(struct net *net, struct sock *ctnl, struct sk_buff *skb,
1191 from->family == to->family)) 1191 from->family == to->family))
1192 return -IPSET_ERR_TYPE_MISMATCH; 1192 return -IPSET_ERR_TYPE_MISMATCH;
1193 1193
1194 if (from->ref_netlink || to->ref_netlink) 1194 write_lock_bh(&ip_set_ref_lock);
1195
1196 if (from->ref_netlink || to->ref_netlink) {
1197 write_unlock_bh(&ip_set_ref_lock);
1195 return -EBUSY; 1198 return -EBUSY;
1199 }
1196 1200
1197 strncpy(from_name, from->name, IPSET_MAXNAMELEN); 1201 strncpy(from_name, from->name, IPSET_MAXNAMELEN);
1198 strncpy(from->name, to->name, IPSET_MAXNAMELEN); 1202 strncpy(from->name, to->name, IPSET_MAXNAMELEN);
1199 strncpy(to->name, from_name, IPSET_MAXNAMELEN); 1203 strncpy(to->name, from_name, IPSET_MAXNAMELEN);
1200 1204
1201 write_lock_bh(&ip_set_ref_lock);
1202 swap(from->ref, to->ref); 1205 swap(from->ref, to->ref);
1203 ip_set(inst, from_id) = to; 1206 ip_set(inst, from_id) = to;
1204 ip_set(inst, to_id) = from; 1207 ip_set(inst, to_id) = from;
@@ -2072,25 +2075,28 @@ static struct pernet_operations ip_set_net_ops = {
2072static int __init 2075static int __init
2073ip_set_init(void) 2076ip_set_init(void)
2074{ 2077{
2075 int ret = nfnetlink_subsys_register(&ip_set_netlink_subsys); 2078 int ret = register_pernet_subsys(&ip_set_net_ops);
2079
2080 if (ret) {
2081 pr_err("ip_set: cannot register pernet_subsys.\n");
2082 return ret;
2083 }
2076 2084
2085 ret = nfnetlink_subsys_register(&ip_set_netlink_subsys);
2077 if (ret != 0) { 2086 if (ret != 0) {
2078 pr_err("ip_set: cannot register with nfnetlink.\n"); 2087 pr_err("ip_set: cannot register with nfnetlink.\n");
2088 unregister_pernet_subsys(&ip_set_net_ops);
2079 return ret; 2089 return ret;
2080 } 2090 }
2091
2081 ret = nf_register_sockopt(&so_set); 2092 ret = nf_register_sockopt(&so_set);
2082 if (ret != 0) { 2093 if (ret != 0) {
2083 pr_err("SO_SET registry failed: %d\n", ret); 2094 pr_err("SO_SET registry failed: %d\n", ret);
2084 nfnetlink_subsys_unregister(&ip_set_netlink_subsys); 2095 nfnetlink_subsys_unregister(&ip_set_netlink_subsys);
2096 unregister_pernet_subsys(&ip_set_net_ops);
2085 return ret; 2097 return ret;
2086 } 2098 }
2087 ret = register_pernet_subsys(&ip_set_net_ops); 2099
2088 if (ret) {
2089 pr_err("ip_set: cannot register pernet_subsys.\n");
2090 nf_unregister_sockopt(&so_set);
2091 nfnetlink_subsys_unregister(&ip_set_netlink_subsys);
2092 return ret;
2093 }
2094 pr_info("ip_set: protocol %u\n", IPSET_PROTOCOL); 2100 pr_info("ip_set: protocol %u\n", IPSET_PROTOCOL);
2095 return 0; 2101 return 0;
2096} 2102}
@@ -2098,9 +2104,10 @@ ip_set_init(void)
2098static void __exit 2104static void __exit
2099ip_set_fini(void) 2105ip_set_fini(void)
2100{ 2106{
2101 unregister_pernet_subsys(&ip_set_net_ops);
2102 nf_unregister_sockopt(&so_set); 2107 nf_unregister_sockopt(&so_set);
2103 nfnetlink_subsys_unregister(&ip_set_netlink_subsys); 2108 nfnetlink_subsys_unregister(&ip_set_netlink_subsys);
2109
2110 unregister_pernet_subsys(&ip_set_net_ops);
2104 pr_debug("these are the famous last words\n"); 2111 pr_debug("these are the famous last words\n");
2105} 2112}
2106 2113
diff --git a/net/netfilter/ipset/ip_set_hash_ip.c b/net/netfilter/ipset/ip_set_hash_ip.c
index 20bfbd315f61..613eb212cb48 100644
--- a/net/netfilter/ipset/ip_set_hash_ip.c
+++ b/net/netfilter/ipset/ip_set_hash_ip.c
@@ -123,13 +123,12 @@ hash_ip4_uadt(struct ip_set *set, struct nlattr *tb[],
123 return ret; 123 return ret;
124 124
125 ip &= ip_set_hostmask(h->netmask); 125 ip &= ip_set_hostmask(h->netmask);
126 e.ip = htonl(ip);
127 if (e.ip == 0)
128 return -IPSET_ERR_HASH_ELEM;
126 129
127 if (adt == IPSET_TEST) { 130 if (adt == IPSET_TEST)
128 e.ip = htonl(ip);
129 if (e.ip == 0)
130 return -IPSET_ERR_HASH_ELEM;
131 return adtfn(set, &e, &ext, &ext, flags); 131 return adtfn(set, &e, &ext, &ext, flags);
132 }
133 132
134 ip_to = ip; 133 ip_to = ip;
135 if (tb[IPSET_ATTR_IP_TO]) { 134 if (tb[IPSET_ATTR_IP_TO]) {
@@ -148,17 +147,20 @@ hash_ip4_uadt(struct ip_set *set, struct nlattr *tb[],
148 147
149 hosts = h->netmask == 32 ? 1 : 2 << (32 - h->netmask - 1); 148 hosts = h->netmask == 32 ? 1 : 2 << (32 - h->netmask - 1);
150 149
151 if (retried) 150 if (retried) {
152 ip = ntohl(h->next.ip); 151 ip = ntohl(h->next.ip);
153 for (; !before(ip_to, ip); ip += hosts) {
154 e.ip = htonl(ip); 152 e.ip = htonl(ip);
155 if (e.ip == 0) 153 }
156 return -IPSET_ERR_HASH_ELEM; 154 for (; ip <= ip_to;) {
157 ret = adtfn(set, &e, &ext, &ext, flags); 155 ret = adtfn(set, &e, &ext, &ext, flags);
158
159 if (ret && !ip_set_eexist(ret, flags)) 156 if (ret && !ip_set_eexist(ret, flags))
160 return ret; 157 return ret;
161 158
159 ip += hosts;
160 e.ip = htonl(ip);
161 if (e.ip == 0)
162 return 0;
163
162 ret = 0; 164 ret = 0;
163 } 165 }
164 return ret; 166 return ret;
diff --git a/net/netfilter/ipset/ip_set_hash_ipmark.c b/net/netfilter/ipset/ip_set_hash_ipmark.c
index b64cf14e8352..f3ba8348cf9d 100644
--- a/net/netfilter/ipset/ip_set_hash_ipmark.c
+++ b/net/netfilter/ipset/ip_set_hash_ipmark.c
@@ -149,7 +149,7 @@ hash_ipmark4_uadt(struct ip_set *set, struct nlattr *tb[],
149 149
150 if (retried) 150 if (retried)
151 ip = ntohl(h->next.ip); 151 ip = ntohl(h->next.ip);
152 for (; !before(ip_to, ip); ip++) { 152 for (; ip <= ip_to; ip++) {
153 e.ip = htonl(ip); 153 e.ip = htonl(ip);
154 ret = adtfn(set, &e, &ext, &ext, flags); 154 ret = adtfn(set, &e, &ext, &ext, flags);
155 155
diff --git a/net/netfilter/ipset/ip_set_hash_ipport.c b/net/netfilter/ipset/ip_set_hash_ipport.c
index f438740e6c6a..ddb8039ec1d2 100644
--- a/net/netfilter/ipset/ip_set_hash_ipport.c
+++ b/net/netfilter/ipset/ip_set_hash_ipport.c
@@ -178,7 +178,7 @@ hash_ipport4_uadt(struct ip_set *set, struct nlattr *tb[],
178 178
179 if (retried) 179 if (retried)
180 ip = ntohl(h->next.ip); 180 ip = ntohl(h->next.ip);
181 for (; !before(ip_to, ip); ip++) { 181 for (; ip <= ip_to; ip++) {
182 p = retried && ip == ntohl(h->next.ip) ? ntohs(h->next.port) 182 p = retried && ip == ntohl(h->next.ip) ? ntohs(h->next.port)
183 : port; 183 : port;
184 for (; p <= port_to; p++) { 184 for (; p <= port_to; p++) {
diff --git a/net/netfilter/ipset/ip_set_hash_ipportip.c b/net/netfilter/ipset/ip_set_hash_ipportip.c
index 6215fb898c50..a7f4d7a85420 100644
--- a/net/netfilter/ipset/ip_set_hash_ipportip.c
+++ b/net/netfilter/ipset/ip_set_hash_ipportip.c
@@ -185,7 +185,7 @@ hash_ipportip4_uadt(struct ip_set *set, struct nlattr *tb[],
185 185
186 if (retried) 186 if (retried)
187 ip = ntohl(h->next.ip); 187 ip = ntohl(h->next.ip);
188 for (; !before(ip_to, ip); ip++) { 188 for (; ip <= ip_to; ip++) {
189 p = retried && ip == ntohl(h->next.ip) ? ntohs(h->next.port) 189 p = retried && ip == ntohl(h->next.ip) ? ntohs(h->next.port)
190 : port; 190 : port;
191 for (; p <= port_to; p++) { 191 for (; p <= port_to; p++) {
diff --git a/net/netfilter/ipset/ip_set_hash_ipportnet.c b/net/netfilter/ipset/ip_set_hash_ipportnet.c
index 5ab1b99a53c2..a2f19b9906e9 100644
--- a/net/netfilter/ipset/ip_set_hash_ipportnet.c
+++ b/net/netfilter/ipset/ip_set_hash_ipportnet.c
@@ -271,7 +271,7 @@ hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
271 271
272 if (retried) 272 if (retried)
273 ip = ntohl(h->next.ip); 273 ip = ntohl(h->next.ip);
274 for (; !before(ip_to, ip); ip++) { 274 for (; ip <= ip_to; ip++) {
275 e.ip = htonl(ip); 275 e.ip = htonl(ip);
276 p = retried && ip == ntohl(h->next.ip) ? ntohs(h->next.port) 276 p = retried && ip == ntohl(h->next.ip) ? ntohs(h->next.port)
277 : port; 277 : port;
@@ -281,7 +281,7 @@ hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
281 ip == ntohl(h->next.ip) && 281 ip == ntohl(h->next.ip) &&
282 p == ntohs(h->next.port) 282 p == ntohs(h->next.port)
283 ? ntohl(h->next.ip2) : ip2_from; 283 ? ntohl(h->next.ip2) : ip2_from;
284 while (!after(ip2, ip2_to)) { 284 while (ip2 <= ip2_to) {
285 e.ip2 = htonl(ip2); 285 e.ip2 = htonl(ip2);
286 ip2_last = ip_set_range_to_cidr(ip2, ip2_to, 286 ip2_last = ip_set_range_to_cidr(ip2, ip2_to,
287 &cidr); 287 &cidr);
diff --git a/net/netfilter/ipset/ip_set_hash_net.c b/net/netfilter/ipset/ip_set_hash_net.c
index 5d9e895452e7..1c67a1761e45 100644
--- a/net/netfilter/ipset/ip_set_hash_net.c
+++ b/net/netfilter/ipset/ip_set_hash_net.c
@@ -193,7 +193,7 @@ hash_net4_uadt(struct ip_set *set, struct nlattr *tb[],
193 } 193 }
194 if (retried) 194 if (retried)
195 ip = ntohl(h->next.ip); 195 ip = ntohl(h->next.ip);
196 while (!after(ip, ip_to)) { 196 while (ip <= ip_to) {
197 e.ip = htonl(ip); 197 e.ip = htonl(ip);
198 last = ip_set_range_to_cidr(ip, ip_to, &e.cidr); 198 last = ip_set_range_to_cidr(ip, ip_to, &e.cidr);
199 ret = adtfn(set, &e, &ext, &ext, flags); 199 ret = adtfn(set, &e, &ext, &ext, flags);
diff --git a/net/netfilter/ipset/ip_set_hash_netiface.c b/net/netfilter/ipset/ip_set_hash_netiface.c
index 44cf11939c91..d417074f1c1a 100644
--- a/net/netfilter/ipset/ip_set_hash_netiface.c
+++ b/net/netfilter/ipset/ip_set_hash_netiface.c
@@ -255,7 +255,7 @@ hash_netiface4_uadt(struct ip_set *set, struct nlattr *tb[],
255 255
256 if (retried) 256 if (retried)
257 ip = ntohl(h->next.ip); 257 ip = ntohl(h->next.ip);
258 while (!after(ip, ip_to)) { 258 while (ip <= ip_to) {
259 e.ip = htonl(ip); 259 e.ip = htonl(ip);
260 last = ip_set_range_to_cidr(ip, ip_to, &e.cidr); 260 last = ip_set_range_to_cidr(ip, ip_to, &e.cidr);
261 ret = adtfn(set, &e, &ext, &ext, flags); 261 ret = adtfn(set, &e, &ext, &ext, flags);
diff --git a/net/netfilter/ipset/ip_set_hash_netnet.c b/net/netfilter/ipset/ip_set_hash_netnet.c
index db614e13b193..7f9ae2e9645b 100644
--- a/net/netfilter/ipset/ip_set_hash_netnet.c
+++ b/net/netfilter/ipset/ip_set_hash_netnet.c
@@ -250,13 +250,13 @@ hash_netnet4_uadt(struct ip_set *set, struct nlattr *tb[],
250 if (retried) 250 if (retried)
251 ip = ntohl(h->next.ip[0]); 251 ip = ntohl(h->next.ip[0]);
252 252
253 while (!after(ip, ip_to)) { 253 while (ip <= ip_to) {
254 e.ip[0] = htonl(ip); 254 e.ip[0] = htonl(ip);
255 last = ip_set_range_to_cidr(ip, ip_to, &e.cidr[0]); 255 last = ip_set_range_to_cidr(ip, ip_to, &e.cidr[0]);
256 ip2 = (retried && 256 ip2 = (retried &&
257 ip == ntohl(h->next.ip[0])) ? ntohl(h->next.ip[1]) 257 ip == ntohl(h->next.ip[0])) ? ntohl(h->next.ip[1])
258 : ip2_from; 258 : ip2_from;
259 while (!after(ip2, ip2_to)) { 259 while (ip2 <= ip2_to) {
260 e.ip[1] = htonl(ip2); 260 e.ip[1] = htonl(ip2);
261 last2 = ip_set_range_to_cidr(ip2, ip2_to, &e.cidr[1]); 261 last2 = ip_set_range_to_cidr(ip2, ip2_to, &e.cidr[1]);
262 ret = adtfn(set, &e, &ext, &ext, flags); 262 ret = adtfn(set, &e, &ext, &ext, flags);
diff --git a/net/netfilter/ipset/ip_set_hash_netport.c b/net/netfilter/ipset/ip_set_hash_netport.c
index 54b64b6cd0cd..e6ef382febe4 100644
--- a/net/netfilter/ipset/ip_set_hash_netport.c
+++ b/net/netfilter/ipset/ip_set_hash_netport.c
@@ -241,7 +241,7 @@ hash_netport4_uadt(struct ip_set *set, struct nlattr *tb[],
241 241
242 if (retried) 242 if (retried)
243 ip = ntohl(h->next.ip); 243 ip = ntohl(h->next.ip);
244 while (!after(ip, ip_to)) { 244 while (ip <= ip_to) {
245 e.ip = htonl(ip); 245 e.ip = htonl(ip);
246 last = ip_set_range_to_cidr(ip, ip_to, &cidr); 246 last = ip_set_range_to_cidr(ip, ip_to, &cidr);
247 e.cidr = cidr - 1; 247 e.cidr = cidr - 1;
diff --git a/net/netfilter/ipset/ip_set_hash_netportnet.c b/net/netfilter/ipset/ip_set_hash_netportnet.c
index aff846960ac4..8602f2595a1a 100644
--- a/net/netfilter/ipset/ip_set_hash_netportnet.c
+++ b/net/netfilter/ipset/ip_set_hash_netportnet.c
@@ -291,7 +291,7 @@ hash_netportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
291 if (retried) 291 if (retried)
292 ip = ntohl(h->next.ip[0]); 292 ip = ntohl(h->next.ip[0]);
293 293
294 while (!after(ip, ip_to)) { 294 while (ip <= ip_to) {
295 e.ip[0] = htonl(ip); 295 e.ip[0] = htonl(ip);
296 ip_last = ip_set_range_to_cidr(ip, ip_to, &e.cidr[0]); 296 ip_last = ip_set_range_to_cidr(ip, ip_to, &e.cidr[0]);
297 p = retried && ip == ntohl(h->next.ip[0]) ? ntohs(h->next.port) 297 p = retried && ip == ntohl(h->next.ip[0]) ? ntohs(h->next.port)
@@ -301,7 +301,7 @@ hash_netportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
301 ip2 = (retried && ip == ntohl(h->next.ip[0]) && 301 ip2 = (retried && ip == ntohl(h->next.ip[0]) &&
302 p == ntohs(h->next.port)) ? ntohl(h->next.ip[1]) 302 p == ntohs(h->next.port)) ? ntohl(h->next.ip[1])
303 : ip2_from; 303 : ip2_from;
304 while (!after(ip2, ip2_to)) { 304 while (ip2 <= ip2_to) {
305 e.ip[1] = htonl(ip2); 305 e.ip[1] = htonl(ip2);
306 ip2_last = ip_set_range_to_cidr(ip2, ip2_to, 306 ip2_last = ip_set_range_to_cidr(ip2, ip2_to,
307 &e.cidr[1]); 307 &e.cidr[1]);
diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
index 90d396814798..4527921b1c3a 100644
--- a/net/netfilter/ipvs/ip_vs_xmit.c
+++ b/net/netfilter/ipvs/ip_vs_xmit.c
@@ -921,6 +921,7 @@ ip_vs_prepare_tunneled_skb(struct sk_buff *skb, int skb_af,
921{ 921{
922 struct sk_buff *new_skb = NULL; 922 struct sk_buff *new_skb = NULL;
923 struct iphdr *old_iph = NULL; 923 struct iphdr *old_iph = NULL;
924 __u8 old_dsfield;
924#ifdef CONFIG_IP_VS_IPV6 925#ifdef CONFIG_IP_VS_IPV6
925 struct ipv6hdr *old_ipv6h = NULL; 926 struct ipv6hdr *old_ipv6h = NULL;
926#endif 927#endif
@@ -945,7 +946,7 @@ ip_vs_prepare_tunneled_skb(struct sk_buff *skb, int skb_af,
945 *payload_len = 946 *payload_len =
946 ntohs(old_ipv6h->payload_len) + 947 ntohs(old_ipv6h->payload_len) +
947 sizeof(*old_ipv6h); 948 sizeof(*old_ipv6h);
948 *dsfield = ipv6_get_dsfield(old_ipv6h); 949 old_dsfield = ipv6_get_dsfield(old_ipv6h);
949 *ttl = old_ipv6h->hop_limit; 950 *ttl = old_ipv6h->hop_limit;
950 if (df) 951 if (df)
951 *df = 0; 952 *df = 0;
@@ -960,12 +961,15 @@ ip_vs_prepare_tunneled_skb(struct sk_buff *skb, int skb_af,
960 961
961 /* fix old IP header checksum */ 962 /* fix old IP header checksum */
962 ip_send_check(old_iph); 963 ip_send_check(old_iph);
963 *dsfield = ipv4_get_dsfield(old_iph); 964 old_dsfield = ipv4_get_dsfield(old_iph);
964 *ttl = old_iph->ttl; 965 *ttl = old_iph->ttl;
965 if (payload_len) 966 if (payload_len)
966 *payload_len = ntohs(old_iph->tot_len); 967 *payload_len = ntohs(old_iph->tot_len);
967 } 968 }
968 969
970 /* Implement full-functionality option for ECN encapsulation */
971 *dsfield = INET_ECN_encapsulate(old_dsfield, old_dsfield);
972
969 return skb; 973 return skb;
970error: 974error:
971 kfree_skb(skb); 975 kfree_skb(skb);
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 929927171426..64e1ee091225 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -1048,7 +1048,7 @@ static int nf_tables_fill_chain_info(struct sk_buff *skb, struct net *net,
1048 if (nla_put_string(skb, NFTA_CHAIN_TYPE, basechain->type->name)) 1048 if (nla_put_string(skb, NFTA_CHAIN_TYPE, basechain->type->name))
1049 goto nla_put_failure; 1049 goto nla_put_failure;
1050 1050
1051 if (nft_dump_stats(skb, nft_base_chain(chain)->stats)) 1051 if (basechain->stats && nft_dump_stats(skb, basechain->stats))
1052 goto nla_put_failure; 1052 goto nla_put_failure;
1053 } 1053 }
1054 1054
@@ -1487,8 +1487,8 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy,
1487 1487
1488 chain2 = nf_tables_chain_lookup(table, nla[NFTA_CHAIN_NAME], 1488 chain2 = nf_tables_chain_lookup(table, nla[NFTA_CHAIN_NAME],
1489 genmask); 1489 genmask);
1490 if (IS_ERR(chain2)) 1490 if (!IS_ERR(chain2))
1491 return PTR_ERR(chain2); 1491 return -EEXIST;
1492 } 1492 }
1493 1493
1494 if (nla[NFTA_CHAIN_COUNTERS]) { 1494 if (nla[NFTA_CHAIN_COUNTERS]) {
@@ -2741,8 +2741,10 @@ cont:
2741 list_for_each_entry(i, &ctx->table->sets, list) { 2741 list_for_each_entry(i, &ctx->table->sets, list) {
2742 if (!nft_is_active_next(ctx->net, i)) 2742 if (!nft_is_active_next(ctx->net, i))
2743 continue; 2743 continue;
2744 if (!strcmp(set->name, i->name)) 2744 if (!strcmp(set->name, i->name)) {
2745 kfree(set->name);
2745 return -ENFILE; 2746 return -ENFILE;
2747 }
2746 } 2748 }
2747 return 0; 2749 return 0;
2748} 2750}
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index c83a3b5e1c6c..d8571f414208 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -892,7 +892,7 @@ void *xt_copy_counters_from_user(const void __user *user, unsigned int len,
892 if (copy_from_user(&compat_tmp, user, sizeof(compat_tmp)) != 0) 892 if (copy_from_user(&compat_tmp, user, sizeof(compat_tmp)) != 0)
893 return ERR_PTR(-EFAULT); 893 return ERR_PTR(-EFAULT);
894 894
895 strlcpy(info->name, compat_tmp.name, sizeof(info->name)); 895 memcpy(info->name, compat_tmp.name, sizeof(info->name) - 1);
896 info->num_counters = compat_tmp.num_counters; 896 info->num_counters = compat_tmp.num_counters;
897 user += sizeof(compat_tmp); 897 user += sizeof(compat_tmp);
898 } else 898 } else
@@ -905,9 +905,9 @@ void *xt_copy_counters_from_user(const void __user *user, unsigned int len,
905 if (copy_from_user(info, user, sizeof(*info)) != 0) 905 if (copy_from_user(info, user, sizeof(*info)) != 0)
906 return ERR_PTR(-EFAULT); 906 return ERR_PTR(-EFAULT);
907 907
908 info->name[sizeof(info->name) - 1] = '\0';
909 user += sizeof(*info); 908 user += sizeof(*info);
910 } 909 }
910 info->name[sizeof(info->name) - 1] = '\0';
911 911
912 size = sizeof(struct xt_counters); 912 size = sizeof(struct xt_counters);
913 size *= info->num_counters; 913 size *= info->num_counters;
diff --git a/net/netfilter/xt_bpf.c b/net/netfilter/xt_bpf.c
index 38986a95216c..29123934887b 100644
--- a/net/netfilter/xt_bpf.c
+++ b/net/netfilter/xt_bpf.c
@@ -8,6 +8,7 @@
8 */ 8 */
9 9
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/syscalls.h>
11#include <linux/skbuff.h> 12#include <linux/skbuff.h>
12#include <linux/filter.h> 13#include <linux/filter.h>
13#include <linux/bpf.h> 14#include <linux/bpf.h>
@@ -49,6 +50,22 @@ static int __bpf_mt_check_fd(int fd, struct bpf_prog **ret)
49 return 0; 50 return 0;
50} 51}
51 52
53static int __bpf_mt_check_path(const char *path, struct bpf_prog **ret)
54{
55 mm_segment_t oldfs = get_fs();
56 int retval, fd;
57
58 set_fs(KERNEL_DS);
59 fd = bpf_obj_get_user(path);
60 set_fs(oldfs);
61 if (fd < 0)
62 return fd;
63
64 retval = __bpf_mt_check_fd(fd, ret);
65 sys_close(fd);
66 return retval;
67}
68
52static int bpf_mt_check(const struct xt_mtchk_param *par) 69static int bpf_mt_check(const struct xt_mtchk_param *par)
53{ 70{
54 struct xt_bpf_info *info = par->matchinfo; 71 struct xt_bpf_info *info = par->matchinfo;
@@ -66,9 +83,10 @@ static int bpf_mt_check_v1(const struct xt_mtchk_param *par)
66 return __bpf_mt_check_bytecode(info->bpf_program, 83 return __bpf_mt_check_bytecode(info->bpf_program,
67 info->bpf_program_num_elem, 84 info->bpf_program_num_elem,
68 &info->filter); 85 &info->filter);
69 else if (info->mode == XT_BPF_MODE_FD_PINNED || 86 else if (info->mode == XT_BPF_MODE_FD_ELF)
70 info->mode == XT_BPF_MODE_FD_ELF)
71 return __bpf_mt_check_fd(info->fd, &info->filter); 87 return __bpf_mt_check_fd(info->fd, &info->filter);
88 else if (info->mode == XT_BPF_MODE_PATH_PINNED)
89 return __bpf_mt_check_path(info->path, &info->filter);
72 else 90 else
73 return -EINVAL; 91 return -EINVAL;
74} 92}
diff --git a/net/netfilter/xt_socket.c b/net/netfilter/xt_socket.c
index e75ef39669c5..575d2153e3b8 100644
--- a/net/netfilter/xt_socket.c
+++ b/net/netfilter/xt_socket.c
@@ -76,7 +76,7 @@ socket_match(const struct sk_buff *skb, struct xt_action_param *par,
76 transparent = nf_sk_is_transparent(sk); 76 transparent = nf_sk_is_transparent(sk);
77 77
78 if (info->flags & XT_SOCKET_RESTORESKMARK && !wildcard && 78 if (info->flags & XT_SOCKET_RESTORESKMARK && !wildcard &&
79 transparent) 79 transparent && sk_fullsock(sk))
80 pskb->mark = sk->sk_mark; 80 pskb->mark = sk->sk_mark;
81 81
82 if (sk != skb->sk) 82 if (sk != skb->sk)
@@ -133,7 +133,7 @@ socket_mt6_v1_v2_v3(const struct sk_buff *skb, struct xt_action_param *par)
133 transparent = nf_sk_is_transparent(sk); 133 transparent = nf_sk_is_transparent(sk);
134 134
135 if (info->flags & XT_SOCKET_RESTORESKMARK && !wildcard && 135 if (info->flags & XT_SOCKET_RESTORESKMARK && !wildcard &&
136 transparent) 136 transparent && sk_fullsock(sk))
137 pskb->mark = sk->sk_mark; 137 pskb->mark = sk->sk_mark;
138 138
139 if (sk != skb->sk) 139 if (sk != skb->sk)
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 94c11cf0459d..f34750691c5c 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2266,16 +2266,17 @@ int __netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
2266 cb->min_dump_alloc = control->min_dump_alloc; 2266 cb->min_dump_alloc = control->min_dump_alloc;
2267 cb->skb = skb; 2267 cb->skb = skb;
2268 2268
2269 if (cb->start) {
2270 ret = cb->start(cb);
2271 if (ret)
2272 goto error_unlock;
2273 }
2274
2269 nlk->cb_running = true; 2275 nlk->cb_running = true;
2270 2276
2271 mutex_unlock(nlk->cb_mutex); 2277 mutex_unlock(nlk->cb_mutex);
2272 2278
2273 ret = 0; 2279 ret = netlink_dump(sk);
2274 if (cb->start)
2275 ret = cb->start(cb);
2276
2277 if (!ret)
2278 ret = netlink_dump(sk);
2279 2280
2280 sock_put(sk); 2281 sock_put(sk);
2281 2282
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 9b5de31aa429..c1841f234a71 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -2203,7 +2203,7 @@ static void xs_udp_setup_socket(struct work_struct *work)
2203 struct sock_xprt *transport = 2203 struct sock_xprt *transport =
2204 container_of(work, struct sock_xprt, connect_worker.work); 2204 container_of(work, struct sock_xprt, connect_worker.work);
2205 struct rpc_xprt *xprt = &transport->xprt; 2205 struct rpc_xprt *xprt = &transport->xprt;
2206 struct socket *sock = transport->sock; 2206 struct socket *sock;
2207 int status = -EIO; 2207 int status = -EIO;
2208 2208
2209 sock = xs_create_sock(xprt, transport, 2209 sock = xs_create_sock(xprt, transport,
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index 7d99029df342..a140dd4a84af 100644
--- a/net/tipc/bcast.c
+++ b/net/tipc/bcast.c
@@ -233,7 +233,7 @@ static int tipc_bcast_xmit(struct net *net, struct sk_buff_head *pkts,
233 struct sk_buff_head xmitq; 233 struct sk_buff_head xmitq;
234 int rc = 0; 234 int rc = 0;
235 235
236 __skb_queue_head_init(&xmitq); 236 skb_queue_head_init(&xmitq);
237 tipc_bcast_lock(net); 237 tipc_bcast_lock(net);
238 if (tipc_link_bc_peers(l)) 238 if (tipc_link_bc_peers(l))
239 rc = tipc_link_xmit(l, pkts, &xmitq); 239 rc = tipc_link_xmit(l, pkts, &xmitq);
@@ -263,7 +263,7 @@ static int tipc_rcast_xmit(struct net *net, struct sk_buff_head *pkts,
263 u32 dst, selector; 263 u32 dst, selector;
264 264
265 selector = msg_link_selector(buf_msg(skb_peek(pkts))); 265 selector = msg_link_selector(buf_msg(skb_peek(pkts)));
266 __skb_queue_head_init(&_pkts); 266 skb_queue_head_init(&_pkts);
267 267
268 list_for_each_entry_safe(n, tmp, &dests->list, list) { 268 list_for_each_entry_safe(n, tmp, &dests->list, list) {
269 dst = n->value; 269 dst = n->value;
diff --git a/net/tipc/msg.c b/net/tipc/msg.c
index 121e59a1d0e7..17146c16ee2d 100644
--- a/net/tipc/msg.c
+++ b/net/tipc/msg.c
@@ -568,6 +568,14 @@ bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, int *err)
568 msg_set_destnode(msg, dnode); 568 msg_set_destnode(msg, dnode);
569 msg_set_destport(msg, dport); 569 msg_set_destport(msg, dport);
570 *err = TIPC_OK; 570 *err = TIPC_OK;
571
572 if (!skb_cloned(skb))
573 return true;
574
575 /* Unclone buffer in case it was bundled */
576 if (pskb_expand_head(skb, BUF_HEADROOM, BUF_TAILROOM, GFP_ATOMIC))
577 return false;
578
571 return true; 579 return true;
572} 580}
573 581
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 690874293cfc..d396cb61a280 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -549,6 +549,14 @@ nl80211_nan_srf_policy[NL80211_NAN_SRF_ATTR_MAX + 1] = {
549 [NL80211_NAN_SRF_MAC_ADDRS] = { .type = NLA_NESTED }, 549 [NL80211_NAN_SRF_MAC_ADDRS] = { .type = NLA_NESTED },
550}; 550};
551 551
552/* policy for packet pattern attributes */
553static const struct nla_policy
554nl80211_packet_pattern_policy[MAX_NL80211_PKTPAT + 1] = {
555 [NL80211_PKTPAT_MASK] = { .type = NLA_BINARY, },
556 [NL80211_PKTPAT_PATTERN] = { .type = NLA_BINARY, },
557 [NL80211_PKTPAT_OFFSET] = { .type = NLA_U32 },
558};
559
552static int nl80211_prepare_wdev_dump(struct sk_buff *skb, 560static int nl80211_prepare_wdev_dump(struct sk_buff *skb,
553 struct netlink_callback *cb, 561 struct netlink_callback *cb,
554 struct cfg80211_registered_device **rdev, 562 struct cfg80211_registered_device **rdev,
@@ -10532,7 +10540,8 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
10532 u8 *mask_pat; 10540 u8 *mask_pat;
10533 10541
10534 nla_parse_nested(pat_tb, MAX_NL80211_PKTPAT, pat, 10542 nla_parse_nested(pat_tb, MAX_NL80211_PKTPAT, pat,
10535 NULL, info->extack); 10543 nl80211_packet_pattern_policy,
10544 info->extack);
10536 err = -EINVAL; 10545 err = -EINVAL;
10537 if (!pat_tb[NL80211_PKTPAT_MASK] || 10546 if (!pat_tb[NL80211_PKTPAT_MASK] ||
10538 !pat_tb[NL80211_PKTPAT_PATTERN]) 10547 !pat_tb[NL80211_PKTPAT_PATTERN])
@@ -10781,7 +10790,8 @@ static int nl80211_parse_coalesce_rule(struct cfg80211_registered_device *rdev,
10781 rem) { 10790 rem) {
10782 u8 *mask_pat; 10791 u8 *mask_pat;
10783 10792
10784 nla_parse_nested(pat_tb, MAX_NL80211_PKTPAT, pat, NULL, NULL); 10793 nla_parse_nested(pat_tb, MAX_NL80211_PKTPAT, pat,
10794 nl80211_packet_pattern_policy, NULL);
10785 if (!pat_tb[NL80211_PKTPAT_MASK] || 10795 if (!pat_tb[NL80211_PKTPAT_MASK] ||
10786 !pat_tb[NL80211_PKTPAT_PATTERN]) 10796 !pat_tb[NL80211_PKTPAT_PATTERN])
10787 return -EINVAL; 10797 return -EINVAL;
diff --git a/net/xfrm/xfrm_device.c b/net/xfrm/xfrm_device.c
index acf00104ef31..30e5746085b8 100644
--- a/net/xfrm/xfrm_device.c
+++ b/net/xfrm/xfrm_device.c
@@ -91,6 +91,7 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
91 } 91 }
92 92
93 if (!dev->xfrmdev_ops || !dev->xfrmdev_ops->xdo_dev_state_add) { 93 if (!dev->xfrmdev_ops || !dev->xfrmdev_ops->xdo_dev_state_add) {
94 xso->dev = NULL;
94 dev_put(dev); 95 dev_put(dev);
95 return 0; 96 return 0;
96 } 97 }
diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
index 2515cd2bc5db..8ac9d32fb79d 100644
--- a/net/xfrm/xfrm_input.c
+++ b/net/xfrm/xfrm_input.c
@@ -429,7 +429,8 @@ resume:
429 nf_reset(skb); 429 nf_reset(skb);
430 430
431 if (decaps) { 431 if (decaps) {
432 skb->sp->olen = 0; 432 if (skb->sp)
433 skb->sp->olen = 0;
433 skb_dst_drop(skb); 434 skb_dst_drop(skb);
434 gro_cells_receive(&gro_cells, skb); 435 gro_cells_receive(&gro_cells, skb);
435 return 0; 436 return 0;
@@ -440,7 +441,8 @@ resume:
440 441
441 err = x->inner_mode->afinfo->transport_finish(skb, xfrm_gro || async); 442 err = x->inner_mode->afinfo->transport_finish(skb, xfrm_gro || async);
442 if (xfrm_gro) { 443 if (xfrm_gro) {
443 skb->sp->olen = 0; 444 if (skb->sp)
445 skb->sp->olen = 0;
444 skb_dst_drop(skb); 446 skb_dst_drop(skb);
445 gro_cells_receive(&gro_cells, skb); 447 gro_cells_receive(&gro_cells, skb);
446 return err; 448 return err;
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 0dab1cd79ce4..12213477cd3a 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -732,12 +732,12 @@ restart:
732 } 732 }
733 } 733 }
734 } 734 }
735out:
736 spin_unlock_bh(&net->xfrm.xfrm_state_lock);
735 if (cnt) { 737 if (cnt) {
736 err = 0; 738 err = 0;
737 xfrm_policy_cache_flush(); 739 xfrm_policy_cache_flush();
738 } 740 }
739out:
740 spin_unlock_bh(&net->xfrm.xfrm_state_lock);
741 return err; 741 return err;
742} 742}
743EXPORT_SYMBOL(xfrm_state_flush); 743EXPORT_SYMBOL(xfrm_state_flush);
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 2bfbd9121e3b..b997f1395357 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -657,6 +657,7 @@ static int xfrm_add_sa(struct sk_buff *skb, struct nlmsghdr *nlh,
657 657
658 if (err < 0) { 658 if (err < 0) {
659 x->km.state = XFRM_STATE_DEAD; 659 x->km.state = XFRM_STATE_DEAD;
660 xfrm_dev_state_delete(x);
660 __xfrm_state_put(x); 661 __xfrm_state_put(x);
661 goto out; 662 goto out;
662 } 663 }
diff --git a/scripts/faddr2line b/scripts/faddr2line
index 29df825d375c..2f6ce802397d 100755
--- a/scripts/faddr2line
+++ b/scripts/faddr2line
@@ -103,11 +103,12 @@ __faddr2line() {
103 103
104 # Go through each of the object's symbols which match the func name. 104 # Go through each of the object's symbols which match the func name.
105 # In rare cases there might be duplicates. 105 # In rare cases there might be duplicates.
106 file_end=$(size -Ax $objfile | awk '$1 == ".text" {print $2}')
106 while read symbol; do 107 while read symbol; do
107 local fields=($symbol) 108 local fields=($symbol)
108 local sym_base=0x${fields[0]} 109 local sym_base=0x${fields[0]}
109 local sym_type=${fields[1]} 110 local sym_type=${fields[1]}
110 local sym_end=0x${fields[3]} 111 local sym_end=${fields[3]}
111 112
112 # calculate the size 113 # calculate the size
113 local sym_size=$(($sym_end - $sym_base)) 114 local sym_size=$(($sym_end - $sym_base))
@@ -157,7 +158,7 @@ __faddr2line() {
157 addr2line -fpie $objfile $addr | sed "s; $dir_prefix\(\./\)*; ;" 158 addr2line -fpie $objfile $addr | sed "s; $dir_prefix\(\./\)*; ;"
158 DONE=1 159 DONE=1
159 160
160 done < <(nm -n $objfile | awk -v fn=$func '$3 == fn { found=1; line=$0; start=$1; next } found == 1 { found=0; print line, $1 }') 161 done < <(nm -n $objfile | awk -v fn=$func -v end=$file_end '$3 == fn { found=1; line=$0; start=$1; next } found == 1 { found=0; print line, "0x"$1 } END {if (found == 1) print line, end; }')
161} 162}
162 163
163[[ $# -lt 2 ]] && usage 164[[ $# -lt 2 ]] && usage
diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index ea2d0ae85bd3..6c9cba2166d9 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -1259,6 +1259,7 @@ static int snd_seq_ioctl_create_port(struct snd_seq_client *client, void *arg)
1259 struct snd_seq_port_info *info = arg; 1259 struct snd_seq_port_info *info = arg;
1260 struct snd_seq_client_port *port; 1260 struct snd_seq_client_port *port;
1261 struct snd_seq_port_callback *callback; 1261 struct snd_seq_port_callback *callback;
1262 int port_idx;
1262 1263
1263 /* it is not allowed to create the port for an another client */ 1264 /* it is not allowed to create the port for an another client */
1264 if (info->addr.client != client->number) 1265 if (info->addr.client != client->number)
@@ -1269,7 +1270,9 @@ static int snd_seq_ioctl_create_port(struct snd_seq_client *client, void *arg)
1269 return -ENOMEM; 1270 return -ENOMEM;
1270 1271
1271 if (client->type == USER_CLIENT && info->kernel) { 1272 if (client->type == USER_CLIENT && info->kernel) {
1272 snd_seq_delete_port(client, port->addr.port); 1273 port_idx = port->addr.port;
1274 snd_seq_port_unlock(port);
1275 snd_seq_delete_port(client, port_idx);
1273 return -EINVAL; 1276 return -EINVAL;
1274 } 1277 }
1275 if (client->type == KERNEL_CLIENT) { 1278 if (client->type == KERNEL_CLIENT) {
@@ -1290,6 +1293,7 @@ static int snd_seq_ioctl_create_port(struct snd_seq_client *client, void *arg)
1290 1293
1291 snd_seq_set_port_info(port, info); 1294 snd_seq_set_port_info(port, info);
1292 snd_seq_system_client_ev_port_start(port->addr.client, port->addr.port); 1295 snd_seq_system_client_ev_port_start(port->addr.client, port->addr.port);
1296 snd_seq_port_unlock(port);
1293 1297
1294 return 0; 1298 return 0;
1295} 1299}
diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c
index 0a7020c82bfc..d21ece9f8d73 100644
--- a/sound/core/seq/seq_ports.c
+++ b/sound/core/seq/seq_ports.c
@@ -122,7 +122,9 @@ static void port_subs_info_init(struct snd_seq_port_subs_info *grp)
122} 122}
123 123
124 124
125/* create a port, port number is returned (-1 on failure) */ 125/* create a port, port number is returned (-1 on failure);
126 * the caller needs to unref the port via snd_seq_port_unlock() appropriately
127 */
126struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client, 128struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client,
127 int port) 129 int port)
128{ 130{
@@ -151,6 +153,7 @@ struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client,
151 snd_use_lock_init(&new_port->use_lock); 153 snd_use_lock_init(&new_port->use_lock);
152 port_subs_info_init(&new_port->c_src); 154 port_subs_info_init(&new_port->c_src);
153 port_subs_info_init(&new_port->c_dest); 155 port_subs_info_init(&new_port->c_dest);
156 snd_use_lock_use(&new_port->use_lock);
154 157
155 num = port >= 0 ? port : 0; 158 num = port >= 0 ? port : 0;
156 mutex_lock(&client->ports_mutex); 159 mutex_lock(&client->ports_mutex);
@@ -165,9 +168,9 @@ struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client,
165 list_add_tail(&new_port->list, &p->list); 168 list_add_tail(&new_port->list, &p->list);
166 client->num_ports++; 169 client->num_ports++;
167 new_port->addr.port = num; /* store the port number in the port */ 170 new_port->addr.port = num; /* store the port number in the port */
171 sprintf(new_port->name, "port-%d", num);
168 write_unlock_irqrestore(&client->ports_lock, flags); 172 write_unlock_irqrestore(&client->ports_lock, flags);
169 mutex_unlock(&client->ports_mutex); 173 mutex_unlock(&client->ports_mutex);
170 sprintf(new_port->name, "port-%d", num);
171 174
172 return new_port; 175 return new_port;
173} 176}
diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c
index 8d93a4021c78..f48a4cd24ffc 100644
--- a/sound/core/seq/seq_virmidi.c
+++ b/sound/core/seq/seq_virmidi.c
@@ -77,13 +77,17 @@ static void snd_virmidi_init_event(struct snd_virmidi *vmidi,
77 * decode input event and put to read buffer of each opened file 77 * decode input event and put to read buffer of each opened file
78 */ 78 */
79static int snd_virmidi_dev_receive_event(struct snd_virmidi_dev *rdev, 79static int snd_virmidi_dev_receive_event(struct snd_virmidi_dev *rdev,
80 struct snd_seq_event *ev) 80 struct snd_seq_event *ev,
81 bool atomic)
81{ 82{
82 struct snd_virmidi *vmidi; 83 struct snd_virmidi *vmidi;
83 unsigned char msg[4]; 84 unsigned char msg[4];
84 int len; 85 int len;
85 86
86 read_lock(&rdev->filelist_lock); 87 if (atomic)
88 read_lock(&rdev->filelist_lock);
89 else
90 down_read(&rdev->filelist_sem);
87 list_for_each_entry(vmidi, &rdev->filelist, list) { 91 list_for_each_entry(vmidi, &rdev->filelist, list) {
88 if (!vmidi->trigger) 92 if (!vmidi->trigger)
89 continue; 93 continue;
@@ -97,7 +101,10 @@ static int snd_virmidi_dev_receive_event(struct snd_virmidi_dev *rdev,
97 snd_rawmidi_receive(vmidi->substream, msg, len); 101 snd_rawmidi_receive(vmidi->substream, msg, len);
98 } 102 }
99 } 103 }
100 read_unlock(&rdev->filelist_lock); 104 if (atomic)
105 read_unlock(&rdev->filelist_lock);
106 else
107 up_read(&rdev->filelist_sem);
101 108
102 return 0; 109 return 0;
103} 110}
@@ -115,7 +122,7 @@ int snd_virmidi_receive(struct snd_rawmidi *rmidi, struct snd_seq_event *ev)
115 struct snd_virmidi_dev *rdev; 122 struct snd_virmidi_dev *rdev;
116 123
117 rdev = rmidi->private_data; 124 rdev = rmidi->private_data;
118 return snd_virmidi_dev_receive_event(rdev, ev); 125 return snd_virmidi_dev_receive_event(rdev, ev, true);
119} 126}
120#endif /* 0 */ 127#endif /* 0 */
121 128
@@ -130,7 +137,7 @@ static int snd_virmidi_event_input(struct snd_seq_event *ev, int direct,
130 rdev = private_data; 137 rdev = private_data;
131 if (!(rdev->flags & SNDRV_VIRMIDI_USE)) 138 if (!(rdev->flags & SNDRV_VIRMIDI_USE))
132 return 0; /* ignored */ 139 return 0; /* ignored */
133 return snd_virmidi_dev_receive_event(rdev, ev); 140 return snd_virmidi_dev_receive_event(rdev, ev, atomic);
134} 141}
135 142
136/* 143/*
@@ -209,7 +216,6 @@ static int snd_virmidi_input_open(struct snd_rawmidi_substream *substream)
209 struct snd_virmidi_dev *rdev = substream->rmidi->private_data; 216 struct snd_virmidi_dev *rdev = substream->rmidi->private_data;
210 struct snd_rawmidi_runtime *runtime = substream->runtime; 217 struct snd_rawmidi_runtime *runtime = substream->runtime;
211 struct snd_virmidi *vmidi; 218 struct snd_virmidi *vmidi;
212 unsigned long flags;
213 219
214 vmidi = kzalloc(sizeof(*vmidi), GFP_KERNEL); 220 vmidi = kzalloc(sizeof(*vmidi), GFP_KERNEL);
215 if (vmidi == NULL) 221 if (vmidi == NULL)
@@ -223,9 +229,11 @@ static int snd_virmidi_input_open(struct snd_rawmidi_substream *substream)
223 vmidi->client = rdev->client; 229 vmidi->client = rdev->client;
224 vmidi->port = rdev->port; 230 vmidi->port = rdev->port;
225 runtime->private_data = vmidi; 231 runtime->private_data = vmidi;
226 write_lock_irqsave(&rdev->filelist_lock, flags); 232 down_write(&rdev->filelist_sem);
233 write_lock_irq(&rdev->filelist_lock);
227 list_add_tail(&vmidi->list, &rdev->filelist); 234 list_add_tail(&vmidi->list, &rdev->filelist);
228 write_unlock_irqrestore(&rdev->filelist_lock, flags); 235 write_unlock_irq(&rdev->filelist_lock);
236 up_write(&rdev->filelist_sem);
229 vmidi->rdev = rdev; 237 vmidi->rdev = rdev;
230 return 0; 238 return 0;
231} 239}
@@ -264,9 +272,11 @@ static int snd_virmidi_input_close(struct snd_rawmidi_substream *substream)
264 struct snd_virmidi_dev *rdev = substream->rmidi->private_data; 272 struct snd_virmidi_dev *rdev = substream->rmidi->private_data;
265 struct snd_virmidi *vmidi = substream->runtime->private_data; 273 struct snd_virmidi *vmidi = substream->runtime->private_data;
266 274
275 down_write(&rdev->filelist_sem);
267 write_lock_irq(&rdev->filelist_lock); 276 write_lock_irq(&rdev->filelist_lock);
268 list_del(&vmidi->list); 277 list_del(&vmidi->list);
269 write_unlock_irq(&rdev->filelist_lock); 278 write_unlock_irq(&rdev->filelist_lock);
279 up_write(&rdev->filelist_sem);
270 snd_midi_event_free(vmidi->parser); 280 snd_midi_event_free(vmidi->parser);
271 substream->runtime->private_data = NULL; 281 substream->runtime->private_data = NULL;
272 kfree(vmidi); 282 kfree(vmidi);
@@ -520,6 +530,7 @@ int snd_virmidi_new(struct snd_card *card, int device, struct snd_rawmidi **rrmi
520 rdev->rmidi = rmidi; 530 rdev->rmidi = rmidi;
521 rdev->device = device; 531 rdev->device = device;
522 rdev->client = -1; 532 rdev->client = -1;
533 init_rwsem(&rdev->filelist_sem);
523 rwlock_init(&rdev->filelist_lock); 534 rwlock_init(&rdev->filelist_lock);
524 INIT_LIST_HEAD(&rdev->filelist); 535 INIT_LIST_HEAD(&rdev->filelist);
525 rdev->seq_mode = SNDRV_VIRMIDI_SEQ_DISPATCH; 536 rdev->seq_mode = SNDRV_VIRMIDI_SEQ_DISPATCH;
diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c
index 0fb6b1b79261..d8409d9ae55b 100644
--- a/sound/usb/caiaq/device.c
+++ b/sound/usb/caiaq/device.c
@@ -469,10 +469,12 @@ static int init_card(struct snd_usb_caiaqdev *cdev)
469 469
470 err = snd_usb_caiaq_send_command(cdev, EP1_CMD_GET_DEVICE_INFO, NULL, 0); 470 err = snd_usb_caiaq_send_command(cdev, EP1_CMD_GET_DEVICE_INFO, NULL, 0);
471 if (err) 471 if (err)
472 return err; 472 goto err_kill_urb;
473 473
474 if (!wait_event_timeout(cdev->ep1_wait_queue, cdev->spec_received, HZ)) 474 if (!wait_event_timeout(cdev->ep1_wait_queue, cdev->spec_received, HZ)) {
475 return -ENODEV; 475 err = -ENODEV;
476 goto err_kill_urb;
477 }
476 478
477 usb_string(usb_dev, usb_dev->descriptor.iManufacturer, 479 usb_string(usb_dev, usb_dev->descriptor.iManufacturer,
478 cdev->vendor_name, CAIAQ_USB_STR_LEN); 480 cdev->vendor_name, CAIAQ_USB_STR_LEN);
@@ -507,6 +509,10 @@ static int init_card(struct snd_usb_caiaqdev *cdev)
507 509
508 setup_card(cdev); 510 setup_card(cdev);
509 return 0; 511 return 0;
512
513 err_kill_urb:
514 usb_kill_urb(&cdev->ep1_in_urb);
515 return err;
510} 516}
511 517
512static int snd_probe(struct usb_interface *intf, 518static int snd_probe(struct usb_interface *intf,
diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c
index 0ff5a7d2e19f..c8f723c3a033 100644
--- a/sound/usb/line6/driver.c
+++ b/sound/usb/line6/driver.c
@@ -779,9 +779,10 @@ int line6_probe(struct usb_interface *interface,
779 return 0; 779 return 0;
780 780
781 error: 781 error:
782 if (line6->disconnect) 782 /* we can call disconnect callback here because no close-sync is
783 line6->disconnect(line6); 783 * needed yet at this point
784 snd_card_free(card); 784 */
785 line6_disconnect(interface);
785 return ret; 786 return ret;
786} 787}
787EXPORT_SYMBOL_GPL(line6_probe); 788EXPORT_SYMBOL_GPL(line6_probe);
diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c
index 956f847a96e4..451007c27743 100644
--- a/sound/usb/line6/podhd.c
+++ b/sound/usb/line6/podhd.c
@@ -301,7 +301,8 @@ static void podhd_disconnect(struct usb_line6 *line6)
301 301
302 intf = usb_ifnum_to_if(line6->usbdev, 302 intf = usb_ifnum_to_if(line6->usbdev,
303 pod->line6.properties->ctrl_if); 303 pod->line6.properties->ctrl_if);
304 usb_driver_release_interface(&podhd_driver, intf); 304 if (intf)
305 usb_driver_release_interface(&podhd_driver, intf);
305 } 306 }
306} 307}
307 308
@@ -317,6 +318,9 @@ static int podhd_init(struct usb_line6 *line6,
317 318
318 line6->disconnect = podhd_disconnect; 319 line6->disconnect = podhd_disconnect;
319 320
321 init_timer(&pod->startup_timer);
322 INIT_WORK(&pod->startup_work, podhd_startup_workqueue);
323
320 if (pod->line6.properties->capabilities & LINE6_CAP_CONTROL) { 324 if (pod->line6.properties->capabilities & LINE6_CAP_CONTROL) {
321 /* claim the data interface */ 325 /* claim the data interface */
322 intf = usb_ifnum_to_if(line6->usbdev, 326 intf = usb_ifnum_to_if(line6->usbdev,
@@ -358,8 +362,6 @@ static int podhd_init(struct usb_line6 *line6,
358 } 362 }
359 363
360 /* init device and delay registering */ 364 /* init device and delay registering */
361 init_timer(&pod->startup_timer);
362 INIT_WORK(&pod->startup_work, podhd_startup_workqueue);
363 podhd_startup(pod); 365 podhd_startup(pod);
364 return 0; 366 return 0;
365} 367}
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 9732edf77f86..91bc8f18791e 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -2234,6 +2234,9 @@ static int parse_audio_unit(struct mixer_build *state, int unitid)
2234 2234
2235static void snd_usb_mixer_free(struct usb_mixer_interface *mixer) 2235static void snd_usb_mixer_free(struct usb_mixer_interface *mixer)
2236{ 2236{
2237 /* kill pending URBs */
2238 snd_usb_mixer_disconnect(mixer);
2239
2237 kfree(mixer->id_elems); 2240 kfree(mixer->id_elems);
2238 if (mixer->urb) { 2241 if (mixer->urb) {
2239 kfree(mixer->urb->transfer_buffer); 2242 kfree(mixer->urb->transfer_buffer);
@@ -2584,8 +2587,13 @@ _error:
2584 2587
2585void snd_usb_mixer_disconnect(struct usb_mixer_interface *mixer) 2588void snd_usb_mixer_disconnect(struct usb_mixer_interface *mixer)
2586{ 2589{
2587 usb_kill_urb(mixer->urb); 2590 if (mixer->disconnected)
2588 usb_kill_urb(mixer->rc_urb); 2591 return;
2592 if (mixer->urb)
2593 usb_kill_urb(mixer->urb);
2594 if (mixer->rc_urb)
2595 usb_kill_urb(mixer->rc_urb);
2596 mixer->disconnected = true;
2589} 2597}
2590 2598
2591#ifdef CONFIG_PM 2599#ifdef CONFIG_PM
diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h
index 2b4b067646ab..545d99b09706 100644
--- a/sound/usb/mixer.h
+++ b/sound/usb/mixer.h
@@ -22,6 +22,8 @@ struct usb_mixer_interface {
22 struct urb *rc_urb; 22 struct urb *rc_urb;
23 struct usb_ctrlrequest *rc_setup_packet; 23 struct usb_ctrlrequest *rc_setup_packet;
24 u8 rc_buffer[6]; 24 u8 rc_buffer[6];
25
26 bool disconnected;
25}; 27};
26 28
27#define MAX_CHANNELS 16 /* max logical channels */ 29#define MAX_CHANNELS 16 /* max logical channels */
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index b8cb57aeec77..9ddaae3784f5 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -1138,6 +1138,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip)
1138 case USB_ID(0x047F, 0x0415): /* Plantronics BT-300 */ 1138 case USB_ID(0x047F, 0x0415): /* Plantronics BT-300 */
1139 case USB_ID(0x047F, 0xAA05): /* Plantronics DA45 */ 1139 case USB_ID(0x047F, 0xAA05): /* Plantronics DA45 */
1140 case USB_ID(0x047F, 0xC022): /* Plantronics C310 */ 1140 case USB_ID(0x047F, 0xC022): /* Plantronics C310 */
1141 case USB_ID(0x047F, 0xC02F): /* Plantronics P610 */
1141 case USB_ID(0x047F, 0xC036): /* Plantronics C520-M */ 1142 case USB_ID(0x047F, 0xC036): /* Plantronics C520-M */
1142 case USB_ID(0x04D8, 0xFEEA): /* Benchmark DAC1 Pre */ 1143 case USB_ID(0x04D8, 0xFEEA): /* Benchmark DAC1 Pre */
1143 case USB_ID(0x0556, 0x0014): /* Phoenix Audio TMX320VC */ 1144 case USB_ID(0x0556, 0x0014): /* Phoenix Audio TMX320VC */
diff --git a/tools/testing/selftests/mqueue/Makefile b/tools/testing/selftests/mqueue/Makefile
index 0f5e347b068d..152823b6cb21 100644
--- a/tools/testing/selftests/mqueue/Makefile
+++ b/tools/testing/selftests/mqueue/Makefile
@@ -5,8 +5,8 @@ TEST_GEN_PROGS := mq_open_tests mq_perf_tests
5include ../lib.mk 5include ../lib.mk
6 6
7override define RUN_TESTS 7override define RUN_TESTS
8 $(OUTPUT)/mq_open_tests /test1 || echo "selftests: mq_open_tests [FAIL]" 8 @$(OUTPUT)/mq_open_tests /test1 || echo "selftests: mq_open_tests [FAIL]"
9 $(OUTPUT)//mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]" 9 @$(OUTPUT)/mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]"
10endef 10endef
11 11
12override define EMIT_TESTS 12override define EMIT_TESTS
diff --git a/tools/testing/selftests/networking/timestamping/rxtimestamp.c b/tools/testing/selftests/networking/timestamping/rxtimestamp.c
index 00f286661dcd..dd4162fc0419 100644
--- a/tools/testing/selftests/networking/timestamping/rxtimestamp.c
+++ b/tools/testing/selftests/networking/timestamping/rxtimestamp.c
@@ -341,7 +341,7 @@ int main(int argc, char **argv)
341 return 0; 341 return 0;
342 case 'n': 342 case 'n':
343 t = atoi(optarg); 343 t = atoi(optarg);
344 if (t > ARRAY_SIZE(test_cases)) 344 if (t >= ARRAY_SIZE(test_cases))
345 error(1, 0, "Invalid test case: %d", t); 345 error(1, 0, "Invalid test case: %d", t);
346 all_tests = false; 346 all_tests = false;
347 test_cases[t].enabled = true; 347 test_cases[t].enabled = true;
diff --git a/tools/testing/selftests/x86/Makefile b/tools/testing/selftests/x86/Makefile
index 97f187e2663f..0a74a20ca32b 100644
--- a/tools/testing/selftests/x86/Makefile
+++ b/tools/testing/selftests/x86/Makefile
@@ -20,7 +20,7 @@ BINARIES_64 := $(TARGETS_C_64BIT_ALL:%=%_64)
20BINARIES_32 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_32)) 20BINARIES_32 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_32))
21BINARIES_64 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_64)) 21BINARIES_64 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_64))
22 22
23CFLAGS := -O2 -g -std=gnu99 -pthread -Wall 23CFLAGS := -O2 -g -std=gnu99 -pthread -Wall -no-pie
24 24
25UNAME_M := $(shell uname -m) 25UNAME_M := $(shell uname -m)
26CAN_BUILD_I386 := $(shell ./check_cc.sh $(CC) trivial_32bit_program.c -m32) 26CAN_BUILD_I386 := $(shell ./check_cc.sh $(CC) trivial_32bit_program.c -m32)