diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/alpha/include/asm/types.h linux-libre-3.16.50-gnu/arch/alpha/include/asm/types.h
--- linux-libre-3.16.49-gnu/arch/alpha/include/asm/types.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/alpha/include/asm/types.h	2017-11-11 08:34:06.000000000 -0500
@@ -1,7 +1,6 @@
 #ifndef _ALPHA_TYPES_H
 #define _ALPHA_TYPES_H
 
-#include <asm-generic/int-ll64.h>
 #include <uapi/asm/types.h>
 
 #endif /* _ALPHA_TYPES_H */
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/alpha/include/uapi/asm/types.h linux-libre-3.16.50-gnu/arch/alpha/include/uapi/asm/types.h
--- linux-libre-3.16.49-gnu/arch/alpha/include/uapi/asm/types.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/alpha/include/uapi/asm/types.h	2017-11-11 08:34:06.000000000 -0500
@@ -9,8 +9,18 @@
  * need to be careful to avoid a name clashes.
  */
 
-#ifndef __KERNEL__
+/*
+ * This is here because we used to use l64 for alpha
+ * and we don't want to impact user mode with our change to ll64
+ * in the kernel.
+ *
+ * However, some user programs are fine with this.  They can
+ * flag __SANE_USERSPACE_TYPES__ to get int-ll64.h here.
+ */
+#if !defined(__SANE_USERSPACE_TYPES__) && !defined(__KERNEL__)
 #include <asm-generic/int-l64.h>
+#else
+#include <asm-generic/int-ll64.h>
 #endif
 
 #endif /* _UAPI_ALPHA_TYPES_H */
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/arm/include/asm/kexec.h linux-libre-3.16.50-gnu/arch/arm/include/asm/kexec.h
--- linux-libre-3.16.49-gnu/arch/arm/include/asm/kexec.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/arm/include/asm/kexec.h	2017-11-11 08:34:06.000000000 -0500
@@ -19,6 +19,11 @@
 
 #ifndef __ASSEMBLY__
 
+#define ARCH_HAS_KIMAGE_ARCH
+struct kimage_arch {
+	u32 kernel_r2;
+};
+
 /**
  * crash_setup_regs() - save registers for the panic kernel
  * @newregs: registers are saved here
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/arm/kernel/iwmmxt.S linux-libre-3.16.50-gnu/arch/arm/kernel/iwmmxt.S
--- linux-libre-3.16.49-gnu/arch/arm/kernel/iwmmxt.S	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/arm/kernel/iwmmxt.S	2017-11-11 08:34:06.000000000 -0500
@@ -58,6 +58,7 @@
 #define MMX_SIZE		(0x98)
 
 	.text
+	.arm
 
 /*
  * Lazy switching of Concan coprocessor context
@@ -182,6 +183,8 @@ concan_load:
 	tmcr	wCon, r2
 	mov	pc, lr
 
+ENDPROC(iwmmxt_task_enable)
+
 /*
  * Back up Concan regs to save area and disable access to them
  * (mainly for gdb or sleep mode usage)
@@ -232,6 +235,8 @@ ENTRY(iwmmxt_task_disable)
 1:	msr	cpsr_c, ip			@ restore interrupt mode
 	ldmfd	sp!, {r4, pc}
 
+ENDPROC(iwmmxt_task_disable)
+
 /*
  * Copy Concan state to given memory address
  *
@@ -268,6 +273,8 @@ ENTRY(iwmmxt_task_copy)
 	msr	cpsr_c, ip			@ restore interrupt mode
 	mov	pc, r3
 
+ENDPROC(iwmmxt_task_copy)
+
 /*
  * Restore Concan state from given memory address
  *
@@ -304,6 +311,8 @@ ENTRY(iwmmxt_task_restore)
 	msr	cpsr_c, ip			@ restore interrupt mode
 	mov	pc, r3
 
+ENDPROC(iwmmxt_task_restore)
+
 /*
  * Concan handling on task switch
  *
@@ -335,6 +344,8 @@ ENTRY(iwmmxt_task_switch)
 	mrc	p15, 0, r1, c2, c0, 0
 	sub	pc, lr, r1, lsr #32		@ cpwait and return
 
+ENDPROC(iwmmxt_task_switch)
+
 /*
  * Remove Concan ownership of given task
  *
@@ -353,6 +364,8 @@ ENTRY(iwmmxt_task_release)
 	msr	cpsr_c, r2			@ restore interrupts
 	mov	pc, lr
 
+ENDPROC(iwmmxt_task_release)
+
 	.data
 concan_owner:
 	.word	0
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/arm/kernel/machine_kexec.c linux-libre-3.16.50-gnu/arch/arm/kernel/machine_kexec.c
--- linux-libre-3.16.49-gnu/arch/arm/kernel/machine_kexec.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/arm/kernel/machine_kexec.c	2017-11-11 08:34:06.000000000 -0500
@@ -40,6 +40,9 @@ int machine_kexec_prepare(struct kimage
 	__be32 header;
 	int i, err;
 
+	image->arch.kernel_r2 = image->start - KEXEC_ARM_ZIMAGE_OFFSET
+				     + KEXEC_ARM_ATAGS_OFFSET;
+
 	/*
 	 * Validate that if the current HW supports SMP, then the SW supports
 	 * and implements CPU hotplug for the current HW. If not, we won't be
@@ -63,8 +66,8 @@ int machine_kexec_prepare(struct kimage
 		if (err)
 			return err;
 
-		if (be32_to_cpu(header) == OF_DT_HEADER)
-			kexec_boot_atags = current_segment->mem;
+		if (header == cpu_to_be32(OF_DT_HEADER))
+			image->arch.kernel_r2 = current_segment->mem;
 	}
 	return 0;
 }
@@ -166,9 +169,7 @@ void machine_kexec(struct kimage *image)
 	kexec_start_address = image->start;
 	kexec_indirection_page = page_list;
 	kexec_mach_type = machine_arch_type;
-	if (!kexec_boot_atags)
-		kexec_boot_atags = image->start - KEXEC_ARM_ZIMAGE_OFFSET + KEXEC_ARM_ATAGS_OFFSET;
-
+	kexec_boot_atags = image->arch.kernel_r2;
 
 	/* copy our kernel relocation code to the control code page */
 	reboot_entry = fncpy(reboot_code_buffer,
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/arm/kernel/pj4-cp0.c linux-libre-3.16.50-gnu/arch/arm/kernel/pj4-cp0.c
--- linux-libre-3.16.49-gnu/arch/arm/kernel/pj4-cp0.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/arm/kernel/pj4-cp0.c	2017-11-11 08:34:06.000000000 -0500
@@ -66,9 +66,13 @@ static void __init pj4_cp_access_write(u
 
 	__asm__ __volatile__ (
 		"mcr	p15, 0, %1, c1, c0, 2\n\t"
+#ifdef CONFIG_THUMB2_KERNEL
+		"isb\n\t"
+#else
 		"mrc	p15, 0, %0, c1, c0, 2\n\t"
 		"mov	%0, %0\n\t"
 		"sub	pc, pc, #4\n\t"
+#endif
 		: "=r" (temp) : "r" (value));
 }
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/arm/kernel/return_address.c linux-libre-3.16.50-gnu/arch/arm/kernel/return_address.c
--- linux-libre-3.16.49-gnu/arch/arm/kernel/return_address.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/arm/kernel/return_address.c	2017-11-11 08:34:06.000000000 -0500
@@ -59,10 +59,6 @@ void *return_address(unsigned int level)
 
 #else /* if defined(CONFIG_FRAME_POINTER) && !defined(CONFIG_ARM_UNWIND) */
 
-#if defined(CONFIG_ARM_UNWIND)
-#warning "TODO: return_address should use unwind tables"
-#endif
-
 void *return_address(unsigned int level)
 {
 	return NULL;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/arm/mach-cns3xxx/Makefile linux-libre-3.16.50-gnu/arch/arm/mach-cns3xxx/Makefile
--- linux-libre-3.16.49-gnu/arch/arm/mach-cns3xxx/Makefile	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/arm/mach-cns3xxx/Makefile	2017-11-11 08:34:06.000000000 -0500
@@ -2,4 +2,5 @@ obj-$(CONFIG_ARCH_CNS3XXX)		+= cns3xxx.o
 cns3xxx-y				+= core.o pm.o
 cns3xxx-$(CONFIG_ATAGS)			+= devices.o
 cns3xxx-$(CONFIG_PCI)			+= pcie.o
+CFLAGS_pcie.o				+= -Wframe-larger-than=1536 # override default 1024, this is safe here
 cns3xxx-$(CONFIG_MACH_CNS3420VB)	+= cns3420vb.o
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/arm/mach-omap2/Kconfig linux-libre-3.16.50-gnu/arch/arm/mach-omap2/Kconfig
--- linux-libre-3.16.49-gnu/arch/arm/mach-omap2/Kconfig	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/arm/mach-omap2/Kconfig	2017-11-11 08:34:06.000000000 -0500
@@ -1,9 +1,6 @@
 menu "TI OMAP/AM/DM/DRA Family"
 	depends on ARCH_MULTI_V6 || ARCH_MULTI_V7
 
-config ARCH_OMAP
-	bool
-
 config ARCH_OMAP2
 	bool "TI OMAP2"
 	depends on ARCH_MULTI_V6
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/arm/mach-pxa/Kconfig linux-libre-3.16.50-gnu/arch/arm/mach-pxa/Kconfig
--- linux-libre-3.16.49-gnu/arch/arm/mach-pxa/Kconfig	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/arm/mach-pxa/Kconfig	2017-11-11 08:34:06.000000000 -0500
@@ -546,6 +546,7 @@ config MACH_ICONTROL
 config ARCH_PXA_ESERIES
 	bool "PXA based Toshiba e-series PDAs"
 	select FB_W100
+	select FB
 	select PXA25x
 
 config MACH_E330
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/arm/mm/cache-l2x0.c linux-libre-3.16.50-gnu/arch/arm/mm/cache-l2x0.c
--- linux-libre-3.16.49-gnu/arch/arm/mm/cache-l2x0.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/arm/mm/cache-l2x0.c	2017-11-11 08:34:06.000000000 -0500
@@ -135,73 +135,6 @@ static void l2c_disable(void)
 	dsb(st);
 }
 
-#ifdef CONFIG_CACHE_PL310
-static inline void cache_wait(void __iomem *reg, unsigned long mask)
-{
-	/* cache operations by line are atomic on PL310 */
-}
-#else
-#define cache_wait	l2c_wait_mask
-#endif
-
-static inline void cache_sync(void)
-{
-	void __iomem *base = l2x0_base;
-
-	writel_relaxed(0, base + sync_reg_offset);
-	cache_wait(base + L2X0_CACHE_SYNC, 1);
-}
-
-#if defined(CONFIG_PL310_ERRATA_588369) || defined(CONFIG_PL310_ERRATA_727915)
-static inline void debug_writel(unsigned long val)
-{
-	l2c_set_debug(l2x0_base, val);
-}
-#else
-/* Optimised out for non-errata case */
-static inline void debug_writel(unsigned long val)
-{
-}
-#endif
-
-static void l2x0_cache_sync(void)
-{
-	unsigned long flags;
-
-	raw_spin_lock_irqsave(&l2x0_lock, flags);
-	cache_sync();
-	raw_spin_unlock_irqrestore(&l2x0_lock, flags);
-}
-
-static void __l2x0_flush_all(void)
-{
-	debug_writel(0x03);
-	__l2c_op_way(l2x0_base + L2X0_CLEAN_INV_WAY);
-	cache_sync();
-	debug_writel(0x00);
-}
-
-static void l2x0_flush_all(void)
-{
-	unsigned long flags;
-
-	/* clean all ways */
-	raw_spin_lock_irqsave(&l2x0_lock, flags);
-	__l2x0_flush_all();
-	raw_spin_unlock_irqrestore(&l2x0_lock, flags);
-}
-
-static void l2x0_disable(void)
-{
-	unsigned long flags;
-
-	raw_spin_lock_irqsave(&l2x0_lock, flags);
-	__l2x0_flush_all();
-	l2c_write_sec(0, l2x0_base, L2X0_CTRL);
-	dsb(st);
-	raw_spin_unlock_irqrestore(&l2x0_lock, flags);
-}
-
 static void l2c_save(void __iomem *base)
 {
 	l2x0_saved_regs.aux_ctrl = readl_relaxed(l2x0_base + L2X0_AUX_CTRL);
@@ -1126,14 +1059,15 @@ static unsigned long calc_range_end(unsi
 static void aurora_pa_range(unsigned long start, unsigned long end,
 			unsigned long offset)
 {
+	void __iomem *base = l2x0_base;
 	unsigned long flags;
 
 	raw_spin_lock_irqsave(&l2x0_lock, flags);
-	writel_relaxed(start, l2x0_base + AURORA_RANGE_BASE_ADDR_REG);
-	writel_relaxed(end, l2x0_base + offset);
+	writel_relaxed(start, base + AURORA_RANGE_BASE_ADDR_REG);
+	writel_relaxed(end, base + offset);
 	raw_spin_unlock_irqrestore(&l2x0_lock, flags);
 
-	cache_sync();
+	writel_relaxed(0, base + AURORA_SYNC_REG);
 }
 
 static void aurora_inv_range(unsigned long start, unsigned long end)
@@ -1193,6 +1127,37 @@ static void aurora_flush_range(unsigned
 	}
 }
 
+static void aurora_flush_all(void)
+{
+	void __iomem *base = l2x0_base;
+	unsigned long flags;
+
+	/* clean all ways */
+	raw_spin_lock_irqsave(&l2x0_lock, flags);
+	__l2c_op_way(base + L2X0_CLEAN_INV_WAY);
+	raw_spin_unlock_irqrestore(&l2x0_lock, flags);
+
+	writel_relaxed(0, base + AURORA_SYNC_REG);
+}
+
+static void aurora_cache_sync(void)
+{
+	writel_relaxed(0, l2x0_base + AURORA_SYNC_REG);
+}
+
+static void aurora_disable(void)
+{
+	void __iomem *base = l2x0_base;
+	unsigned long flags;
+
+	raw_spin_lock_irqsave(&l2x0_lock, flags);
+	__l2c_op_way(base + L2X0_CLEAN_INV_WAY);
+	writel_relaxed(0, base + AURORA_SYNC_REG);
+	l2c_write_sec(0, base, L2X0_CTRL);
+	dsb(st);
+	raw_spin_unlock_irqrestore(&l2x0_lock, flags);
+}
+
 static void aurora_save(void __iomem *base)
 {
 	l2x0_saved_regs.ctrl = readl_relaxed(base + L2X0_CTRL);
@@ -1267,9 +1232,9 @@ static const struct l2c_init_data of_aur
 		.inv_range   = aurora_inv_range,
 		.clean_range = aurora_clean_range,
 		.flush_range = aurora_flush_range,
-		.flush_all   = l2x0_flush_all,
-		.disable     = l2x0_disable,
-		.sync        = l2x0_cache_sync,
+		.flush_all   = aurora_flush_all,
+		.disable     = aurora_disable,
+		.sync	     = aurora_cache_sync,
 		.resume      = aurora_resume,
 	},
 };
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/arm/plat-omap/Kconfig linux-libre-3.16.50-gnu/arch/arm/plat-omap/Kconfig
--- linux-libre-3.16.49-gnu/arch/arm/plat-omap/Kconfig	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/arm/plat-omap/Kconfig	2017-11-11 08:34:06.000000000 -0500
@@ -1,3 +1,6 @@
+config ARCH_OMAP
+	bool
+
 if ARCH_OMAP
 
 menu "TI OMAP Common Features"
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/arm64/kernel/fpsimd.c linux-libre-3.16.50-gnu/arch/arm64/kernel/fpsimd.c
--- linux-libre-3.16.49-gnu/arch/arm64/kernel/fpsimd.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/arm64/kernel/fpsimd.c	2017-11-11 08:34:06.000000000 -0500
@@ -156,9 +156,11 @@ void fpsimd_thread_switch(struct task_st
 
 void fpsimd_flush_thread(void)
 {
+	preempt_disable();
 	memset(&current->thread.fpsimd_state, 0, sizeof(struct fpsimd_state));
 	fpsimd_flush_task_state(current);
 	set_thread_flag(TIF_FOREIGN_FPSTATE);
+	preempt_enable();
 }
 
 /*
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/arm64/mm/fault.c linux-libre-3.16.50-gnu/arch/arm64/mm/fault.c
--- linux-libre-3.16.49-gnu/arch/arm64/mm/fault.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/arm64/mm/fault.c	2017-11-11 08:34:06.000000000 -0500
@@ -252,8 +252,11 @@ retry:
 	 * signal first. We do not need to release the mmap_sem because it
 	 * would already be released in __lock_page_or_retry in mm/filemap.c.
 	 */
-	if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
+	if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) {
+		if (!user_mode(regs))
+			goto no_context;
 		return 0;
+	}
 
 	/*
 	 * Major/minor page fault accounting is only done on the initial
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/mips/boot/elf2ecoff.c linux-libre-3.16.50-gnu/arch/mips/boot/elf2ecoff.c
--- linux-libre-3.16.49-gnu/arch/mips/boot/elf2ecoff.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/mips/boot/elf2ecoff.c	2017-11-11 08:34:06.000000000 -0500
@@ -49,7 +49,8 @@
 /*
  * Some extra ELF definitions
  */
-#define PT_MIPS_REGINFO 0x70000000	/* Register usage information */
+#define PT_MIPS_REGINFO 	0x70000000	/* Register usage information */
+#define PT_MIPS_ABIFLAGS	0x70000003	/* Records ABI related flags  */
 
 /* -------------------------------------------------------------------- */
 
@@ -267,7 +268,6 @@ int main(int argc, char *argv[])
 	Elf32_Ehdr ex;
 	Elf32_Phdr *ph;
 	Elf32_Shdr *sh;
-	char *shstrtab;
 	int i, pad;
 	struct sect text, data, bss;
 	struct filehdr efh;
@@ -335,9 +335,6 @@ int main(int argc, char *argv[])
 				     "sh");
 	if (must_convert_endian)
 		convert_elf_shdrs(sh, ex.e_shnum);
-	/* Read in the section string table. */
-	shstrtab = saveRead(infile, sh[ex.e_shstrndx].sh_offset,
-			    sh[ex.e_shstrndx].sh_size, "shstrtab");
 
 	/* Figure out if we can cram the program header into an ECOFF
 	   header...  Basically, we can't handle anything but loadable
@@ -351,7 +348,8 @@ int main(int argc, char *argv[])
 		/* Section types we can ignore... */
 		if (ph[i].p_type == PT_NULL || ph[i].p_type == PT_NOTE ||
 		    ph[i].p_type == PT_PHDR
-		    || ph[i].p_type == PT_MIPS_REGINFO)
+		    || ph[i].p_type == PT_MIPS_REGINFO
+		    || ph[i].p_type == PT_MIPS_ABIFLAGS)
 			continue;
 		/* Section types we can't handle... */
 		else if (ph[i].p_type != PT_LOAD) {
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/mips/dec/int-handler.S linux-libre-3.16.50-gnu/arch/mips/dec/int-handler.S
--- linux-libre-3.16.49-gnu/arch/mips/dec/int-handler.S	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/mips/dec/int-handler.S	2017-11-11 08:34:06.000000000 -0500
@@ -146,7 +146,14 @@
 		/*
 		 * Find irq with highest priority
 		 */
-		 PTR_LA	t1,cpu_mask_nr_tbl
+		# open coded PTR_LA t1, cpu_mask_nr_tbl
+#if defined(CONFIG_32BIT) || defined(KBUILD_64BIT_SYM32)
+		# open coded la t1, cpu_mask_nr_tbl
+		lui	t1, %hi(cpu_mask_nr_tbl)
+		addiu	t1, %lo(cpu_mask_nr_tbl)
+#else
+#error GCC `-msym32' option required for 64-bit DECstation builds
+#endif
 1:		lw	t2,(t1)
 		nop
 		and	t2,t0
@@ -195,7 +202,14 @@
 		/*
 		 * Find irq with highest priority
 		 */
-		 PTR_LA	t1,asic_mask_nr_tbl
+		# open coded PTR_LA t1,asic_mask_nr_tbl
+#if defined(CONFIG_32BIT) || defined(KBUILD_64BIT_SYM32)
+		# open coded la t1, asic_mask_nr_tbl
+		lui	t1, %hi(asic_mask_nr_tbl)
+		addiu	t1, %lo(asic_mask_nr_tbl)
+#else
+#error GCC `-msym32' option required for 64-bit DECstation builds
+#endif
 2:		lw	t2,(t1)
 		nop
 		and	t2,t0
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/mips/include/asm/page.h linux-libre-3.16.50-gnu/arch/mips/include/asm/page.h
--- linux-libre-3.16.49-gnu/arch/mips/include/asm/page.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/mips/include/asm/page.h	2017-11-11 08:34:06.000000000 -0500
@@ -223,7 +223,8 @@ static inline int pfn_valid(unsigned lon
 
 #endif
 
-#define virt_to_page(kaddr)	pfn_to_page(PFN_DOWN(virt_to_phys(kaddr)))
+#define virt_to_page(kaddr)	pfn_to_page(PFN_DOWN(virt_to_phys((void *)     \
+								  (kaddr))))
 
 extern int __virt_addr_valid(const volatile void *kaddr);
 #define virt_addr_valid(kaddr)						\
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/mips/jz4740/board-qi_lb60.c linux-libre-3.16.50-gnu/arch/mips/jz4740/board-qi_lb60.c
--- linux-libre-3.16.49-gnu/arch/mips/jz4740/board-qi_lb60.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/mips/jz4740/board-qi_lb60.c	2017-11-11 08:34:06.000000000 -0500
@@ -25,6 +25,7 @@
 #include <linux/power/jz4740-battery.h>
 #include <linux/power/gpio-charger.h>
 
+#include <asm/mach-jz4740/gpio.h>
 #include <asm/mach-jz4740/jz4740_fb.h>
 #include <asm/mach-jz4740/jz4740_mmc.h>
 #include <asm/mach-jz4740/jz4740_nand.h>
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/mips/jz4740/gpio.c linux-libre-3.16.50-gnu/arch/mips/jz4740/gpio.c
--- linux-libre-3.16.49-gnu/arch/mips/jz4740/gpio.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/mips/jz4740/gpio.c	2017-11-11 08:34:06.000000000 -0500
@@ -27,6 +27,7 @@
 #include <linux/seq_file.h>
 
 #include <asm/mach-jz4740/base.h>
+#include <asm/mach-jz4740/gpio.h>
 
 #include "irq.h"
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/mips/jz4740/irq.h linux-libre-3.16.50-gnu/arch/mips/jz4740/irq.h
--- linux-libre-3.16.49-gnu/arch/mips/jz4740/irq.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/mips/jz4740/irq.h	2017-11-11 08:34:06.000000000 -0500
@@ -16,7 +16,9 @@
 #define __MIPS_JZ4740_IRQ_H__
 
 #include <linux/irq.h>
+#include <asm/mach-jz4740/irq.h>
 
+struct irq_data;
 extern void jz4740_irq_suspend(struct irq_data *data);
 extern void jz4740_irq_resume(struct irq_data *data);
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/mips/kernel/bmips_vec.S linux-libre-3.16.50-gnu/arch/mips/kernel/bmips_vec.S
--- linux-libre-3.16.49-gnu/arch/mips/kernel/bmips_vec.S	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/mips/kernel/bmips_vec.S	2017-11-11 08:34:06.000000000 -0500
@@ -211,7 +211,6 @@ bmips_reset_nmi_vec_end:
 END(bmips_reset_nmi_vec)
 
 	.set	pop
-	.previous
 
 /***********************************************************************
  * CPU1 warm restart vector (used for second and subsequent boots).
@@ -286,5 +285,3 @@ LEAF(bmips_enable_xks01)
 	jr	ra
 
 END(bmips_enable_xks01)
-
-	.previous
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/mips/pci/ops-pmcmsp.c linux-libre-3.16.50-gnu/arch/mips/pci/ops-pmcmsp.c
--- linux-libre-3.16.49-gnu/arch/mips/pci/ops-pmcmsp.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/mips/pci/ops-pmcmsp.c	2017-11-11 08:34:06.000000000 -0500
@@ -193,8 +193,6 @@ static void pci_proc_init(void)
 }
 #endif /* CONFIG_PROC_FS && PCI_COUNTERS */
 
-static DEFINE_SPINLOCK(bpci_lock);
-
 /*****************************************************************************
  *
  *  STRUCT: pci_io_resource
@@ -368,7 +366,6 @@ int msp_pcibios_config_access(unsigned c
 	struct msp_pci_regs *preg = (void *)PCI_BASE_REG;
 	unsigned char bus_num = bus->number;
 	unsigned char dev_fn = (unsigned char)devfn;
-	unsigned long flags;
 	unsigned long intr;
 	unsigned long value;
 	static char pciirqflag;
@@ -401,10 +398,7 @@ int msp_pcibios_config_access(unsigned c
 	}
 
 #if defined(CONFIG_PMC_MSP7120_GW) || defined(CONFIG_PMC_MSP7120_EVAL)
-	local_irq_save(flags);
 	vpe_status = dvpe();
-#else
-	spin_lock_irqsave(&bpci_lock, flags);
 #endif
 
 	/*
@@ -457,9 +451,6 @@ int msp_pcibios_config_access(unsigned c
 
 #if defined(CONFIG_PMC_MSP7120_GW) || defined(CONFIG_PMC_MSP7120_EVAL)
 		evpe(vpe_status);
-		local_irq_restore(flags);
-#else
-		spin_unlock_irqrestore(&bpci_lock, flags);
 #endif
 
 		return -1;
@@ -467,9 +458,6 @@ int msp_pcibios_config_access(unsigned c
 
 #if defined(CONFIG_PMC_MSP7120_GW) || defined(CONFIG_PMC_MSP7120_EVAL)
 	evpe(vpe_status);
-	local_irq_restore(flags);
-#else
-	spin_unlock_irqrestore(&bpci_lock, flags);
 #endif
 
 	return PCIBIOS_SUCCESSFUL;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/mips/pci/ops-tx4927.c linux-libre-3.16.50-gnu/arch/mips/pci/ops-tx4927.c
--- linux-libre-3.16.49-gnu/arch/mips/pci/ops-tx4927.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/mips/pci/ops-tx4927.c	2017-11-11 08:34:06.000000000 -0500
@@ -199,8 +199,6 @@ static struct {
 
 char *tx4927_pcibios_setup(char *str)
 {
-	unsigned long val;
-
 	if (!strncmp(str, "trdyto=", 7)) {
 		u8 val = 0;
 		if (kstrtou8(str + 7, 0, &val) == 0)
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/mips/sgi-ip22/Platform linux-libre-3.16.50-gnu/arch/mips/sgi-ip22/Platform
--- linux-libre-3.16.49-gnu/arch/mips/sgi-ip22/Platform	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/mips/sgi-ip22/Platform	2017-11-11 08:34:06.000000000 -0500
@@ -25,7 +25,7 @@ endif
 # Simplified: what IP22 does at 128MB+ in ksegN, IP28 does at 512MB+ in xkphys
 #
 ifdef CONFIG_SGI_IP28
-  ifeq ($(call cc-option-yn,-mr10k-cache-barrier=store), n)
+  ifeq ($(call cc-option-yn,-march=r10000 -mr10k-cache-barrier=store), n)
       $(error gcc doesn't support needed option -mr10k-cache-barrier=store)
   endif
 endif
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/powerpc/boot/Makefile linux-libre-3.16.50-gnu/arch/powerpc/boot/Makefile
--- linux-libre-3.16.49-gnu/arch/powerpc/boot/Makefile	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/powerpc/boot/Makefile	2017-11-11 08:34:06.000000000 -0500
@@ -21,11 +21,19 @@ all: $(obj)/zImage
 
 BOOTCFLAGS    := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
 		 -fno-strict-aliasing -Os -msoft-float -pipe \
-		 -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
-		 -isystem $(shell $(CROSS32CC) -print-file-name=include)
+		 -fomit-frame-pointer -fno-builtin -fPIC -nostdinc
+BOOTCC := $(CC)
 ifdef CONFIG_PPC64_BOOT_WRAPPER
 BOOTCFLAGS	+= -m64
+else
+BOOTCFLAGS	+= -m32
+ifdef CROSS32_COMPILE
+    BOOTCC := $(CROSS32_COMPILE)gcc
 endif
+endif
+
+BOOTCFLAGS	+= -isystem $(shell $(BOOTCC) -print-file-name=include)
+
 ifdef CONFIG_CPU_BIG_ENDIAN
 BOOTCFLAGS	+= -mbig-endian
 else
@@ -165,10 +173,10 @@ clean-files := $(zlib) $(zlibheader) $(z
 		empty.c zImage.coff.lds zImage.ps3.lds zImage.lds
 
 quiet_cmd_bootcc = BOOTCC  $@
-      cmd_bootcc = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $<
+      cmd_bootcc = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $<
 
 quiet_cmd_bootas = BOOTAS  $@
-      cmd_bootas = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
+      cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
 
 quiet_cmd_bootar = BOOTAR  $@
       cmd_bootar = $(CROSS32AR) -cr$(KBUILD_ARFLAGS) $@.$$$$ $(filter-out FORCE,$^); mv $@.$$$$ $@
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/powerpc/kvm/book3s_hv.c linux-libre-3.16.50-gnu/arch/powerpc/kvm/book3s_hv.c
--- linux-libre-3.16.49-gnu/arch/powerpc/kvm/book3s_hv.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/powerpc/kvm/book3s_hv.c	2017-11-11 08:34:06.000000000 -0500
@@ -1816,6 +1816,8 @@ static int kvmppc_vcpu_run_hv(struct kvm
 			run->fail_entry.hardware_entry_failure_reason = 0;
 			return -EINVAL;
 		}
+		/* Enable TM so we can read the TM SPRs */
+		mtmsr(mfmsr() | MSR_TM);
 		current->thread.tm_tfhar = mfspr(SPRN_TFHAR);
 		current->thread.tm_tfiar = mfspr(SPRN_TFIAR);
 		current->thread.tm_texasr = mfspr(SPRN_TEXASR);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/powerpc/mm/subpage-prot.c linux-libre-3.16.50-gnu/arch/powerpc/mm/subpage-prot.c
--- linux-libre-3.16.49-gnu/arch/powerpc/mm/subpage-prot.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/powerpc/mm/subpage-prot.c	2017-11-11 08:34:06.000000000 -0500
@@ -36,7 +36,7 @@ void subpage_prot_free(struct mm_struct
 		}
 	}
 	addr = 0;
-	for (i = 0; i < 2; ++i) {
+	for (i = 0; i < (TASK_SIZE_USER64 >> 43); ++i) {
 		p = spt->protptrs[i];
 		if (!p)
 			continue;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/powerpc/platforms/pseries/reconfig.c linux-libre-3.16.50-gnu/arch/powerpc/platforms/pseries/reconfig.c
--- linux-libre-3.16.49-gnu/arch/powerpc/platforms/pseries/reconfig.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/powerpc/platforms/pseries/reconfig.c	2017-11-11 08:34:06.000000000 -0500
@@ -112,7 +112,6 @@ static int pSeries_reconfig_remove_node(
 
 	of_detach_node(np);
 	of_node_put(parent);
-	of_node_put(np); /* Must decrement the refcount */
 	return 0;
 }
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/x86/boot/compressed/misc.h linux-libre-3.16.50-gnu/arch/x86/boot/compressed/misc.h
--- linux-libre-3.16.49-gnu/arch/x86/boot/compressed/misc.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/x86/boot/compressed/misc.h	2017-11-11 08:34:06.000000000 -0500
@@ -2,14 +2,13 @@
 #define BOOT_COMPRESSED_MISC_H
 
 /*
- * we have to be careful, because no indirections are allowed here, and
- * paravirt_ops is a kind of one. As it will only run in baremetal anyway,
- * we just keep it from happening
+ * Special hack: we have to be careful, because no indirections are allowed here,
+ * and paravirt_ops is a kind of one. As it will only run in baremetal anyway,
+ * we just keep it from happening. (This list needs to be extended when new
+ * paravirt and debugging variants are added.)
  */
 #undef CONFIG_PARAVIRT
-#ifdef CONFIG_X86_32
-#define _ASM_X86_DESC_H 1
-#endif
+#undef CONFIG_PARAVIRT_SPINLOCKS
 
 #include <linux/linkage.h>
 #include <linux/screen_info.h>
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/x86/crypto/sha1_avx2_x86_64_asm.S linux-libre-3.16.50-gnu/arch/x86/crypto/sha1_avx2_x86_64_asm.S
--- linux-libre-3.16.49-gnu/arch/x86/crypto/sha1_avx2_x86_64_asm.S	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/x86/crypto/sha1_avx2_x86_64_asm.S	2017-11-11 08:34:06.000000000 -0500
@@ -117,11 +117,10 @@
 	.set T1, REG_T1
 .endm
 
-#define K_BASE		%r8
 #define HASH_PTR	%r9
+#define BLOCKS_CTR	%r8
 #define BUFFER_PTR	%r10
 #define BUFFER_PTR2	%r13
-#define BUFFER_END	%r11
 
 #define PRECALC_BUF	%r14
 #define WK_BUF		%r15
@@ -205,14 +204,14 @@
 		 * blended AVX2 and ALU instruction scheduling
 		 * 1 vector iteration per 8 rounds
 		 */
-		vmovdqu ((i * 2) + PRECALC_OFFSET)(BUFFER_PTR), W_TMP
+		vmovdqu (i * 2)(BUFFER_PTR), W_TMP
 	.elseif ((i & 7) == 1)
-		vinsertf128 $1, (((i-1) * 2)+PRECALC_OFFSET)(BUFFER_PTR2),\
+		vinsertf128 $1, ((i-1) * 2)(BUFFER_PTR2),\
 			 WY_TMP, WY_TMP
 	.elseif ((i & 7) == 2)
 		vpshufb YMM_SHUFB_BSWAP, WY_TMP, WY
 	.elseif ((i & 7) == 4)
-		vpaddd  K_XMM(K_BASE), WY, WY_TMP
+		vpaddd  K_XMM + K_XMM_AR(%rip), WY, WY_TMP
 	.elseif ((i & 7) == 7)
 		vmovdqu  WY_TMP, PRECALC_WK(i&~7)
 
@@ -255,7 +254,7 @@
 		vpxor	WY, WY_TMP, WY_TMP
 	.elseif ((i & 7) == 7)
 		vpxor	WY_TMP2, WY_TMP, WY
-		vpaddd	K_XMM(K_BASE), WY, WY_TMP
+		vpaddd  K_XMM + K_XMM_AR(%rip), WY, WY_TMP
 		vmovdqu	WY_TMP, PRECALC_WK(i&~7)
 
 		PRECALC_ROTATE_WY
@@ -291,7 +290,7 @@
 		vpsrld	$30, WY, WY
 		vpor	WY, WY_TMP, WY
 	.elseif ((i & 7) == 7)
-		vpaddd	K_XMM(K_BASE), WY, WY_TMP
+		vpaddd  K_XMM + K_XMM_AR(%rip), WY, WY_TMP
 		vmovdqu	WY_TMP, PRECALC_WK(i&~7)
 
 		PRECALC_ROTATE_WY
@@ -446,6 +445,16 @@
 
 .endm
 
+/* Add constant only if (%2 > %3) condition met (uses RTA as temp)
+ * %1 + %2 >= %3 ? %4 : 0
+ */
+.macro ADD_IF_GE a, b, c, d
+	mov     \a, RTA
+	add     $\d, RTA
+	cmp     $\c, \b
+	cmovge  RTA, \a
+.endm
+
 /*
  * macro implements 80 rounds of SHA-1, for multiple blocks with s/w pipelining
  */
@@ -463,13 +472,16 @@
 	lea	(2*4*80+32)(%rsp), WK_BUF
 
 	# Precalc WK for first 2 blocks
-	PRECALC_OFFSET = 0
+	ADD_IF_GE BUFFER_PTR2, BLOCKS_CTR, 2, 64
 	.set i, 0
 	.rept    160
 		PRECALC i
 		.set i, i + 1
 	.endr
-	PRECALC_OFFSET = 128
+
+	/* Go to next block if needed */
+	ADD_IF_GE BUFFER_PTR, BLOCKS_CTR, 3, 128
+	ADD_IF_GE BUFFER_PTR2, BLOCKS_CTR, 4, 128
 	xchg	WK_BUF, PRECALC_BUF
 
 	.align 32
@@ -479,8 +491,8 @@ _loop:
 	 * we use K_BASE value as a signal of a last block,
 	 * it is set below by: cmovae BUFFER_PTR, K_BASE
 	 */
-	cmp	K_BASE, BUFFER_PTR
-	jne	_begin
+	test BLOCKS_CTR, BLOCKS_CTR
+	jnz _begin
 	.align 32
 	jmp	_end
 	.align 32
@@ -512,10 +524,10 @@ _loop0:
 		.set j, j+2
 	.endr
 
-	add	$(2*64), BUFFER_PTR       /* move to next odd-64-byte block */
-	cmp	BUFFER_END, BUFFER_PTR    /* is current block the last one? */
-	cmovae	K_BASE, BUFFER_PTR	/* signal the last iteration smartly */
-
+	/* Update Counter */
+	sub $1, BLOCKS_CTR
+	/* Move to the next block only if needed*/
+	ADD_IF_GE BUFFER_PTR, BLOCKS_CTR, 4, 128
 	/*
 	 * rounds
 	 * 60,62,64,66,68
@@ -532,8 +544,8 @@ _loop0:
 	UPDATE_HASH	12(HASH_PTR), D
 	UPDATE_HASH	16(HASH_PTR), E
 
-	cmp	K_BASE, BUFFER_PTR	/* is current block the last one? */
-	je	_loop
+	test	BLOCKS_CTR, BLOCKS_CTR
+	jz	_loop
 
 	mov	TB, B
 
@@ -575,10 +587,10 @@ _loop2:
 		.set j, j+2
 	.endr
 
-	add	$(2*64), BUFFER_PTR2      /* move to next even-64-byte block */
-
-	cmp	BUFFER_END, BUFFER_PTR2   /* is current block the last one */
-	cmovae	K_BASE, BUFFER_PTR       /* signal the last iteration smartly */
+	/* update counter */
+	sub     $1, BLOCKS_CTR
+	/* Move to the next block only if needed*/
+	ADD_IF_GE BUFFER_PTR2, BLOCKS_CTR, 4, 128
 
 	jmp	_loop3
 _loop3:
@@ -641,19 +653,12 @@ _loop3:
 
 	avx2_zeroupper
 
-	lea	K_XMM_AR(%rip), K_BASE
-
+	/* Setup initial values */
 	mov	CTX, HASH_PTR
 	mov	BUF, BUFFER_PTR
-	lea	64(BUF), BUFFER_PTR2
-
-	shl	$6, CNT			/* mul by 64 */
-	add	BUF, CNT
-	add	$64, CNT
-	mov	CNT, BUFFER_END
 
-	cmp	BUFFER_END, BUFFER_PTR2
-	cmovae	K_BASE, BUFFER_PTR2
+	mov	BUF, BUFFER_PTR2
+	mov	CNT, BLOCKS_CTR
 
 	xmm_mov	BSWAP_SHUFB_CTL(%rip), YMM_SHUFB_BSWAP
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/x86/crypto/sha1_ssse3_glue.c linux-libre-3.16.50-gnu/arch/x86/crypto/sha1_ssse3_glue.c
--- linux-libre-3.16.49-gnu/arch/x86/crypto/sha1_ssse3_glue.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/x86/crypto/sha1_ssse3_glue.c	2017-11-11 08:34:06.000000000 -0500
@@ -224,7 +224,7 @@ static bool __init avx_usable(void)
 #ifdef CONFIG_AS_AVX2
 static bool __init avx2_usable(void)
 {
-	if (false && avx_usable() && cpu_has_avx2 &&
+	if (avx_usable() && cpu_has_avx2 &&
 	    boot_cpu_has(X86_FEATURE_BMI1) &&
 	    boot_cpu_has(X86_FEATURE_BMI2))
 		return true;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/x86/kernel/acpi/boot.c linux-libre-3.16.50-gnu/arch/x86/kernel/acpi/boot.c
--- linux-libre-3.16.49-gnu/arch/x86/kernel/acpi/boot.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/x86/kernel/acpi/boot.c	2017-11-11 08:34:06.000000000 -0500
@@ -910,6 +910,14 @@ void __init mp_override_legacy_irq(u8 bu
 	struct mpc_intsrc mp_irq;
 
 	/*
+	 * Check bus_irq boundary.
+	 */
+	if (bus_irq >= NR_IRQS_LEGACY) {
+		pr_warn("Invalid bus_irq %u for legacy override\n", bus_irq);
+		return;
+	}
+
+	/*
 	 * Convert 'gsi' to 'ioapic.pin'.
 	 */
 	ioapic = mp_find_ioapic(gsi);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/x86/kernel/cpu/perf_event.c linux-libre-3.16.50-gnu/arch/x86/kernel/cpu/perf_event.c
--- linux-libre-3.16.49-gnu/arch/x86/kernel/cpu/perf_event.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/x86/kernel/cpu/perf_event.c	2017-11-11 08:34:06.000000000 -0500
@@ -2009,17 +2009,14 @@ static unsigned long get_segment_base(un
 	if ((segment & SEGMENT_TI_MASK) == SEGMENT_LDT) {
 		struct ldt_struct *ldt;
 
-		if (idx > LDT_ENTRIES)
-			return 0;
-
 		/* IRQs are off, so this synchronizes with smp_store_release */
 		ldt = lockless_dereference(current->active_mm->context.ldt);
-		if (!ldt || idx > ldt->size)
+		if (!ldt || idx >= ldt->size)
 			return 0;
 
 		desc = &ldt->entries[idx];
 	} else {
-		if (idx > GDT_ENTRIES)
+		if (idx >= GDT_ENTRIES)
 			return 0;
 
 		desc = __this_cpu_ptr(&gdt_page.gdt[0]) + idx;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/x86/kernel/entry_64.S linux-libre-3.16.50-gnu/arch/x86/kernel/entry_64.S
--- linux-libre-3.16.49-gnu/arch/x86/kernel/entry_64.S	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/x86/kernel/entry_64.S	2017-11-11 08:34:06.000000000 -0500
@@ -1476,6 +1476,8 @@ ENTRY(nmi)
 	 * other IST entries.
 	 */
 
+	ASM_CLAC
+
 	/* Use %rdx as out temp variable throughout */
 	pushq_cfi %rdx
 	CFI_REL_OFFSET rdx, 0
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/x86/kernel/kprobes/core.c linux-libre-3.16.50-gnu/arch/x86/kernel/kprobes/core.c
--- linux-libre-3.16.49-gnu/arch/x86/kernel/kprobes/core.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/x86/kernel/kprobes/core.c	2017-11-11 08:34:06.000000000 -0500
@@ -401,6 +401,8 @@ static int arch_copy_kprobe(struct kprob
 
 int arch_prepare_kprobe(struct kprobe *p)
 {
+	int ret;
+
 	if (alternatives_text_reserved(p->addr, p->addr))
 		return -EINVAL;
 
@@ -411,7 +413,13 @@ int arch_prepare_kprobe(struct kprobe *p
 	if (!p->ainsn.insn)
 		return -ENOMEM;
 
-	return arch_copy_kprobe(p);
+	ret = arch_copy_kprobe(p);
+	if (ret) {
+		free_insn_slot(p->ainsn.insn, 0);
+		p->ainsn.insn = NULL;
+	}
+
+	return ret;
 }
 
 void arch_arm_kprobe(struct kprobe *p)
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/x86/kernel/kvm.c linux-libre-3.16.50-gnu/arch/x86/kernel/kvm.c
--- linux-libre-3.16.49-gnu/arch/x86/kernel/kvm.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/x86/kernel/kvm.c	2017-11-11 08:34:06.000000000 -0500
@@ -150,6 +150,8 @@ void kvm_async_pf_task_wait(u32 token)
 		if (hlist_unhashed(&n.link))
 			break;
 
+		rcu_irq_exit();
+
 		if (!n.halted) {
 			local_irq_enable();
 			schedule();
@@ -158,11 +160,11 @@ void kvm_async_pf_task_wait(u32 token)
 			/*
 			 * We cannot reschedule. So halt.
 			 */
-			rcu_irq_exit();
 			native_safe_halt();
 			local_irq_disable();
-			rcu_irq_enter();
 		}
+
+		rcu_irq_enter();
 	}
 	if (!n.halted)
 		finish_wait(&n.wq, &wait);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/x86/xen/mmu.c linux-libre-3.16.50-gnu/arch/x86/xen/mmu.c
--- linux-libre-3.16.49-gnu/arch/x86/xen/mmu.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/x86/xen/mmu.c	2017-11-11 08:34:06.000000000 -0500
@@ -1187,7 +1187,7 @@ static void __init xen_cleanhighmap(unsi
 
 	/* NOTE: The loop is more greedy than the cleanup_highmap variant.
 	 * We include the PMD passed in on _both_ boundaries. */
-	for (; vaddr <= vaddr_end && (pmd < (level2_kernel_pgt + PAGE_SIZE));
+	for (; vaddr <= vaddr_end && (pmd < (level2_kernel_pgt + PTRS_PER_PMD));
 			pmd++, vaddr += PMD_SIZE) {
 		if (pmd_none(*pmd))
 			continue;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/xtensa/kernel/xtensa_ksyms.c linux-libre-3.16.50-gnu/arch/xtensa/kernel/xtensa_ksyms.c
--- linux-libre-3.16.49-gnu/arch/xtensa/kernel/xtensa_ksyms.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/xtensa/kernel/xtensa_ksyms.c	2017-11-11 08:34:06.000000000 -0500
@@ -94,13 +94,11 @@ unsigned long __sync_fetch_and_or_4(unsi
 }
 EXPORT_SYMBOL(__sync_fetch_and_or_4);
 
-#ifdef CONFIG_NET
 /*
  * Networking support
  */
 EXPORT_SYMBOL(csum_partial);
 EXPORT_SYMBOL(csum_partial_copy_generic);
-#endif /* CONFIG_NET */
 
 /*
  * Architecture-specific symbols
diff -druNp --no-dereference linux-libre-3.16.49-gnu/arch/xtensa/mm/cache.c linux-libre-3.16.50-gnu/arch/xtensa/mm/cache.c
--- linux-libre-3.16.49-gnu/arch/xtensa/mm/cache.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/arch/xtensa/mm/cache.c	2017-11-11 08:34:06.000000000 -0500
@@ -63,7 +63,7 @@
 #error "HIGHMEM is not supported on cores with aliasing cache."
 #endif
 
-#if (DCACHE_WAY_SIZE > PAGE_SIZE) && XCHAL_DCACHE_IS_WRITEBACK
+#if (DCACHE_WAY_SIZE > PAGE_SIZE)
 
 /*
  * Any time the kernel writes to a user page cache page, or it is about to
@@ -116,7 +116,7 @@ void flush_dcache_page(struct page *page
 
 	/* There shouldn't be an entry in the cache for this page anymore. */
 }
-
+EXPORT_SYMBOL(flush_dcache_page);
 
 /*
  * For now, flush the whole cache. FIXME??
@@ -128,6 +128,7 @@ void local_flush_cache_range(struct vm_a
 	__flush_invalidate_dcache_all();
 	__invalidate_icache_all();
 }
+EXPORT_SYMBOL(local_flush_cache_range);
 
 /* 
  * Remove any entry in the cache for this page. 
@@ -147,8 +148,9 @@ void local_flush_cache_page(struct vm_ar
 	__flush_invalidate_dcache_page_alias(virt, phys);
 	__invalidate_icache_page_alias(virt, phys);
 }
+EXPORT_SYMBOL(local_flush_cache_page);
 
-#endif
+#endif /* DCACHE_WAY_SIZE > PAGE_SIZE */
 
 void
 update_mmu_cache(struct vm_area_struct * vma, unsigned long addr, pte_t *ptep)
@@ -165,7 +167,7 @@ update_mmu_cache(struct vm_area_struct *
 
 	flush_tlb_page(vma, addr);
 
-#if (DCACHE_WAY_SIZE > PAGE_SIZE) && XCHAL_DCACHE_IS_WRITEBACK
+#if (DCACHE_WAY_SIZE > PAGE_SIZE)
 
 	if (!PageReserved(page) && test_bit(PG_arch_1, &page->flags)) {
 
@@ -197,7 +199,7 @@ update_mmu_cache(struct vm_area_struct *
  * flush_dcache_page() on the page.
  */
 
-#if (DCACHE_WAY_SIZE > PAGE_SIZE) && XCHAL_DCACHE_IS_WRITEBACK
+#if (DCACHE_WAY_SIZE > PAGE_SIZE)
 
 void copy_to_user_page(struct vm_area_struct *vma, struct page *page,
 		unsigned long vaddr, void *dst, const void *src,
diff -druNp --no-dereference linux-libre-3.16.49-gnu/block/bio.c linux-libre-3.16.50-gnu/block/bio.c
--- linux-libre-3.16.49-gnu/block/bio.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/block/bio.c	2017-11-11 08:34:06.000000000 -0500
@@ -1337,6 +1337,7 @@ static struct bio *__bio_map_user_iov(st
 		offset = uaddr & ~PAGE_MASK;
 		for (j = cur_page; j < page_limit; j++) {
 			unsigned int bytes = PAGE_SIZE - offset;
+			unsigned short prev_bi_vcnt = bio->bi_vcnt;
 
 			if (len <= 0)
 				break;
@@ -1351,6 +1352,13 @@ static struct bio *__bio_map_user_iov(st
 					    bytes)
 				break;
 
+			/*
+			 * check if vector was merged with previous
+			 * drop page reference if needed
+			 */
+			if (bio->bi_vcnt == prev_bi_vcnt)
+				put_page(pages[j]);
+
 			len -= bytes;
 			offset = 0;
 		}
diff -druNp --no-dereference linux-libre-3.16.49-gnu/Documentation/video4linux/v4l2-pci-skeleton.c linux-libre-3.16.50-gnu/Documentation/video4linux/v4l2-pci-skeleton.c
--- linux-libre-3.16.49-gnu/Documentation/video4linux/v4l2-pci-skeleton.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/Documentation/video4linux/v4l2-pci-skeleton.c	2017-11-11 08:34:06.000000000 -0500
@@ -42,7 +42,6 @@
 MODULE_DESCRIPTION("V4L2 PCI Skeleton Driver");
 MODULE_AUTHOR("Hans Verkuil");
 MODULE_LICENSE("GPL v2");
-MODULE_DEVICE_TABLE(pci, skeleton_pci_tbl);
 
 /**
  * struct skeleton - All internal data for one instance of device
@@ -95,6 +94,7 @@ static const struct pci_device_id skelet
 	/* { PCI_DEVICE(PCI_VENDOR_ID_, PCI_DEVICE_ID_) }, */
 	{ 0, }
 };
+MODULE_DEVICE_TABLE(pci, skeleton_pci_tbl);
 
 /*
  * HDTV: this structure has the capabilities of the HDTV receiver.
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/ata/libata-scsi.c linux-libre-3.16.50-gnu/drivers/ata/libata-scsi.c
--- linux-libre-3.16.49-gnu/drivers/ata/libata-scsi.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/ata/libata-scsi.c	2017-11-11 08:34:06.000000000 -0500
@@ -2796,10 +2796,12 @@ static unsigned int atapi_xlat(struct at
 static struct ata_device *ata_find_dev(struct ata_port *ap, int devno)
 {
 	if (!sata_pmp_attached(ap)) {
-		if (likely(devno < ata_link_max_devices(&ap->link)))
+		if (likely(devno >= 0 &&
+			   devno < ata_link_max_devices(&ap->link)))
 			return &ap->link.device[devno];
 	} else {
-		if (likely(devno < ap->nr_pmp_links))
+		if (likely(devno >= 0 &&
+			   devno < ap->nr_pmp_links))
 			return &ap->pmp_link[devno].device[0];
 	}
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/ata/pata_hpt366.c linux-libre-3.16.50-gnu/drivers/ata/pata_hpt366.c
--- linux-libre-3.16.49-gnu/drivers/ata/pata_hpt366.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/ata/pata_hpt366.c	2017-11-11 08:34:06.000000000 -0500
@@ -352,7 +352,7 @@ static int hpt36x_init_one(struct pci_de
 	};
 	const struct ata_port_info *ppi[] = { &info_hpt366, NULL };
 
-	void *hpriv = NULL;
+	const void *hpriv = NULL;
 	u32 reg1;
 	int rc;
 
@@ -383,7 +383,7 @@ static int hpt36x_init_one(struct pci_de
 		break;
 	}
 	/* Now kick off ATA set up */
-	return ata_pci_bmdma_init_one(dev, ppi, &hpt36x_sht, hpriv, 0);
+	return ata_pci_bmdma_init_one(dev, ppi, &hpt36x_sht, (void *)hpriv, 0);
 }
 
 #ifdef CONFIG_PM_SLEEP
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/block/drbd/drbd_bitmap.c linux-libre-3.16.50-gnu/drivers/block/drbd/drbd_bitmap.c
--- linux-libre-3.16.49-gnu/drivers/block/drbd/drbd_bitmap.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/block/drbd/drbd_bitmap.c	2017-11-11 08:34:06.000000000 -0500
@@ -478,8 +478,14 @@ void drbd_bm_cleanup(struct drbd_device
  * this masks out the remaining bits.
  * Returns the number of bits cleared.
  */
+#ifndef BITS_PER_PAGE
 #define BITS_PER_PAGE		(1UL << (PAGE_SHIFT + 3))
 #define BITS_PER_PAGE_MASK	(BITS_PER_PAGE - 1)
+#else
+# if BITS_PER_PAGE != (1UL << (PAGE_SHIFT + 3))
+#  error "ambiguous BITS_PER_PAGE"
+# endif
+#endif
 #define BITS_PER_LONG_MASK	(BITS_PER_LONG - 1)
 static int bm_clear_surplus(struct drbd_bitmap *b)
 {
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/block/paride/pg.c linux-libre-3.16.50-gnu/drivers/block/paride/pg.c
--- linux-libre-3.16.49-gnu/drivers/block/paride/pg.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/block/paride/pg.c	2017-11-11 08:34:06.000000000 -0500
@@ -137,7 +137,7 @@
 
 */
 
-static bool verbose = 0;
+static int verbose;
 static int major = PG_MAJOR;
 static char *name = PG_NAME;
 static int disable = 0;
@@ -168,7 +168,7 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_SLV,
 
 #include <asm/uaccess.h>
 
-module_param(verbose, bool, 0644);
+module_param(verbose, int, 0644);
 module_param(major, int, 0);
 module_param(name, charp, 0);
 module_param_array(drive0, int, NULL, 0);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/clk/clk-efm32gg.c linux-libre-3.16.50-gnu/drivers/clk/clk-efm32gg.c
--- linux-libre-3.16.49-gnu/drivers/clk/clk-efm32gg.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/clk/clk-efm32gg.c	2017-11-11 08:34:06.000000000 -0500
@@ -22,7 +22,7 @@ static struct clk_onecell_data clk_data
 	.clk_num = ARRAY_SIZE(clk),
 };
 
-static int __init efm32gg_cmu_init(struct device_node *np)
+static void __init efm32gg_cmu_init(struct device_node *np)
 {
 	int i;
 	void __iomem *base;
@@ -33,7 +33,7 @@ static int __init efm32gg_cmu_init(struc
 	base = of_iomap(np, 0);
 	if (!base) {
 		pr_warn("Failed to map address range for efm32gg,cmu node\n");
-		return -EADDRNOTAVAIL;
+		return;
 	}
 
 	clk[clk_HFXO] = clk_register_fixed_rate(NULL, "HFXO", NULL,
@@ -76,6 +76,6 @@ static int __init efm32gg_cmu_init(struc
 	clk[clk_HFPERCLKDAC0] = clk_register_gate(NULL, "HFPERCLK.DAC0",
 			"HFXO", 0, base + CMU_HFPERCLKEN0, 17, 0, NULL);
 
-	return of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
+	of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
 }
 CLK_OF_DECLARE(efm32ggcmu, "efm32gg,cmu", efm32gg_cmu_init);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/dma/amba-pl08x.c linux-libre-3.16.50-gnu/drivers/dma/amba-pl08x.c
--- linux-libre-3.16.49-gnu/drivers/dma/amba-pl08x.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/dma/amba-pl08x.c	2017-11-11 08:34:06.000000000 -0500
@@ -1040,7 +1040,7 @@ static int pl08x_fill_llis_for_desc(stru
 
 		if (early_bytes) {
 			dev_vdbg(&pl08x->adev->dev,
-				"%s byte width LLIs (remain 0x%08x)\n",
+				"%s byte width LLIs (remain 0x%08zx)\n",
 				__func__, bd.remainder);
 			prep_byte_width_lli(pl08x, &bd, &cctl, early_bytes,
 				num_llis++, &total_bytes);
@@ -1662,7 +1662,7 @@ static struct dma_async_tx_descriptor *p
 	dma_addr_t slave_addr;
 
 	dev_dbg(&pl08x->adev->dev,
-		"%s prepare cyclic transaction of %d/%d bytes %s %s\n",
+		"%s prepare cyclic transaction of %zd/%zd bytes %s %s\n",
 		__func__, period_len, buf_len,
 		direction == DMA_MEM_TO_DEV ? "to" : "from",
 		plchan->name);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/gpio/gpio-tegra.c linux-libre-3.16.50-gnu/drivers/gpio/gpio-tegra.c
--- linux-libre-3.16.49-gnu/drivers/gpio/gpio-tegra.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/gpio/gpio-tegra.c	2017-11-11 08:34:06.000000000 -0500
@@ -271,7 +271,7 @@ static void tegra_gpio_irq_handler(unsig
 	struct tegra_gpio_bank *bank;
 	int port;
 	int pin;
-	int unmasked = 0;
+	bool unmasked = false;
 	struct irq_chip *chip = irq_desc_get_chip(desc);
 
 	chained_irq_enter(chip, desc);
@@ -291,8 +291,8 @@ static void tegra_gpio_irq_handler(unsig
 			 * before executing the hander so that we don't
 			 * miss edges
 			 */
-			if (lvl & (0x100 << pin)) {
-				unmasked = 1;
+			if (!unmasked && lvl & (0x100 << pin)) {
+				unmasked = true;
 				chained_irq_exit(chip, desc);
 			}
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/gpu/drm/drm_gem.c linux-libre-3.16.50-gnu/drivers/gpu/drm/drm_gem.c
--- linux-libre-3.16.49-gnu/drivers/gpu/drm/drm_gem.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/gpu/drm/drm_gem.c	2017-11-11 08:34:06.000000000 -0500
@@ -698,13 +698,13 @@ drm_gem_object_release_handle(int id, vo
 	struct drm_gem_object *obj = ptr;
 	struct drm_device *dev = obj->dev;
 
+	if (dev->driver->gem_close_object)
+		dev->driver->gem_close_object(obj, file_priv);
+
 	if (drm_core_check_feature(dev, DRIVER_PRIME))
 		drm_gem_remove_prime_handles(obj, file_priv);
 	drm_vma_node_revoke(&obj->vma_node, file_priv->filp);
 
-	if (dev->driver->gem_close_object)
-		dev->driver->gem_close_object(obj, file_priv);
-
 	drm_gem_object_handle_unreference_unlocked(obj);
 
 	return 0;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/gpu/drm/i915/i915_debugfs.c linux-libre-3.16.50-gnu/drivers/gpu/drm/i915/i915_debugfs.c
--- linux-libre-3.16.49-gnu/drivers/gpu/drm/i915/i915_debugfs.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/gpu/drm/i915/i915_debugfs.c	2017-11-11 08:34:06.000000000 -0500
@@ -141,10 +141,11 @@ describe_obj(struct seq_file *m, struct
 		   obj->madv == I915_MADV_DONTNEED ? " purgeable" : "");
 	if (obj->base.name)
 		seq_printf(m, " (name: %d)", obj->base.name);
-	list_for_each_entry(vma, &obj->vma_list, vma_link)
+	list_for_each_entry(vma, &obj->vma_list, vma_link) {
 		if (vma->pin_count > 0)
 			pin_count++;
-		seq_printf(m, " (pinned x %d)", pin_count);
+	}
+	seq_printf(m, " (pinned x %d)", pin_count);
 	if (obj->pin_display)
 		seq_printf(m, " (display)");
 	if (obj->fence_reg != I915_FENCE_REG_NONE)
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/gpu/drm/msm/msm_gem_submit.c linux-libre-3.16.50-gnu/drivers/gpu/drm/msm/msm_gem_submit.c
--- linux-libre-3.16.49-gnu/drivers/gpu/drm/msm/msm_gem_submit.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/gpu/drm/msm/msm_gem_submit.c	2017-11-11 08:34:06.000000000 -0500
@@ -34,10 +34,13 @@ static inline void __user *to_user_ptr(u
 }
 
 static struct msm_gem_submit *submit_create(struct drm_device *dev,
-		struct msm_gpu *gpu, int nr)
+		struct msm_gpu *gpu, uint32_t nr)
 {
 	struct msm_gem_submit *submit;
-	int sz = sizeof(*submit) + (nr * sizeof(submit->bos[0]));
+	uint64_t sz = sizeof(*submit) + ((u64)nr * sizeof(submit->bos[0]));
+
+	if (sz > SIZE_MAX)
+		return NULL;
 
 	submit = kmalloc(sz, GFP_TEMPORARY | __GFP_NOWARN | __GFP_NORETRY);
 	if (submit) {
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c linux-libre-3.16.50-gnu/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
--- linux-libre-3.16.49-gnu/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c	2017-11-11 08:34:06.000000000 -0500
@@ -285,7 +285,7 @@ static int vmw_cmd_invalid(struct vmw_pr
 			   struct vmw_sw_context *sw_context,
 			   SVGA3dCmdHeader *header)
 {
-	return capable(CAP_SYS_ADMIN) ? : -EINVAL;
+	return -EINVAL;
 }
 
 static int vmw_cmd_ok(struct vmw_private *dev_priv,
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/hid/usbhid/hid-core.c linux-libre-3.16.50-gnu/drivers/hid/usbhid/hid-core.c
--- linux-libre-3.16.49-gnu/drivers/hid/usbhid/hid-core.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/hid/usbhid/hid-core.c	2017-11-11 08:34:06.000000000 -0500
@@ -975,6 +975,8 @@ static int usbhid_parse(struct hid_devic
 	unsigned int rsize = 0;
 	char *rdesc;
 	int ret, n;
+	int num_descriptors;
+	size_t offset = offsetof(struct hid_descriptor, desc);
 
 	quirks = usbhid_lookup_quirk(le16_to_cpu(dev->descriptor.idVendor),
 			le16_to_cpu(dev->descriptor.idProduct));
@@ -997,10 +999,18 @@ static int usbhid_parse(struct hid_devic
 		return -ENODEV;
 	}
 
+	if (hdesc->bLength < sizeof(struct hid_descriptor)) {
+		dbg_hid("hid descriptor is too short\n");
+		return -EINVAL;
+	}
+
 	hid->version = le16_to_cpu(hdesc->bcdHID);
 	hid->country = hdesc->bCountryCode;
 
-	for (n = 0; n < hdesc->bNumDescriptors; n++)
+	num_descriptors = min_t(int, hdesc->bNumDescriptors,
+	       (hdesc->bLength - offset) / sizeof(struct hid_class_descriptor));
+
+	for (n = 0; n < num_descriptors; n++)
 		if (hdesc->desc[n].bDescriptorType == HID_DT_REPORT)
 			rsize = le16_to_cpu(hdesc->desc[n].wDescriptorLength);
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/i2c/busses/i2c-ismt.c linux-libre-3.16.50-gnu/drivers/i2c/busses/i2c-ismt.c
--- linux-libre-3.16.49-gnu/drivers/i2c/busses/i2c-ismt.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/i2c/busses/i2c-ismt.c	2017-11-11 08:34:06.000000000 -0500
@@ -343,6 +343,11 @@ static int ismt_process_desc(const struc
 			data->word = dma_buffer[0] | (dma_buffer[1] << 8);
 			break;
 		case I2C_SMBUS_BLOCK_DATA:
+			if (desc->rxbytes != dma_buffer[0] + 1)
+				return -EMSGSIZE;
+
+			memcpy(data->block, dma_buffer, desc->rxbytes);
+			break;
 		case I2C_SMBUS_I2C_BLOCK_DATA:
 			memcpy(&data->block[1], dma_buffer, desc->rxbytes);
 			data->block[0] = desc->rxbytes;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/i2c/muxes/Kconfig linux-libre-3.16.50-gnu/drivers/i2c/muxes/Kconfig
--- linux-libre-3.16.49-gnu/drivers/i2c/muxes/Kconfig	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/i2c/muxes/Kconfig	2017-11-11 08:34:06.000000000 -0500
@@ -58,6 +58,6 @@ config I2C_MUX_PINCTRL
 	  different sets of pins at run-time.
 
 	  This driver can also be built as a module. If so, the module will be
-	  called pinctrl-i2cmux.
+	  called i2c-mux-pinctrl.
 
 endmenu
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/iio/adc/exynos_adc.c linux-libre-3.16.50-gnu/drivers/iio/adc/exynos_adc.c
--- linux-libre-3.16.49-gnu/drivers/iio/adc/exynos_adc.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/iio/adc/exynos_adc.c	2017-11-11 08:34:06.000000000 -0500
@@ -109,7 +109,7 @@ static inline unsigned int exynos_adc_ge
 	const struct of_device_id *match;
 
 	match = of_match_node(exynos_adc_match, pdev->dev.of_node);
-	return (unsigned int)match->data;
+	return (uintptr_t)match->data;
 }
 
 static void exynos_adc_hw_init(struct exynos_adc *info)
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/iio/adc/vf610_adc.c linux-libre-3.16.50-gnu/drivers/iio/adc/vf610_adc.c
--- linux-libre-3.16.49-gnu/drivers/iio/adc/vf610_adc.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/iio/adc/vf610_adc.c	2017-11-11 08:34:06.000000000 -0500
@@ -71,7 +71,7 @@
 #define VF610_ADC_ADSTS_MASK		0x300
 #define VF610_ADC_ADLPC_EN		0x80
 #define VF610_ADC_ADHSC_EN		0x400
-#define VF610_ADC_REFSEL_VALT		0x100
+#define VF610_ADC_REFSEL_VALT		0x800
 #define VF610_ADC_REFSEL_VBG		0x1000
 #define VF610_ADC_ADTRG_HARD		0x2000
 #define VF610_ADC_AVGS_8		0x4000
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/iio/imu/adis16480.c linux-libre-3.16.50-gnu/drivers/iio/imu/adis16480.c
--- linux-libre-3.16.49-gnu/drivers/iio/imu/adis16480.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/iio/imu/adis16480.c	2017-11-11 08:34:06.000000000 -0500
@@ -724,7 +724,7 @@ static const struct adis16480_chip_info
 		.gyro_max_val = IIO_RAD_TO_DEGREE(22500),
 		.gyro_max_scale = 450,
 		.accel_max_val = IIO_M_S_2_TO_G(12500),
-		.accel_max_scale = 5,
+		.accel_max_scale = 10,
 	},
 	[ADIS16485] = {
 		.channels = adis16485_channels,
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/iio/light/tsl2563.c linux-libre-3.16.50-gnu/drivers/iio/light/tsl2563.c
--- linux-libre-3.16.49-gnu/drivers/iio/light/tsl2563.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/iio/light/tsl2563.c	2017-11-11 08:34:06.000000000 -0500
@@ -626,7 +626,7 @@ static irqreturn_t tsl2563_event_handler
 	struct tsl2563_chip *chip = iio_priv(dev_info);
 
 	iio_push_event(dev_info,
-		       IIO_UNMOD_EVENT_CODE(IIO_LIGHT,
+		       IIO_UNMOD_EVENT_CODE(IIO_INTENSITY,
 					    0,
 					    IIO_EV_TYPE_THRESH,
 					    IIO_EV_DIR_EITHER),
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/infiniband/core/cma.c linux-libre-3.16.50-gnu/drivers/infiniband/core/cma.c
--- linux-libre-3.16.49-gnu/drivers/infiniband/core/cma.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/infiniband/core/cma.c	2017-11-11 08:34:06.000000000 -0500
@@ -753,6 +753,8 @@ int rdma_init_qp_attr(struct rdma_cm_id
 		} else
 			ret = iw_cm_init_qp_attr(id_priv->cm_id.iw, qp_attr,
 						 qp_attr_mask);
+		qp_attr->port_num = id_priv->id.port_num;
+		*qp_attr_mask |= IB_QP_PORT;
 		break;
 	default:
 		ret = -ENOSYS;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/infiniband/core/uverbs_cmd.c linux-libre-3.16.50-gnu/drivers/infiniband/core/uverbs_cmd.c
--- linux-libre-3.16.49-gnu/drivers/infiniband/core/uverbs_cmd.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/infiniband/core/uverbs_cmd.c	2017-11-11 08:34:06.000000000 -0500
@@ -1303,7 +1303,7 @@ ssize_t ib_uverbs_resize_cq(struct ib_uv
 			    int out_len)
 {
 	struct ib_uverbs_resize_cq	cmd;
-	struct ib_uverbs_resize_cq_resp	resp;
+	struct ib_uverbs_resize_cq_resp	resp = {};
 	struct ib_udata                 udata;
 	struct ib_cq			*cq;
 	int				ret = -EINVAL;
@@ -1915,7 +1915,8 @@ ssize_t ib_uverbs_modify_qp(struct ib_uv
 		goto out;
 	}
 
-	if (!rdma_is_port_valid(qp->device, cmd.port_num)) {
+	if ((cmd.attr_mask & IB_QP_PORT) &&
+	    !rdma_is_port_valid(qp->device, cmd.port_num)) {
 		ret = -EINVAL;
 		goto release_qp;
 	}
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/infiniband/core/uverbs_main.c linux-libre-3.16.50-gnu/drivers/infiniband/core/uverbs_main.c
--- linux-libre-3.16.49-gnu/drivers/infiniband/core/uverbs_main.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/infiniband/core/uverbs_main.c	2017-11-11 08:34:06.000000000 -0500
@@ -315,6 +315,7 @@ static void ib_uverbs_release_file(struc
 	if (atomic_dec_and_test(&file->device->refcount))
 		ib_uverbs_comp_dev(file->device);
 
+	kobject_put(&file->device->kobj);
 	kfree(file);
 }
 
@@ -784,7 +785,6 @@ err:
 static int ib_uverbs_close(struct inode *inode, struct file *filp)
 {
 	struct ib_uverbs_file *file = filp->private_data;
-	struct ib_uverbs_device *dev = file->device;
 
 	ib_uverbs_cleanup_ucontext(file, file->ucontext);
 
@@ -792,7 +792,6 @@ static int ib_uverbs_close(struct inode
 		kref_put(&file->async_file->ref, ib_uverbs_release_event_file);
 
 	kref_put(&file->ref, ib_uverbs_release_file);
-	kobject_put(&dev->kobj);
 
 	return 0;
 }
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/infiniband/hw/cxgb3/iwch_provider.c linux-libre-3.16.50-gnu/drivers/infiniband/hw/cxgb3/iwch_provider.c
--- linux-libre-3.16.49-gnu/drivers/infiniband/hw/cxgb3/iwch_provider.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/infiniband/hw/cxgb3/iwch_provider.c	2017-11-11 08:34:06.000000000 -0500
@@ -794,7 +794,7 @@ static struct ib_mr *iwch_alloc_fast_reg
 	struct iwch_mr *mhp;
 	u32 mmid;
 	u32 stag = 0;
-	int ret = 0;
+	int ret = -ENOMEM;
 
 	php = to_iwch_pd(pd);
 	rhp = php->rhp;
@@ -817,7 +817,8 @@ static struct ib_mr *iwch_alloc_fast_reg
 	mhp->attr.state = 1;
 	mmid = (stag) >> 8;
 	mhp->ibmr.rkey = mhp->ibmr.lkey = stag;
-	if (insert_handle(rhp, &rhp->mmidr, mhp, mmid))
+	ret = insert_handle(rhp, &rhp->mmidr, mhp, mmid);
+	if (ret)
 		goto err3;
 
 	PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/infiniband/hw/cxgb4/cq.c linux-libre-3.16.50-gnu/drivers/infiniband/hw/cxgb4/cq.c
--- linux-libre-3.16.49-gnu/drivers/infiniband/hw/cxgb4/cq.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/infiniband/hw/cxgb4/cq.c	2017-11-11 08:34:06.000000000 -0500
@@ -938,6 +938,7 @@ struct ib_cq *c4iw_create_cq(struct ib_d
 		goto err2;
 
 	if (ucontext) {
+		ret = -ENOMEM;
 		mm = kmalloc(sizeof *mm, GFP_KERNEL);
 		if (!mm)
 			goto err3;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/infiniband/hw/mlx5/mem.c linux-libre-3.16.50-gnu/drivers/infiniband/hw/mlx5/mem.c
--- linux-libre-3.16.49-gnu/drivers/infiniband/hw/mlx5/mem.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/infiniband/hw/mlx5/mem.c	2017-11-11 08:34:06.000000000 -0500
@@ -68,7 +68,7 @@ void mlx5_ib_cont_pages(struct ib_umem *
 		for (k = 0; k < len; k++) {
 			if (!(i & mask)) {
 				tmp = (unsigned long)pfn;
-				m = min(m, find_first_bit(&tmp, sizeof(tmp)));
+				m = min_t(unsigned long, m, find_first_bit(&tmp, sizeof(tmp)));
 				skip = 1 << m;
 				mask = skip - 1;
 				base = pfn;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c linux-libre-3.16.50-gnu/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
--- linux-libre-3.16.49-gnu/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c	2017-11-11 08:34:06.000000000 -0500
@@ -565,7 +565,8 @@ err:
 	if (is_uctx_pd) {
 		ocrdma_release_ucontext_pd(uctx);
 	} else {
-		status = ocrdma_mbx_dealloc_pd(dev, pd);
+		if (ocrdma_mbx_dealloc_pd(dev, pd))
+			pr_err("%s: ocrdma_mbx_dealloc_pd() failed\n", __func__);
 		kfree(pd);
 	}
 exit:
@@ -1719,6 +1720,7 @@ struct ib_srq *ocrdma_create_srq(struct
 		goto err;
 
 	if (udata == NULL) {
+		status = -ENOMEM;
 		srq->rqe_wr_id_tbl = kzalloc(sizeof(u64) * srq->rq.max_cnt,
 			    GFP_KERNEL);
 		if (srq->rqe_wr_id_tbl == NULL)
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/infiniband/ulp/ipoib/ipoib_cm.c linux-libre-3.16.50-gnu/drivers/infiniband/ulp/ipoib/ipoib_cm.c
--- linux-libre-3.16.49-gnu/drivers/infiniband/ulp/ipoib/ipoib_cm.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/infiniband/ulp/ipoib/ipoib_cm.c	2017-11-11 08:34:06.000000000 -0500
@@ -508,7 +508,6 @@ static int ipoib_cm_rx_handler(struct ib
 	case IB_CM_REQ_RECEIVED:
 		return ipoib_cm_req_handler(cm_id, event);
 	case IB_CM_DREQ_RECEIVED:
-		p = cm_id->context;
 		ib_send_cm_drep(cm_id, NULL, 0);
 		/* Fall through */
 	case IB_CM_REJ_RECEIVED:
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/infiniband/ulp/ipoib/ipoib_main.c linux-libre-3.16.50-gnu/drivers/infiniband/ulp/ipoib/ipoib_main.c
--- linux-libre-3.16.49-gnu/drivers/infiniband/ulp/ipoib/ipoib_main.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/infiniband/ulp/ipoib/ipoib_main.c	2017-11-11 08:34:06.000000000 -0500
@@ -1235,6 +1235,7 @@ static void ipoib_flush_neighs(struct ip
 	int i, wait_flushed = 0;
 
 	init_completion(&priv->ntbl.flushed);
+	set_bit(IPOIB_NEIGH_TBL_FLUSH, &priv->flags);
 
 	spin_lock_irqsave(&priv->lock, flags);
 
@@ -1279,7 +1280,6 @@ static void ipoib_neigh_hash_uninit(stru
 
 	ipoib_dbg(priv, "ipoib_neigh_hash_uninit\n");
 	init_completion(&priv->ntbl.deleted);
-	set_bit(IPOIB_NEIGH_TBL_FLUSH, &priv->flags);
 
 	/* Stop GC if called at init fail need to cancel work */
 	stopped = test_and_set_bit(IPOIB_STOP_NEIGH_GC, &priv->flags);
@@ -1768,6 +1768,7 @@ static int __init ipoib_init_module(void
 	ipoib_sendq_size = max3(ipoib_sendq_size, 2 * MAX_SEND_CQE, IPOIB_MIN_QUEUE_SIZE);
 #ifdef CONFIG_INFINIBAND_IPOIB_CM
 	ipoib_max_conn_qp = min(ipoib_max_conn_qp, IPOIB_CM_MAX_CONN_QP);
+	ipoib_max_conn_qp = max(ipoib_max_conn_qp, 0);
 #endif
 
 	/*
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/input/joystick/analog.c linux-libre-3.16.50-gnu/drivers/input/joystick/analog.c
--- linux-libre-3.16.49-gnu/drivers/input/joystick/analog.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/input/joystick/analog.c	2017-11-11 08:34:06.000000000 -0500
@@ -158,7 +158,7 @@ static unsigned int get_time_pit(void)
 #define GET_TIME(x)	rdtscl(x)
 #define DELTA(x,y)	((y)-(x))
 #define TIME_NAME	"TSC"
-#elif defined(__alpha__) || defined(CONFIG_MN10300) || defined(CONFIG_ARM) || defined(CONFIG_TILE)
+#elif defined(__alpha__) || defined(CONFIG_MN10300) || defined(CONFIG_ARM) || defined(CONFIG_ARM64) || defined(CONFIG_TILE)
 #define GET_TIME(x)	do { x = get_cycles(); } while (0)
 #define DELTA(x,y)	((y)-(x))
 #define TIME_NAME	"get_cycles"
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/input/mouse/trackpoint.c linux-libre-3.16.50-gnu/drivers/input/mouse/trackpoint.c
--- linux-libre-3.16.49-gnu/drivers/input/mouse/trackpoint.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/input/mouse/trackpoint.c	2017-11-11 08:34:06.000000000 -0500
@@ -263,7 +263,8 @@ static int trackpoint_start_protocol(str
 	if (ps2_command(&psmouse->ps2dev, param, MAKE_PS2_CMD(0, 2, TP_READ_ID)))
 		return -1;
 
-	if (param[0] != TP_MAGIC_IDENT)
+	/* add new TP ID. */
+	if (!(param[0] & TP_MAGIC_IDENT))
 		return -1;
 
 	if (firmware_id)
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/input/mouse/trackpoint.h linux-libre-3.16.50-gnu/drivers/input/mouse/trackpoint.h
--- linux-libre-3.16.49-gnu/drivers/input/mouse/trackpoint.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/input/mouse/trackpoint.h	2017-11-11 08:34:06.000000000 -0500
@@ -21,8 +21,9 @@
 #define TP_COMMAND		0xE2	/* Commands start with this */
 
 #define TP_READ_ID		0xE1	/* Sent for device identification */
-#define TP_MAGIC_IDENT		0x01	/* Sent after a TP_READ_ID followed */
+#define TP_MAGIC_IDENT		0x03	/* Sent after a TP_READ_ID followed */
 					/* by the firmware ID */
+					/* Firmware ID includes 0x1, 0x2, 0x3 */
 
 
 /*
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/input/serio/gscps2.c linux-libre-3.16.50-gnu/drivers/input/serio/gscps2.c
--- linux-libre-3.16.49-gnu/drivers/input/serio/gscps2.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/input/serio/gscps2.c	2017-11-11 08:34:06.000000000 -0500
@@ -40,7 +40,6 @@
 MODULE_AUTHOR("Laurent Canet <canetl@esiee.fr>, Thibaut Varene <varenet@parisc-linux.org>, Helge Deller <deller@gmx.de>");
 MODULE_DESCRIPTION("HP GSC PS2 port driver");
 MODULE_LICENSE("GPL");
-MODULE_DEVICE_TABLE(parisc, gscps2_device_tbl);
 
 #define PFX "gscps2.c: "
 
@@ -439,6 +438,7 @@ static struct parisc_device_id gscps2_de
 #endif
 	{ 0, }	/* 0 terminated list */
 };
+MODULE_DEVICE_TABLE(parisc, gscps2_device_tbl);
 
 static struct parisc_driver parisc_ps2_driver = {
 	.name		= "gsc_ps2",
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/iommu/amd_iommu_init.c linux-libre-3.16.50-gnu/drivers/iommu/amd_iommu_init.c
--- linux-libre-3.16.49-gnu/drivers/iommu/amd_iommu_init.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/iommu/amd_iommu_init.c	2017-11-11 08:34:06.000000000 -0500
@@ -2027,11 +2027,11 @@ static int __init state_next(void)
 		break;
 	case IOMMU_ACPI_FINISHED:
 		early_enable_iommus();
-		register_syscore_ops(&amd_iommu_syscore_ops);
 		x86_platform.iommu_shutdown = disable_iommus;
 		init_state = IOMMU_ENABLED;
 		break;
 	case IOMMU_ENABLED:
+		register_syscore_ops(&amd_iommu_syscore_ops);
 		ret = amd_iommu_init_pci();
 		init_state = ret ? IOMMU_INIT_ERROR : IOMMU_PCI_INIT;
 		enable_iommus_v2();
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/irqchip/irq-brcmstb-l2.c linux-libre-3.16.50-gnu/drivers/irqchip/irq-brcmstb-l2.c
--- linux-libre-3.16.49-gnu/drivers/irqchip/irq-brcmstb-l2.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/irqchip/irq-brcmstb-l2.c	2017-11-11 08:34:06.000000000 -0500
@@ -176,6 +176,7 @@ int __init brcmstb_l2_intc_of_init(struc
 
 	ct->chip.irq_suspend = brcmstb_l2_intc_suspend;
 	ct->chip.irq_resume = brcmstb_l2_intc_resume;
+	ct->chip.irq_pm_shutdown = brcmstb_l2_intc_suspend;
 
 	if (of_property_read_bool(np, "brcm,irq-can-wake")) {
 		data->can_wake = true;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/isdn/hardware/mISDN/mISDNipac.c linux-libre-3.16.50-gnu/drivers/isdn/hardware/mISDN/mISDNipac.c
--- linux-libre-3.16.49-gnu/drivers/isdn/hardware/mISDN/mISDNipac.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/isdn/hardware/mISDN/mISDNipac.c	2017-11-11 08:34:06.000000000 -0500
@@ -754,10 +754,10 @@ dbusy_timer_handler(struct isac_hw *isac
 }
 
 static int
-open_dchannel(struct isac_hw *isac, struct channel_req *rq)
+open_dchannel_caller(struct isac_hw *isac, struct channel_req *rq, void *caller)
 {
 	pr_debug("%s: %s dev(%d) open from %p\n", isac->name, __func__,
-		 isac->dch.dev.id, __builtin_return_address(1));
+		 isac->dch.dev.id, caller);
 	if (rq->protocol != ISDN_P_TE_S0)
 		return -EINVAL;
 	if (rq->adr.channel == 1)
@@ -771,6 +771,12 @@ open_dchannel(struct isac_hw *isac, stru
 	return 0;
 }
 
+static int
+open_dchannel(struct isac_hw *isac, struct channel_req *rq)
+{
+	return open_dchannel_caller(isac, rq, __builtin_return_address(0));
+}
+
 static const char *ISACVer[] =
 {"2086/2186 V1.1", "2085 B1", "2085 B2",
  "2085 V2.3"};
@@ -1547,7 +1553,7 @@ ipac_dctrl(struct mISDNchannel *ch, u32
 	case OPEN_CHANNEL:
 		rq = arg;
 		if (rq->protocol == ISDN_P_TE_S0)
-			err = open_dchannel(isac, rq);
+			err = open_dchannel_caller(isac, rq, __builtin_return_address(0));
 		else
 			err = open_bchannel(ipac, rq);
 		if (err)
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/isdn/hardware/mISDN/w6692.c linux-libre-3.16.50-gnu/drivers/isdn/hardware/mISDN/w6692.c
--- linux-libre-3.16.49-gnu/drivers/isdn/hardware/mISDN/w6692.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/isdn/hardware/mISDN/w6692.c	2017-11-11 08:34:06.000000000 -0500
@@ -1176,10 +1176,10 @@ w6692_l1callback(struct dchannel *dch, u
 }
 
 static int
-open_dchannel(struct w6692_hw *card, struct channel_req *rq)
+open_dchannel(struct w6692_hw *card, struct channel_req *rq, void *caller)
 {
 	pr_debug("%s: %s dev(%d) open from %p\n", card->name, __func__,
-		 card->dch.dev.id, __builtin_return_address(1));
+		 card->dch.dev.id, caller);
 	if (rq->protocol != ISDN_P_TE_S0)
 		return -EINVAL;
 	if (rq->adr.channel == 1)
@@ -1207,7 +1207,7 @@ w6692_dctrl(struct mISDNchannel *ch, u32
 	case OPEN_CHANNEL:
 		rq = arg;
 		if (rq->protocol == ISDN_P_TE_S0)
-			err = open_dchannel(card, rq);
+			err = open_dchannel(card, rq, __builtin_return_address(0));
 		else
 			err = open_bchannel(card, rq);
 		if (err)
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/md/dm-bufio.c linux-libre-3.16.50-gnu/drivers/md/dm-bufio.c
--- linux-libre-3.16.49-gnu/drivers/md/dm-bufio.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/md/dm-bufio.c	2017-11-11 08:34:06.000000000 -0500
@@ -349,6 +349,7 @@ static void *alloc_buffer_data(struct dm
 	 * as if GFP_NOIO was specified.
 	 */
 
+	noio_flag = 0;
 	if (gfp_mask & __GFP_NORETRY)
 		noio_flag = memalloc_noio_save();
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/md/dm.c linux-libre-3.16.50-gnu/drivers/md/dm.c
--- linux-libre-3.16.49-gnu/drivers/md/dm.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/md/dm.c	2017-11-11 08:34:06.000000000 -0500
@@ -24,16 +24,6 @@
 
 #define DM_MSG_PREFIX "core"
 
-#ifdef CONFIG_PRINTK
-/*
- * ratelimit state to be used in DMXXX_LIMIT().
- */
-DEFINE_RATELIMIT_STATE(dm_ratelimit_state,
-		       DEFAULT_RATELIMIT_INTERVAL,
-		       DEFAULT_RATELIMIT_BURST);
-EXPORT_SYMBOL(dm_ratelimit_state);
-#endif
-
 /*
  * Cookies are numeric values sent with CHANGE and REMOVE
  * uevents while resuming, removing or renaming the device.
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/md/raid5.c linux-libre-3.16.50-gnu/drivers/md/raid5.c
--- linux-libre-3.16.49-gnu/drivers/md/raid5.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/md/raid5.c	2017-11-11 08:34:06.000000000 -0500
@@ -5240,6 +5240,8 @@ static void raid5_do_work(struct work_st
 	pr_debug("%d stripes handled\n", handled);
 
 	spin_unlock_irq(&conf->device_lock);
+
+	async_tx_issue_pending_all();
 	blk_finish_plug(&plug);
 
 	pr_debug("--- raid5worker inactive\n");
@@ -6741,12 +6743,10 @@ static void end_reshape(struct r5conf *c
 {
 
 	if (!test_bit(MD_RECOVERY_INTR, &conf->mddev->recovery)) {
-		struct md_rdev *rdev;
 
 		spin_lock_irq(&conf->device_lock);
 		conf->previous_raid_disks = conf->raid_disks;
-		rdev_for_each(rdev, conf->mddev)
-			rdev->data_offset = rdev->new_data_offset;
+		md_finish_reshape(conf->mddev);
 		smp_wmb();
 		conf->reshape_progress = MaxSector;
 		spin_unlock_irq(&conf->device_lock);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/media/platform/davinci/vpfe_capture.c linux-libre-3.16.50-gnu/drivers/media/platform/davinci/vpfe_capture.c
--- linux-libre-3.16.49-gnu/drivers/media/platform/davinci/vpfe_capture.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/media/platform/davinci/vpfe_capture.c	2017-11-11 08:34:06.000000000 -0500
@@ -1708,27 +1708,9 @@ static long vpfe_param_handler(struct fi
 
 	switch (cmd) {
 	case VPFE_CMD_S_CCDC_RAW_PARAMS:
+		ret = -EINVAL;
 		v4l2_warn(&vpfe_dev->v4l2_dev,
-			  "VPFE_CMD_S_CCDC_RAW_PARAMS: experimental ioctl\n");
-		if (ccdc_dev->hw_ops.set_params) {
-			ret = ccdc_dev->hw_ops.set_params(param);
-			if (ret) {
-				v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
-					"Error setting parameters in CCDC\n");
-				goto unlock_out;
-			}
-			ret = vpfe_get_ccdc_image_format(vpfe_dev,
-							 &vpfe_dev->fmt);
-			if (ret < 0) {
-				v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
-					"Invalid image format at CCDC\n");
-				goto unlock_out;
-			}
-		} else {
-			ret = -EINVAL;
-			v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
-				"VPFE_CMD_S_CCDC_RAW_PARAMS not supported\n");
-		}
+			"VPFE_CMD_S_CCDC_RAW_PARAMS not supported\n");
 		break;
 	default:
 		ret = -ENOTTY;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/media/rc/ir-lirc-codec.c linux-libre-3.16.50-gnu/drivers/media/rc/ir-lirc-codec.c
--- linux-libre-3.16.49-gnu/drivers/media/rc/ir-lirc-codec.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/media/rc/ir-lirc-codec.c	2017-11-11 08:34:06.000000000 -0500
@@ -257,7 +257,7 @@ static long ir_lirc_ioctl(struct file *f
 		return 0;
 
 	case LIRC_GET_REC_RESOLUTION:
-		val = dev->rx_resolution;
+		val = dev->rx_resolution / 1000;
 		break;
 
 	case LIRC_SET_WIDEBAND_RECEIVER:
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/message/i2o/i2o_config.c linux-libre-3.16.50-gnu/drivers/message/i2o/i2o_config.c
--- linux-libre-3.16.49-gnu/drivers/message/i2o/i2o_config.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/message/i2o/i2o_config.c	2017-11-11 08:34:06.000000000 -0500
@@ -772,7 +772,7 @@ static long i2o_cfg_compat_ioctl(struct
 
 #endif
 
-#ifdef CONFIG_I2O_EXT_ADAPTEC
+#if defined(CONFIG_I2O_EXT_ADAPTEC) && !defined(CONFIG_64BIT)
 static int i2o_cfg_passthru(unsigned long arg)
 {
 	struct i2o_cmd_passthru __user *cmd =
@@ -1045,7 +1045,7 @@ static long i2o_cfg_ioctl(struct file *f
 		ret = i2o_cfg_evt_get(arg, fp);
 		break;
 
-#ifdef CONFIG_I2O_EXT_ADAPTEC
+#if defined(CONFIG_I2O_EXT_ADAPTEC) && !defined(CONFIG_64BIT)
 	case I2OPASSTHRU:
 		ret = i2o_cfg_passthru(arg);
 		break;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/mfd/arizona-core.c linux-libre-3.16.50-gnu/drivers/mfd/arizona-core.c
--- linux-libre-3.16.49-gnu/drivers/mfd/arizona-core.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/mfd/arizona-core.c	2017-11-11 08:34:06.000000000 -0500
@@ -497,12 +497,12 @@ const struct dev_pm_ops arizona_pm_ops =
 EXPORT_SYMBOL_GPL(arizona_pm_ops);
 
 #ifdef CONFIG_OF
-int arizona_of_get_type(struct device *dev)
+unsigned long arizona_of_get_type(struct device *dev)
 {
 	const struct of_device_id *id = of_match_device(arizona_of_match, dev);
 
 	if (id)
-		return (int)id->data;
+		return (unsigned long)id->data;
 	else
 		return 0;
 }
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/mfd/arizona.h linux-libre-3.16.50-gnu/drivers/mfd/arizona.h
--- linux-libre-3.16.49-gnu/drivers/mfd/arizona.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/mfd/arizona.h	2017-11-11 08:34:06.000000000 -0500
@@ -46,9 +46,9 @@ int arizona_irq_init(struct arizona *ari
 int arizona_irq_exit(struct arizona *arizona);
 
 #ifdef CONFIG_OF
-int arizona_of_get_type(struct device *dev);
+unsigned long arizona_of_get_type(struct device *dev);
 #else
-static inline int arizona_of_get_type(struct device *dev)
+static inline unsigned long arizona_of_get_type(struct device *dev)
 {
 	return 0;
 }
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/mfd/arizona-i2c.c linux-libre-3.16.50-gnu/drivers/mfd/arizona-i2c.c
--- linux-libre-3.16.49-gnu/drivers/mfd/arizona-i2c.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/mfd/arizona-i2c.c	2017-11-11 08:34:06.000000000 -0500
@@ -24,11 +24,12 @@
 #include "arizona.h"
 
 static int arizona_i2c_probe(struct i2c_client *i2c,
-					  const struct i2c_device_id *id)
+			     const struct i2c_device_id *id)
 {
 	struct arizona *arizona;
 	const struct regmap_config *regmap_config;
-	int ret, type;
+	unsigned long type;
+	int ret;
 
 	if (i2c->dev.of_node)
 		type = arizona_of_get_type(&i2c->dev);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/mfd/arizona-spi.c linux-libre-3.16.50-gnu/drivers/mfd/arizona-spi.c
--- linux-libre-3.16.49-gnu/drivers/mfd/arizona-spi.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/mfd/arizona-spi.c	2017-11-11 08:34:06.000000000 -0500
@@ -28,7 +28,8 @@ static int arizona_spi_probe(struct spi_
 	const struct spi_device_id *id = spi_get_device_id(spi);
 	struct arizona *arizona;
 	const struct regmap_config *regmap_config;
-	int ret, type;
+	unsigned long type;
+	int ret;
 
 	if (spi->dev.of_node)
 		type = arizona_of_get_type(&spi->dev);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/mtd/maps/pmcmsp-flash.c linux-libre-3.16.50-gnu/drivers/mtd/maps/pmcmsp-flash.c
--- linux-libre-3.16.49-gnu/drivers/mtd/maps/pmcmsp-flash.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/mtd/maps/pmcmsp-flash.c	2017-11-11 08:34:06.000000000 -0500
@@ -139,15 +139,13 @@ static int __init init_msp_flash(void)
 		}
 
 		msp_maps[i].bankwidth = 1;
-		msp_maps[i].name = kmalloc(7, GFP_KERNEL);
+		msp_maps[i].name = kstrndup(flash_name, 7, GFP_KERNEL);
 		if (!msp_maps[i].name) {
 			iounmap(msp_maps[i].virt);
 			kfree(msp_parts[i]);
 			goto cleanup_loop;
 		}
 
-		msp_maps[i].name = strncpy(msp_maps[i].name, flash_name, 7);
-
 		for (j = 0; j < pcnt; j++) {
 			part_name[5] = '0' + i;
 			part_name[7] = '0' + j;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/mtd/maps/rbtx4939-flash.c linux-libre-3.16.50-gnu/drivers/mtd/maps/rbtx4939-flash.c
--- linux-libre-3.16.49-gnu/drivers/mtd/maps/rbtx4939-flash.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/mtd/maps/rbtx4939-flash.c	2017-11-11 08:34:06.000000000 -0500
@@ -35,8 +35,6 @@ static int rbtx4939_flash_remove(struct
 		return 0;
 
 	if (info->mtd) {
-		struct rbtx4939_flash_data *pdata = dev_get_platdata(&dev->dev);
-
 		mtd_device_unregister(info->mtd);
 		map_destroy(info->mtd);
 	}
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/mtd/nand/nandsim.c linux-libre-3.16.50-gnu/drivers/mtd/nand/nandsim.c
--- linux-libre-3.16.49-gnu/drivers/mtd/nand/nandsim.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/mtd/nand/nandsim.c	2017-11-11 08:34:06.000000000 -0500
@@ -2387,6 +2387,7 @@ static int __init ns_init_module(void)
         return 0;
 
 err_exit:
+	nandsim_debugfs_remove(nand);
 	free_nandsim(nand);
 	nand_release(nsmtd);
 	for (i = 0;i < ARRAY_SIZE(nand->partitions); ++i)
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/amd/amd8111e.c linux-libre-3.16.50-gnu/drivers/net/ethernet/amd/amd8111e.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/amd/amd8111e.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/amd/amd8111e.c	2017-11-11 08:34:06.000000000 -0500
@@ -101,7 +101,6 @@ Revision History:
 MODULE_AUTHOR("Advanced Micro Devices, Inc.");
 MODULE_DESCRIPTION ("AMD8111 based 10/100 Ethernet Controller. Driver Version "MODULE_VERS);
 MODULE_LICENSE("GPL");
-MODULE_DEVICE_TABLE(pci, amd8111e_pci_tbl);
 module_param_array(speed_duplex, int, NULL, 0);
 MODULE_PARM_DESC(speed_duplex, "Set device speed and duplex modes, 0: Auto Negotiate, 1: 10Mbps Half Duplex, 2: 10Mbps Full Duplex, 3: 100Mbps Half Duplex, 4: 100Mbps Full Duplex");
 module_param_array(coalesce, bool, NULL, 0);
@@ -109,13 +108,6 @@ MODULE_PARM_DESC(coalesce, "Enable or Di
 module_param_array(dynamic_ipg, bool, NULL, 0);
 MODULE_PARM_DESC(dynamic_ipg, "Enable or Disable dynamic IPG, 1: Enable, 0: Disable");
 
-static DEFINE_PCI_DEVICE_TABLE(amd8111e_pci_tbl) = {
-
-	{ PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD8111E_7462,
-	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
-	{ 0, }
-
-};
 /*
 This function will read the PHY registers.
 */
@@ -1970,6 +1962,17 @@ err_disable_pdev:
 
 }
 
+static const struct pci_device_id amd8111e_pci_tbl[] = {
+	{
+	 .vendor = PCI_VENDOR_ID_AMD,
+	 .device = PCI_DEVICE_ID_AMD8111E_7462,
+	},
+	{
+	 .vendor = 0,
+	}
+};
+MODULE_DEVICE_TABLE(pci, amd8111e_pci_tbl);
+
 static struct pci_driver amd8111e_driver = {
 	.name   	= MODULE_NAME,
 	.id_table	= amd8111e_pci_tbl,
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/amd/nmclan_cs.c linux-libre-3.16.50-gnu/drivers/net/ethernet/amd/nmclan_cs.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/amd/nmclan_cs.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/amd/nmclan_cs.c	2017-11-11 08:34:06.000000000 -0500
@@ -621,7 +621,7 @@ static int nmclan_config(struct pcmcia_d
   ret = pcmcia_request_io(link);
   if (ret)
 	  goto failed;
-  ret = pcmcia_request_exclusive_irq(link, mace_interrupt);
+  ret = pcmcia_request_irq(link, mace_interrupt);
   if (ret)
 	  goto failed;
   ret = pcmcia_enable_device(link);
@@ -952,6 +952,8 @@ static irqreturn_t mace_interrupt(int ir
   do {
     /* WARNING: MACE_IR is a READ/CLEAR port! */
     status = inb(ioaddr + AM2150_MACE_BASE + MACE_IR);
+    if (!(status & ~MACE_IMR_DEFAULT) && IntrCnt == MACE_MAX_IR_ITERATIONS)
+      return IRQ_NONE;
 
     pr_debug("mace_interrupt: irq 0x%X status 0x%X.\n", irq, status);
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/broadcom/b44.c linux-libre-3.16.50-gnu/drivers/net/ethernet/broadcom/b44.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/broadcom/b44.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/broadcom/b44.c	2017-11-11 08:34:06.000000000 -0500
@@ -2372,6 +2372,7 @@ static int b44_init_one(struct ssb_devic
 	bp->msg_enable = netif_msg_init(b44_debug, B44_DEF_MSG_ENABLE);
 
 	spin_lock_init(&bp->lock);
+	u64_stats_init(&bp->hw_stats.syncp);
 
 	bp->rx_pending = B44_DEF_RX_RING_PENDING;
 	bp->tx_pending = B44_DEF_TX_RING_PENDING;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/broadcom/bcmsysport.c linux-libre-3.16.50-gnu/drivers/net/ethernet/broadcom/bcmsysport.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/broadcom/bcmsysport.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/broadcom/bcmsysport.c	2017-11-11 08:34:06.000000000 -0500
@@ -386,7 +386,7 @@ static void bcm_sysport_get_stats(struct
 
 static void bcm_sysport_free_cb(struct bcm_sysport_cb *cb)
 {
-	dev_kfree_skb_any(cb->skb);
+	dev_consume_skb_any(cb->skb);
 	cb->skb = NULL;
 	dma_unmap_addr_set(cb, dma_addr, 0);
 }
@@ -1024,6 +1024,8 @@ static int bcm_sysport_init_tx_ring(stru
 
 	ring->cbs = kzalloc(sizeof(struct bcm_sysport_cb) * size, GFP_KERNEL);
 	if (!ring->cbs) {
+		dma_free_coherent(kdev, sizeof(struct dma_desc),
+				  ring->desc_cpu, ring->desc_dma);
 		netif_err(priv, hw, priv->netdev, "CB allocation failed\n");
 		return -ENOMEM;
 	}
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/broadcom/genet/bcmgenet.c linux-libre-3.16.50-gnu/drivers/net/ethernet/broadcom/genet/bcmgenet.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/broadcom/genet/bcmgenet.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/broadcom/genet/bcmgenet.c	2017-11-11 08:34:06.000000000 -0500
@@ -900,12 +900,21 @@ static struct enet_cb *bcmgenet_get_txcb
 	return tx_cb_ptr;
 }
 
-/* Simple helper to free a control block's resources */
-static void bcmgenet_free_cb(struct enet_cb *cb)
+static struct enet_cb *bcmgenet_put_txcb(struct bcmgenet_priv *priv,
+					 struct bcmgenet_tx_ring *ring)
 {
-	dev_kfree_skb_any(cb->skb);
-	cb->skb = NULL;
-	dma_unmap_addr_set(cb, dma_addr, 0);
+	struct enet_cb *tx_cb_ptr;
+
+	tx_cb_ptr = ring->cbs;
+	tx_cb_ptr += ring->write_ptr - ring->cb_ptr;
+
+	/* Rewinding local write pointer */
+	if (ring->write_ptr == ring->cb_ptr)
+		ring->write_ptr = ring->end_ptr;
+	else
+		ring->write_ptr--;
+
+	return tx_cb_ptr;
 }
 
 static inline void bcmgenet_tx_ring16_int_disable(struct bcmgenet_priv *priv,
@@ -940,69 +949,116 @@ static inline void bcmgenet_tx_ring_int_
 	priv->int1_mask |= (1 << ring->index);
 }
 
+/* Simple helper to free a transmit control block's resources
+ * Returns an skb when the last transmit control block associated with the
+ * skb is freed.  The skb should be freed by the caller if necessary.
+ */
+static struct sk_buff *bcmgenet_free_tx_cb(struct device *dev,
+					   struct enet_cb *cb)
+{
+	struct sk_buff *skb;
+
+	skb = cb->skb;
+
+	if (skb) {
+		cb->skb = NULL;
+		if (cb == GENET_CB(skb)->first_cb)
+			dma_unmap_single(dev, dma_unmap_addr(cb, dma_addr),
+					 dma_unmap_len(cb, dma_len),
+					 DMA_TO_DEVICE);
+		else
+			dma_unmap_page(dev, dma_unmap_addr(cb, dma_addr),
+				       dma_unmap_len(cb, dma_len),
+				       DMA_TO_DEVICE);
+		dma_unmap_addr_set(cb, dma_addr, 0);
+
+		if (cb == GENET_CB(skb)->last_cb)
+			return skb;
+
+	} else if (dma_unmap_addr(cb, dma_addr)) {
+		dma_unmap_page(dev,
+			       dma_unmap_addr(cb, dma_addr),
+			       dma_unmap_len(cb, dma_len),
+			       DMA_TO_DEVICE);
+		dma_unmap_addr_set(cb, dma_addr, 0);
+	}
+
+	return 0;
+}
+
+/* Simple helper to free a receive control block's resources */
+static struct sk_buff *bcmgenet_free_rx_cb(struct device *dev,
+					   struct enet_cb *cb)
+{
+	struct sk_buff *skb;
+
+	skb = cb->skb;
+	cb->skb = NULL;
+
+	if (dma_unmap_addr(cb, dma_addr)) {
+		dma_unmap_single(dev, dma_unmap_addr(cb, dma_addr),
+				 dma_unmap_len(cb, dma_len), DMA_FROM_DEVICE);
+		dma_unmap_addr_set(cb, dma_addr, 0);
+	}
+
+	return skb;
+}
+
 /* Unlocked version of the reclaim routine */
 static void __bcmgenet_tx_reclaim(struct net_device *dev,
 				struct bcmgenet_tx_ring *ring)
 {
 	struct bcmgenet_priv *priv = netdev_priv(dev);
-	struct device *kdev = &priv->pdev->dev;
-	int last_tx_cn, last_c_index, num_tx_bds;
-	struct enet_cb *tx_cb_ptr;
 	struct netdev_queue *txq;
+	unsigned int txbds_processed = 0;
+	unsigned int bytes_compl = 0;
+	unsigned int pkts_compl = 0;
+	unsigned int txbds_ready;
 	unsigned int c_index;
+	struct sk_buff *skb;
 
 	/* Compute how many buffers are transmited since last xmit call */
 	c_index = bcmgenet_tdma_ring_readl(priv, ring->index, TDMA_CONS_INDEX);
-	txq = netdev_get_tx_queue(dev, ring->queue);
-
-	last_c_index = ring->c_index;
-	num_tx_bds = ring->size;
-
-	c_index &= (num_tx_bds - 1);
+	c_index &= DMA_C_INDEX_MASK;
 
-	if (c_index >= last_c_index)
-		last_tx_cn = c_index - last_c_index;
+	if (likely(c_index >= ring->c_index))
+		txbds_ready = c_index - ring->c_index;
 	else
-		last_tx_cn = num_tx_bds - last_c_index + c_index;
+		txbds_ready = (DMA_C_INDEX_MASK + 1) - ring->c_index + c_index;
 
 	netif_dbg(priv, tx_done, dev,
-			"%s ring=%d index=%d last_tx_cn=%d last_index=%d\n",
-			__func__, ring->index,
-			c_index, last_tx_cn, last_c_index);
+		  "%s ring=%d old_c_index=%u c_index=%u txbds_ready=%u\n",
+		  __func__, ring->index, ring->c_index, c_index, txbds_ready);
 
 	/* Reclaim transmitted buffers */
-	while (last_tx_cn-- > 0) {
-		tx_cb_ptr = ring->cbs + last_c_index;
-		if (tx_cb_ptr->skb) {
-			dev->stats.tx_bytes += tx_cb_ptr->skb->len;
-			dma_unmap_single(kdev,
-					dma_unmap_addr(tx_cb_ptr, dma_addr),
-					dma_unmap_len(tx_cb_ptr, dma_len),
-					DMA_TO_DEVICE);
-			bcmgenet_free_cb(tx_cb_ptr);
-		} else if (dma_unmap_addr(tx_cb_ptr, dma_addr)) {
-			dev->stats.tx_bytes +=
-				dma_unmap_len(tx_cb_ptr, dma_len);
-			dma_unmap_page(kdev,
-					dma_unmap_addr(tx_cb_ptr, dma_addr),
-					dma_unmap_len(tx_cb_ptr, dma_len),
-					DMA_TO_DEVICE);
-			dma_unmap_addr_set(tx_cb_ptr, dma_addr, 0);
+	while (txbds_processed < txbds_ready) {
+		skb = bcmgenet_free_tx_cb(&priv->pdev->dev,
+					  &priv->tx_cbs[ring->clean_ptr]);
+		if (skb) {
+			pkts_compl++;
+			bytes_compl += GENET_CB(skb)->bytes_sent;
+			dev_consume_skb_any(skb);
 		}
-		dev->stats.tx_packets++;
-		ring->free_bds += 1;
 
-		last_c_index++;
-		last_c_index &= (num_tx_bds - 1);
+		txbds_processed++;
+		if (likely(ring->clean_ptr < ring->end_ptr))
+			ring->clean_ptr++;
+		else
+			ring->clean_ptr = ring->cb_ptr;
 	}
 
+	ring->free_bds += txbds_processed;
+	ring->c_index = (ring->c_index + txbds_processed) & DMA_C_INDEX_MASK;
+
+	dev->stats.tx_packets += pkts_compl;
+	dev->stats.tx_bytes += bytes_compl;
+
 	if (ring->free_bds > (MAX_SKB_FRAGS + 1))
 		ring->int_disable(priv, ring);
 
+	txq = netdev_get_tx_queue(dev, ring->queue);
 	if (netif_tx_queue_stopped(txq))
 		netif_tx_wake_queue(txq);
-
-	ring->c_index = c_index;
 }
 
 static void bcmgenet_tx_reclaim(struct net_device *dev,
@@ -1028,100 +1084,6 @@ static void bcmgenet_tx_reclaim_all(stru
 	bcmgenet_tx_reclaim(dev, &priv->tx_rings[DESC_INDEX]);
 }
 
-/* Transmits a single SKB (either head of a fragment or a single SKB)
- * caller must hold priv->lock
- */
-static int bcmgenet_xmit_single(struct net_device *dev,
-				struct sk_buff *skb,
-				u16 dma_desc_flags,
-				struct bcmgenet_tx_ring *ring)
-{
-	struct bcmgenet_priv *priv = netdev_priv(dev);
-	struct device *kdev = &priv->pdev->dev;
-	struct enet_cb *tx_cb_ptr;
-	unsigned int skb_len;
-	dma_addr_t mapping;
-	u32 length_status;
-	int ret;
-
-	tx_cb_ptr = bcmgenet_get_txcb(priv, ring);
-
-	if (unlikely(!tx_cb_ptr))
-		BUG();
-
-	tx_cb_ptr->skb = skb;
-
-	skb_len = skb_headlen(skb);
-
-	mapping = dma_map_single(kdev, skb->data, skb_len, DMA_TO_DEVICE);
-	ret = dma_mapping_error(kdev, mapping);
-	if (ret) {
-		netif_err(priv, tx_err, dev, "Tx DMA map failed\n");
-		dev_kfree_skb(skb);
-		return ret;
-	}
-
-	dma_unmap_addr_set(tx_cb_ptr, dma_addr, mapping);
-	dma_unmap_len_set(tx_cb_ptr, dma_len, skb_len);
-	length_status = (skb_len << DMA_BUFLENGTH_SHIFT) | dma_desc_flags |
-			(priv->hw_params->qtag_mask << DMA_TX_QTAG_SHIFT) |
-			DMA_TX_APPEND_CRC;
-
-	if (skb->ip_summed == CHECKSUM_PARTIAL)
-		length_status |= DMA_TX_DO_CSUM;
-
-	dmadesc_set(priv, tx_cb_ptr->bd_addr, mapping, length_status);
-
-	/* Decrement total BD count and advance our write pointer */
-	ring->free_bds -= 1;
-	ring->prod_index += 1;
-	ring->prod_index &= DMA_P_INDEX_MASK;
-
-	return 0;
-}
-
-/* Transmit a SKB fragement */
-static int bcmgenet_xmit_frag(struct net_device *dev,
-				skb_frag_t *frag,
-				u16 dma_desc_flags,
-				struct bcmgenet_tx_ring *ring)
-{
-	struct bcmgenet_priv *priv = netdev_priv(dev);
-	struct device *kdev = &priv->pdev->dev;
-	struct enet_cb *tx_cb_ptr;
-	dma_addr_t mapping;
-	int ret;
-
-	tx_cb_ptr = bcmgenet_get_txcb(priv, ring);
-
-	if (unlikely(!tx_cb_ptr))
-		BUG();
-	tx_cb_ptr->skb = NULL;
-
-	mapping = skb_frag_dma_map(kdev, frag, 0,
-		skb_frag_size(frag), DMA_TO_DEVICE);
-	ret = dma_mapping_error(kdev, mapping);
-	if (ret) {
-		netif_err(priv, tx_err, dev, "%s: Tx DMA map failed\n",
-				__func__);
-		return ret;
-	}
-
-	dma_unmap_addr_set(tx_cb_ptr, dma_addr, mapping);
-	dma_unmap_len_set(tx_cb_ptr, dma_len, frag->size);
-
-	dmadesc_set(priv, tx_cb_ptr->bd_addr, mapping,
-			(frag->size << DMA_BUFLENGTH_SHIFT) | dma_desc_flags |
-			(priv->hw_params->qtag_mask << DMA_TX_QTAG_SHIFT));
-
-
-	ring->free_bds -= 1;
-	ring->prod_index += 1;
-	ring->prod_index &= DMA_P_INDEX_MASK;
-
-	return 0;
-}
-
 /* Reallocate the SKB to put enough headroom in front of it and insert
  * the transmit checksum offsets in the descriptors
  */
@@ -1187,11 +1149,16 @@ static int bcmgenet_put_tx_csum(struct n
 static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb, struct net_device *dev)
 {
 	struct bcmgenet_priv *priv = netdev_priv(dev);
+	struct device *kdev = &priv->pdev->dev;
 	struct bcmgenet_tx_ring *ring = NULL;
+	struct enet_cb *tx_cb_ptr;
 	struct netdev_queue *txq;
 	unsigned long flags = 0;
 	int nr_frags, index;
-	u16 dma_desc_flags;
+	dma_addr_t mapping;
+	unsigned int size;
+	skb_frag_t *frag;
+	u32 len_stat;
 	int ret;
 	int i;
 
@@ -1226,6 +1193,11 @@ static netdev_tx_t bcmgenet_xmit(struct
 		goto out;
 	}
 
+	/* Retain how many bytes will be sent on the wire, without TSB inserted
+	 * by transmit checksum offload
+	 */
+	GENET_CB(skb)->bytes_sent = skb->len;
+
 	/* set the SKB transmit checksum */
 	if (priv->desc_64b_en) {
 		ret = bcmgenet_put_tx_csum(dev, skb);
@@ -1235,33 +1207,59 @@ static netdev_tx_t bcmgenet_xmit(struct
 		}
 	}
 
-	dma_desc_flags = DMA_SOP;
-	if (nr_frags == 0)
-		dma_desc_flags |= DMA_EOP;
+	for (i = 0; i <= nr_frags; i++) {
+		tx_cb_ptr = bcmgenet_get_txcb(priv, ring);
 
-	/* Transmit single SKB or head of fragment list */
-	ret = bcmgenet_xmit_single(dev, skb, dma_desc_flags, ring);
-	if (ret) {
-		ret = NETDEV_TX_OK;
-		goto out;
-	}
+		if (unlikely(!tx_cb_ptr))
+			BUG();
 
-	/* xmit fragment */
-	for (i = 0; i < nr_frags; i++) {
-		ret = bcmgenet_xmit_frag(dev,
-				&skb_shinfo(skb)->frags[i],
-				(i == nr_frags - 1) ? DMA_EOP : 0, ring);
+		if (!i) {
+			/* Transmit single SKB or head of fragment list */
+			GENET_CB(skb)->first_cb = tx_cb_ptr;
+			size = skb_headlen(skb);
+			mapping = dma_map_single(kdev, skb->data, size,
+						 DMA_TO_DEVICE);
+		} else {
+			/* xmit fragment */
+			frag = &skb_shinfo(skb)->frags[i - 1];
+			size = skb_frag_size(frag);
+			mapping = skb_frag_dma_map(kdev, frag, 0, size,
+						   DMA_TO_DEVICE);
+		}
+
+		ret = dma_mapping_error(kdev, mapping);
 		if (ret) {
+			netif_err(priv, tx_err, dev, "Tx DMA map failed\n");
 			ret = NETDEV_TX_OK;
-			goto out;
+			goto out_unmap_frags;
+		}
+		dma_unmap_addr_set(tx_cb_ptr, dma_addr, mapping);
+		dma_unmap_len_set(tx_cb_ptr, dma_len, size);
+
+		tx_cb_ptr->skb = skb;
+
+		len_stat = (size << DMA_BUFLENGTH_SHIFT) |
+			   (priv->hw_params->qtag_mask << DMA_TX_QTAG_SHIFT);
+
+		if (!i) {
+			len_stat |= DMA_TX_APPEND_CRC | DMA_SOP;
+			if (skb->ip_summed == CHECKSUM_PARTIAL)
+				len_stat |= DMA_TX_DO_CSUM;
 		}
+		if (i == nr_frags)
+			len_stat |= DMA_EOP;
+
+		dmadesc_set(priv, tx_cb_ptr->bd_addr, mapping, len_stat);
 	}
 
+	GENET_CB(skb)->last_cb = tx_cb_ptr;
 	skb_tx_timestamp(skb);
 
-	/* we kept a software copy of how much we should advance the TDMA
-	 * producer index, now write it down to the hardware
-	 */
+	/* Decrement total BD count and advance our write pointer */
+	ring->free_bds -= nr_frags + 1;
+	ring->prod_index += nr_frags + 1;
+	ring->prod_index &= DMA_P_INDEX_MASK;
+
 	bcmgenet_tdma_ring_writel(priv, ring->index,
 			ring->prod_index, TDMA_PROD_INDEX);
 
@@ -1274,36 +1272,55 @@ out:
 	spin_unlock_irqrestore(&ring->lock, flags);
 
 	return ret;
-}
 
+out_unmap_frags:
+	/* Back up for failed control block mapping */
+	bcmgenet_put_txcb(priv, ring);
 
-static int bcmgenet_rx_refill(struct bcmgenet_priv *priv,
-				struct enet_cb *cb)
+	/* Unmap successfully mapped control blocks */
+	while (i-- > 0) {
+		tx_cb_ptr = bcmgenet_put_txcb(priv, ring);
+		bcmgenet_free_tx_cb(kdev, tx_cb_ptr);
+	}
+
+	dev_kfree_skb(skb);
+	goto out;
+}
+
+static struct sk_buff *bcmgenet_rx_refill(struct bcmgenet_priv *priv,
+					  struct enet_cb *cb)
 {
 	struct device *kdev = &priv->pdev->dev;
 	struct sk_buff *skb;
+	struct sk_buff *rx_skb;
 	dma_addr_t mapping;
-	int ret;
 
+	/* Allocate a new Rx skb */
 	skb = netdev_alloc_skb(priv->dev,
 				priv->rx_buf_len + SKB_ALIGNMENT);
-	if (!skb)
-		return -ENOMEM;
+	if (!skb) {
+		netif_err(priv, rx_err, priv->dev,
+			  "%s: Rx skb allocation failed\n", __func__);
+		return NULL;
+	}
 
-	/* a caller did not release this control block */
-	WARN_ON(cb->skb != NULL);
-	cb->skb = skb;
-	mapping = dma_map_single(kdev, skb->data,
-			priv->rx_buf_len, DMA_FROM_DEVICE);
-	ret = dma_mapping_error(kdev, mapping);
-	if (ret) {
-		bcmgenet_free_cb(cb);
+	/* DMA-map the new Rx skb */
+	mapping = dma_map_single(kdev, skb->data, priv->rx_buf_len,
+				 DMA_FROM_DEVICE);
+	if (dma_mapping_error(kdev, mapping)) {
+		dev_kfree_skb_any(skb);
 		netif_err(priv, rx_err, priv->dev,
-				"%s DMA map failed\n", __func__);
-		return ret;
+			  "%s: Rx skb DMA mapping failed\n", __func__);
+		return NULL;
 	}
 
+	/* Grab the current Rx skb from the ring and DMA-unmap it */
+	rx_skb = bcmgenet_free_rx_cb(kdev, cb);
+
+	/* Put the new Rx skb on the ring */
+	cb->skb = skb;
 	dma_unmap_addr_set(cb, dma_addr, mapping);
+	dma_unmap_len_set(cb, dma_len, priv->rx_buf_len);
 	/* assign packet, prepare descriptor, and advance pointer */
 
 	dmadesc_set_addr(priv, priv->rx_bd_assign_ptr, mapping);
@@ -1315,7 +1332,8 @@ static int bcmgenet_rx_refill(struct bcm
 	priv->rx_bd_assign_ptr = priv->rx_bds +
 		(priv->rx_bd_assign_index * DMA_DESC_SIZE);
 
-	return 0;
+	/* Return the current Rx skb to caller */
+	return rx_skb;
 }
 
 /* bcmgenet_desc_rx - descriptor based rx process.
@@ -1330,7 +1348,7 @@ static unsigned int bcmgenet_desc_rx(str
 	struct sk_buff *skb;
 	u32 dma_length_status;
 	unsigned long dma_flag;
-	int len, err;
+	int len;
 	unsigned int rxpktprocessed = 0, rxpkttoprocess;
 	unsigned int p_index;
 	unsigned int chksum_ok = 0;
@@ -1351,14 +1369,14 @@ static unsigned int bcmgenet_desc_rx(str
 	while ((rxpktprocessed < rxpkttoprocess) &&
 			(rxpktprocessed < budget)) {
 
-		/* Unmap the packet contents such that we can use the
-		 * RSV from the 64 bytes descriptor when enabled and save
-		 * a 32-bits register read
-		 */
 		cb = &priv->rx_cbs[priv->rx_read_ptr];
-		skb = cb->skb;
-		dma_unmap_single(kdev, dma_unmap_addr(cb, dma_addr),
-				priv->rx_buf_len, DMA_FROM_DEVICE);
+		skb = bcmgenet_rx_refill(priv, cb);
+
+		if (unlikely(!skb)) {
+			dev->stats.rx_dropped++;
+			dev->stats.rx_errors++;
+			goto next;
+		}
 
 		if (!priv->desc_64b_en) {
 			dma_length_status = dmadesc_get_length_status(priv,
@@ -1382,27 +1400,15 @@ static unsigned int bcmgenet_desc_rx(str
 			__func__, p_index, priv->rx_c_index, priv->rx_read_ptr,
 			dma_length_status);
 
-		rxpktprocessed++;
-
-		priv->rx_read_ptr++;
-		priv->rx_read_ptr &= (priv->num_rx_bds - 1);
-
-		/* out of memory, just drop packets at the hardware level */
-		if (unlikely(!skb)) {
-			dev->stats.rx_dropped++;
-			dev->stats.rx_errors++;
-			goto refill;
-		}
-
 		if (unlikely(!(dma_flag & DMA_EOP) || !(dma_flag & DMA_SOP))) {
 			netif_err(priv, rx_status, dev,
 					"Droping fragmented packet!\n");
 			dev->stats.rx_dropped++;
 			dev->stats.rx_errors++;
-			dev_kfree_skb_any(cb->skb);
-			cb->skb = NULL;
-			goto refill;
+			dev_kfree_skb_any(skb);
+			goto next;
 		}
+
 		/* report errors */
 		if (unlikely(dma_flag & (DMA_RX_CRC_ERROR |
 						DMA_RX_OV |
@@ -1421,11 +1427,8 @@ static unsigned int bcmgenet_desc_rx(str
 				dev->stats.rx_length_errors++;
 			dev->stats.rx_dropped++;
 			dev->stats.rx_errors++;
-
-			/* discard the packet and advance consumer index.*/
-			dev_kfree_skb_any(cb->skb);
-			cb->skb = NULL;
-			goto refill;
+			dev_kfree_skb_any(skb);
+			goto next;
 		} /* error packet */
 
 		chksum_ok = (dma_flag & priv->dma_rx_chk_bit) &&
@@ -1458,14 +1461,12 @@ static unsigned int bcmgenet_desc_rx(str
 
 		/* Notify kernel */
 		napi_gro_receive(&priv->napi, skb);
-		cb->skb = NULL;
 		netif_dbg(priv, rx_status, dev, "pushed up to kernel\n");
 
-		/* refill RX path on the current control block */
-refill:
-		err = bcmgenet_rx_refill(priv, cb);
-		if (err)
-			netif_err(priv, rx_err, dev, "Rx refill failed\n");
+next:
+		rxpktprocessed++;
+		priv->rx_read_ptr++;
+		priv->rx_read_ptr &= (priv->num_rx_bds - 1);
 	}
 
 	return rxpktprocessed;
@@ -1475,7 +1476,7 @@ refill:
 static int bcmgenet_alloc_rx_buffers(struct bcmgenet_priv *priv)
 {
 	struct enet_cb *cb;
-	int ret = 0;
+	struct sk_buff *skb;
 	int i;
 
 	netif_dbg(priv, hw, priv->dev, "%s:\n", __func__);
@@ -1483,36 +1484,28 @@ static int bcmgenet_alloc_rx_buffers(str
 	/* loop here for each buffer needing assign */
 	for (i = 0; i < priv->num_rx_bds; i++) {
 		cb = &priv->rx_cbs[priv->rx_bd_assign_index];
-		if (cb->skb)
-			continue;
-
-		ret = bcmgenet_rx_refill(priv, cb);
-		if (ret)
-			break;
-
+		skb = bcmgenet_rx_refill(priv, cb);
+		if (skb)
+			dev_consume_skb_any(skb);
+		if (!cb->skb)
+			return -ENOMEM;
 	}
 
-	return ret;
+	return 0;
 }
 
 static void bcmgenet_free_rx_buffers(struct bcmgenet_priv *priv)
 {
-	struct device *kdev = &priv->pdev->dev;
+	struct sk_buff *skb;
 	struct enet_cb *cb;
 	int i;
 
 	for (i = 0; i < priv->num_rx_bds; i++) {
 		cb = &priv->rx_cbs[i];
 
-		if (dma_unmap_addr(cb, dma_addr)) {
-			dma_unmap_single(kdev,
-					dma_unmap_addr(cb, dma_addr),
-					priv->rx_buf_len, DMA_FROM_DEVICE);
-			dma_unmap_addr_set(cb, dma_addr, 0);
-		}
-
-		if (cb->skb)
-			bcmgenet_free_cb(cb);
+		skb = bcmgenet_free_rx_cb(&priv->pdev->dev, cb);
+		if (skb)
+			dev_consume_skb_any(skb);
 	}
 }
 
@@ -1640,6 +1633,7 @@ static void bcmgenet_init_tx_ring(struct
 	}
 	ring->cbs = priv->tx_cbs + write_ptr;
 	ring->size = size;
+	ring->clean_ptr = write_ptr;
 	ring->c_index = 0;
 	ring->free_bds = size;
 	ring->write_ptr = write_ptr;
@@ -1788,6 +1782,8 @@ static void bcmgenet_init_multiq(struct
 
 static void bcmgenet_fini_dma(struct bcmgenet_priv *priv)
 {
+	struct sk_buff *skb;
+	struct enet_cb *cb;
 	int i;
 
 	/* disable DMA */
@@ -1795,10 +1791,10 @@ static void bcmgenet_fini_dma(struct bcm
 	bcmgenet_tdma_writel(priv, 0, DMA_CTRL);
 
 	for (i = 0; i < priv->num_tx_bds; i++) {
-		if (priv->tx_cbs[i].skb != NULL) {
-			dev_kfree_skb(priv->tx_cbs[i].skb);
-			priv->tx_cbs[i].skb = NULL;
-		}
+		cb = priv->tx_cbs + i;
+		skb = bcmgenet_free_tx_cb(&priv->pdev->dev, cb);
+		if (skb)
+			dev_kfree_skb(skb);
 	}
 
 	bcmgenet_free_rx_buffers(priv);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/broadcom/genet/bcmgenet.h linux-libre-3.16.50-gnu/drivers/net/ethernet/broadcom/genet/bcmgenet.h
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/broadcom/genet/bcmgenet.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/broadcom/genet/bcmgenet.h	2017-11-11 08:34:06.000000000 -0500
@@ -504,12 +504,21 @@ struct bcmgenet_hw_params {
 	u32		flags;
 };
 
+struct bcmgenet_skb_cb {
+	struct enet_cb *first_cb;	/* First control block of SKB */
+	struct enet_cb *last_cb;	/* Last control block of SKB */
+	unsigned int bytes_sent;	/* bytes on the wire (no TSB) */
+};
+
+#define GENET_CB(skb)	((struct bcmgenet_skb_cb *)((skb)->cb))
+
 struct bcmgenet_tx_ring {
 	spinlock_t	lock;		/* ring lock */
 	unsigned int	index;		/* ring index */
 	unsigned int	queue;		/* queue index */
 	struct enet_cb	*cbs;		/* tx ring buffer control block*/
 	unsigned int	size;		/* size of each tx ring */
+	unsigned int    clean_ptr;      /* Tx ring clean pointer */
 	unsigned int	c_index;	/* last consumer index of each ring*/
 	unsigned int	free_bds;	/* # of free bds for each ring */
 	unsigned int	write_ptr;	/* Tx ring write pointer SW copy */
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/dec/tulip/tulip_core.c linux-libre-3.16.50-gnu/drivers/net/ethernet/dec/tulip/tulip_core.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/dec/tulip/tulip_core.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/dec/tulip/tulip_core.c	2017-11-11 08:34:06.000000000 -0500
@@ -98,8 +98,7 @@ static int csr0 = 0x01A00000 | 0x4800;
 #elif defined(__mips__)
 static int csr0 = 0x00200000 | 0x4000;
 #else
-#warning Processor architecture undefined!
-static int csr0 = 0x00A00000 | 0x4800;
+static int csr0;
 #endif
 
 /* Operational parameters that usually are not changed. */
@@ -1982,6 +1981,12 @@ static int __init tulip_init (void)
 	pr_info("%s", version);
 #endif
 
+	if (!csr0) {
+		pr_warn("tulip: unknown CPU architecture, using default csr0\n");
+		/* default to 8 longword cache line alignment */
+		csr0 = 0x00A00000 | 0x4800;
+	}
+
 	/* copy module parms into globals */
 	tulip_rx_copybreak = rx_copybreak;
 	tulip_max_interrupt_work = max_interrupt_work;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/dec/tulip/uli526x.c linux-libre-3.16.50-gnu/drivers/net/ethernet/dec/tulip/uli526x.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/dec/tulip/uli526x.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/dec/tulip/uli526x.c	2017-11-11 08:34:06.000000000 -0500
@@ -1115,7 +1115,7 @@ static void uli526x_timer(unsigned long
 				netif_carrier_off(dev);
 			}
 		}
-		db->init=0;
+	db->init = 0;
 
 	/* Timer active again */
 	db->timer.expires = ULI526X_TIMER_WUT;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/dec/tulip/winbond-840.c linux-libre-3.16.50-gnu/drivers/net/ethernet/dec/tulip/winbond-840.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/dec/tulip/winbond-840.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/dec/tulip/winbond-840.c	2017-11-11 08:34:06.000000000 -0500
@@ -907,7 +907,7 @@ static void init_registers(struct net_de
 #elif defined(CONFIG_SPARC) || defined (CONFIG_PARISC)
 	i |= 0x4800;
 #else
-#warning Processor architecture undefined
+	dev_warn(&dev->dev, "unknown CPU architecture, using default csr0 setting\n");
 	i |= 0x4800;
 #endif
 	iowrite32(i, ioaddr + PCIBusCfg);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/emulex/benet/be_main.c linux-libre-3.16.50-gnu/drivers/net/ethernet/emulex/benet/be_main.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/emulex/benet/be_main.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/emulex/benet/be_main.c	2017-11-11 08:34:06.000000000 -0500
@@ -26,7 +26,6 @@
 #include <net/vxlan.h>
 
 MODULE_VERSION(DRV_VER);
-MODULE_DEVICE_TABLE(pci, be_dev_ids);
 MODULE_DESCRIPTION(DRV_DESC " " DRV_VER);
 MODULE_AUTHOR("Emulex Corporation");
 MODULE_LICENSE("GPL");
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/intel/e1000e/ich8lan.c linux-libre-3.16.50-gnu/drivers/net/ethernet/intel/e1000e/ich8lan.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/intel/e1000e/ich8lan.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/intel/e1000e/ich8lan.c	2017-11-11 08:34:06.000000000 -0500
@@ -984,7 +984,7 @@ static s32 e1000_platform_pm_pch_lpt(str
 		u16 max_snoop, max_nosnoop;
 		u16 max_ltr_enc;	/* max LTR latency encoded */
 		s64 lat_ns;	/* latency (ns) */
-		s64 value;
+		u64 value;
 		u32 rxa;
 
 		if (!hw->adapter->max_frame_size) {
@@ -1011,12 +1011,13 @@ static s32 e1000_platform_pm_pch_lpt(str
 		 */
 		lat_ns = ((s64)rxa * 1024 -
 			  (2 * (s64)hw->adapter->max_frame_size)) * 8 * 1000;
-		if (lat_ns < 0)
-			lat_ns = 0;
-		else
-			do_div(lat_ns, speed);
+		if (lat_ns < 0) {
+			value = 0;
+		} else {
+			value = lat_ns;
+			do_div(value, speed);
+		}
 
-		value = lat_ns;
 		while (value > PCI_LTR_VALUE_MASK) {
 			scale++;
 			value = DIV_ROUND_UP(value, (1 << 5));
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/intel/i40e/i40e_debugfs.c linux-libre-3.16.50-gnu/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/intel/i40e/i40e_debugfs.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/intel/i40e/i40e_debugfs.c	2017-11-11 08:34:06.000000000 -0500
@@ -754,7 +754,7 @@ static void i40e_dbg_dump_desc(int cnt,
 {
 	struct i40e_tx_desc *txd;
 	union i40e_rx_desc *rxd;
-	struct i40e_ring ring;
+	struct i40e_ring *ring;
 	struct i40e_vsi *vsi;
 	int i;
 
@@ -773,29 +773,32 @@ static void i40e_dbg_dump_desc(int cnt,
 			 vsi_seid);
 		return;
 	}
-	if (is_rx_ring)
-		ring = *vsi->rx_rings[ring_id];
-	else
-		ring = *vsi->tx_rings[ring_id];
+
+	ring = kmemdup(is_rx_ring
+		       ? vsi->rx_rings[ring_id] : vsi->tx_rings[ring_id],
+		       sizeof(*ring), GFP_KERNEL);
+	if (!ring)
+		return;
+
 	if (cnt == 2) {
 		dev_info(&pf->pdev->dev, "vsi = %02i %s ring = %02i\n",
 			 vsi_seid, is_rx_ring ? "rx" : "tx", ring_id);
-		for (i = 0; i < ring.count; i++) {
+		for (i = 0; i < ring->count; i++) {
 			if (!is_rx_ring) {
-				txd = I40E_TX_DESC(&ring, i);
+				txd = I40E_TX_DESC(ring, i);
 				dev_info(&pf->pdev->dev,
 					 "   d[%03i] = 0x%016llx 0x%016llx\n",
 					 i, txd->buffer_addr,
 					 txd->cmd_type_offset_bsz);
 			} else if (sizeof(union i40e_rx_desc) ==
 				   sizeof(union i40e_16byte_rx_desc)) {
-				rxd = I40E_RX_DESC(&ring, i);
+				rxd = I40E_RX_DESC(ring, i);
 				dev_info(&pf->pdev->dev,
 					 "   d[%03i] = 0x%016llx 0x%016llx\n",
 					 i, rxd->read.pkt_addr,
 					 rxd->read.hdr_addr);
 			} else {
-				rxd = I40E_RX_DESC(&ring, i);
+				rxd = I40E_RX_DESC(ring, i);
 				dev_info(&pf->pdev->dev,
 					 "   d[%03i] = 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n",
 					 i, rxd->read.pkt_addr,
@@ -804,26 +807,26 @@ static void i40e_dbg_dump_desc(int cnt,
 			}
 		}
 	} else if (cnt == 3) {
-		if (desc_n >= ring.count || desc_n < 0) {
+		if (desc_n >= ring->count || desc_n < 0) {
 			dev_info(&pf->pdev->dev,
 				 "descriptor %d not found\n", desc_n);
 			return;
 		}
 		if (!is_rx_ring) {
-			txd = I40E_TX_DESC(&ring, desc_n);
+			txd = I40E_TX_DESC(ring, desc_n);
 			dev_info(&pf->pdev->dev,
 				 "vsi = %02i tx ring = %02i d[%03i] = 0x%016llx 0x%016llx\n",
 				 vsi_seid, ring_id, desc_n,
 				 txd->buffer_addr, txd->cmd_type_offset_bsz);
 		} else if (sizeof(union i40e_rx_desc) ==
 			   sizeof(union i40e_16byte_rx_desc)) {
-			rxd = I40E_RX_DESC(&ring, desc_n);
+			rxd = I40E_RX_DESC(ring, desc_n);
 			dev_info(&pf->pdev->dev,
 				 "vsi = %02i rx ring = %02i d[%03i] = 0x%016llx 0x%016llx\n",
 				 vsi_seid, ring_id, desc_n,
 				 rxd->read.pkt_addr, rxd->read.hdr_addr);
 		} else {
-			rxd = I40E_RX_DESC(&ring, desc_n);
+			rxd = I40E_RX_DESC(ring, desc_n);
 			dev_info(&pf->pdev->dev,
 				 "vsi = %02i rx ring = %02i d[%03i] = 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n",
 				 vsi_seid, ring_id, desc_n,
@@ -833,6 +836,7 @@ static void i40e_dbg_dump_desc(int cnt,
 	} else {
 		dev_info(&pf->pdev->dev, "dump desc rx/tx <vsi_seid> <ring_id> [<desc_n>]\n");
 	}
+	kfree(ring);
 }
 
 /**
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/intel/i40e/i40e_txrx.c linux-libre-3.16.50-gnu/drivers/net/ethernet/intel/i40e/i40e_txrx.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/intel/i40e/i40e_txrx.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/intel/i40e/i40e_txrx.c	2017-11-11 08:34:06.000000000 -0500
@@ -914,6 +914,8 @@ int i40e_setup_tx_descriptors(struct i40
 	if (!tx_ring->tx_bi)
 		goto err;
 
+	u64_stats_init(&tx_ring->syncp);
+
 	/* round up to nearest 4K */
 	tx_ring->size = tx_ring->count * sizeof(struct i40e_tx_desc);
 	/* add u32 for head writeback, align after this takes care of
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c linux-libre-3.16.50-gnu/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c	2017-11-11 08:34:06.000000000 -0500
@@ -2535,6 +2535,8 @@ int ixgbevf_setup_tx_resources(struct ix
 	if (!tx_ring->tx_buffer_info)
 		goto err;
 
+	u64_stats_init(&tx_ring->syncp);
+
 	/* round up to nearest 4K */
 	tx_ring->size = tx_ring->count * sizeof(union ixgbe_adv_tx_desc);
 	tx_ring->size = ALIGN(tx_ring->size, 4096);
@@ -2595,6 +2597,8 @@ int ixgbevf_setup_rx_resources(struct ix
 	if (!rx_ring->rx_buffer_info)
 		goto err;
 
+	u64_stats_init(&rx_ring->syncp);
+
 	/* Round up to nearest 4K */
 	rx_ring->size = rx_ring->count * sizeof(union ixgbe_adv_rx_desc);
 	rx_ring->size = ALIGN(rx_ring->size, 4096);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c linux-libre-3.16.50-gnu/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c	2017-11-11 08:34:06.000000000 -0500
@@ -142,6 +142,7 @@ static void mlx4_en_get_wol(struct net_d
 			    struct ethtool_wolinfo *wol)
 {
 	struct mlx4_en_priv *priv = netdev_priv(netdev);
+	struct mlx4_caps *caps = &priv->mdev->dev->caps;
 	int err = 0;
 	u64 config = 0;
 	u64 mask;
@@ -154,24 +155,24 @@ static void mlx4_en_get_wol(struct net_d
 	mask = (priv->port == 1) ? MLX4_DEV_CAP_FLAG_WOL_PORT1 :
 		MLX4_DEV_CAP_FLAG_WOL_PORT2;
 
-	if (!(priv->mdev->dev->caps.flags & mask)) {
+	if (!(caps->flags & mask)) {
 		wol->supported = 0;
 		wol->wolopts = 0;
 		return;
 	}
 
+	if (caps->wol_port[priv->port])
+		wol->supported = WAKE_MAGIC;
+	else
+		wol->supported = 0;
+
 	err = mlx4_wol_read(priv->mdev->dev, &config, priv->port);
 	if (err) {
 		en_err(priv, "Failed to get WoL information\n");
 		return;
 	}
 
-	if (config & MLX4_EN_WOL_MAGIC)
-		wol->supported = WAKE_MAGIC;
-	else
-		wol->supported = 0;
-
-	if (config & MLX4_EN_WOL_ENABLED)
+	if ((config & MLX4_EN_WOL_ENABLED) && (config & MLX4_EN_WOL_MAGIC))
 		wol->wolopts = WAKE_MAGIC;
 	else
 		wol->wolopts = 0;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/mellanox/mlx4/en_netdev.c linux-libre-3.16.50-gnu/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/mellanox/mlx4/en_netdev.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/mellanox/mlx4/en_netdev.c	2017-11-11 08:34:06.000000000 -0500
@@ -1535,17 +1535,13 @@ static int mlx4_en_init_affinity_hint(st
 {
 	struct mlx4_en_rx_ring *ring = priv->rx_ring[ring_idx];
 	int numa_node = priv->mdev->dev->numa_node;
-	int ret = 0;
 
 	if (!zalloc_cpumask_var(&ring->affinity_mask, GFP_KERNEL))
 		return -ENOMEM;
 
-	ret = cpumask_set_cpu_local_first(ring_idx, numa_node,
-					  ring->affinity_mask);
-	if (ret)
-		free_cpumask_var(ring->affinity_mask);
-
-	return ret;
+	cpumask_set_cpu(cpumask_local_spread(ring_idx, numa_node),
+			ring->affinity_mask);
+	return 0;
 }
 
 static void mlx4_en_free_affinity_hint(struct mlx4_en_priv *priv, int ring_idx)
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/mellanox/mlx4/en_tx.c linux-libre-3.16.50-gnu/drivers/net/ethernet/mellanox/mlx4/en_tx.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/mellanox/mlx4/en_tx.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/mellanox/mlx4/en_tx.c	2017-11-11 08:34:06.000000000 -0500
@@ -133,9 +133,9 @@ int mlx4_en_create_tx_ring(struct mlx4_e
 	ring->queue_index = queue_index;
 
 	if (queue_index < priv->num_tx_rings_p_up)
-		cpumask_set_cpu_local_first(queue_index,
-					    priv->mdev->dev->numa_node,
-					    &ring->affinity_mask);
+		cpumask_set_cpu(cpumask_local_spread(queue_index,
+						     priv->mdev->dev->numa_node),
+				&ring->affinity_mask);
 
 	*pring = ring;
 	return 0;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/mellanox/mlx4/fw.c linux-libre-3.16.50-gnu/drivers/net/ethernet/mellanox/mlx4/fw.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/mellanox/mlx4/fw.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/mellanox/mlx4/fw.c	2017-11-11 08:34:06.000000000 -0500
@@ -532,6 +532,7 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *
 #define QUERY_DEV_CAP_CQ_TS_SUPPORT_OFFSET	0x3e
 #define QUERY_DEV_CAP_MAX_PKEY_OFFSET		0x3f
 #define QUERY_DEV_CAP_EXT_FLAGS_OFFSET		0x40
+#define QUERY_DEV_CAP_WOL_OFFSET		0x43
 #define QUERY_DEV_CAP_FLAGS_OFFSET		0x44
 #define QUERY_DEV_CAP_RSVD_UAR_OFFSET		0x48
 #define QUERY_DEV_CAP_UAR_SZ_OFFSET		0x49
@@ -658,6 +659,9 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *
 	MLX4_GET(ext_flags, outbox, QUERY_DEV_CAP_EXT_FLAGS_OFFSET);
 	MLX4_GET(flags, outbox, QUERY_DEV_CAP_FLAGS_OFFSET);
 	dev_cap->flags = flags | (u64)ext_flags << 32;
+	MLX4_GET(field, outbox, QUERY_DEV_CAP_WOL_OFFSET);
+	dev_cap->wol_port[1] = !!(field & 0x20);
+	dev_cap->wol_port[2] = !!(field & 0x40);
 	MLX4_GET(field, outbox, QUERY_DEV_CAP_RSVD_UAR_OFFSET);
 	dev_cap->reserved_uars = field >> 4;
 	MLX4_GET(field, outbox, QUERY_DEV_CAP_UAR_SZ_OFFSET);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/mellanox/mlx4/fw.h linux-libre-3.16.50-gnu/drivers/net/ethernet/mellanox/mlx4/fw.h
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/mellanox/mlx4/fw.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/mellanox/mlx4/fw.h	2017-11-11 08:34:06.000000000 -0500
@@ -120,6 +120,7 @@ struct mlx4_dev_cap {
 	u8  log_max_macs[MLX4_MAX_PORTS + 1];
 	u8  log_max_vlans[MLX4_MAX_PORTS + 1];
 	u32 max_counters;
+	bool wol_port[MLX4_MAX_PORTS + 1];
 };
 
 struct mlx4_func_cap {
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/mellanox/mlx4/main.c linux-libre-3.16.50-gnu/drivers/net/ethernet/mellanox/mlx4/main.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/mellanox/mlx4/main.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/mellanox/mlx4/main.c	2017-11-11 08:34:06.000000000 -0500
@@ -279,6 +279,8 @@ static int mlx4_dev_cap(struct mlx4_dev
 	dev->caps.stat_rate_support  = dev_cap->stat_rate_support;
 	dev->caps.max_gso_sz	     = dev_cap->max_gso_sz;
 	dev->caps.max_rss_tbl_sz     = dev_cap->max_rss_tbl_sz;
+	dev->caps.wol_port[1]          = dev_cap->wol_port[1];
+	dev->caps.wol_port[2]          = dev_cap->wol_port[2];
 
 	/* Sense port always allowed on supported devices for ConnectX-1 and -2 */
 	if (mlx4_priv(dev)->pci_dev_data & MLX4_PCI_DEV_FORCE_SENSE_PORT)
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/mellanox/mlx5/core/cmd.c linux-libre-3.16.50-gnu/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/mellanox/mlx5/core/cmd.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/mellanox/mlx5/core/cmd.c	2017-11-11 08:34:06.000000000 -0500
@@ -547,6 +547,10 @@ static void cb_timeout_handler(struct wo
 	mlx5_cmd_comp_handler(dev, 1UL << ent->idx);
 }
 
+static void free_msg(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *msg);
+static void mlx5_free_cmd_msg(struct mlx5_core_dev *dev,
+			      struct mlx5_cmd_msg *msg);
+
 static void cmd_work_handler(struct work_struct *work)
 {
 	struct mlx5_cmd_work_ent *ent = container_of(work, struct mlx5_cmd_work_ent, work);
@@ -555,16 +559,27 @@ static void cmd_work_handler(struct work
 	unsigned long cb_timeout = msecs_to_jiffies(MLX5_CMD_TIMEOUT_MSEC);
 	struct mlx5_cmd_layout *lay;
 	struct semaphore *sem;
+	int alloc_ret;
 
 	sem = ent->page_queue ? &cmd->pages_sem : &cmd->sem;
 	down(sem);
 	if (!ent->page_queue) {
-		ent->idx = alloc_ent(cmd);
-		if (ent->idx < 0) {
+		alloc_ret = alloc_ent(cmd);
+		if (alloc_ret < 0) {
 			mlx5_core_err(dev, "failed to allocate command entry\n");
+			if (ent->callback) {
+				ent->callback(-EAGAIN, ent->context);
+				mlx5_free_cmd_msg(dev, ent->out);
+				free_msg(dev, ent->in);
+				free_cmd(ent);
+			} else {
+				ent->ret = -EAGAIN;
+				complete(&ent->done);
+			}
 			up(sem);
 			return;
 		}
+		ent->idx = alloc_ret;
 	} else {
 		ent->idx = cmd->max_reg_cmds;
 	}
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c linux-libre-3.16.50-gnu/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c	2017-11-11 08:34:06.000000000 -0500
@@ -300,11 +300,11 @@ static u64 qp_read_field(struct mlx5_cor
 		param = qp->pid;
 		break;
 	case QP_STATE:
-		param = (u64)mlx5_qp_state_str(be32_to_cpu(ctx->flags) >> 28);
+		param = (unsigned long)mlx5_qp_state_str(be32_to_cpu(ctx->flags) >> 28);
 		*is_str = 1;
 		break;
 	case QP_XPORT:
-		param = (u64)mlx5_qp_type_str((be32_to_cpu(ctx->flags) >> 16) & 0xff);
+		param = (unsigned long)mlx5_qp_type_str((be32_to_cpu(ctx->flags) >> 16) & 0xff);
 		*is_str = 1;
 		break;
 	case QP_MTU:
@@ -464,7 +464,7 @@ static ssize_t dbg_read(struct file *fil
 
 
 	if (is_str)
-		ret = snprintf(tbuf, sizeof(tbuf), "%s\n", (const char *)field);
+		ret = snprintf(tbuf, sizeof(tbuf), "%s\n", (const char *)(unsigned long)field);
 	else
 		ret = snprintf(tbuf, sizeof(tbuf), "0x%llx\n", field);
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/neterion/vxge/vxge-main.c linux-libre-3.16.50-gnu/drivers/net/ethernet/neterion/vxge/vxge-main.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/neterion/vxge/vxge-main.c	2017-10-12 22:01:21.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/neterion/vxge/vxge-main.c	2017-11-13 09:12:54.000000000 -0500
@@ -2224,8 +2224,6 @@ static irqreturn_t vxge_isr_napi(int irq
 	return IRQ_NONE;
 }
 
-#ifdef CONFIG_PCI_MSI
-
 static irqreturn_t vxge_tx_msix_handle(int irq, void *dev_id)
 {
 	struct vxge_fifo *fifo = (struct vxge_fifo *)dev_id;
@@ -2443,16 +2441,13 @@ static void vxge_rem_msix_isr(struct vxg
 	if (vdev->config.intr_type == MSI_X)
 		pci_disable_msix(vdev->pdev);
 }
-#endif
 
 static void vxge_rem_isr(struct vxgedev *vdev)
 {
-#ifdef CONFIG_PCI_MSI
-	if (vdev->config.intr_type == MSI_X) {
+	if (IS_ENABLED(CONFIG_PCI_MSI) &&
+	    vdev->config.intr_type == MSI_X) {
 		vxge_rem_msix_isr(vdev);
-	} else
-#endif
-	if (vdev->config.intr_type == INTA) {
+	} else if (vdev->config.intr_type == INTA) {
 			synchronize_irq(vdev->pdev->irq);
 			free_irq(vdev->pdev->irq, vdev);
 	}
@@ -2461,11 +2456,10 @@ static void vxge_rem_isr(struct vxgedev
 static int vxge_add_isr(struct vxgedev *vdev)
 {
 	int ret = 0;
-#ifdef CONFIG_PCI_MSI
 	int vp_idx = 0, intr_idx = 0, intr_cnt = 0, msix_idx = 0, irq_req = 0;
 	int pci_fun = PCI_FUNC(vdev->pdev->devfn);
 
-	if (vdev->config.intr_type == MSI_X)
+	if (IS_ENABLED(CONFIG_PCI_MSI) && vdev->config.intr_type == MSI_X)
 		ret = vxge_enable_msix(vdev);
 
 	if (ret) {
@@ -2476,7 +2470,7 @@ static int vxge_add_isr(struct vxgedev *
 		vdev->config.intr_type = INTA;
 	}
 
-	if (vdev->config.intr_type == MSI_X) {
+	if (IS_ENABLED(CONFIG_PCI_MSI) && vdev->config.intr_type == MSI_X) {
 		for (intr_idx = 0;
 		     intr_idx < (vdev->no_of_vpath *
 			VXGE_HW_VPATH_MSIX_ACTIVE); intr_idx++) {
@@ -2577,9 +2571,8 @@ static int vxge_add_isr(struct vxgedev *
 		vdev->vxge_entries[intr_cnt].in_use = 1;
 		vdev->vxge_entries[intr_cnt].arg = &vdev->vpaths[0];
 	}
-INTA_MODE:
-#endif
 
+INTA_MODE:
 	if (vdev->config.intr_type == INTA) {
 		snprintf(vdev->desc[0], VXGE_INTR_STRLEN,
 			"%s:vxge:INTA", vdev->ndev->name);
@@ -3890,12 +3883,12 @@ static void vxge_device_config_init(stru
 	if (max_mac_vpath > VXGE_MAX_MAC_ADDR_COUNT)
 		max_mac_vpath = VXGE_MAX_MAC_ADDR_COUNT;
 
-#ifndef CONFIG_PCI_MSI
-	vxge_debug_init(VXGE_ERR,
-		"%s: This Kernel does not support "
-		"MSI-X. Defaulting to INTA", VXGE_DRIVER_NAME);
-	*intr_type = INTA;
-#endif
+	if (!IS_ENABLED(CONFIG_PCI_MSI)) {
+		vxge_debug_init(VXGE_ERR,
+			"%s: This Kernel does not support "
+			"MSI-X. Defaulting to INTA", VXGE_DRIVER_NAME);
+		*intr_type = INTA;
+	}
 
 	/* Configure whether MSI-X or IRQL. */
 	switch (*intr_type) {
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c linux-libre-3.16.50-gnu/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c	2017-11-11 08:34:06.000000000 -0500
@@ -2332,7 +2332,7 @@ netxen_md_rdqueue(struct netxen_adapter
 				 loop_cnt++) {
 		NX_WR_DUMP_REG(select_addr, adapter->ahw.pci_base0, queue_id);
 		read_addr = queueEntry->read_addr;
-		for (k = 0; k < read_cnt; k--) {
+		for (k = 0; k < read_cnt; k++) {
 			NX_RD_DUMP_REG(read_addr, adapter->ahw.pci_base0,
 							&read_value);
 			*data_buff++ = read_value;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c linux-libre-3.16.50-gnu/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c	2017-11-11 08:34:06.000000000 -0500
@@ -724,7 +724,7 @@ static void ql_build_coredump_seg_header
 	seg_hdr->cookie = MPI_COREDUMP_COOKIE;
 	seg_hdr->segNum = seg_number;
 	seg_hdr->segSize = seg_size;
-	memcpy(seg_hdr->description, desc, (sizeof(seg_hdr->description)) - 1);
+	strncpy(seg_hdr->description, desc, (sizeof(seg_hdr->description)) - 1);
 }
 
 /*
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/realtek/r8169.c linux-libre-3.16.50-gnu/drivers/net/ethernet/realtek/r8169.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/realtek/r8169.c	2017-10-12 22:00:43.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/realtek/r8169.c	2017-11-13 09:12:22.000000000 -0500
@@ -5846,8 +5846,7 @@ static void rtl8169_tx_clear_range(struc
 			rtl8169_unmap_tx_skb(&tp->pci_dev->dev, tx_skb,
 					     tp->TxDescArray + entry);
 			if (skb) {
-				tp->dev->stats.tx_dropped++;
-				dev_kfree_skb_any(skb);
+				dev_consume_skb_any(skb);
 				tx_skb->skb = NULL;
 			}
 		}
@@ -6155,7 +6154,7 @@ static void rtl_tx(struct net_device *de
 			tp->tx_stats.packets++;
 			tp->tx_stats.bytes += tx_skb->skb->len;
 			u64_stats_update_end(&tp->tx_stats.syncp);
-			dev_kfree_skb_any(tx_skb->skb);
+			dev_consume_skb_any(tx_skb->skb);
 			tx_skb->skb = NULL;
 		}
 		dirty_tx++;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/ti/cpmac.c linux-libre-3.16.50-gnu/drivers/net/ethernet/ti/cpmac.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/ti/cpmac.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/ti/cpmac.c	2017-11-11 08:34:06.000000000 -0500
@@ -543,7 +543,8 @@ fatal_error:
 
 static int cpmac_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
-	int queue, len;
+	int queue;
+	unsigned int len;
 	struct cpmac_desc *desc;
 	struct cpmac_priv *priv = netdev_priv(dev);
 
@@ -553,7 +554,7 @@ static int cpmac_start_xmit(struct sk_bu
 	if (unlikely(skb_padto(skb, ETH_ZLEN)))
 		return NETDEV_TX_OK;
 
-	len = max(skb->len, ETH_ZLEN);
+	len = max_t(unsigned int, skb->len, ETH_ZLEN);
 	queue = skb_get_queue_mapping(skb);
 	netif_stop_subqueue(dev, queue);
 
@@ -1226,7 +1227,7 @@ int cpmac_init(void)
 		goto fail_alloc;
 	}
 
-#warning FIXME: unhardcode gpio&reset bits
+	/* FIXME: unhardcode gpio&reset bits */
 	ar7_gpio_disable(26);
 	ar7_gpio_disable(27);
 	ar7_device_reset(AR7_RESET_BIT_CPMAC_LO);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/xilinx/ll_temac_main.c linux-libre-3.16.50-gnu/drivers/net/ethernet/xilinx/ll_temac_main.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/xilinx/ll_temac_main.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/xilinx/ll_temac_main.c	2017-11-11 08:34:06.000000000 -0500
@@ -72,7 +72,7 @@ void temac_iow(struct temac_local *lp, i
 
 int temac_indirect_busywait(struct temac_local *lp)
 {
-	long end = jiffies + 2;
+	unsigned long end = jiffies + 2;
 
 	while (!(temac_ior(lp, XTE_RDY0_OFFSET) & XTE_RDY0_HARD_ACS_RDY_MASK)) {
 		if (time_before_eq(end, jiffies)) {
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c linux-libre-3.16.50-gnu/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c	2017-11-11 08:34:06.000000000 -0500
@@ -19,7 +19,7 @@
 /* Wait till MDIO interface is ready to accept a new transaction.*/
 int axienet_mdio_wait_until_ready(struct axienet_local *lp)
 {
-	long end = jiffies + 2;
+	unsigned long end = jiffies + 2;
 	while (!(axienet_ior(lp, XAE_MDIO_MCR_OFFSET) &
 		 XAE_MDIO_MCR_READY_MASK)) {
 		if (time_before_eq(end, jiffies)) {
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/ethernet/xilinx/xilinx_emaclite.c linux-libre-3.16.50-gnu/drivers/net/ethernet/xilinx/xilinx_emaclite.c
--- linux-libre-3.16.49-gnu/drivers/net/ethernet/xilinx/xilinx_emaclite.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/ethernet/xilinx/xilinx_emaclite.c	2017-11-11 08:34:06.000000000 -0500
@@ -707,7 +707,7 @@ static irqreturn_t xemaclite_interrupt(i
 
 static int xemaclite_mdio_wait(struct net_local *lp)
 {
-	long end = jiffies + 2;
+	unsigned long end = jiffies + 2;
 
 	/* wait for the MDIO interface to not be busy or timeout
 	   after some time.
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/hyperv/netvsc_drv.c linux-libre-3.16.50-gnu/drivers/net/hyperv/netvsc_drv.c
--- linux-libre-3.16.49-gnu/drivers/net/hyperv/netvsc_drv.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/hyperv/netvsc_drv.c	2017-11-11 08:34:06.000000000 -0500
@@ -777,9 +777,14 @@ static void netvsc_link_change(struct wo
 	struct rndis_device *rdev;
 	bool notify;
 
-	rtnl_lock();
-
 	ndev_ctx = container_of(w, struct net_device_context, dwork.work);
+
+	/* if changes are happening, comeback later */
+	if (!rtnl_trylock()) {
+		schedule_delayed_work(&ndev_ctx->dwork, 2 * HZ);
+		return;
+	}
+
 	net_device = hv_get_drvdata(ndev_ctx->device_ctx);
 	rdev = net_device->extension;
 	net = net_device->ndev;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/Kconfig linux-libre-3.16.50-gnu/drivers/net/Kconfig
--- linux-libre-3.16.49-gnu/drivers/net/Kconfig	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/Kconfig	2017-11-11 08:34:06.000000000 -0500
@@ -331,6 +331,9 @@ config XEN_NETDEV_FRONTEND
 config XEN_NETDEV_BACKEND
 	tristate "Xen backend network device"
 	depends on XEN_BACKEND
+	depends on !(PAGE_SIZE_64KB || ARM64_64K_PAGES || \
+		     IA64_PAGE_SIZE_64KB || MICROBLAZE_64K_PAGES || \
+		     PARISC_PAGE_SIZE_64KB || PPC_64K_PAGES)
 	help
 	  This driver allows the kernel to act as a Xen network driver
 	  domain which exports paravirtual network devices to other
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c linux-libre-3.16.50-gnu/drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c
--- linux-libre-3.16.49-gnu/drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/wireless/brcm80211/brcmfmac/fwsignal.c	2017-11-11 08:34:06.000000000 -0500
@@ -607,7 +607,7 @@ static int brcmf_fws_hanger_pushpkt(stru
 	return 0;
 }
 
-static int brcmf_fws_hanger_poppkt(struct brcmf_fws_hanger *h,
+static inline int brcmf_fws_hanger_poppkt(struct brcmf_fws_hanger *h,
 					  u32 slot_id, struct sk_buff **pktout,
 					  bool remove_item)
 {
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c linux-libre-3.16.50-gnu/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
--- linux-libre-3.16.49-gnu/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c	2017-11-11 08:34:06.000000000 -0500
@@ -2692,6 +2692,7 @@ brcmf_cfg80211_escan_handler(struct brcm
 	s32 status;
 	s32 err = 0;
 	struct brcmf_escan_result_le *escan_result_le;
+	u32 escan_buflen;
 	struct brcmf_bss_info_le *bss_info_le;
 	struct brcmf_bss_info_le *bss = NULL;
 	u32 bi_length;
@@ -2708,11 +2709,23 @@ brcmf_cfg80211_escan_handler(struct brcm
 
 	if (status == BRCMF_E_STATUS_PARTIAL) {
 		brcmf_dbg(SCAN, "ESCAN Partial result\n");
+		if (e->datalen < sizeof(*escan_result_le)) {
+			brcmf_err("invalid event data length\n");
+			goto exit;
+		}
 		escan_result_le = (struct brcmf_escan_result_le *) data;
 		if (!escan_result_le) {
 			brcmf_err("Invalid escan result (NULL pointer)\n");
 			goto exit;
 		}
+		escan_buflen = le32_to_cpu(escan_result_le->buflen);
+		if (escan_buflen > WL_ESCAN_BUF_SIZE ||
+		    escan_buflen > e->datalen ||
+		    escan_buflen < sizeof(*escan_result_le)) {
+			brcmf_err("Invalid escan buffer length: %d\n",
+				  escan_buflen);
+			goto exit;
+		}
 		if (le16_to_cpu(escan_result_le->bss_count) != 1) {
 			brcmf_err("Invalid bss_count %d: ignoring\n",
 				  escan_result_le->bss_count);
@@ -2729,9 +2742,8 @@ brcmf_cfg80211_escan_handler(struct brcm
 		}
 
 		bi_length = le32_to_cpu(bss_info_le->length);
-		if (bi_length != (le32_to_cpu(escan_result_le->buflen) -
-					WL_ESCAN_RESULTS_FIXED_SIZE)) {
-			brcmf_err("Invalid bss_info length %d: ignoring\n",
+		if (bi_length != escan_buflen -	WL_ESCAN_RESULTS_FIXED_SIZE) {
+			brcmf_err("Ignoring invalid bss_info length: %d\n",
 				  bi_length);
 			goto exit;
 		}
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/wireless/hostap/hostap_hw.c linux-libre-3.16.50-gnu/drivers/net/wireless/hostap/hostap_hw.c
--- linux-libre-3.16.49-gnu/drivers/net/wireless/hostap/hostap_hw.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/wireless/hostap/hostap_hw.c	2017-11-11 08:34:06.000000000 -0500
@@ -836,25 +836,30 @@ static int hfa384x_get_rid(struct net_de
 	spin_lock_bh(&local->baplock);
 
 	res = hfa384x_setup_bap(dev, BAP0, rid, 0);
-	if (!res)
-		res = hfa384x_from_bap(dev, BAP0, &rec, sizeof(rec));
+	if (res)
+		goto unlock;
+
+	res = hfa384x_from_bap(dev, BAP0, &rec, sizeof(rec));
+	if (res)
+		goto unlock;
 
 	if (le16_to_cpu(rec.len) == 0) {
 		/* RID not available */
 		res = -ENODATA;
+		goto unlock;
 	}
 
 	rlen = (le16_to_cpu(rec.len) - 1) * 2;
-	if (!res && exact_len && rlen != len) {
+	if (exact_len && rlen != len) {
 		printk(KERN_DEBUG "%s: hfa384x_get_rid - RID len mismatch: "
 		       "rid=0x%04x, len=%d (expected %d)\n",
 		       dev->name, rid, rlen, len);
 		res = -ENODATA;
 	}
 
-	if (!res)
-		res = hfa384x_from_bap(dev, BAP0, buf, len);
+	res = hfa384x_from_bap(dev, BAP0, buf, len);
 
+unlock:
 	spin_unlock_bh(&local->baplock);
 	mutex_unlock(&local->rid_bap_mtx);
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/wireless/iwlegacy/3945.c linux-libre-3.16.50-gnu/drivers/net/wireless/iwlegacy/3945.c
--- linux-libre-3.16.49-gnu/drivers/net/wireless/iwlegacy/3945.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/wireless/iwlegacy/3945.c	2017-11-11 08:34:06.000000000 -0500
@@ -1019,12 +1019,13 @@ il3945_hw_txq_ctx_free(struct il_priv *i
 	int txq_id;
 
 	/* Tx queues */
-	if (il->txq)
+	if (il->txq) {
 		for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++)
 			if (txq_id == IL39_CMD_QUEUE_NUM)
 				il_cmd_queue_free(il);
 			else
 				il_tx_queue_free(il, txq_id);
+	}
 
 	/* free tx queue structure */
 	il_free_txq_mem(il);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/wireless/iwlwifi/dvm/tx.c linux-libre-3.16.50-gnu/drivers/net/wireless/iwlwifi/dvm/tx.c
--- linux-libre-3.16.49-gnu/drivers/net/wireless/iwlwifi/dvm/tx.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/wireless/iwlwifi/dvm/tx.c	2017-11-11 08:34:06.000000000 -0500
@@ -1190,11 +1190,11 @@ int iwlagn_rx_reply_tx(struct iwl_priv *
 				next_reclaimed;
 			IWL_DEBUG_TX_REPLY(priv, "Next reclaimed packet:%d\n",
 						  next_reclaimed);
+			iwlagn_check_ratid_empty(priv, sta_id, tid);
 		}
 
 		iwl_trans_reclaim(priv->trans, txq_id, ssn, &skbs);
 
-		iwlagn_check_ratid_empty(priv, sta_id, tid);
 		freed = 0;
 
 		/* process frames */
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/wireless/iwlwifi/mvm/sta.c linux-libre-3.16.50-gnu/drivers/net/wireless/iwlwifi/mvm/sta.c
--- linux-libre-3.16.49-gnu/drivers/net/wireless/iwlwifi/mvm/sta.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/wireless/iwlwifi/mvm/sta.c	2017-11-11 08:34:06.000000000 -0500
@@ -114,7 +114,8 @@ int iwl_mvm_sta_send_to_fw(struct iwl_mv
 	add_sta_cmd.add_modify = update ? 1 : 0;
 
 	add_sta_cmd.station_flags_msk |= cpu_to_le32(STA_FLG_FAT_EN_MSK |
-						     STA_FLG_MIMO_EN_MSK);
+						     STA_FLG_MIMO_EN_MSK |
+						     STA_FLG_RTS_MIMO_PROT);
 
 	switch (sta->bandwidth) {
 	case IEEE80211_STA_RX_BW_160:
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/net/wireless/ti/wl1251/main.c linux-libre-3.16.50-gnu/drivers/net/wireless/ti/wl1251/main.c
--- linux-libre-3.16.49-gnu/drivers/net/wireless/ti/wl1251/main.c	2017-10-12 22:07:06.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/net/wireless/ti/wl1251/main.c	2017-11-13 09:16:59.000000000 -0500
@@ -1571,6 +1571,7 @@ struct ieee80211_hw *wl1251_alloc_hw(voi
 
 	wl->state = WL1251_STATE_OFF;
 	mutex_init(&wl->mutex);
+	spin_lock_init(&wl->wl_lock);
 
 	wl->tx_mgmt_frm_rate = DEFAULT_HW_GEN_TX_RATE;
 	wl->tx_mgmt_frm_mod = DEFAULT_HW_GEN_MODULATION_TYPE;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/of/device.c linux-libre-3.16.50-gnu/drivers/of/device.c
--- linux-libre-3.16.49-gnu/drivers/of/device.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/of/device.c	2017-11-11 08:34:06.000000000 -0500
@@ -128,6 +128,7 @@ ssize_t of_device_get_modalias(struct de
 
 	return tsize;
 }
+EXPORT_SYMBOL_GPL(of_device_get_modalias);
 
 /**
  * of_device_uevent - Display OF related uevent information
@@ -190,3 +191,4 @@ int of_device_uevent_modalias(struct dev
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(of_device_uevent_modalias);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/parisc/dino.c linux-libre-3.16.50-gnu/drivers/parisc/dino.c
--- linux-libre-3.16.49-gnu/drivers/parisc/dino.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/parisc/dino.c	2017-11-11 08:34:06.000000000 -0500
@@ -954,7 +954,7 @@ static int __init dino_probe(struct pari
 
 	dino_dev->hba.dev = dev;
 	dino_dev->hba.base_addr = ioremap_nocache(hpa, 4096);
-	dino_dev->hba.lmmio_space_offset = 0;	/* CPU addrs == bus addrs */
+	dino_dev->hba.lmmio_space_offset = PCI_F_EXTEND;
 	spin_lock_init(&dino_dev->dinosaur_pen);
 	dino_dev->hba.iommu = ccio_get_iommu(dev);
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/pinctrl/sunxi/pinctrl-sun4i-a10.c linux-libre-3.16.50-gnu/drivers/pinctrl/sunxi/pinctrl-sun4i-a10.c
--- linux-libre-3.16.49-gnu/drivers/pinctrl/sunxi/pinctrl-sun4i-a10.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/pinctrl/sunxi/pinctrl-sun4i-a10.c	2017-11-11 08:34:06.000000000 -0500
@@ -800,6 +800,7 @@ static const struct sunxi_desc_pin sun4i
 		  SUNXI_FUNCTION(0x2, "lcd1"),		/* D16 */
 		  SUNXI_FUNCTION(0x3, "pata"),		/* ATAD12 */
 		  SUNXI_FUNCTION(0x4, "keypad"),	/* IN6 */
+		  SUNXI_FUNCTION(0x5, "sim"),		/* DET */
 		  SUNXI_FUNCTION_IRQ(0x6, 16),		/* EINT16 */
 		  SUNXI_FUNCTION(0x7, "csi1")),		/* D16 */
 	SUNXI_PIN(SUNXI_PINCTRL_PIN(H, 17),
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/platform/x86/samsung-laptop.c linux-libre-3.16.50-gnu/drivers/platform/x86/samsung-laptop.c
--- linux-libre-3.16.49-gnu/drivers/platform/x86/samsung-laptop.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/platform/x86/samsung-laptop.c	2017-11-11 08:34:06.000000000 -0500
@@ -1347,9 +1347,9 @@ static int __init samsung_sabi_init(stru
 	const struct sabi_config *config = NULL;
 	const struct sabi_commands *commands;
 	unsigned int ifaceP;
+	int loca = 0xffff;
 	int ret = 0;
 	int i;
-	int loca;
 
 	samsung->f0000_segment = ioremap_nocache(0xf0000, 0xffff);
 	if (!samsung->f0000_segment) {
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/power/reset/xgene-reboot.c linux-libre-3.16.50-gnu/drivers/power/reset/xgene-reboot.c
--- linux-libre-3.16.49-gnu/drivers/power/reset/xgene-reboot.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/power/reset/xgene-reboot.c	2017-11-11 08:34:06.000000000 -0500
@@ -40,7 +40,7 @@ struct xgene_reboot_context {
 
 static struct xgene_reboot_context *xgene_restart_ctx;
 
-static void xgene_restart(char str, const char *cmd)
+static void xgene_restart(enum reboot_mode mode, const char *cmd)
 {
 	struct xgene_reboot_context *ctx = xgene_restart_ctx;
 	unsigned long timeout;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/s390/net/qeth_l3_main.c linux-libre-3.16.50-gnu/drivers/s390/net/qeth_l3_main.c
--- linux-libre-3.16.49-gnu/drivers/s390/net/qeth_l3_main.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/s390/net/qeth_l3_main.c	2017-11-11 08:34:06.000000000 -0500
@@ -2816,7 +2816,7 @@ static void qeth_l3_fill_header(struct q
 		struct rtable *rt = (struct rtable *) dst;
 		__be32 *pkey = &ip_hdr(skb)->daddr;
 
-		if (rt->rt_gateway)
+		if (rt && rt->rt_gateway)
 			pkey = &rt->rt_gateway;
 
 		/* IPv4 */
@@ -2827,7 +2827,7 @@ static void qeth_l3_fill_header(struct q
 		struct rt6_info *rt = (struct rt6_info *) dst;
 		struct in6_addr *pkey = &ipv6_hdr(skb)->daddr;
 
-		if (!ipv6_addr_any(&rt->rt6i_gateway))
+		if (rt && !ipv6_addr_any(&rt->rt6i_gateway))
 			pkey = &rt->rt6i_gateway;
 
 		/* IPv6 */
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/scsi/advansys.c linux-libre-3.16.50-gnu/drivers/scsi/advansys.c
--- linux-libre-3.16.49-gnu/drivers/scsi/advansys.c	2017-10-12 22:09:53.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/scsi/advansys.c	2017-11-13 09:20:05.000000000 -0500
@@ -49,7 +49,7 @@
 #include <scsi/scsi.h>
 #include <scsi/scsi_host.h>
 
-/* FIXME:
+/* Fixed in linux-4.2, not backported to 3.16:
  *
  *  1. Although all of the necessary command mapping places have the
  *     appropriate dma_map.. APIs, the driver still processes its internal
@@ -68,7 +68,6 @@
  *  7. advansys_info is not safe against multiple simultaneous callers
  *  8. Add module_param to override ISA/VLB ioport array
  */
-#warning this driver is still not properly converted to the DMA API
 
 /* Enable driver /proc statistics. */
 #define ADVANSYS_STATS
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/scsi/aic94xx/aic94xx_sds.c linux-libre-3.16.50-gnu/drivers/scsi/aic94xx/aic94xx_sds.c
--- linux-libre-3.16.49-gnu/drivers/scsi/aic94xx/aic94xx_sds.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/scsi/aic94xx/aic94xx_sds.c	2017-11-11 08:34:06.000000000 -0500
@@ -983,7 +983,7 @@ static int asd_process_ctrl_a_user(struc
 {
 	int err, i;
 	u32 offs, size;
-	struct asd_ll_el *el;
+	struct asd_ll_el *el = NULL;
 	struct asd_ctrla_phy_settings *ps;
 	struct asd_ctrla_phy_settings dflt_ps;
 
@@ -1004,6 +1004,7 @@ static int asd_process_ctrl_a_user(struc
 
 		size = sizeof(struct asd_ctrla_phy_settings);
 		ps = &dflt_ps;
+		goto out_process;
 	}
 
 	if (size == 0)
@@ -1028,7 +1029,7 @@ static int asd_process_ctrl_a_user(struc
 		ASD_DPRINTK("couldn't find ctrla phy settings struct\n");
 		goto out2;
 	}
-
+out_process:
 	err = asd_process_ctrla_phy_settings(asd_ha, ps);
 	if (err) {
 		ASD_DPRINTK("couldn't process ctrla phy settings\n");
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/scsi/be2iscsi/be_main.c linux-libre-3.16.50-gnu/drivers/scsi/be2iscsi/be_main.c
--- linux-libre-3.16.49-gnu/drivers/scsi/be2iscsi/be_main.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/scsi/be2iscsi/be_main.c	2017-11-11 08:34:06.000000000 -0500
@@ -48,7 +48,6 @@ static unsigned int be_iopoll_budget = 1
 static unsigned int be_max_phys_size = 64;
 static unsigned int enable_msix = 1;
 
-MODULE_DEVICE_TABLE(pci, beiscsi_pci_id_table);
 MODULE_DESCRIPTION(DRV_DESC " " BUILD_STR);
 MODULE_VERSION(BUILD_STR);
 MODULE_AUTHOR("Emulex Corporation");
@@ -3153,7 +3152,7 @@ be_sgl_create_contiguous(void *virtual_a
 {
 	WARN_ON(!virtual_address);
 	WARN_ON(!physical_address);
-	WARN_ON(!length > 0);
+	WARN_ON(!length);
 	WARN_ON(!sgl);
 
 	sgl->va = virtual_address;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/scsi/bfa/bfa_ioc.c linux-libre-3.16.50-gnu/drivers/scsi/bfa/bfa_ioc.c
--- linux-libre-3.16.49-gnu/drivers/scsi/bfa/bfa_ioc.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/scsi/bfa/bfa_ioc.c	2017-11-11 08:34:06.000000000 -0500
@@ -3665,19 +3665,19 @@ bfa_cb_sfp_state_query(struct bfa_sfp_s
 		if (sfp->state_query_cbfn)
 			sfp->state_query_cbfn(sfp->state_query_cbarg,
 					sfp->status);
-			sfp->media = NULL;
-		}
+		sfp->media = NULL;
+	}
 
-		if (sfp->portspeed) {
-			sfp->status = bfa_sfp_speed_valid(sfp, sfp->portspeed);
-			if (sfp->state_query_cbfn)
-				sfp->state_query_cbfn(sfp->state_query_cbarg,
-						sfp->status);
-				sfp->portspeed = BFA_PORT_SPEED_UNKNOWN;
-		}
+	if (sfp->portspeed) {
+		sfp->status = bfa_sfp_speed_valid(sfp, sfp->portspeed);
+		if (sfp->state_query_cbfn)
+			sfp->state_query_cbfn(sfp->state_query_cbarg,
+					sfp->status);
+		sfp->portspeed = BFA_PORT_SPEED_UNKNOWN;
+	}
 
-		sfp->state_query_lock = 0;
-		sfp->state_query_cbfn = NULL;
+	sfp->state_query_lock = 0;
+	sfp->state_query_cbfn = NULL;
 }
 
 /*
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/scsi/ips.c linux-libre-3.16.50-gnu/drivers/scsi/ips.c
--- linux-libre-3.16.49-gnu/drivers/scsi/ips.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/scsi/ips.c	2017-11-11 08:34:06.000000000 -0500
@@ -206,10 +206,6 @@ module_param(ips, charp, 0);
 #define IPS_VERSION_HIGH        IPS_VER_MAJOR_STRING "." IPS_VER_MINOR_STRING
 #define IPS_VERSION_LOW         "." IPS_VER_BUILD_STRING " "
 
-#if !defined(__i386__) && !defined(__ia64__) && !defined(__x86_64__)
-#warning "This driver has only been tested on the x86/ia64/x86_64 platforms"
-#endif
-
 #define IPS_DMA_DIR(scb) ((!scb->scsi_cmd || ips_is_passthru(scb->scsi_cmd) || \
                          DMA_NONE == scb->scsi_cmd->sc_data_direction) ? \
                          PCI_DMA_BIDIRECTIONAL : \
@@ -6789,6 +6785,11 @@ ips_remove_device(struct pci_dev *pci_de
 static int __init
 ips_module_init(void)
 {
+#if !defined(__i386__) && !defined(__ia64__) && !defined(__x86_64__)
+	printk(KERN_ERR "ips: This driver has only been tested on the x86/ia64/x86_64 platforms\n");
+	add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_STILL_OK);
+#endif
+
 	if (pci_register_driver(&ips_pci_driver) < 0)
 		return -ENODEV;
 	ips_driver_template.module = THIS_MODULE;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/scsi/mvsas/mv_sas.c linux-libre-3.16.50-gnu/drivers/scsi/mvsas/mv_sas.c
--- linux-libre-3.16.49-gnu/drivers/scsi/mvsas/mv_sas.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/scsi/mvsas/mv_sas.c	2017-11-11 08:34:06.000000000 -0500
@@ -737,8 +737,8 @@ static int mvs_task_prep(struct sas_task
 			mv_dprintk("device %016llx not ready.\n",
 				SAS_ADDR(dev->sas_addr));
 
-			rc = SAS_PHY_DOWN;
-			return rc;
+		rc = SAS_PHY_DOWN;
+		return rc;
 	}
 	tei.port = dev->port->lldd_port;
 	if (tei.port && !tei.port->port_attached && !tmf) {
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/scsi/scsi_tgt_if.c linux-libre-3.16.50-gnu/drivers/scsi/scsi_tgt_if.c
--- linux-libre-3.16.49-gnu/drivers/scsi/scsi_tgt_if.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/scsi/scsi_tgt_if.c	2017-11-11 08:34:06.000000000 -0500
@@ -286,7 +286,7 @@ static int uspace_ring_map(struct vm_are
 	int i, err;
 
 	for (i = 0; i < TGT_RING_PAGES; i++) {
-		struct page *page = virt_to_page(ring->tr_pages[i]);
+		struct page *page = virt_to_page((void *)ring->tr_pages[i]);
 		err = vm_insert_page(vma, addr, page);
 		if (err)
 			return err;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/scsi/st.c linux-libre-3.16.50-gnu/drivers/scsi/st.c
--- linux-libre-3.16.49-gnu/drivers/scsi/st.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/scsi/st.c	2017-11-11 08:34:06.000000000 -0500
@@ -4115,11 +4115,11 @@ static int st_probe(struct device *dev)
 	kref_init(&tpnt->kref);
 	tpnt->disk = disk;
 	disk->private_data = &tpnt->driver;
-	disk->queue = SDp->request_queue;
 	/* SCSI tape doesn't register this gendisk via add_disk().  Manually
 	 * take queue reference that release_disk() expects. */
-	if (!blk_get_queue(disk->queue))
+	if (!blk_get_queue(SDp->request_queue))
 		goto out_put_disk;
+	disk->queue = SDp->request_queue;
 	tpnt->driver = &st_template;
 
 	tpnt->device = SDp;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/spi/spi-atmel.c linux-libre-3.16.50-gnu/drivers/spi/spi-atmel.c
--- linux-libre-3.16.49-gnu/drivers/spi/spi-atmel.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/spi/spi-atmel.c	2017-11-11 08:34:06.000000000 -0500
@@ -1020,7 +1020,7 @@ static int atmel_spi_setup(struct spi_de
 	csr |= SPI_BF(DLYBCT, 0);
 
 	/* chipselect must have been muxed as GPIO (e.g. in board setup) */
-	npcs_pin = (unsigned int)spi->controller_data;
+	npcs_pin = (unsigned long)spi->controller_data;
 
 	if (gpio_is_valid(spi->cs_gpio))
 		npcs_pin = spi->cs_gpio;
@@ -1255,7 +1255,7 @@ msg_done:
 static void atmel_spi_cleanup(struct spi_device *spi)
 {
 	struct atmel_spi_device	*asd = spi->controller_state;
-	unsigned		gpio = (unsigned) spi->controller_data;
+	unsigned		gpio = (unsigned long) spi->controller_data;
 
 	if (!asd)
 		return;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/spi/spi-pl022.c linux-libre-3.16.50-gnu/drivers/spi/spi-pl022.c
--- linux-libre-3.16.49-gnu/drivers/spi/spi-pl022.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/spi/spi-pl022.c	2017-11-11 08:34:06.000000000 -0500
@@ -1417,7 +1417,7 @@ static void do_interrupt_dma_transfer(st
 	 * Default is to enable all interrupts except RX -
 	 * this will be enabled once TX is complete
 	 */
-	u32 irqflags = ENABLE_ALL_INTERRUPTS & ~SSP_IMSC_MASK_RXIM;
+	u32 irqflags = (u32)(ENABLE_ALL_INTERRUPTS & ~SSP_IMSC_MASK_RXIM);
 
 	/* Enable target chip, if not already active */
 	if (!pl022->next_msg_cs_active)
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/spi/spi-rspi.c linux-libre-3.16.50-gnu/drivers/spi/spi-rspi.c
--- linux-libre-3.16.49-gnu/drivers/spi/spi-rspi.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/spi/spi-rspi.c	2017-11-11 08:34:06.000000000 -0500
@@ -630,7 +630,6 @@ static int rspi_rz_transfer_one(struct s
 				struct spi_transfer *xfer)
 {
 	struct rspi_data *rspi = spi_master_get_devdata(master);
-	int ret;
 
 	rspi_rz_receive_init(rspi);
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/spmi/spmi.c linux-libre-3.16.50-gnu/drivers/spmi/spmi.c
--- linux-libre-3.16.49-gnu/drivers/spmi/spmi.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/spmi/spmi.c	2017-11-11 08:34:06.000000000 -0500
@@ -354,11 +354,23 @@ static int spmi_drv_remove(struct device
 	return 0;
 }
 
+static int spmi_drv_uevent(struct device *dev, struct kobj_uevent_env *env)
+{
+	int ret;
+
+	ret = of_device_uevent_modalias(dev, env);
+	if (ret != -ENODEV)
+		return ret;
+
+	return 0;
+}
+
 static struct bus_type spmi_bus_type = {
 	.name		= "spmi",
 	.match		= spmi_device_match,
 	.probe		= spmi_drv_probe,
 	.remove		= spmi_drv_remove,
+	.uevent		= spmi_drv_uevent,
 };
 
 /**
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/staging/bcm/Kconfig linux-libre-3.16.50-gnu/drivers/staging/bcm/Kconfig
--- linux-libre-3.16.49-gnu/drivers/staging/bcm/Kconfig	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/staging/bcm/Kconfig	2017-11-11 08:34:06.000000000 -0500
@@ -1,6 +1,7 @@
 config BCM_WIMAX
        tristate "Beceem BCS200/BCS220-3 and BCSM250 wimax support"
        depends on USB && NET
+	depends on !64BIT
        help
          This is an experimental driver for the Beceem WIMAX chipset used
 	 by Sprint 4G.
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/staging/dgnc/dgnc_tty.c linux-libre-3.16.50-gnu/drivers/staging/dgnc/dgnc_tty.c
--- linux-libre-3.16.49-gnu/drivers/staging/dgnc/dgnc_tty.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/staging/dgnc/dgnc_tty.c	2017-11-11 08:34:06.000000000 -0500
@@ -481,13 +481,18 @@ void dgnc_sniff_nowait_nolock(struct cha
 	int nbuf;
 	int i;
 	int tmpbuflen;
-	char tmpbuf[TMPBUFLEN];
-	char *p = tmpbuf;
+	char *tmpbuf;
+	char *p;
 	int too_much_data;
 
+	tmpbuf = kzalloc(TMPBUFLEN, GFP_KERNEL);
+	if (!tmpbuf)
+		return;
+	p = tmpbuf;
+
 	/* Leave if sniff not open */
 	if (!(ch->ch_sniff_flags & SNIFF_OPEN))
-		return;
+		goto exit;
 
 	do_gettimeofday(&tv);
 
@@ -534,7 +539,7 @@ void dgnc_sniff_nowait_nolock(struct cha
 			 * function was probably called by the interrupt/timer routines!
 			 */
 			if (n == 0)
-				return;
+				goto exit;
 
 			/*
 			 * Copy as much data as will fit.
@@ -579,6 +584,9 @@ void dgnc_sniff_nowait_nolock(struct cha
 		}
 
 	} while (too_much_data);
+
+exit:
+	kfree(tmpbuf);
 }
 
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/staging/iio/adc/ad7192.c linux-libre-3.16.50-gnu/drivers/staging/iio/adc/ad7192.c
--- linux-libre-3.16.49-gnu/drivers/staging/iio/adc/ad7192.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/staging/iio/adc/ad7192.c	2017-11-11 08:34:06.000000000 -0500
@@ -236,7 +236,7 @@ static int ad7192_setup(struct ad7192_st
 			st->mclk = pdata->ext_clk_Hz;
 		else
 			st->mclk = AD7192_INT_FREQ_MHz;
-			break;
+		break;
 	default:
 		ret = -EINVAL;
 		goto out;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/staging/iio/resolver/ad2s1210.c linux-libre-3.16.50-gnu/drivers/staging/iio/resolver/ad2s1210.c
--- linux-libre-3.16.49-gnu/drivers/staging/iio/resolver/ad2s1210.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/staging/iio/resolver/ad2s1210.c	2017-11-11 08:34:06.000000000 -0500
@@ -462,7 +462,7 @@ static int ad2s1210_read_raw(struct iio_
 			     long m)
 {
 	struct ad2s1210_state *st = iio_priv(indio_dev);
-	bool negative;
+	u16 negative;
 	int ret = 0;
 	u16 pos;
 	s16 vel;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/staging/imx-drm/imx-hdmi.c linux-libre-3.16.50-gnu/drivers/staging/imx-drm/imx-hdmi.c
--- linux-libre-3.16.49-gnu/drivers/staging/imx-drm/imx-hdmi.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/staging/imx-drm/imx-hdmi.c	2017-11-11 08:34:06.000000000 -0500
@@ -968,7 +968,7 @@ static void hdmi_config_AVI(struct imx_h
 	else
 		pix_fmt = HDMI_FC_AVICONF0_PIX_FMT_RGB;
 
-		under_scan =  HDMI_FC_AVICONF0_SCAN_INFO_NODATA;
+	under_scan =  HDMI_FC_AVICONF0_SCAN_INFO_NODATA;
 
 	/*
 	 * Active format identification data is present in the AVI InfoFrame.
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/staging/lustre/lustre/llite/llite_lib.c linux-libre-3.16.50-gnu/drivers/staging/lustre/lustre/llite/llite_lib.c
--- linux-libre-3.16.49-gnu/drivers/staging/lustre/lustre/llite/llite_lib.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/staging/lustre/lustre/llite/llite_lib.c	2017-11-11 08:34:06.000000000 -0500
@@ -1489,7 +1489,7 @@ int ll_setattr_raw(struct dentry *dentry
 
 	if (attr->ia_valid & (ATTR_SIZE |
 			      ATTR_ATIME | ATTR_ATIME_SET |
-			      ATTR_MTIME | ATTR_MTIME_SET))
+			      ATTR_MTIME | ATTR_MTIME_SET)) {
 		/* For truncate and utimes sending attributes to OSTs, setting
 		 * mtime/atime to the past will be performed under PW [0:EOF]
 		 * extent lock (new_size:EOF for truncate).  It may seem
@@ -1501,6 +1501,7 @@ int ll_setattr_raw(struct dentry *dentry
 		rc = ll_setattr_ost(inode, attr);
 		if (attr->ia_valid & ATTR_SIZE)
 			up_write(&lli->lli_trunc_sem);
+	}
 out:
 	if (op_data) {
 		if (op_data->op_ioepoch) {
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/staging/rtl8188eu/os_dep/usb_intf.c linux-libre-3.16.50-gnu/drivers/staging/rtl8188eu/os_dep/usb_intf.c
--- linux-libre-3.16.49-gnu/drivers/staging/rtl8188eu/os_dep/usb_intf.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/staging/rtl8188eu/os_dep/usb_intf.c	2017-11-11 08:34:06.000000000 -0500
@@ -59,7 +59,9 @@ static struct usb_device_id rtw_usb_id_t
 	{USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */
 	{USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */
 	{USB_DEVICE(0x2001, 0x3311)}, /* DLink GO-USB-N150 REV B1 */
+	{USB_DEVICE(0x2357, 0x010c)}, /* TP-Link TL-WN722N v2 */
 	{USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */
+	{USB_DEVICE(USB_VENDER_ID_REALTEK, 0xffef)}, /* Rosewill RNX-N150NUB */
 	{}	/* Terminating entry */
 };
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/staging/rtl8192ee/pci.c linux-libre-3.16.50-gnu/drivers/staging/rtl8192ee/pci.c
--- linux-libre-3.16.49-gnu/drivers/staging/rtl8192ee/pci.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/staging/rtl8192ee/pci.c	2017-11-11 08:34:06.000000000 -0500
@@ -882,8 +882,8 @@ static void _rtl_pci_rx_interrupt(struct
 
 		} else {
 			if (err_count++ < 10) {
-				pr_info("skb->end (%d) - skb->tail (%d) > len (%d)\n",
-					skb->end, skb->tail, len);
+				pr_info("skb end: %d) - tailroom (%d) > len (%d)\n",
+					skb_end_offset(skb), skb_tailroom(skb), len);
 				RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_EMERG,
 					      "RX desc\n",
 					      (u8 *)pdesc, 32);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/staging/rtl8723au/core/rtw_wlan_util.c linux-libre-3.16.50-gnu/drivers/staging/rtl8723au/core/rtw_wlan_util.c
--- linux-libre-3.16.49-gnu/drivers/staging/rtl8723au/core/rtw_wlan_util.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/staging/rtl8723au/core/rtw_wlan_util.c	2017-11-11 08:34:06.000000000 -0500
@@ -546,7 +546,7 @@ void WMMOnAssocRsp23a(struct rtw_adapter
 	else
 		aSifsTime = 16;
 
-		for (i = 0; i < 4; i++) {
+	for (i = 0; i < 4; i++) {
 		ACI = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN >> 5) & 0x03;
 		ACM = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN >> 4) & 0x01;
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/staging/vt6655/device_main.c linux-libre-3.16.50-gnu/drivers/staging/vt6655/device_main.c
--- linux-libre-3.16.49-gnu/drivers/staging/vt6655/device_main.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/staging/vt6655/device_main.c	2017-11-11 08:34:06.000000000 -0500
@@ -2933,11 +2933,13 @@ static int  device_ioctl(struct net_devi
 		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWSENS \n");
 		rc = -EOPNOTSUPP;
 		break;
-
 	case SIOCGIWAPLIST: {
-		char buffer[IW_MAX_AP * (sizeof(struct sockaddr) + sizeof(struct iw_quality))];
+		char *buffer = kzalloc(IW_MAX_AP * (sizeof(struct sockaddr) +
+				       sizeof(struct iw_quality)), GFP_KERNEL);
 
-		if (wrq->u.data.pointer) {
+		if (!buffer) {
+			rc = -ENOMEM;
+		} else if (wrq->u.data.pointer) {
 			rc = iwctl_giwaplist(dev, NULL, &(wrq->u.data), buffer);
 			if (rc == 0) {
 				if (copy_to_user(wrq->u.data.pointer,
@@ -2947,6 +2949,7 @@ static int  device_ioctl(struct net_devi
 					rc = -EFAULT;
 			}
 		}
+		kfree(buffer);
 	}
 	break;
 
@@ -2993,7 +2996,6 @@ static int  device_ioctl(struct net_devi
 		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWGENIE \n");
 		rc = iwctl_giwgenie(dev, NULL, &(wrq->u.data), wrq->u.data.pointer);
 		break;
-
 	case SIOCSIWENCODEEXT: {
 		char extra[sizeof(struct iw_encode_ext)+MAX_KEY_LEN+1];
 		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODEEXT \n");
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/staging/wlan-ng/prism2fw.c linux-libre-3.16.50-gnu/drivers/staging/wlan-ng/prism2fw.c
--- linux-libre-3.16.49-gnu/drivers/staging/wlan-ng/prism2fw.c	2017-10-12 22:05:05.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/staging/wlan-ng/prism2fw.c	2017-11-13 09:15:38.000000000 -0500
@@ -763,30 +763,35 @@ static int plugimage(struct imgchunk *fc
 static int read_cardpda(struct pda *pda, wlandevice_t *wlandev)
 {
 	int result = 0;
-	struct p80211msg_p2req_readpda msg;
+	struct p80211msg_p2req_readpda *msg;
+
+	msg = kzalloc(sizeof(*msg), GFP_KERNEL);
+	if (!msg)
+		return -ENOMEM;
 
 	/* set up the msg */
-	msg.msgcode = DIDmsg_p2req_readpda;
-	msg.msglen = sizeof(msg);
-	strcpy(msg.devname, wlandev->name);
-	msg.pda.did = DIDmsg_p2req_readpda_pda;
-	msg.pda.len = HFA384x_PDA_LEN_MAX;
-	msg.pda.status = P80211ENUM_msgitem_status_no_value;
-	msg.resultcode.did = DIDmsg_p2req_readpda_resultcode;
-	msg.resultcode.len = sizeof(u32);
-	msg.resultcode.status = P80211ENUM_msgitem_status_no_value;
+	msg->msgcode = DIDmsg_p2req_readpda;
+	msg->msglen = sizeof(msg);
+	strcpy(msg->devname, wlandev->name);
+	msg->pda.did = DIDmsg_p2req_readpda_pda;
+	msg->pda.len = HFA384x_PDA_LEN_MAX;
+	msg->pda.status = P80211ENUM_msgitem_status_no_value;
+	msg->resultcode.did = DIDmsg_p2req_readpda_resultcode;
+	msg->resultcode.len = sizeof(u32);
+	msg->resultcode.status = P80211ENUM_msgitem_status_no_value;
 
-	if (prism2mgmt_readpda(wlandev, &msg) != 0) {
+	if (prism2mgmt_readpda(wlandev, msg) != 0) {
 		/* prism2mgmt_readpda prints an errno if appropriate */
 		result = -1;
-	} else if (msg.resultcode.data == P80211ENUM_resultcode_success) {
-		memcpy(pda->buf, msg.pda.data, HFA384x_PDA_LEN_MAX);
+	} else if (msg->resultcode.data == P80211ENUM_resultcode_success) {
+		memcpy(pda->buf, msg->pda.data, HFA384x_PDA_LEN_MAX);
 		result = mkpdrlist(pda);
 	} else {
 		/* resultcode must've been something other than success */
 		result = -1;
 	}
 
+	kfree(msg);
 	return result;
 }
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/target/iscsi/iscsi_target.c linux-libre-3.16.50-gnu/drivers/target/iscsi/iscsi_target.c
--- linux-libre-3.16.49-gnu/drivers/target/iscsi/iscsi_target.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/target/iscsi/iscsi_target.c	2017-11-11 08:34:06.000000000 -0500
@@ -431,6 +431,7 @@ int iscsit_reset_np_thread(
 		return 0;
 	}
 	np->np_thread_state = ISCSI_NP_THREAD_RESET;
+	atomic_inc(&np->np_reset_count);
 
 	if (np->np_thread) {
 		spin_unlock_bh(&np->np_thread_lock);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/target/iscsi/iscsi_target_core.h linux-libre-3.16.50-gnu/drivers/target/iscsi/iscsi_target_core.h
--- linux-libre-3.16.49-gnu/drivers/target/iscsi/iscsi_target_core.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/target/iscsi/iscsi_target_core.h	2017-11-11 08:34:06.000000000 -0500
@@ -792,6 +792,7 @@ struct iscsi_np {
 	int			np_sock_type;
 	enum np_thread_state_table np_thread_state;
 	bool                    enabled;
+	atomic_t		np_reset_count;
 	enum iscsi_timer_flags_table np_login_timer_flags;
 	u32			np_exports;
 	enum np_flags_table	np_flags;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/target/iscsi/iscsi_target_login.c linux-libre-3.16.50-gnu/drivers/target/iscsi/iscsi_target_login.c
--- linux-libre-3.16.49-gnu/drivers/target/iscsi/iscsi_target_login.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/target/iscsi/iscsi_target_login.c	2017-11-11 08:34:06.000000000 -0500
@@ -1277,9 +1277,11 @@ static int __iscsi_target_login_thread(s
 	flush_signals(current);
 
 	spin_lock_bh(&np->np_thread_lock);
-	if (np->np_thread_state == ISCSI_NP_THREAD_RESET) {
+	if (atomic_dec_if_positive(&np->np_reset_count) >= 0) {
 		np->np_thread_state = ISCSI_NP_THREAD_ACTIVE;
+		spin_unlock_bh(&np->np_thread_lock);
 		complete(&np->np_restart_comp);
+		return 1;
 	} else if (np->np_thread_state == ISCSI_NP_THREAD_SHUTDOWN) {
 		spin_unlock_bh(&np->np_thread_lock);
 		goto exit;
@@ -1312,7 +1314,8 @@ static int __iscsi_target_login_thread(s
 		goto exit;
 	} else if (rc < 0) {
 		spin_lock_bh(&np->np_thread_lock);
-		if (np->np_thread_state == ISCSI_NP_THREAD_RESET) {
+		if (atomic_dec_if_positive(&np->np_reset_count) >= 0) {
+			np->np_thread_state = ISCSI_NP_THREAD_ACTIVE;
 			spin_unlock_bh(&np->np_thread_lock);
 			complete(&np->np_restart_comp);
 			iscsit_put_transport(conn->conn_transport);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/tty/isicom.c linux-libre-3.16.50-gnu/drivers/tty/isicom.c
--- linux-libre-3.16.49-gnu/drivers/tty/isicom.c	2017-10-12 21:51:04.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/tty/isicom.c	2017-11-13 09:05:18.000000000 -0500
@@ -1055,7 +1055,7 @@ static int isicom_send_break(struct tty_
 
 	outw(0x8000 | ((port->channel) << (card->shift_count)) | 0x3, base);
 	outw((length & 0xff) << 8 | 0x00, base);
-	outw((length & 0xff00), base);
+	outw((length & 0xff00u), base);
 	InterruptTheCard(base);
 
 	unlock_card(card);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/tty/nozomi.c linux-libre-3.16.50-gnu/drivers/tty/nozomi.c
--- linux-libre-3.16.49-gnu/drivers/tty/nozomi.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/tty/nozomi.c	2017-11-11 08:34:06.000000000 -0500
@@ -823,7 +823,7 @@ static int receive_data(enum port_type i
 	struct tty_struct *tty = tty_port_tty_get(&port->port);
 	int i, ret;
 
-	read_mem32((u32 *) &size, addr, 4);
+	size = __le32_to_cpu(readl(addr));
 	/*  DBG1( "%d bytes port: %d", size, index); */
 
 	if (tty && test_bit(TTY_THROTTLED, &tty->flags)) {
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/usb/class/cdc-acm.c linux-libre-3.16.50-gnu/drivers/usb/class/cdc-acm.c
--- linux-libre-3.16.49-gnu/drivers/usb/class/cdc-acm.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/usb/class/cdc-acm.c	2017-11-11 08:34:06.000000000 -0500
@@ -1772,6 +1772,9 @@ static const struct usb_device_id acm_id
 	{ USB_DEVICE(0x1576, 0x03b1), /* Maretron USB100 */
 	.driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */
 	},
+	{ USB_DEVICE(0xfff0, 0x0100), /* DATECS FP-2000 */
+	.driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */
+	},
 
 	{ USB_DEVICE(0x2912, 0x0001), /* ATOL FPrint */
 	.driver_info = CLEAR_HALT_CONDITIONS,
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/usb/core/config.c linux-libre-3.16.50-gnu/drivers/usb/core/config.c
--- linux-libre-3.16.49-gnu/drivers/usb/core/config.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/usb/core/config.c	2017-11-11 08:34:06.000000000 -0500
@@ -607,15 +607,23 @@ static int usb_parse_configuration(struc
 
 		} else if (header->bDescriptorType ==
 				USB_DT_INTERFACE_ASSOCIATION) {
+			struct usb_interface_assoc_descriptor *d;
+
+			d = (struct usb_interface_assoc_descriptor *)header;
+			if (d->bLength < USB_DT_INTERFACE_ASSOCIATION_SIZE) {
+				dev_warn(ddev,
+					 "config %d has an invalid interface association descriptor of length %d, skipping\n",
+					 cfgno, d->bLength);
+				continue;
+			}
+
 			if (iad_num == USB_MAXIADS) {
 				dev_warn(ddev, "found more Interface "
 					       "Association Descriptors "
 					       "than allocated for in "
 					       "configuration %d\n", cfgno);
 			} else {
-				config->intf_assoc[iad_num] =
-					(struct usb_interface_assoc_descriptor
-					*)header;
+				config->intf_assoc[iad_num] = d;
 				iad_num++;
 			}
 
@@ -916,10 +924,12 @@ int usb_get_bos_descriptor(struct usb_de
 	for (i = 0; i < num; i++) {
 		buffer += length;
 		cap = (struct usb_dev_cap_header *)buffer;
-		length = cap->bLength;
 
-		if (total_len < length)
+		if (total_len < sizeof(*cap) || total_len < cap->bLength) {
+			dev->bos->desc->bNumDeviceCaps = i;
 			break;
+		}
+		length = cap->bLength;
 		total_len -= length;
 
 		if (cap->bDescriptorType != USB_DT_DEVICE_CAPABILITY) {
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/usb/core/hcd.c linux-libre-3.16.50-gnu/drivers/usb/core/hcd.c
--- linux-libre-3.16.49-gnu/drivers/usb/core/hcd.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/usb/core/hcd.c	2017-11-11 08:34:06.000000000 -0500
@@ -2402,6 +2402,8 @@ void usb_hc_died (struct usb_hcd *hcd)
 	}
 	if (usb_hcd_is_primary_hcd(hcd) && hcd->shared_hcd) {
 		hcd = hcd->shared_hcd;
+		clear_bit(HCD_FLAG_RH_RUNNING, &hcd->flags);
+		set_bit(HCD_FLAG_DEAD, &hcd->flags);
 		if (hcd->rh_registered) {
 			clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/usb/core/hub.c linux-libre-3.16.50-gnu/drivers/usb/core/hub.c
--- linux-libre-3.16.49-gnu/drivers/usb/core/hub.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/usb/core/hub.c	2017-11-11 08:34:06.000000000 -0500
@@ -4602,7 +4602,8 @@ hub_power_remaining (struct usb_hub *hub
 static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
 		u16 portchange)
 {
-	int status, i;
+	int status = -ENODEV;
+	int i;
 	unsigned unit_load;
 	struct usb_device *hdev = hub->hdev;
 	struct usb_hcd *hcd = bus_to_hcd(hdev->bus);
@@ -4799,9 +4800,10 @@ loop:
 
 done:
 	hub_port_disable(hub, port1, 1);
-	if (hcd->driver->relinquish_port && !hub->hdev->parent)
-		hcd->driver->relinquish_port(hcd, port1);
-
+	if (hcd->driver->relinquish_port && !hub->hdev->parent) {
+		if (status != -ENOTCONN && status != -ENODEV)
+			hcd->driver->relinquish_port(hcd, port1);
+	}
 }
 
 /* Handle physical or logical connection change events.
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/usb/core/quirks.c linux-libre-3.16.50-gnu/drivers/usb/core/quirks.c
--- linux-libre-3.16.49-gnu/drivers/usb/core/quirks.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/usb/core/quirks.c	2017-11-11 08:34:06.000000000 -0500
@@ -147,6 +147,9 @@ static const struct usb_device_id usb_qu
 	/* appletouch */
 	{ USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME },
 
+	/* Genesys Logic hub, internally used by Moshi USB to Ethernet Adapter */
+	{ USB_DEVICE(0x05e3, 0x0616), .driver_info = USB_QUIRK_NO_LPM },
+
 	/* Avision AV600U */
 	{ USB_DEVICE(0x0638, 0x0a13), .driver_info =
 	  USB_QUIRK_STRING_FETCH_255 },
@@ -246,6 +249,7 @@ static const struct usb_device_id usb_am
 	{ USB_DEVICE(0x093a, 0x2500), .driver_info = USB_QUIRK_RESET_RESUME },
 	{ USB_DEVICE(0x093a, 0x2510), .driver_info = USB_QUIRK_RESET_RESUME },
 	{ USB_DEVICE(0x093a, 0x2521), .driver_info = USB_QUIRK_RESET_RESUME },
+	{ USB_DEVICE(0x03f0, 0x2b4a), .driver_info = USB_QUIRK_RESET_RESUME },
 
 	/* Logitech Optical Mouse M90/M100 */
 	{ USB_DEVICE(0x046d, 0xc05a), .driver_info = USB_QUIRK_RESET_RESUME },
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/usb/host/pci-quirks.c linux-libre-3.16.50-gnu/drivers/usb/host/pci-quirks.c
--- linux-libre-3.16.49-gnu/drivers/usb/host/pci-quirks.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/usb/host/pci-quirks.c	2017-11-11 08:34:06.000000000 -0500
@@ -78,6 +78,16 @@
 #define USB_INTEL_USB3_PSSEN   0xD8
 #define USB_INTEL_USB3PRM      0xDC
 
+/* ASMEDIA quirk use */
+#define ASMT_DATA_WRITE0_REG	0xF8
+#define ASMT_DATA_WRITE1_REG	0xFC
+#define ASMT_CONTROL_REG	0xE0
+#define ASMT_CONTROL_WRITE_BIT	0x02
+#define ASMT_WRITEREG_CMD	0x10423
+#define ASMT_FLOWCTL_ADDR	0xFA30
+#define ASMT_FLOWCTL_DATA	0xBA
+#define ASMT_PSEUDO_DATA	0
+
 /*
  * amd_chipset_gen values represent AMD different chipset generations
  */
@@ -89,6 +99,7 @@ enum amd_chipset_gen {
 	AMD_CHIPSET_HUDSON2,
 	AMD_CHIPSET_BOLTON,
 	AMD_CHIPSET_YANGTZE,
+	AMD_CHIPSET_TAISHAN,
 	AMD_CHIPSET_UNKNOWN,
 };
 
@@ -132,6 +143,11 @@ static int amd_chipset_sb_type_init(stru
 			pinfo->sb_type.gen = AMD_CHIPSET_SB700;
 		else if (rev >= 0x40 && rev <= 0x4f)
 			pinfo->sb_type.gen = AMD_CHIPSET_SB800;
+	}
+	pinfo->smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD,
+					  0x145c, NULL);
+	if (pinfo->smbus_dev) {
+		pinfo->sb_type.gen = AMD_CHIPSET_TAISHAN;
 	} else {
 		pinfo->smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD,
 				PCI_DEVICE_ID_AMD_HUDSON2_SMBUS, NULL);
@@ -253,11 +269,12 @@ int usb_hcd_amd_remote_wakeup_quirk(stru
 {
 	/* Make sure amd chipset type has already been initialized */
 	usb_amd_find_chipset_info();
-	if (amd_chipset.sb_type.gen != AMD_CHIPSET_YANGTZE)
-		return 0;
-
-	dev_dbg(&pdev->dev, "QUIRK: Enable AMD remote wakeup fix\n");
-	return 1;
+	if (amd_chipset.sb_type.gen == AMD_CHIPSET_YANGTZE ||
+	    amd_chipset.sb_type.gen == AMD_CHIPSET_TAISHAN) {
+		dev_dbg(&pdev->dev, "QUIRK: Enable AMD remote wakeup fix\n");
+		return 1;
+	}
+	return 0;
 }
 EXPORT_SYMBOL_GPL(usb_hcd_amd_remote_wakeup_quirk);
 
@@ -415,6 +432,50 @@ void usb_amd_quirk_pll_disable(void)
 }
 EXPORT_SYMBOL_GPL(usb_amd_quirk_pll_disable);
 
+static int usb_asmedia_wait_write(struct pci_dev *pdev)
+{
+	unsigned long retry_count;
+	unsigned char value;
+
+	for (retry_count = 1000; retry_count > 0; --retry_count) {
+
+		pci_read_config_byte(pdev, ASMT_CONTROL_REG, &value);
+
+		if (value == 0xff) {
+			dev_err(&pdev->dev, "%s: check_ready ERROR", __func__);
+			return -EIO;
+		}
+
+		if ((value & ASMT_CONTROL_WRITE_BIT) == 0)
+			return 0;
+
+		usleep_range(40, 60);
+	}
+
+	dev_warn(&pdev->dev, "%s: check_write_ready timeout", __func__);
+	return -ETIMEDOUT;
+}
+
+void usb_asmedia_modifyflowcontrol(struct pci_dev *pdev)
+{
+	if (usb_asmedia_wait_write(pdev) != 0)
+		return;
+
+	/* send command and address to device */
+	pci_write_config_dword(pdev, ASMT_DATA_WRITE0_REG, ASMT_WRITEREG_CMD);
+	pci_write_config_dword(pdev, ASMT_DATA_WRITE1_REG, ASMT_FLOWCTL_ADDR);
+	pci_write_config_byte(pdev, ASMT_CONTROL_REG, ASMT_CONTROL_WRITE_BIT);
+
+	if (usb_asmedia_wait_write(pdev) != 0)
+		return;
+
+	/* send data to device */
+	pci_write_config_dword(pdev, ASMT_DATA_WRITE0_REG, ASMT_FLOWCTL_DATA);
+	pci_write_config_dword(pdev, ASMT_DATA_WRITE1_REG, ASMT_PSEUDO_DATA);
+	pci_write_config_byte(pdev, ASMT_CONTROL_REG, ASMT_CONTROL_WRITE_BIT);
+}
+EXPORT_SYMBOL_GPL(usb_asmedia_modifyflowcontrol);
+
 void usb_amd_quirk_pll_enable(void)
 {
 	usb_amd_quirk_pll(0);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/usb/host/pci-quirks.h linux-libre-3.16.50-gnu/drivers/usb/host/pci-quirks.h
--- linux-libre-3.16.49-gnu/drivers/usb/host/pci-quirks.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/usb/host/pci-quirks.h	2017-11-11 08:34:06.000000000 -0500
@@ -11,6 +11,7 @@ bool usb_amd_prefetch_quirk(void);
 void usb_amd_dev_put(void);
 void usb_amd_quirk_pll_disable(void);
 void usb_amd_quirk_pll_enable(void);
+void usb_asmedia_modifyflowcontrol(struct pci_dev *pdev);
 void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev);
 void usb_disable_xhci_ports(struct pci_dev *xhci_pdev);
 void sb800_prefetch(struct device *dev, int on);
@@ -18,6 +19,7 @@ void sb800_prefetch(struct device *dev,
 struct pci_dev;
 static inline void usb_amd_quirk_pll_disable(void) {}
 static inline void usb_amd_quirk_pll_enable(void) {}
+static inline void usb_asmedia_modifyflowcontrol(struct pci_dev *pdev) {}
 static inline void usb_amd_dev_put(void) {}
 static inline void usb_disable_xhci_ports(struct pci_dev *xhci_pdev) {}
 static inline void sb800_prefetch(struct device *dev, int on) {}
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/usb/host/xhci.c linux-libre-3.16.50-gnu/drivers/usb/host/xhci.c
--- linux-libre-3.16.49-gnu/drivers/usb/host/xhci.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/usb/host/xhci.c	2017-11-11 08:34:06.000000000 -0500
@@ -191,6 +191,9 @@ int xhci_reset(struct xhci_hcd *xhci)
 	if (ret)
 		return ret;
 
+	if (xhci->quirks & XHCI_ASMEDIA_MODIFY_FLOWCONTROL)
+		usb_asmedia_modifyflowcontrol(to_pci_dev(xhci_to_hcd(xhci)->self.controller));
+
 	xhci_dbg_trace(xhci, trace_xhci_dbg_init,
 			 "Wait for controller to be ready for doorbell rings");
 	/*
@@ -659,8 +662,10 @@ int xhci_run(struct usb_hcd *hcd)
 		command = xhci_alloc_command(xhci, false, false, GFP_KERNEL);
 		if (!command)
 			return -ENOMEM;
-		xhci_queue_vendor_command(xhci, command, 0, 0, 0,
+		ret = xhci_queue_vendor_command(xhci, command, 0, 0, 0,
 				TRB_TYPE(TRB_NEC_GET_FW));
+		if (ret)
+			xhci_free_command(xhci, command);
 	}
 	xhci_dbg_trace(xhci, trace_xhci_dbg_init,
 			"Finished xhci_run for USB2 roothub");
@@ -1116,6 +1121,9 @@ int xhci_resume(struct xhci_hcd *xhci, b
 	if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && !comp_timer_running)
 		compliance_mode_recovery_timer_init(xhci);
 
+	if (xhci->quirks & XHCI_ASMEDIA_MODIFY_FLOWCONTROL)
+		usb_asmedia_modifyflowcontrol(to_pci_dev(hcd->self.controller));
+
 	/* Re-enable port polling. */
 	xhci_dbg(xhci, "%s: starting port polling.\n", __func__);
 	set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/usb/host/xhci.h linux-libre-3.16.50-gnu/drivers/usb/host/xhci.h
--- linux-libre-3.16.49-gnu/drivers/usb/host/xhci.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/usb/host/xhci.h	2017-11-11 08:34:06.000000000 -0500
@@ -1570,6 +1570,7 @@ struct xhci_hcd {
 #define XHCI_PME_STUCK_QUIRK	(1 << 20)
 #define XHCI_MISSING_CAS	(1 << 24)
 #define XHCI_U2_DISABLE_WAKE	(1 << 27)
+#define XHCI_ASMEDIA_MODIFY_FLOWCONTROL	(1 << 28)
 	unsigned int		num_active_eps;
 	unsigned int		limit_active_eps;
 	/* There are two roothubs to keep track of bus suspend info for */
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/usb/host/xhci-hub.c linux-libre-3.16.50-gnu/drivers/usb/host/xhci-hub.c
--- linux-libre-3.16.49-gnu/drivers/usb/host/xhci-hub.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/usb/host/xhci-hub.c	2017-11-11 08:34:06.000000000 -0500
@@ -644,6 +644,9 @@ static u32 xhci_get_port_status(struct u
 			clear_bit(wIndex, &bus_state->resuming_ports);
 
 			set_bit(wIndex, &bus_state->rexit_ports);
+
+			xhci_test_and_clear_bit(xhci, port_array, wIndex,
+						PORT_PLC);
 			xhci_set_link_state(xhci, port_array, wIndex,
 					XDEV_U0);
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/usb/host/xhci-pci.c linux-libre-3.16.50-gnu/drivers/usb/host/xhci-pci.c
--- linux-libre-3.16.49-gnu/drivers/usb/host/xhci-pci.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/usb/host/xhci-pci.c	2017-11-11 08:34:06.000000000 -0500
@@ -52,6 +52,8 @@
 #define PCI_DEVICE_ID_AMD_PROMONTORYA_2			0x43bb
 #define PCI_DEVICE_ID_AMD_PROMONTORYA_1			0x43bc
 
+#define PCI_DEVICE_ID_ASMEDIA_1042A_XHCI		0x1142
+
 static const char hcd_name[] = "xhci_hcd";
 
 /* called after powerup, by probe or system-pm "wakeup" */
@@ -198,6 +200,10 @@ static void xhci_pci_quirks(struct devic
 			pdev->device == 0x1142)
 		xhci->quirks |= XHCI_TRUST_TX_LENGTH;
 
+	if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
+		pdev->device == PCI_DEVICE_ID_ASMEDIA_1042A_XHCI)
+		xhci->quirks |= XHCI_ASMEDIA_MODIFY_FLOWCONTROL;
+
 	if (xhci->quirks & XHCI_RESET_ON_RESUME)
 		xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
 				"QUIRK: Resetting on resume");
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/usb/host/xhci-ring.c linux-libre-3.16.50-gnu/drivers/usb/host/xhci-ring.c
--- linux-libre-3.16.49-gnu/drivers/usb/host/xhci-ring.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/usb/host/xhci-ring.c	2017-11-11 08:34:06.000000000 -0500
@@ -821,13 +821,16 @@ static void xhci_kill_endpoint_urbs(stru
 			(ep->ep_state & EP_GETTING_NO_STREAMS)) {
 		int stream_id;
 
-		for (stream_id = 0; stream_id < ep->stream_info->num_streams;
+		for (stream_id = 1; stream_id < ep->stream_info->num_streams;
 				stream_id++) {
+			ring = ep->stream_info->stream_rings[stream_id];
+			if (!ring)
+				continue;
+
 			xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
 					"Killing URBs for slot ID %u, ep index %u, stream %u",
-					slot_id, ep_index, stream_id + 1);
-			xhci_kill_ring_urbs(xhci,
-					ep->stream_info->stream_rings[stream_id]);
+					slot_id, ep_index, stream_id);
+			xhci_kill_ring_urbs(xhci, ring);
 		}
 	} else {
 		ring = ep->ring;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/usb/misc/usbtest.c linux-libre-3.16.50-gnu/drivers/usb/misc/usbtest.c
--- linux-libre-3.16.49-gnu/drivers/usb/misc/usbtest.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/usb/misc/usbtest.c	2017-11-11 08:34:06.000000000 -0500
@@ -164,12 +164,13 @@ found:
 			return tmp;
 	}
 
-	if (in) {
+	if (in)
 		dev->in_pipe = usb_rcvbulkpipe(udev,
 			in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
+	if (out)
 		dev->out_pipe = usb_sndbulkpipe(udev,
 			out->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
-	}
+
 	if (iso_in) {
 		dev->iso_in = &iso_in->desc;
 		dev->in_iso_pipe = usb_rcvisocpipe(udev,
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/usb/renesas_usbhs/common.c linux-libre-3.16.50-gnu/drivers/usb/renesas_usbhs/common.c
--- linux-libre-3.16.49-gnu/drivers/usb/renesas_usbhs/common.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/usb/renesas_usbhs/common.c	2017-11-11 08:34:06.000000000 -0500
@@ -600,8 +600,10 @@ static int usbhsc_resume(struct device *
 	struct usbhs_priv *priv = dev_get_drvdata(dev);
 	struct platform_device *pdev = usbhs_priv_to_pdev(priv);
 
-	if (!usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL))
+	if (!usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL)) {
 		usbhsc_power_ctrl(priv, 1);
+		usbhs_mod_autonomy_mode(priv);
+	}
 
 	usbhs_platform_call(priv, phy_reset, pdev);
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/usb/renesas_usbhs/mod_gadget.c linux-libre-3.16.50-gnu/drivers/usb/renesas_usbhs/mod_gadget.c
--- linux-libre-3.16.49-gnu/drivers/usb/renesas_usbhs/mod_gadget.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/usb/renesas_usbhs/mod_gadget.c	2017-11-11 08:34:06.000000000 -0500
@@ -36,6 +36,7 @@ struct usbhsg_gpriv;
 struct usbhsg_uep {
 	struct usb_ep		 ep;
 	struct usbhs_pipe	*pipe;
+	spinlock_t		lock;	/* protect the pipe */
 
 	char ep_name[EP_NAME_SIZE];
 
@@ -126,7 +127,8 @@ static void usbhsg_queue_pop(struct usbh
 	struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
 	struct device *dev = usbhsg_gpriv_to_dev(gpriv);
 
-	dev_dbg(dev, "pipe %d : queue pop\n", usbhs_pipe_number(pipe));
+	if (pipe)
+		dev_dbg(dev, "pipe %d : queue pop\n", usbhs_pipe_number(pipe));
 
 	ureq->req.status = status;
 	ureq->req.complete(&uep->ep, &ureq->req);
@@ -607,15 +609,26 @@ usbhsg_ep_enable_end:
 static int usbhsg_ep_disable(struct usb_ep *ep)
 {
 	struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep);
+	struct usbhs_pipe *pipe;
+	unsigned long flags;
+	int ret = 0;
 
-	if (!uep->pipe)
-		return -EINVAL;
+	spin_lock_irqsave(&uep->lock, flags);
+	pipe = usbhsg_uep_to_pipe(uep);
+	if (!pipe) {
+		ret = -EINVAL;
+		goto out;
+	}
 
 	usbhsg_pipe_disable(uep);
+	usbhs_pipe_free(pipe);
 
 	uep->pipe->mod_private	= NULL;
 	uep->pipe		= NULL;
 
+out:
+	spin_unlock_irqrestore(&uep->lock, flags);
+
 	return 0;
 }
 
@@ -665,10 +678,20 @@ static int usbhsg_ep_dequeue(struct usb_
 {
 	struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep);
 	struct usbhsg_request *ureq = usbhsg_req_to_ureq(req);
-	struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
+	struct usbhs_pipe *pipe;
+	unsigned long flags;
 
-	usbhs_pkt_pop(pipe, usbhsg_ureq_to_pkt(ureq));
+	spin_lock_irqsave(&uep->lock, flags);
+	pipe = usbhsg_uep_to_pipe(uep);
+	if (pipe)
+		usbhs_pkt_pop(pipe, usbhsg_ureq_to_pkt(ureq));
+
+	/*
+	 * To dequeue a request, this driver should call the usbhsg_queue_pop()
+	 * even if the pipe is NULL.
+	 */
 	usbhsg_queue_pop(uep, ureq, -ECONNRESET);
+	spin_unlock_irqrestore(&uep->lock, flags);
 
 	return 0;
 }
@@ -795,10 +818,10 @@ static int usbhsg_try_stop(struct usbhs_
 {
 	struct usbhsg_gpriv *gpriv = usbhsg_priv_to_gpriv(priv);
 	struct usbhs_mod *mod = usbhs_mod_get_current(priv);
-	struct usbhsg_uep *dcp = usbhsg_gpriv_to_dcp(gpriv);
+	struct usbhsg_uep *uep;
 	struct device *dev = usbhs_priv_to_dev(priv);
 	unsigned long flags;
-	int ret = 0;
+	int ret = 0, i;
 
 	/********************  spin lock ********************/
 	usbhs_lock(priv, flags);
@@ -830,7 +853,9 @@ static int usbhsg_try_stop(struct usbhs_
 	usbhs_sys_set_test_mode(priv, 0);
 	usbhs_sys_function_ctrl(priv, 0);
 
-	usbhsg_ep_disable(&dcp->ep);
+	/* disable all eps */
+	usbhsg_for_each_uep_with_dcp(uep, gpriv, i)
+		usbhsg_ep_disable(&uep->ep);
 
 	dev_dbg(dev, "stop gadget\n");
 
@@ -950,6 +975,7 @@ int usbhs_mod_gadget_probe(struct usbhs_
 		ret = -ENOMEM;
 		goto usbhs_mod_gadget_probe_err_gpriv;
 	}
+	spin_lock_init(&uep->lock);
 
 	/*
 	 * CAUTION
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/usb/renesas_usbhs/pipe.c linux-libre-3.16.50-gnu/drivers/usb/renesas_usbhs/pipe.c
--- linux-libre-3.16.49-gnu/drivers/usb/renesas_usbhs/pipe.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/usb/renesas_usbhs/pipe.c	2017-11-11 08:34:06.000000000 -0500
@@ -640,6 +640,11 @@ static struct usbhs_pipe *usbhsp_get_pip
 	return pipe;
 }
 
+static void usbhsp_put_pipe(struct usbhs_pipe *pipe)
+{
+	usbhsp_flags_init(pipe);
+}
+
 void usbhs_pipe_init(struct usbhs_priv *priv,
 		     int (*dma_map_ctrl)(struct usbhs_pkt *pkt, int map))
 {
@@ -726,6 +731,11 @@ struct usbhs_pipe *usbhs_pipe_malloc(str
 	return pipe;
 }
 
+void usbhs_pipe_free(struct usbhs_pipe *pipe)
+{
+	usbhsp_put_pipe(pipe);
+}
+
 void usbhs_pipe_select_fifo(struct usbhs_pipe *pipe, struct usbhs_fifo *fifo)
 {
 	if (pipe->fifo)
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/usb/renesas_usbhs/pipe.h linux-libre-3.16.50-gnu/drivers/usb/renesas_usbhs/pipe.h
--- linux-libre-3.16.49-gnu/drivers/usb/renesas_usbhs/pipe.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/usb/renesas_usbhs/pipe.h	2017-11-11 08:34:06.000000000 -0500
@@ -75,6 +75,7 @@ struct usbhs_pipe_info {
 char *usbhs_pipe_name(struct usbhs_pipe *pipe);
 struct usbhs_pipe
 *usbhs_pipe_malloc(struct usbhs_priv *priv, int endpoint_type, int dir_in);
+void usbhs_pipe_free(struct usbhs_pipe *pipe);
 int usbhs_pipe_probe(struct usbhs_priv *priv);
 void usbhs_pipe_remove(struct usbhs_priv *priv);
 int usbhs_pipe_is_dir_in(struct usbhs_pipe *pipe);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/usb/serial/cp210x.c linux-libre-3.16.50-gnu/drivers/usb/serial/cp210x.c
--- linux-libre-3.16.49-gnu/drivers/usb/serial/cp210x.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/usb/serial/cp210x.c	2017-11-11 08:34:06.000000000 -0500
@@ -135,6 +135,7 @@ static const struct usb_device_id id_tab
 	{ USB_DEVICE(0x10C4, 0x8998) }, /* KCF Technologies PRN */
 	{ USB_DEVICE(0x10C4, 0x8A2A) }, /* HubZ dual ZigBee and Z-Wave dongle */
 	{ USB_DEVICE(0x10C4, 0x8A5E) }, /* CEL EM3588 ZigBee USB Stick Long Range */
+	{ USB_DEVICE(0x10C4, 0x8B34) }, /* Qivicon ZigBee USB Radio Stick */
 	{ USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
 	{ USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */
 	{ USB_DEVICE(0x10C4, 0xEA70) }, /* Silicon Labs factory default */
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/usb/serial/option.c linux-libre-3.16.50-gnu/drivers/usb/serial/option.c
--- linux-libre-3.16.49-gnu/drivers/usb/serial/option.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/usb/serial/option.c	2017-11-11 08:34:06.000000000 -0500
@@ -2036,6 +2036,8 @@ static const struct usb_device_id option
 	{ USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7d04, 0xff) },			/* D-Link DWM-158 */
 	{ USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7e19, 0xff),			/* D-Link DWM-221 B1 */
 	  .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
+	{ USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7e35, 0xff),			/* D-Link DWM-222 */
+	  .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
 	{ USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */
 	{ USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */
 	{ USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x7e11, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/A3 */
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/usb/storage/isd200.c linux-libre-3.16.50-gnu/drivers/usb/storage/isd200.c
--- linux-libre-3.16.49-gnu/drivers/usb/storage/isd200.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/usb/storage/isd200.c	2017-11-11 08:34:06.000000000 -0500
@@ -1522,8 +1522,11 @@ static void isd200_ata_command(struct sc
 
 	/* Make sure driver was initialized */
 
-	if (us->extra == NULL)
+	if (us->extra == NULL) {
 		usb_stor_dbg(us, "ERROR Driver not initialized\n");
+		srb->result = DID_ERROR << 16;
+		return;
+	}
 
 	scsi_set_resid(srb, 0);
 	/* scsi_bufflen might change in protocol translation to ata */
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/usb/storage/uas.c linux-libre-3.16.50-gnu/drivers/usb/storage/uas.c
--- linux-libre-3.16.49-gnu/drivers/usb/storage/uas.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/usb/storage/uas.c	2017-11-11 08:34:06.000000000 -0500
@@ -1034,14 +1034,14 @@ MODULE_DEVICE_TABLE(usb, uas_usb_ids);
 static int uas_switch_interface(struct usb_device *udev,
 				struct usb_interface *intf)
 {
-	int alt;
+	struct usb_host_interface *alt;
 
 	alt = uas_find_uas_alt_setting(intf);
-	if (alt < 0)
-		return alt;
+	if (!alt)
+		return -ENODEV;
 
-	return usb_set_interface(udev,
-			intf->altsetting[0].desc.bInterfaceNumber, alt);
+	return usb_set_interface(udev, alt->desc.bInterfaceNumber,
+			alt->desc.bAlternateSetting);
 }
 
 static int uas_configure_endpoints(struct uas_dev_info *devinfo)
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/usb/storage/uas-detect.h linux-libre-3.16.50-gnu/drivers/usb/storage/uas-detect.h
--- linux-libre-3.16.49-gnu/drivers/usb/storage/uas-detect.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/usb/storage/uas-detect.h	2017-11-11 08:34:06.000000000 -0500
@@ -9,7 +9,8 @@ static int uas_is_interface(struct usb_h
 		intf->desc.bInterfaceProtocol == USB_PR_UAS);
 }
 
-static int uas_find_uas_alt_setting(struct usb_interface *intf)
+static struct usb_host_interface *uas_find_uas_alt_setting(
+		struct usb_interface *intf)
 {
 	int i;
 
@@ -17,10 +18,10 @@ static int uas_find_uas_alt_setting(stru
 		struct usb_host_interface *alt = &intf->altsetting[i];
 
 		if (uas_is_interface(alt))
-			return alt->desc.bAlternateSetting;
+			return alt;
 	}
 
-	return -ENODEV;
+	return NULL;
 }
 
 static int uas_find_endpoints(struct usb_host_interface *alt,
@@ -58,14 +59,14 @@ static int uas_use_uas_driver(struct usb
 	struct usb_device *udev = interface_to_usbdev(intf);
 	struct usb_hcd *hcd = bus_to_hcd(udev->bus);
 	unsigned long flags = id->driver_info;
-	int r, alt;
-
+	struct usb_host_interface *alt;
+	int r;
 
 	alt = uas_find_uas_alt_setting(intf);
-	if (alt < 0)
+	if (!alt)
 		return 0;
 
-	r = uas_find_endpoints(&intf->altsetting[alt], eps);
+	r = uas_find_endpoints(alt, eps);
 	if (r < 0)
 		return 0;
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/usb/storage/unusual_uas.h linux-libre-3.16.50-gnu/drivers/usb/storage/unusual_uas.h
--- linux-libre-3.16.49-gnu/drivers/usb/storage/unusual_uas.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/usb/storage/unusual_uas.h	2017-11-11 08:34:06.000000000 -0500
@@ -113,9 +113,9 @@ UNUSUAL_DEV(0x0bc2, 0xab2a, 0x0000, 0x99
 /* Reported-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> */
 UNUSUAL_DEV(0x13fd, 0x3940, 0x0000, 0x9999,
 		"Initio Corporation",
-		"",
+		"INIC-3069",
 		USB_SC_DEVICE, USB_PR_DEVICE, NULL,
-		US_FL_NO_ATA_1X),
+		US_FL_NO_ATA_1X | US_FL_IGNORE_RESIDUE),
 
 /* Reported-by: Tom Arild Naess <tanaess@gmail.com> */
 UNUSUAL_DEV(0x152d, 0x0539, 0x0000, 0x9999,
diff -druNp --no-dereference linux-libre-3.16.49-gnu/drivers/video/fbdev/Kconfig linux-libre-3.16.50-gnu/drivers/video/fbdev/Kconfig
--- linux-libre-3.16.49-gnu/drivers/video/fbdev/Kconfig	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/drivers/video/fbdev/Kconfig	2017-11-11 08:34:06.000000000 -0500
@@ -2330,10 +2330,11 @@ config FB_MSM
 config FB_MX3
 	tristate "MX3 Framebuffer support"
 	depends on FB && MX3_IPU
+	select BACKLIGHT_CLASS_DEVICE
+	select BACKLIGHT_LCD_SUPPORT
 	select FB_CFB_FILLRECT
 	select FB_CFB_COPYAREA
 	select FB_CFB_IMAGEBLIT
-	select BACKLIGHT_CLASS_DEVICE
 	default y
 	help
 	  This is a framebuffer device for the i.MX31 LCD Controller. So
diff -druNp --no-dereference linux-libre-3.16.49-gnu/fs/cifs/dir.c linux-libre-3.16.50-gnu/fs/cifs/dir.c
--- linux-libre-3.16.49-gnu/fs/cifs/dir.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/fs/cifs/dir.c	2017-11-11 08:34:06.000000000 -0500
@@ -183,15 +183,21 @@ cifs_bp_rename_retry:
 }
 
 /*
+ * Don't allow path components longer than the server max.
  * Don't allow the separator character in a path component.
  * The VFS will not allow "/", but "\" is allowed by posix.
  */
 static int
-check_name(struct dentry *direntry)
+check_name(struct dentry *direntry, struct cifs_tcon *tcon)
 {
 	struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb);
 	int i;
 
+	if (unlikely(tcon->fsAttrInfo.MaxPathNameComponentLength &&
+		     direntry->d_name.len >
+		     le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength)))
+		return -ENAMETOOLONG;
+
 	if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)) {
 		for (i = 0; i < direntry->d_name.len; i++) {
 			if (direntry->d_name.name[i] == '\\') {
@@ -489,10 +495,6 @@ cifs_atomic_open(struct inode *inode, st
 		return finish_no_open(file, res);
 	}
 
-	rc = check_name(direntry);
-	if (rc)
-		return rc;
-
 	xid = get_xid();
 
 	cifs_dbg(FYI, "parent inode = 0x%p name is: %s and dentry = 0x%p\n",
@@ -505,6 +507,11 @@ cifs_atomic_open(struct inode *inode, st
 	}
 
 	tcon = tlink_tcon(tlink);
+
+	rc = check_name(direntry, tcon);
+	if (rc)
+		goto out;
+
 	server = tcon->ses->server;
 
 	if (server->ops->new_lease_key)
@@ -752,7 +759,7 @@ cifs_lookup(struct inode *parent_dir_ino
 	}
 	pTcon = tlink_tcon(tlink);
 
-	rc = check_name(direntry);
+	rc = check_name(direntry, pTcon);
 	if (rc)
 		goto lookup_out;
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/fs/cifs/smb2pdu.c linux-libre-3.16.50-gnu/fs/cifs/smb2pdu.c
--- linux-libre-3.16.49-gnu/fs/cifs/smb2pdu.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/fs/cifs/smb2pdu.c	2017-11-11 08:34:06.000000000 -0500
@@ -2486,8 +2486,8 @@ copy_fs_info_to_kstatfs(struct smb2_fs_f
 	kst->f_bsize = le32_to_cpu(pfs_inf->BytesPerSector) *
 			  le32_to_cpu(pfs_inf->SectorsPerAllocationUnit);
 	kst->f_blocks = le64_to_cpu(pfs_inf->TotalAllocationUnits);
-	kst->f_bfree  = le64_to_cpu(pfs_inf->ActualAvailableAllocationUnits);
-	kst->f_bavail = le64_to_cpu(pfs_inf->CallerAvailableAllocationUnits);
+	kst->f_bfree  = kst->f_bavail =
+			le64_to_cpu(pfs_inf->CallerAvailableAllocationUnits);
 	return;
 }
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/fs/cifs/smb2pdu.h linux-libre-3.16.50-gnu/fs/cifs/smb2pdu.h
--- linux-libre-3.16.49-gnu/fs/cifs/smb2pdu.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/fs/cifs/smb2pdu.h	2017-11-11 08:34:06.000000000 -0500
@@ -82,8 +82,8 @@
 
 #define NUMBER_OF_SMB2_COMMANDS	0x0013
 
-/* BB FIXME - analyze following length BB */
-#define MAX_SMB2_HDR_SIZE 0x78 /* 4 len + 64 hdr + (2*24 wct) + 2 bct + 2 pad */
+/* 4 len + 52 transform hdr + 64 hdr + 56 create rsp */
+#define MAX_SMB2_HDR_SIZE 0x00b0
 
 #define SMB2_PROTO_NUMBER __constant_cpu_to_le32(0x424d53fe)
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/fs/eventpoll.c linux-libre-3.16.50-gnu/fs/eventpoll.c
--- linux-libre-3.16.49-gnu/fs/eventpoll.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/fs/eventpoll.c	2017-11-11 08:34:06.000000000 -0500
@@ -518,8 +518,13 @@ static void ep_remove_wait_queue(struct
 	wait_queue_head_t *whead;
 
 	rcu_read_lock();
-	/* If it is cleared by POLLFREE, it should be rcu-safe */
-	whead = rcu_dereference(pwq->whead);
+	/*
+	 * If it is cleared by POLLFREE, it should be rcu-safe.
+	 * If we read NULL we need a barrier paired with
+	 * smp_store_release() in ep_poll_callback(), otherwise
+	 * we rely on whead->lock.
+	 */
+	whead = smp_load_acquire(&pwq->whead);
 	if (whead)
 		remove_wait_queue(whead, &pwq->wait);
 	rcu_read_unlock();
@@ -1006,17 +1011,6 @@ static int ep_poll_callback(wait_queue_t
 	struct epitem *epi = ep_item_from_wait(wait);
 	struct eventpoll *ep = epi->ep;
 
-	if ((unsigned long)key & POLLFREE) {
-		ep_pwq_from_wait(wait)->whead = NULL;
-		/*
-		 * whead = NULL above can race with ep_remove_wait_queue()
-		 * which can do another remove_wait_queue() after us, so we
-		 * can't use __remove_wait_queue(). whead->lock is held by
-		 * the caller.
-		 */
-		list_del_init(&wait->task_list);
-	}
-
 	spin_lock_irqsave(&ep->lock, flags);
 
 	/*
@@ -1081,6 +1075,22 @@ out_unlock:
 	if (pwake)
 		ep_poll_safewake(&ep->poll_wait);
 
+	if ((unsigned long)key & POLLFREE) {
+		/*
+		 * If we race with ep_remove_wait_queue() it can miss
+		 * ->whead = NULL and do another remove_wait_queue() after
+		 * us, so we can't use __remove_wait_queue().
+		 */
+		list_del_init(&wait->task_list);
+		/*
+		 * ->whead != NULL protects us from the race with ep_free()
+		 * or ep_remove(), ep_remove_wait_queue() takes whead->lock
+		 * held by the caller. Once we nullify it, nothing protects
+		 * ep/epi or even wait.
+		 */
+		smp_store_release(&ep_pwq_from_wait(wait)->whead, NULL);
+	}
+
 	return 1;
 }
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/fs/ext4/file.c linux-libre-3.16.50-gnu/fs/ext4/file.c
--- linux-libre-3.16.49-gnu/fs/ext4/file.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/fs/ext4/file.c	2017-11-11 08:34:06.000000000 -0500
@@ -344,6 +344,8 @@ static int ext4_find_unwritten_pgoff(str
 				lastoff = page_offset(page);
 				bh = head = page_buffers(page);
 				do {
+					if (lastoff + bh->b_size <= startoff)
+						goto next;
 					if (buffer_uptodate(bh) ||
 					    buffer_unwritten(bh)) {
 						if (whence == SEEK_DATA)
@@ -358,6 +360,7 @@ static int ext4_find_unwritten_pgoff(str
 						unlock_page(page);
 						goto out;
 					}
+next:
 					lastoff += bh->b_size;
 					bh = bh->b_this_page;
 				} while (bh != head);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/fs/ext4/resize.c linux-libre-3.16.50-gnu/fs/ext4/resize.c
--- linux-libre-3.16.49-gnu/fs/ext4/resize.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/fs/ext4/resize.c	2017-11-11 08:34:06.000000000 -0500
@@ -1929,7 +1929,8 @@ retry:
 			n_desc_blocks = o_desc_blocks +
 				le16_to_cpu(es->s_reserved_gdt_blocks);
 			n_group = n_desc_blocks * EXT4_DESC_PER_BLOCK(sb);
-			n_blocks_count = n_group * EXT4_BLOCKS_PER_GROUP(sb);
+			n_blocks_count = (ext4_fsblk_t)n_group *
+				EXT4_BLOCKS_PER_GROUP(sb);
 			n_group--; /* set to last group number */
 		}
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/fs/fuse/file.c linux-libre-3.16.50-gnu/fs/fuse/file.c
--- linux-libre-3.16.49-gnu/fs/fuse/file.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/fs/fuse/file.c	2017-11-11 08:34:06.000000000 -0500
@@ -54,7 +54,7 @@ struct fuse_file *fuse_file_alloc(struct
 {
 	struct fuse_file *ff;
 
-	ff = kmalloc(sizeof(struct fuse_file), GFP_KERNEL);
+	ff = kzalloc(sizeof(struct fuse_file), GFP_KERNEL);
 	if (unlikely(!ff))
 		return NULL;
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/fs/gfs2/dir.c linux-libre-3.16.50-gnu/fs/gfs2/dir.c
--- linux-libre-3.16.49-gnu/fs/gfs2/dir.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/fs/gfs2/dir.c	2017-11-11 08:34:06.000000000 -0500
@@ -749,12 +749,15 @@ static int get_leaf_nr(struct gfs2_inode
 		       u64 *leaf_out)
 {
 	__be64 *hash;
+	int error;
 
 	hash = gfs2_dir_get_hash_table(dip);
-	if (IS_ERR(hash))
-		return PTR_ERR(hash);
-	*leaf_out = be64_to_cpu(*(hash + index));
-	return 0;
+	error = PTR_ERR_OR_ZERO(hash);
+
+	if (!error)
+		*leaf_out = be64_to_cpu(*(hash + index));
+
+	return error;
 }
 
 static int get_first_leaf(struct gfs2_inode *dip, u32 index,
diff -druNp --no-dereference linux-libre-3.16.49-gnu/fs/nfs/client.c linux-libre-3.16.50-gnu/fs/nfs/client.c
--- linux-libre-3.16.49-gnu/fs/nfs/client.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/fs/nfs/client.c	2017-11-11 08:34:06.000000000 -0500
@@ -931,6 +931,7 @@ void nfs_server_copy_userdata(struct nfs
 	target->caps = source->caps;
 	target->options = source->options;
 	target->auth_info = source->auth_info;
+	target->port = source->port;
 }
 EXPORT_SYMBOL_GPL(nfs_server_copy_userdata);
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/fs/nfsd/nfs4xdr.c linux-libre-3.16.50-gnu/fs/nfsd/nfs4xdr.c
--- linux-libre-3.16.49-gnu/fs/nfsd/nfs4xdr.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/fs/nfsd/nfs4xdr.c	2017-11-11 08:34:06.000000000 -0500
@@ -134,7 +134,7 @@ static void next_decode_page(struct nfsd
 	argp->p = page_address(argp->pagelist[0]);
 	argp->pagelist++;
 	if (argp->pagelen < PAGE_SIZE) {
-		argp->end = argp->p + (argp->pagelen>>2);
+		argp->end = argp->p + XDR_QUADLEN(argp->pagelen);
 		argp->pagelen = 0;
 	} else {
 		argp->end = argp->p + (PAGE_SIZE>>2);
@@ -1246,9 +1246,7 @@ nfsd4_decode_write(struct nfsd4_compound
 		argp->pagelen -= pages * PAGE_SIZE;
 		len -= pages * PAGE_SIZE;
 
-		argp->p = (__be32 *)page_address(argp->pagelist[0]);
-		argp->pagelist++;
-		argp->end = argp->p + XDR_QUADLEN(PAGE_SIZE);
+		next_decode_page(argp);
 	}
 	argp->p += XDR_QUADLEN(len);
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/fs/nilfs2/btree.c linux-libre-3.16.50-gnu/fs/nilfs2/btree.c
--- linux-libre-3.16.49-gnu/fs/nilfs2/btree.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/fs/nilfs2/btree.c	2017-11-11 08:34:06.000000000 -0500
@@ -1797,7 +1797,7 @@ int nilfs_btree_convert_and_insert(struc
 				   __u64 key, __u64 ptr,
 				   const __u64 *keys, const __u64 *ptrs, int n)
 {
-	struct buffer_head *bh;
+	struct buffer_head *bh = NULL;
 	union nilfs_bmap_ptr_req dreq, nreq, *di, *ni;
 	struct nilfs_bmap_stats stats;
 	int ret;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/fs/nilfs2/recovery.c linux-libre-3.16.50-gnu/fs/nilfs2/recovery.c
--- linux-libre-3.16.49-gnu/fs/nilfs2/recovery.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/fs/nilfs2/recovery.c	2017-11-11 08:34:06.000000000 -0500
@@ -582,7 +582,7 @@ static int nilfs_do_roll_forward(struct
 				 struct nilfs_recovery_info *ri)
 {
 	struct buffer_head *bh_sum = NULL;
-	struct nilfs_segment_summary *sum;
+	struct nilfs_segment_summary *sum = NULL;
 	sector_t pseg_start;
 	sector_t seg_start, seg_end;  /* Starting/ending DBN of full segment */
 	unsigned long nsalvaged_blocks = 0;
@@ -814,7 +814,7 @@ int nilfs_search_super_root(struct the_n
 			    struct nilfs_recovery_info *ri)
 {
 	struct buffer_head *bh_sum = NULL;
-	struct nilfs_segment_summary *sum;
+	struct nilfs_segment_summary *sum = NULL;
 	sector_t pseg_start, pseg_end, sr_pseg_start = 0;
 	sector_t seg_start, seg_end; /* range of full segment (block number) */
 	sector_t b, end;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/fs/nilfs2/super.c linux-libre-3.16.50-gnu/fs/nilfs2/super.c
--- linux-libre-3.16.49-gnu/fs/nilfs2/super.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/fs/nilfs2/super.c	2017-11-11 08:34:06.000000000 -0500
@@ -358,7 +358,7 @@ static int nilfs_move_2nd_super(struct s
 	struct nilfs_super_block *nsbp;
 	sector_t blocknr, newblocknr;
 	unsigned long offset;
-	int sb2i = -1;  /* array index of the secondary superblock */
+	int sb2i;  /* array index of the secondary superblock */
 	int ret = 0;
 
 	/* nilfs->ns_sem must be locked by the caller. */
@@ -369,6 +369,9 @@ static int nilfs_move_2nd_super(struct s
 	} else if (nilfs->ns_sbh[0]->b_blocknr > nilfs->ns_first_data_block) {
 		sb2i = 0;
 		blocknr = nilfs->ns_sbh[0]->b_blocknr;
+	} else {
+		sb2i = -1;
+		blocknr = 0;
 	}
 	if (sb2i >= 0 && (u64)blocknr << nilfs->ns_blocksize_bits == sb2off)
 		goto out;  /* super block location is unchanged */
diff -druNp --no-dereference linux-libre-3.16.49-gnu/fs/ocfs2/acl.c linux-libre-3.16.50-gnu/fs/ocfs2/acl.c
--- linux-libre-3.16.49-gnu/fs/ocfs2/acl.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/fs/ocfs2/acl.c	2017-11-11 08:34:06.000000000 -0500
@@ -240,19 +240,6 @@ int ocfs2_set_acl(handle_t *handle,
 	switch (type) {
 	case ACL_TYPE_ACCESS:
 		name_index = OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS;
-		if (acl) {
-			umode_t mode;
-			ret = posix_acl_update_mode(inode, &mode, &acl);
-			if (ret)
-				return ret;
-			else {
-				ret = ocfs2_acl_set_mode(inode, di_bh,
-							 handle, mode);
-				if (ret)
-					return ret;
-
-			}
-		}
 		break;
 	case ACL_TYPE_DEFAULT:
 		name_index = OCFS2_XATTR_INDEX_POSIX_ACL_DEFAULT;
@@ -283,6 +270,20 @@ int ocfs2_set_acl(handle_t *handle,
 
 int ocfs2_iop_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 {
+	int status;
+
+	if (type == ACL_TYPE_ACCESS && acl) {
+		umode_t mode;
+
+		status = posix_acl_update_mode(inode, &mode, &acl);
+		if (status)
+			return status;
+
+		status = ocfs2_acl_set_mode(inode, NULL, NULL, mode);
+		if (status)
+			return status;
+	}
+
 	return ocfs2_set_acl(NULL, inode, NULL, type, acl, NULL, NULL);
 }
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/fs/xfs/xfs_ialloc.c linux-libre-3.16.50-gnu/fs/xfs/xfs_ialloc.c
--- linux-libre-3.16.49-gnu/fs/xfs/xfs_ialloc.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/fs/xfs/xfs_ialloc.c	2017-11-11 08:34:06.000000000 -0500
@@ -854,13 +854,13 @@ xfs_dialloc_ag_inobt(
 
 			/* free inodes to the left? */
 			if (useleft && trec.ir_freecount) {
-				rec = trec;
 				xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
 				cur = tcur;
 
 				pag->pagl_leftrec = trec.ir_startino;
 				pag->pagl_rightrec = rec.ir_startino;
 				pag->pagl_pagino = pagino;
+				rec = trec;
 				goto alloc_inode;
 			}
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/include/asm-generic/topology.h linux-libre-3.16.50-gnu/include/asm-generic/topology.h
--- linux-libre-3.16.49-gnu/include/asm-generic/topology.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/include/asm-generic/topology.h	2017-11-11 08:34:06.000000000 -0500
@@ -48,7 +48,11 @@
 #define parent_node(node)	((void)(node),0)
 #endif
 #ifndef cpumask_of_node
-#define cpumask_of_node(node)	((void)node, cpu_online_mask)
+  #ifdef CONFIG_NEED_MULTIPLE_NODES
+    #define cpumask_of_node(node)	((node) == 0 ? cpu_online_mask : cpu_none_mask)
+  #else
+    #define cpumask_of_node(node)	((void)node, cpu_online_mask)
+  #endif
 #endif
 #ifndef pcibus_to_node
 #define pcibus_to_node(bus)	((void)(bus), -1)
diff -druNp --no-dereference linux-libre-3.16.49-gnu/include/linux/cpumask.h linux-libre-3.16.50-gnu/include/linux/cpumask.h
--- linux-libre-3.16.49-gnu/include/linux/cpumask.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/include/linux/cpumask.h	2017-11-11 08:34:06.000000000 -0500
@@ -142,10 +142,8 @@ static inline unsigned int cpumask_any_b
 	return 1;
 }
 
-static inline int cpumask_set_cpu_local_first(int i, int numa_node, cpumask_t *dstp)
+static inline unsigned int cpumask_local_spread(unsigned int i, int node)
 {
-	set_bit(0, cpumask_bits(dstp));
-
 	return 0;
 }
 
@@ -199,7 +197,7 @@ static inline unsigned int cpumask_next_
 
 int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
-int cpumask_set_cpu_local_first(int i, int numa_node, cpumask_t *dstp);
+unsigned int cpumask_local_spread(unsigned int i, int node);
 
 /**
  * for_each_cpu - iterate over every cpu in a mask
diff -druNp --no-dereference linux-libre-3.16.49-gnu/include/linux/device-mapper.h linux-libre-3.16.50-gnu/include/linux/device-mapper.h
--- linux-libre-3.16.49-gnu/include/linux/device-mapper.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/include/linux/device-mapper.h	2017-11-11 08:34:06.000000000 -0500
@@ -481,56 +481,32 @@ void *dm_vcalloc(unsigned long nmemb, un
  *---------------------------------------------------------------*/
 #define DM_NAME "device-mapper"
 
-#ifdef CONFIG_PRINTK
-extern struct ratelimit_state dm_ratelimit_state;
-
-#define dm_ratelimit()	__ratelimit(&dm_ratelimit_state)
-#else
-#define dm_ratelimit()	0
-#endif
-
-#define DMCRIT(f, arg...) \
-	printk(KERN_CRIT DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg)
+#define DM_RATELIMIT(pr_func, fmt, ...)					\
+do {									\
+	static DEFINE_RATELIMIT_STATE(rs, DEFAULT_RATELIMIT_INTERVAL,	\
+				      DEFAULT_RATELIMIT_BURST);		\
+									\
+	if (__ratelimit(&rs))						\
+		pr_func(DM_FMT(fmt), ##__VA_ARGS__);			\
+} while (0)
 
-#define DMERR(f, arg...) \
-	printk(KERN_ERR DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg)
-#define DMERR_LIMIT(f, arg...) \
-	do { \
-		if (dm_ratelimit())	\
-			printk(KERN_ERR DM_NAME ": " DM_MSG_PREFIX ": " \
-			       f "\n", ## arg); \
-	} while (0)
+#define DM_FMT(fmt) DM_NAME ": " DM_MSG_PREFIX ": " fmt "\n"
 
-#define DMWARN(f, arg...) \
-	printk(KERN_WARNING DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg)
-#define DMWARN_LIMIT(f, arg...) \
-	do { \
-		if (dm_ratelimit())	\
-			printk(KERN_WARNING DM_NAME ": " DM_MSG_PREFIX ": " \
-			       f "\n", ## arg); \
-	} while (0)
+#define DMCRIT(fmt, ...) pr_crit(DM_FMT(fmt), ##__VA_ARGS__)
 
-#define DMINFO(f, arg...) \
-	printk(KERN_INFO DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg)
-#define DMINFO_LIMIT(f, arg...) \
-	do { \
-		if (dm_ratelimit())	\
-			printk(KERN_INFO DM_NAME ": " DM_MSG_PREFIX ": " f \
-			       "\n", ## arg); \
-	} while (0)
+#define DMERR(fmt, ...) pr_err(DM_FMT(fmt), ##__VA_ARGS__)
+#define DMERR_LIMIT(fmt, ...) DM_RATELIMIT(pr_err, fmt, ##__VA_ARGS__)
+#define DMWARN(fmt, ...) pr_warn(DM_FMT(fmt), ##__VA_ARGS__)
+#define DMWARN_LIMIT(fmt, ...) DM_RATELIMIT(pr_warn, fmt, ##__VA_ARGS__)
+#define DMINFO(fmt, ...) pr_info(DM_FMT(fmt), ##__VA_ARGS__)
+#define DMINFO_LIMIT(fmt, ...) DM_RATELIMIT(pr_info, fmt, ##__VA_ARGS__)
 
 #ifdef CONFIG_DM_DEBUG
-#  define DMDEBUG(f, arg...) \
-	printk(KERN_DEBUG DM_NAME ": " DM_MSG_PREFIX " DEBUG: " f "\n", ## arg)
-#  define DMDEBUG_LIMIT(f, arg...) \
-	do { \
-		if (dm_ratelimit())	\
-			printk(KERN_DEBUG DM_NAME ": " DM_MSG_PREFIX ": " f \
-			       "\n", ## arg); \
-	} while (0)
+#define DMDEBUG(fmt, ...) printk(KERN_DEBUG DM_FMT(fmt), ##__VA_ARGS__)
+#define DMDEBUG_LIMIT(fmt, ...) DM_RATELIMIT(pr_debug, fmt, ##__VA_ARGS__)
 #else
-#  define DMDEBUG(f, arg...) do {} while (0)
-#  define DMDEBUG_LIMIT(f, arg...) do {} while (0)
+#define DMDEBUG(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
+#define DMDEBUG_LIMIT(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
 #endif
 
 #define DMEMIT(x...) sz += ((sz >= maxlen) ? \
diff -druNp --no-dereference linux-libre-3.16.49-gnu/include/linux/fs.h linux-libre-3.16.50-gnu/include/linux/fs.h
--- linux-libre-3.16.49-gnu/include/linux/fs.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/include/linux/fs.h	2017-11-11 08:34:06.000000000 -0500
@@ -809,9 +809,9 @@ static inline struct file *get_file(stru
 /* Page cache limit. The filesystems should put that into their s_maxbytes 
    limits, otherwise bad things can happen in VM. */ 
 #if BITS_PER_LONG==32
-#define MAX_LFS_FILESIZE	(((loff_t)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1) 
+#define MAX_LFS_FILESIZE	((loff_t)ULONG_MAX << PAGE_SHIFT)
 #elif BITS_PER_LONG==64
-#define MAX_LFS_FILESIZE 	((loff_t)0x7fffffffffffffffLL)
+#define MAX_LFS_FILESIZE 	((loff_t)LLONG_MAX)
 #endif
 
 #define FL_POSIX	1
diff -druNp --no-dereference linux-libre-3.16.49-gnu/include/linux/ftrace_event.h linux-libre-3.16.50-gnu/include/linux/ftrace_event.h
--- linux-libre-3.16.49-gnu/include/linux/ftrace_event.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/include/linux/ftrace_event.h	2017-11-11 08:34:06.000000000 -0500
@@ -621,7 +621,7 @@ extern int  ftrace_profile_set_filter(st
 				     char *filter_str);
 extern void ftrace_profile_free_filter(struct perf_event *event);
 extern void *perf_trace_buf_prepare(int size, unsigned short type,
-				    struct pt_regs *regs, int *rctxp);
+				    struct pt_regs **regs, int *rctxp);
 
 static inline void
 perf_trace_buf_submit(void *raw_data, int size, int rctx, u64 addr,
diff -druNp --no-dereference linux-libre-3.16.49-gnu/include/linux/gpio/driver.h linux-libre-3.16.50-gnu/include/linux/gpio/driver.h
--- linux-libre-3.16.49-gnu/include/linux/gpio/driver.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/include/linux/gpio/driver.h	2017-11-11 08:34:06.000000000 -0500
@@ -141,7 +141,7 @@ extern const char *gpiochip_is_requested
 
 /* add/remove chips */
 extern int gpiochip_add(struct gpio_chip *chip);
-extern int __must_check gpiochip_remove(struct gpio_chip *chip);
+extern int gpiochip_remove(struct gpio_chip *chip);
 extern struct gpio_chip *gpiochip_find(void *data,
 			      int (*match)(struct gpio_chip *chip, void *data));
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/include/linux/mlx4/device.h linux-libre-3.16.50-gnu/include/linux/mlx4/device.h
--- linux-libre-3.16.49-gnu/include/linux/mlx4/device.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/include/linux/mlx4/device.h	2017-11-11 08:34:06.000000000 -0500
@@ -467,6 +467,7 @@ struct mlx4_caps {
 	u16			hca_core_clock;
 	u64			phys_port_id[MLX4_MAX_PORTS + 1];
 	int			tunnel_offload_mode;
+	bool			wol_port[MLX4_MAX_PORTS + 1];
 };
 
 struct mlx4_buf_list {
diff -druNp --no-dereference linux-libre-3.16.49-gnu/include/linux/mm_types.h linux-libre-3.16.50-gnu/include/linux/mm_types.h
--- linux-libre-3.16.49-gnu/include/linux/mm_types.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/include/linux/mm_types.h	2017-11-11 08:34:06.000000000 -0500
@@ -451,7 +451,7 @@ struct mm_struct {
 	 * can move process memory needs to flush the TLB when moving a
 	 * PROT_NONE or PROT_NUMA mapped page.
 	 */
-	bool tlb_flush_pending;
+	atomic_t tlb_flush_pending;
 #endif
 	struct uprobes_state uprobes_state;
 };
@@ -479,33 +479,46 @@ static inline cpumask_t *mm_cpumask(stru
 static inline bool mm_tlb_flush_pending(struct mm_struct *mm)
 {
 	barrier();
-	return mm->tlb_flush_pending;
+	return atomic_read(&mm->tlb_flush_pending) > 0;
 }
-static inline void set_tlb_flush_pending(struct mm_struct *mm)
+
+static inline void init_tlb_flush_pending(struct mm_struct *mm)
 {
-	mm->tlb_flush_pending = true;
+	atomic_set(&mm->tlb_flush_pending, 0);
+}
+
+static inline void inc_tlb_flush_pending(struct mm_struct *mm)
+{
+	atomic_inc(&mm->tlb_flush_pending);
 
 	/*
-	 * Guarantee that the tlb_flush_pending store does not leak into the
+	 * Guarantee that the tlb_flush_pending increase does not leak into the
 	 * critical section updating the page tables
 	 */
 	smp_mb__before_spinlock();
 }
+
 /* Clearing is done after a TLB flush, which also provides a barrier. */
-static inline void clear_tlb_flush_pending(struct mm_struct *mm)
+static inline void dec_tlb_flush_pending(struct mm_struct *mm)
 {
 	barrier();
-	mm->tlb_flush_pending = false;
+	atomic_dec(&mm->tlb_flush_pending);
 }
 #else
 static inline bool mm_tlb_flush_pending(struct mm_struct *mm)
 {
 	return false;
 }
-static inline void set_tlb_flush_pending(struct mm_struct *mm)
+
+static inline void init_tlb_flush_pending(struct mm_struct *mm)
 {
 }
-static inline void clear_tlb_flush_pending(struct mm_struct *mm)
+
+static inline void inc_tlb_flush_pending(struct mm_struct *mm)
+{
+}
+
+static inline void dec_tlb_flush_pending(struct mm_struct *mm)
 {
 }
 #endif
diff -druNp --no-dereference linux-libre-3.16.49-gnu/include/linux/module.h linux-libre-3.16.50-gnu/include/linux/module.h
--- linux-libre-3.16.49-gnu/include/linux/module.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/include/linux/module.h	2017-11-11 08:34:06.000000000 -0500
@@ -135,7 +135,7 @@ void trim_init_extable(struct module *m)
 #ifdef MODULE
 /* Creates an alias so file2alias.c can find device table. */
 #define MODULE_DEVICE_TABLE(type, name)					\
-  extern const struct type##_device_id __mod_##type##__##name##_device_table \
+extern const typeof(name) __mod_##type##__##name##_device_table		\
   __attribute__ ((unused, alias(__stringify(name))))
 #else  /* !MODULE */
 #define MODULE_DEVICE_TABLE(type, name)
diff -druNp --no-dereference linux-libre-3.16.49-gnu/include/linux/mtd/map.h linux-libre-3.16.50-gnu/include/linux/mtd/map.h
--- linux-libre-3.16.49-gnu/include/linux/mtd/map.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/include/linux/mtd/map.h	2017-11-11 08:34:06.000000000 -0500
@@ -317,7 +317,17 @@ static inline map_word map_word_or(struc
 	return r;
 }
 
-#define map_word_andequal(m, a, b, z) map_word_equal(m, z, map_word_and(m, a, b))
+static inline int map_word_andequal(struct map_info *map, map_word val1, map_word val2, map_word val3)
+{
+	int i;
+
+	for (i = 0; i < map_words(map); i++) {
+		if ((val1.x[i] & val2.x[i]) != val3.x[i])
+			return 0;
+	}
+
+	return 1;
+}
 
 static inline int map_word_bitsset(struct map_info *map, map_word val1, map_word val2)
 {
diff -druNp --no-dereference linux-libre-3.16.49-gnu/include/linux/perf_event.h linux-libre-3.16.50-gnu/include/linux/perf_event.h
--- linux-libre-3.16.49-gnu/include/linux/perf_event.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/include/linux/perf_event.h	2017-11-11 08:34:06.000000000 -0500
@@ -642,6 +642,7 @@ static inline int is_software_event(stru
 
 extern struct static_key perf_swevent_enabled[PERF_COUNT_SW_MAX];
 
+extern void ___perf_sw_event(u32, u64, struct pt_regs *, u64);
 extern void __perf_sw_event(u32, u64, struct pt_regs *, u64);
 
 #ifndef perf_arch_fetch_caller_regs
@@ -666,14 +667,25 @@ static inline void perf_fetch_caller_reg
 static __always_inline void
 perf_sw_event(u32 event_id, u64 nr, struct pt_regs *regs, u64 addr)
 {
-	struct pt_regs hot_regs;
+	if (static_key_false(&perf_swevent_enabled[event_id]))
+		__perf_sw_event(event_id, nr, regs, addr);
+}
+
+DECLARE_PER_CPU(struct pt_regs, __perf_regs[4]);
 
+/*
+ * 'Special' version for the scheduler, it hard assumes no recursion,
+ * which is guaranteed by us not actually scheduling inside other swevents
+ * because those disable preemption.
+ */
+static __always_inline void
+perf_sw_event_sched(u32 event_id, u64 nr, u64 addr)
+{
 	if (static_key_false(&perf_swevent_enabled[event_id])) {
-		if (!regs) {
-			perf_fetch_caller_regs(&hot_regs);
-			regs = &hot_regs;
-		}
-		__perf_sw_event(event_id, nr, regs, addr);
+		struct pt_regs *regs = this_cpu_ptr(&__perf_regs[0]);
+
+		perf_fetch_caller_regs(regs);
+		___perf_sw_event(event_id, nr, regs, addr);
 	}
 }
 
@@ -689,7 +701,7 @@ static inline void perf_event_task_sched
 static inline void perf_event_task_sched_out(struct task_struct *prev,
 					     struct task_struct *next)
 {
-	perf_sw_event(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, NULL, 0);
+	perf_sw_event_sched(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, 0);
 
 	if (static_key_false(&perf_sched_events.key))
 		__perf_event_task_sched_out(prev, next);
@@ -800,6 +812,8 @@ static inline int perf_event_refresh(str
 static inline void
 perf_sw_event(u32 event_id, u64 nr, struct pt_regs *regs, u64 addr)	{ }
 static inline void
+perf_sw_event_sched(u32 event_id, u64 nr, u64 addr)			{ }
+static inline void
 perf_bp_event(struct perf_event *event, void *data)			{ }
 
 static inline int perf_register_guest_info_callbacks
diff -druNp --no-dereference linux-libre-3.16.49-gnu/include/linux/workqueue.h linux-libre-3.16.50-gnu/include/linux/workqueue.h
--- linux-libre-3.16.49-gnu/include/linux/workqueue.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/include/linux/workqueue.h	2017-11-11 08:34:06.000000000 -0500
@@ -315,6 +315,7 @@ enum {
 
 	__WQ_DRAINING		= 1 << 16, /* internal: workqueue is draining */
 	__WQ_ORDERED		= 1 << 17, /* internal: workqueue is ordered */
+	__WQ_ORDERED_EXPLICIT	= 1 << 18, /* internal: alloc_ordered_workqueue() */
 
 	WQ_MAX_ACTIVE		= 512,	  /* I like 512, better ideas? */
 	WQ_MAX_UNBOUND_PER_CPU	= 4,	  /* 4 * #cpus for unbound wq */
@@ -412,7 +413,8 @@ __alloc_workqueue_key(const char *fmt, u
  * Pointer to the allocated workqueue on success, %NULL on failure.
  */
 #define alloc_ordered_workqueue(fmt, flags, args...)			\
-	alloc_workqueue(fmt, WQ_UNBOUND | __WQ_ORDERED | (flags), 1, ##args)
+	alloc_workqueue(fmt, WQ_UNBOUND | __WQ_ORDERED |		\
+			__WQ_ORDERED_EXPLICIT | (flags), 1, ##args)
 
 #define create_workqueue(name)						\
 	alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, (name))
diff -druNp --no-dereference linux-libre-3.16.49-gnu/include/net/dst.h linux-libre-3.16.50-gnu/include/net/dst.h
--- linux-libre-3.16.49-gnu/include/net/dst.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/include/net/dst.h	2017-11-11 08:34:06.000000000 -0500
@@ -105,16 +105,25 @@ struct dst_entry {
 	};
 };
 
+void *dst_alloc_metrics(gfp_t flags);
+void dst_free_metrics(void *metrics);
 u32 *dst_cow_metrics_generic(struct dst_entry *dst, unsigned long old);
-extern const u32 dst_default_metrics[];
 
 #define DST_METRICS_READ_ONLY		0x1UL
 #define DST_METRICS_FORCE_OVERWRITE	0x2UL
-#define DST_METRICS_FLAGS		0x3UL
+#define DST_METRICS_REFCOUNTED		0x4UL
+#define DST_METRICS_FLAGS		0x7UL
+#define DST_METRICS_ALIGNMENT		0x8UL
 #define __DST_METRICS_PTR(Y)	\
 	((u32 *)((Y) & ~DST_METRICS_FLAGS))
 #define DST_METRICS_PTR(X)	__DST_METRICS_PTR((X)->_metrics)
 
+struct dst_metrics {
+	u32		metrics[RTAX_MAX];
+	atomic_t	refcnt;
+} __aligned(DST_METRICS_ALIGNMENT);
+extern const struct dst_metrics dst_default_metrics;
+
 static inline bool dst_metrics_read_only(const struct dst_entry *dst)
 {
 	return dst->_metrics & DST_METRICS_READ_ONLY;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/include/net/ip6_fib.h linux-libre-3.16.50-gnu/include/net/ip6_fib.h
--- linux-libre-3.16.49-gnu/include/net/ip6_fib.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/include/net/ip6_fib.h	2017-11-11 08:34:06.000000000 -0500
@@ -66,6 +66,7 @@ struct fib6_node {
 	__u16			fn_flags;
 	__u32			fn_sernum;
 	struct rt6_info		*rr_ptr;
+	struct rcu_head		rcu;
 };
 
 #ifndef CONFIG_IPV6_SUBTREES
@@ -95,7 +96,7 @@ struct rt6_info {
 	 * the same cache line.
 	 */
 	struct fib6_table		*rt6i_table;
-	struct fib6_node		*rt6i_node;
+	struct fib6_node __rcu		*rt6i_node;
 
 	struct in6_addr			rt6i_gateway;
 
@@ -193,6 +194,38 @@ static inline void rt6_set_from(struct r
 	rt->dst.from = new;
 }
 
+/* Function to safely get fn->sernum for passed in rt
+ * and store result in passed in cookie.
+ * Return true if we can get cookie safely
+ * Return false if not
+ */
+static inline bool rt6_get_cookie_safe(const struct rt6_info *rt,
+				       u32 *cookie)
+{
+	struct fib6_node *fn;
+	bool status = false;
+
+	rcu_read_lock();
+	fn = rcu_dereference(rt->rt6i_node);
+
+	if (fn) {
+		*cookie = fn->fn_sernum;
+		status = true;
+	}
+
+	rcu_read_unlock();
+	return status;
+}
+
+static inline u32 rt6_get_cookie(const struct rt6_info *rt)
+{
+	u32 cookie = 0;
+
+	rt6_get_cookie_safe(rt, &cookie);
+
+	return cookie;
+}
+
 static inline void ip6_rt_put(struct rt6_info *rt)
 {
 	/* dst_release() accepts a NULL parameter.
diff -druNp --no-dereference linux-libre-3.16.49-gnu/include/net/ip6_route.h linux-libre-3.16.50-gnu/include/net/ip6_route.h
--- linux-libre-3.16.49-gnu/include/net/ip6_route.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/include/net/ip6_route.h	2017-11-11 08:34:06.000000000 -0500
@@ -146,7 +146,7 @@ static inline void __ip6_dst_store(struc
 #ifdef CONFIG_IPV6_SUBTREES
 	np->saddr_cache = saddr;
 #endif
-	np->dst_cookie = rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
+	np->dst_cookie = rt6_get_cookie(rt);
 }
 
 static inline void ip6_dst_store(struct sock *sk, struct dst_entry *dst,
diff -druNp --no-dereference linux-libre-3.16.49-gnu/include/net/ip_fib.h linux-libre-3.16.50-gnu/include/net/ip_fib.h
--- linux-libre-3.16.49-gnu/include/net/ip_fib.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/include/net/ip_fib.h	2017-11-11 08:34:06.000000000 -0500
@@ -108,11 +108,11 @@ struct fib_info {
 	unsigned char		fib_type;
 	__be32			fib_prefsrc;
 	u32			fib_priority;
-	u32			*fib_metrics;
-#define fib_mtu fib_metrics[RTAX_MTU-1]
-#define fib_window fib_metrics[RTAX_WINDOW-1]
-#define fib_rtt fib_metrics[RTAX_RTT-1]
-#define fib_advmss fib_metrics[RTAX_ADVMSS-1]
+	struct dst_metrics	*fib_metrics;
+#define fib_mtu fib_metrics->metrics[RTAX_MTU-1]
+#define fib_window fib_metrics->metrics[RTAX_WINDOW-1]
+#define fib_rtt fib_metrics->metrics[RTAX_RTT-1]
+#define fib_advmss fib_metrics->metrics[RTAX_ADVMSS-1]
 	int			fib_nhs;
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
 	int			fib_power;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/include/net/sch_generic.h linux-libre-3.16.50-gnu/include/net/sch_generic.h
--- linux-libre-3.16.49-gnu/include/net/sch_generic.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/include/net/sch_generic.h	2017-11-11 08:34:06.000000000 -0500
@@ -618,8 +618,11 @@ static inline struct Qdisc *qdisc_replac
 	old = *pold;
 	*pold = new;
 	if (old != NULL) {
-		qdisc_tree_reduce_backlog(old, old->q.qlen, old->qstats.backlog);
+		unsigned int qlen = old->q.qlen;
+		unsigned int backlog = old->qstats.backlog;
+
 		qdisc_reset(old);
+		qdisc_tree_reduce_backlog(old, qlen, backlog);
 	}
 	sch_tree_unlock(sch);
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/include/net/sctp/sctp.h linux-libre-3.16.50-gnu/include/net/sctp/sctp.h
--- linux-libre-3.16.49-gnu/include/net/sctp/sctp.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/include/net/sctp/sctp.h	2017-11-11 08:34:06.000000000 -0500
@@ -448,6 +448,8 @@ _sctp_walk_params((pos), (chunk), ntohs(
 
 #define _sctp_walk_params(pos, chunk, end, member)\
 for (pos.v = chunk->member;\
+     (pos.v + offsetof(struct sctp_paramhdr, length) + sizeof(pos.p->length) <=\
+      (void *)chunk + end) &&\
      pos.v <= (void *)chunk + end - ntohs(pos.p->length) &&\
      ntohs(pos.p->length) >= sizeof(sctp_paramhdr_t);\
      pos.v += WORD_ROUND(ntohs(pos.p->length)))
@@ -458,6 +460,8 @@ _sctp_walk_errors((err), (chunk_hdr), nt
 #define _sctp_walk_errors(err, chunk_hdr, end)\
 for (err = (sctp_errhdr_t *)((void *)chunk_hdr + \
 	    sizeof(sctp_chunkhdr_t));\
+     ((void *)err + offsetof(sctp_errhdr_t, length) + sizeof(err->length) <=\
+      (void *)chunk_hdr + end) &&\
      (void *)err <= (void *)chunk_hdr + end - ntohs(err->length) &&\
      ntohs(err->length) >= sizeof(sctp_errhdr_t); \
      err = (sctp_errhdr_t *)((void *)err + WORD_ROUND(ntohs(err->length))))
diff -druNp --no-dereference linux-libre-3.16.49-gnu/include/rdma/ib_addr.h linux-libre-3.16.50-gnu/include/rdma/ib_addr.h
--- linux-libre-3.16.49-gnu/include/rdma/ib_addr.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/include/rdma/ib_addr.h	2017-11-11 08:34:06.000000000 -0500
@@ -184,10 +184,14 @@ static inline void iboe_addr_get_sgid(st
 
 	dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if);
 	if (dev) {
-		ip4 = (struct in_device *)dev->ip_ptr;
+		ip4 = in_dev_get(dev);
 		if (ip4 && ip4->ifa_list && ip4->ifa_list->ifa_address)
 			ipv6_addr_set_v4mapped(ip4->ifa_list->ifa_address,
 					       (struct in6_addr *)gid);
+
+		if (ip4)
+			in_dev_put(ip4);
+
 		dev_put(dev);
 	}
 }
diff -druNp --no-dereference linux-libre-3.16.49-gnu/include/trace/ftrace.h linux-libre-3.16.50-gnu/include/trace/ftrace.h
--- linux-libre-3.16.49-gnu/include/trace/ftrace.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/include/trace/ftrace.h	2017-11-11 08:34:06.000000000 -0500
@@ -765,7 +765,7 @@ perf_trace_##call(void *__data, proto)
 	struct ftrace_event_call *event_call = __data;			\
 	struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
 	struct ftrace_raw_##call *entry;				\
-	struct pt_regs __regs;						\
+	struct pt_regs *__regs;						\
 	u64 __addr = 0, __count = 1;					\
 	struct task_struct *__task = NULL;				\
 	struct hlist_head *head;					\
@@ -784,18 +784,19 @@ perf_trace_##call(void *__data, proto)
 			     sizeof(u64));				\
 	__entry_size -= sizeof(u32);					\
 									\
-	perf_fetch_caller_regs(&__regs);				\
 	entry = perf_trace_buf_prepare(__entry_size,			\
 			event_call->event.type, &__regs, &rctx);	\
 	if (!entry)							\
 		return;							\
 									\
+	perf_fetch_caller_regs(__regs);					\
+									\
 	tstruct								\
 									\
 	{ assign; }							\
 									\
 	perf_trace_buf_submit(entry, __entry_size, rctx, __addr,	\
-		__count, &__regs, head, __task);			\
+		__count, __regs, head, __task);				\
 }
 
 /*
diff -druNp --no-dereference linux-libre-3.16.49-gnu/include/uapi/linux/usb/ch9.h linux-libre-3.16.50-gnu/include/uapi/linux/usb/ch9.h
--- linux-libre-3.16.49-gnu/include/uapi/linux/usb/ch9.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/include/uapi/linux/usb/ch9.h	2017-11-11 08:34:06.000000000 -0500
@@ -724,6 +724,7 @@ struct usb_interface_assoc_descriptor {
 	__u8  iFunction;
 } __attribute__ ((packed));
 
+#define USB_DT_INTERFACE_ASSOCIATION_SIZE	8
 
 /*-------------------------------------------------------------------------*/
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/kernel/audit_watch.c linux-libre-3.16.50-gnu/kernel/audit_watch.c
--- linux-libre-3.16.49-gnu/kernel/audit_watch.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/kernel/audit_watch.c	2017-11-11 08:34:06.000000000 -0500
@@ -455,13 +455,15 @@ void audit_remove_watch_rule(struct audi
 	list_del(&krule->rlist);
 
 	if (list_empty(&watch->rules)) {
+		/*
+		 * audit_remove_watch() drops our reference to 'parent' which
+		 * can get freed. Grab our own reference to be safe.
+		 */
+		audit_get_parent(parent);
 		audit_remove_watch(watch);
-
-		if (list_empty(&parent->watches)) {
-			audit_get_parent(parent);
+		if (list_empty(&parent->watches))
 			fsnotify_destroy_mark(&parent->mark, audit_watch_group);
-			audit_put_parent(parent);
-		}
+		audit_put_parent(parent);
 	}
 }
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/kernel/events/core.c linux-libre-3.16.50-gnu/kernel/events/core.c
--- linux-libre-3.16.49-gnu/kernel/events/core.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/kernel/events/core.c	2017-11-11 08:34:06.000000000 -0500
@@ -3565,50 +3565,77 @@ u64 perf_event_read_value(struct perf_ev
 }
 EXPORT_SYMBOL_GPL(perf_event_read_value);
 
-static int perf_event_read_group(struct perf_event *event,
-				   u64 read_format, char __user *buf)
+static void __perf_read_group_add(struct perf_event *leader,
+					u64 read_format, u64 *values)
 {
-	struct perf_event *leader = event->group_leader, *sub;
 	struct perf_event_context *ctx = leader->ctx;
-	int n = 0, size = 0, ret;
+	struct perf_event *sub;
+	unsigned long flags;
+	int n = 1; /* skip @nr */
 	u64 count, enabled, running;
-	u64 values[5];
-
-	lockdep_assert_held(&ctx->mutex);
 
 	count = perf_event_read_value(leader, &enabled, &running);
 
-	values[n++] = 1 + leader->nr_siblings;
+	/*
+	 * Since we co-schedule groups, {enabled,running} times of siblings
+	 * will be identical to those of the leader, so we only publish one
+	 * set.
+	 */
 	if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED)
 		values[n++] = enabled;
 	if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING)
 		values[n++] = running;
-	values[n++] = count;
+
+	/*
+	 * Write {count,id} tuples for every sibling.
+	 */
+	values[n++] += count;
 	if (read_format & PERF_FORMAT_ID)
 		values[n++] = primary_event_id(leader);
 
-	size = n * sizeof(u64);
-
-	if (copy_to_user(buf, values, size))
-		return -EFAULT;
-
-	ret = size;
+	raw_spin_lock_irqsave(&ctx->lock, flags);
 
 	list_for_each_entry(sub, &leader->sibling_list, group_entry) {
-		n = 0;
-
 		values[n++] = perf_event_read_value(sub, &enabled, &running);
 		if (read_format & PERF_FORMAT_ID)
 			values[n++] = primary_event_id(sub);
+	}
 
-		size = n * sizeof(u64);
+	raw_spin_unlock_irqrestore(&ctx->lock, flags);
+}
 
-		if (copy_to_user(buf + ret, values, size)) {
-			return -EFAULT;
-		}
+static int perf_event_read_group(struct perf_event *event,
+				   u64 read_format, char __user *buf)
+{
+	struct perf_event *leader = event->group_leader, *child;
+	struct perf_event_context *ctx = leader->ctx;
+	int ret = event->read_size;
+	u64 *values;
 
-		ret += size;
-	}
+	lockdep_assert_held(&ctx->mutex);
+
+	values = kzalloc(event->read_size, GFP_KERNEL);
+	if (!values)
+		return -ENOMEM;
+
+	values[0] = 1 + leader->nr_siblings;
+
+	/*
+	 * By locking the child_mutex of the leader we effectively
+	 * lock the child list of all siblings.. XXX explain how.
+	 */
+	mutex_lock(&leader->child_mutex);
+
+	__perf_read_group_add(leader, read_format, values);
+	list_for_each_entry(child, &leader->child_list, child_list)
+		__perf_read_group_add(child, read_format, values);
+
+	mutex_unlock(&leader->child_mutex);
+
+	if (copy_to_user(buf, values, event->read_size))
+		ret = -EFAULT;
+
+	kfree(values);
 
 	return ret;
 }
@@ -5938,6 +5965,8 @@ end:
 	rcu_read_unlock();
 }
 
+DEFINE_PER_CPU(struct pt_regs, __perf_regs[4]);
+
 int perf_swevent_get_recursion_context(void)
 {
 	struct swevent_htable *swhash = &__get_cpu_var(swevent_htable);
@@ -5953,21 +5982,30 @@ inline void perf_swevent_put_recursion_c
 	put_recursion_context(swhash->recursion, rctx);
 }
 
-void __perf_sw_event(u32 event_id, u64 nr, struct pt_regs *regs, u64 addr)
+void ___perf_sw_event(u32 event_id, u64 nr, struct pt_regs *regs, u64 addr)
 {
 	struct perf_sample_data data;
-	int rctx;
 
-	preempt_disable_notrace();
-	rctx = perf_swevent_get_recursion_context();
-	if (rctx < 0)
+	if (WARN_ON_ONCE(!regs))
 		return;
 
 	perf_sample_data_init(&data, addr, 0);
-
 	do_perf_sw_event(PERF_TYPE_SOFTWARE, event_id, nr, &data, regs);
+}
+
+void __perf_sw_event(u32 event_id, u64 nr, struct pt_regs *regs, u64 addr)
+{
+	int rctx;
+
+	preempt_disable_notrace();
+	rctx = perf_swevent_get_recursion_context();
+	if (unlikely(rctx < 0))
+		goto fail;
+
+	___perf_sw_event(event_id, nr, regs, addr);
 
 	perf_swevent_put_recursion_context(rctx);
+fail:
 	preempt_enable_notrace();
 }
 
@@ -7514,28 +7552,27 @@ SYSCALL_DEFINE5(perf_event_open,
 		if (group_leader->group_leader != group_leader)
 			goto err_context;
 		/*
-		 * Do not allow to attach to a group in a different
-		 * task or CPU context:
+		 * Make sure we're both events for the same CPU;
+		 * grouping events for different CPUs is broken; since
+		 * you can never concurrently schedule them anyhow.
 		 */
-		if (move_group) {
-			/*
-			 * Make sure we're both on the same task, or both
-			 * per-cpu events.
-			 */
-			if (group_leader->ctx->task != ctx->task)
-				goto err_context;
+		if (group_leader->cpu != event->cpu)
+			goto err_context;
 
-			/*
-			 * Make sure we're both events for the same CPU;
-			 * grouping events for different CPUs is broken; since
-			 * you can never concurrently schedule them anyhow.
-			 */
-			if (group_leader->cpu != event->cpu)
-				goto err_context;
-		} else {
-			if (group_leader->ctx != ctx)
-				goto err_context;
-		}
+		/*
+		 * Make sure we're both on the same task, or both
+		 * per-CPU events.
+		 */
+		if (group_leader->ctx->task != ctx->task)
+			goto err_context;
+
+		/*
+		 * Do not allow to attach to a group in a different task
+		 * or CPU context. If we're moving SW events, we'll fix
+		 * this up later, so allow that.
+		 */
+		if (!move_group && group_leader->ctx != ctx)
+			goto err_context;
 
 		/*
 		 * Only a group leader can be exclusive or pinned
diff -druNp --no-dereference linux-libre-3.16.49-gnu/kernel/fork.c linux-libre-3.16.50-gnu/kernel/fork.c
--- linux-libre-3.16.49-gnu/kernel/fork.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/kernel/fork.c	2017-11-11 08:34:06.000000000 -0500
@@ -539,7 +539,7 @@ static struct mm_struct *mm_init(struct
 	spin_lock_init(&mm->page_table_lock);
 	mm_init_aio(mm);
 	mm_init_owner(mm, p);
-	clear_tlb_flush_pending(mm);
+	init_tlb_flush_pending(mm);
 
 	if (current->mm) {
 		mm->flags = current->mm->flags & MMF_INIT_MASK;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/kernel/sched/core.c linux-libre-3.16.50-gnu/kernel/sched/core.c
--- linux-libre-3.16.49-gnu/kernel/sched/core.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/kernel/sched/core.c	2017-11-11 08:34:06.000000000 -0500
@@ -1083,7 +1083,7 @@ void set_task_cpu(struct task_struct *p,
 		if (p->sched_class->migrate_task_rq)
 			p->sched_class->migrate_task_rq(p, new_cpu);
 		p->se.nr_migrations++;
-		perf_sw_event(PERF_COUNT_SW_CPU_MIGRATIONS, 1, NULL, 0);
+		perf_sw_event_sched(PERF_COUNT_SW_CPU_MIGRATIONS, 1, 0);
 
 		tmn.task = p;
 		tmn.from_cpu = task_cpu(p);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/kernel/trace/trace.c linux-libre-3.16.50-gnu/kernel/trace/trace.c
--- linux-libre-3.16.49-gnu/kernel/trace/trace.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/kernel/trace/trace.c	2017-11-11 08:34:06.000000000 -0500
@@ -6373,6 +6373,7 @@ static int instance_delete(const char *n
 	debugfs_remove_recursive(tr->dir);
 	free_trace_buffers(tr);
 
+	free_cpumask_var(tr->tracing_cpumask);
 	kfree(tr->name);
 	kfree(tr);
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/kernel/trace/trace_event_perf.c linux-libre-3.16.50-gnu/kernel/trace/trace_event_perf.c
--- linux-libre-3.16.49-gnu/kernel/trace/trace_event_perf.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/kernel/trace/trace_event_perf.c	2017-11-11 08:34:06.000000000 -0500
@@ -249,7 +249,7 @@ void perf_trace_del(struct perf_event *p
 }
 
 void *perf_trace_buf_prepare(int size, unsigned short type,
-			     struct pt_regs *regs, int *rctxp)
+			     struct pt_regs **regs, int *rctxp)
 {
 	struct trace_entry *entry;
 	unsigned long flags;
@@ -268,6 +268,8 @@ void *perf_trace_buf_prepare(int size, u
 	if (*rctxp < 0)
 		return NULL;
 
+	if (regs)
+		*regs = this_cpu_ptr(&__perf_regs[*rctxp]);
 	raw_data = this_cpu_ptr(perf_trace_buf[*rctxp]);
 
 	/* zero the dead bytes from align to not leak stack to user */
diff -druNp --no-dereference linux-libre-3.16.49-gnu/kernel/trace/trace_events_filter.c linux-libre-3.16.50-gnu/kernel/trace/trace_events_filter.c
--- linux-libre-3.16.49-gnu/kernel/trace/trace_events_filter.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/kernel/trace/trace_events_filter.c	2017-11-11 08:34:06.000000000 -0500
@@ -1950,6 +1950,10 @@ static int create_filter(struct ftrace_e
 		if (err && set_str)
 			append_filter_err(ps, filter);
 	}
+	if (err && !set_str) {
+		free_event_filter(filter);
+		filter = NULL;
+	}
 	create_filter_finish(ps);
 
 	*filterp = filter;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/kernel/trace/trace_kprobe.c linux-libre-3.16.50-gnu/kernel/trace/trace_kprobe.c
--- linux-libre-3.16.49-gnu/kernel/trace/trace_kprobe.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/kernel/trace/trace_kprobe.c	2017-11-11 08:34:06.000000000 -0500
@@ -1155,7 +1155,7 @@ kprobe_perf_func(struct trace_kprobe *tk
 	size = ALIGN(__size + sizeof(u32), sizeof(u64));
 	size -= sizeof(u32);
 
-	entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx);
+	entry = perf_trace_buf_prepare(size, call->event.type, NULL, &rctx);
 	if (!entry)
 		return;
 
@@ -1186,7 +1186,7 @@ kretprobe_perf_func(struct trace_kprobe
 	size = ALIGN(__size + sizeof(u32), sizeof(u64));
 	size -= sizeof(u32);
 
-	entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx);
+	entry = perf_trace_buf_prepare(size, call->event.type, NULL, &rctx);
 	if (!entry)
 		return;
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/kernel/trace/trace_syscalls.c linux-libre-3.16.50-gnu/kernel/trace/trace_syscalls.c
--- linux-libre-3.16.49-gnu/kernel/trace/trace_syscalls.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/kernel/trace/trace_syscalls.c	2017-11-11 08:34:06.000000000 -0500
@@ -586,7 +586,7 @@ static void perf_syscall_enter(void *ign
 	size -= sizeof(u32);
 
 	rec = (struct syscall_trace_enter *)perf_trace_buf_prepare(size,
-				sys_data->enter_event->event.type, regs, &rctx);
+				sys_data->enter_event->event.type, NULL, &rctx);
 	if (!rec)
 		return;
 
@@ -659,7 +659,7 @@ static void perf_syscall_exit(void *igno
 	size -= sizeof(u32);
 
 	rec = (struct syscall_trace_exit *)perf_trace_buf_prepare(size,
-				sys_data->exit_event->event.type, regs, &rctx);
+				sys_data->exit_event->event.type, NULL, &rctx);
 	if (!rec)
 		return;
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/kernel/trace/trace_uprobe.c linux-libre-3.16.50-gnu/kernel/trace/trace_uprobe.c
--- linux-libre-3.16.49-gnu/kernel/trace/trace_uprobe.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/kernel/trace/trace_uprobe.c	2017-11-11 08:34:06.000000000 -0500
@@ -1116,7 +1116,7 @@ static void __uprobe_perf_func(struct tr
 	if (hlist_empty(head))
 		goto out;
 
-	entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx);
+	entry = perf_trace_buf_prepare(size, call->event.type, NULL, &rctx);
 	if (!entry)
 		goto out;
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/kernel/workqueue.c linux-libre-3.16.50-gnu/kernel/workqueue.c
--- linux-libre-3.16.49-gnu/kernel/workqueue.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/kernel/workqueue.c	2017-11-11 08:34:06.000000000 -0500
@@ -3324,7 +3324,7 @@ int workqueue_sysfs_register(struct work
 	 * attributes breaks ordering guarantee.  Disallow exposing ordered
 	 * workqueues.
 	 */
-	if (WARN_ON(wq->flags & __WQ_ORDERED))
+	if (WARN_ON(wq->flags & __WQ_ORDERED_EXPLICIT))
 		return -EINVAL;
 
 	wq->wq_dev = wq_dev = kzalloc(sizeof(*wq_dev), GFP_KERNEL);
@@ -3907,8 +3907,12 @@ int apply_workqueue_attrs(struct workque
 		return -EINVAL;
 
 	/* creating multiple pwqs breaks ordering guarantee */
-	if (WARN_ON((wq->flags & __WQ_ORDERED) && !list_empty(&wq->pwqs)))
-		return -EINVAL;
+	if (!list_empty(&wq->pwqs)) {
+		if (WARN_ON(wq->flags & __WQ_ORDERED_EXPLICIT))
+			return -EINVAL;
+
+		wq->flags &= ~__WQ_ORDERED;
+	}
 
 	pwq_tbl = kzalloc(wq_numa_tbl_len * sizeof(pwq_tbl[0]), GFP_KERNEL);
 	new_attrs = alloc_workqueue_attrs(GFP_KERNEL);
@@ -4152,6 +4156,16 @@ struct workqueue_struct *__alloc_workque
 	struct workqueue_struct *wq;
 	struct pool_workqueue *pwq;
 
+	/*
+	 * Unbound && max_active == 1 used to imply ordered, which is no
+	 * longer the case on NUMA machines due to per-node pools.  While
+	 * alloc_ordered_workqueue() is the right way to create an ordered
+	 * workqueue, keep the previous behavior to avoid subtle breakages
+	 * on NUMA.
+	 */
+	if ((flags & WQ_UNBOUND) && max_active == 1)
+		flags |= __WQ_ORDERED;
+
 	/* see the comment above the definition of WQ_POWER_EFFICIENT */
 	if ((flags & WQ_POWER_EFFICIENT) && wq_power_efficient)
 		flags |= WQ_UNBOUND;
@@ -4344,13 +4358,14 @@ void workqueue_set_max_active(struct wor
 	struct pool_workqueue *pwq;
 
 	/* disallow meddling with max_active for ordered workqueues */
-	if (WARN_ON(wq->flags & __WQ_ORDERED))
+	if (WARN_ON(wq->flags & __WQ_ORDERED_EXPLICIT))
 		return;
 
 	max_active = wq_clamp_max_active(max_active, wq->flags, wq->name);
 
 	mutex_lock(&wq->mutex);
 
+	wq->flags &= ~__WQ_ORDERED;
 	wq->saved_max_active = max_active;
 
 	for_each_pwq(pwq, wq)
diff -druNp --no-dereference linux-libre-3.16.49-gnu/lib/assoc_array.c linux-libre-3.16.50-gnu/lib/assoc_array.c
--- linux-libre-3.16.49-gnu/lib/assoc_array.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/lib/assoc_array.c	2017-11-11 08:34:06.000000000 -0500
@@ -597,21 +597,31 @@ static bool assoc_array_insert_into_term
 		if ((edit->segment_cache[ASSOC_ARRAY_FAN_OUT] ^ base_seg) == 0)
 			goto all_leaves_cluster_together;
 
-		/* Otherwise we can just insert a new node ahead of the old
-		 * one.
+		/* Otherwise all the old leaves cluster in the same slot, but
+		 * the new leaf wants to go into a different slot - so we
+		 * create a new node (n0) to hold the new leaf and a pointer to
+		 * a new node (n1) holding all the old leaves.
+		 *
+		 * This can be done by falling through to the node splitting
+		 * path.
 		 */
-		goto present_leaves_cluster_but_not_new_leaf;
+		pr_devel("present leaves cluster but not new leaf\n");
 	}
 
 split_node:
 	pr_devel("split node\n");
 
-	/* We need to split the current node; we know that the node doesn't
-	 * simply contain a full set of leaves that cluster together (it
-	 * contains meta pointers and/or non-clustering leaves).
+	/* We need to split the current node.  The node must contain anything
+	 * from a single leaf (in the one leaf case, this leaf will cluster
+	 * with the new leaf) and the rest meta-pointers, to all leaves, some
+	 * of which may cluster.
+	 *
+	 * It won't contain the case in which all the current leaves plus the
+	 * new leaves want to cluster in the same slot.
 	 *
 	 * We need to expel at least two leaves out of a set consisting of the
-	 * leaves in the node and the new leaf.
+	 * leaves in the node and the new leaf.  The current meta pointers can
+	 * just be copied as they shouldn't cluster with any of the leaves.
 	 *
 	 * We need a new node (n0) to replace the current one and a new node to
 	 * take the expelled nodes (n1).
@@ -716,33 +726,6 @@ found_slot_for_multiple_occupancy:
 	pr_devel("<--%s() = ok [split node]\n", __func__);
 	return true;
 
-present_leaves_cluster_but_not_new_leaf:
-	/* All the old leaves cluster in the same slot, but the new leaf wants
-	 * to go into a different slot, so we create a new node to hold the new
-	 * leaf and a pointer to a new node holding all the old leaves.
-	 */
-	pr_devel("present leaves cluster but not new leaf\n");
-
-	new_n0->back_pointer = node->back_pointer;
-	new_n0->parent_slot = node->parent_slot;
-	new_n0->nr_leaves_on_branch = node->nr_leaves_on_branch;
-	new_n1->back_pointer = assoc_array_node_to_ptr(new_n0);
-	new_n1->parent_slot = edit->segment_cache[0];
-	new_n1->nr_leaves_on_branch = node->nr_leaves_on_branch;
-	edit->adjust_count_on = new_n0;
-
-	for (i = 0; i < ASSOC_ARRAY_FAN_OUT; i++)
-		new_n1->slots[i] = node->slots[i];
-
-	new_n0->slots[edit->segment_cache[0]] = assoc_array_node_to_ptr(new_n0);
-	edit->leaf_p = &new_n0->slots[edit->segment_cache[ASSOC_ARRAY_FAN_OUT]];
-
-	edit->set[0].ptr = &assoc_array_ptr_to_node(node->back_pointer)->slots[node->parent_slot];
-	edit->set[0].to = assoc_array_node_to_ptr(new_n0);
-	edit->excised_meta[0] = assoc_array_node_to_ptr(node);
-	pr_devel("<--%s() = ok [insert node before]\n", __func__);
-	return true;
-
 all_leaves_cluster_together:
 	/* All the leaves, new and old, want to cluster together in this node
 	 * in the same slot, so we have to replace this node with a shortcut to
diff -druNp --no-dereference linux-libre-3.16.49-gnu/lib/cpumask.c linux-libre-3.16.50-gnu/lib/cpumask.c
--- linux-libre-3.16.49-gnu/lib/cpumask.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/lib/cpumask.c	2017-11-11 08:34:06.000000000 -0500
@@ -198,64 +198,42 @@ void __init free_bootmem_cpumask_var(cpu
 #endif
 
 /**
- * cpumask_set_cpu_local_first - set i'th cpu with local numa cpu's first
- *
+ * cpumask_local_spread - select the i'th cpu with local numa cpu's first
  * @i: index number
- * @numa_node: local numa_node
- * @dstp: cpumask with the relevant cpu bit set according to the policy
+ * @node: local numa_node
  *
- * This function sets the cpumask according to a numa aware policy.
- * cpumask could be used as an affinity hint for the IRQ related to a
- * queue. When the policy is to spread queues across cores - local cores
- * first.
+ * This function selects an online CPU according to a numa aware policy;
+ * local cpus are returned first, followed by non-local ones, then it
+ * wraps around.
  *
- * Returns 0 on success, -ENOMEM for no memory, and -EAGAIN when failed to set
- * the cpu bit and need to re-call the function.
+ * It's not very efficient, but useful for setup.
  */
-int cpumask_set_cpu_local_first(int i, int numa_node, cpumask_t *dstp)
+unsigned int cpumask_local_spread(unsigned int i, int node)
 {
-	cpumask_var_t mask;
 	int cpu;
-	int ret = 0;
-
-	if (!zalloc_cpumask_var(&mask, GFP_KERNEL))
-		return -ENOMEM;
 
+	/* Wrap: we always want a cpu. */
 	i %= num_online_cpus();
 
-	if (numa_node == -1 || !cpumask_of_node(numa_node)) {
-		/* Use all online cpu's for non numa aware system */
-		cpumask_copy(mask, cpu_online_mask);
+	if (node == -1) {
+		for_each_cpu(cpu, cpu_online_mask)
+			if (i-- == 0)
+				return cpu;
 	} else {
-		int n;
-
-		cpumask_and(mask,
-			    cpumask_of_node(numa_node), cpu_online_mask);
+		/* NUMA first. */
+		for_each_cpu_and(cpu, cpumask_of_node(node), cpu_online_mask)
+			if (i-- == 0)
+				return cpu;
 
-		n = cpumask_weight(mask);
-		if (i >= n) {
-			i -= n;
+		for_each_cpu(cpu, cpu_online_mask) {
+			/* Skip NUMA nodes, done above. */
+			if (cpumask_test_cpu(cpu, cpumask_of_node(node)))
+				continue;
 
-			/* If index > number of local cpu's, mask out local
-			 * cpu's
-			 */
-			cpumask_andnot(mask, cpu_online_mask, mask);
+			if (i-- == 0)
+				return cpu;
 		}
 	}
-
-	for_each_cpu(cpu, mask) {
-		if (--i < 0)
-			goto out;
-	}
-
-	ret = -EAGAIN;
-
-out:
-	free_cpumask_var(mask);
-
-	if (!ret)
-		cpumask_set_cpu(cpu, dstp);
-
-	return ret;
+	BUG();
 }
-EXPORT_SYMBOL(cpumask_set_cpu_local_first);
+EXPORT_SYMBOL(cpumask_local_spread);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/Makefile linux-libre-3.16.50-gnu/Makefile
--- linux-libre-3.16.49-gnu/Makefile	2017-10-12 21:48:52.000000000 -0400
+++ linux-libre-3.16.50-gnu/Makefile	2017-11-13 09:03:56.000000000 -0500
@@ -1,6 +1,6 @@
 VERSION = 3
 PATCHLEVEL = 16
-SUBLEVEL = 49
+SUBLEVEL = 50
 EXTRAVERSION =-gnu
 NAME = Museum of Fishiegoodies
 
@@ -616,6 +616,7 @@ all: vmlinux
 include $(srctree)/arch/$(SRCARCH)/Makefile
 
 KBUILD_CFLAGS	+= $(call cc-option,-fno-delete-null-pointer-checks,)
+KBUILD_CFLAGS	+= $(call cc-disable-warning,frame-address,)
 
 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
 KBUILD_CFLAGS	+= -Os $(call cc-disable-warning,maybe-uninitialized,)
diff -druNp --no-dereference linux-libre-3.16.49-gnu/mm/hugetlb.c linux-libre-3.16.50-gnu/mm/hugetlb.c
--- linux-libre-3.16.49-gnu/mm/hugetlb.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/mm/hugetlb.c	2017-11-11 08:34:06.000000000 -0500
@@ -1105,14 +1105,20 @@ out:
 int dissolve_free_huge_pages(unsigned long start_pfn, unsigned long end_pfn)
 {
 	unsigned long pfn;
+	struct page *page;
 	int rc = 0;
 
 	if (!hugepages_supported())
 		return rc;
 
-	for (pfn = start_pfn; pfn < end_pfn; pfn += 1 << minimum_order)
-		if (rc = dissolve_free_huge_page(pfn_to_page(pfn)))
-			break;
+	for (pfn = start_pfn; pfn < end_pfn; pfn += 1 << minimum_order) {
+		page = pfn_to_page(pfn);
+		if (PageHuge(page) && !page_count(page)) {
+			rc = dissolve_free_huge_page(page);
+			if (rc)
+				break;
+		}
+	}
 
 	return rc;
 }
diff -druNp --no-dereference linux-libre-3.16.49-gnu/mm/mempolicy.c linux-libre-3.16.50-gnu/mm/mempolicy.c
--- linux-libre-3.16.49-gnu/mm/mempolicy.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/mm/mempolicy.c	2017-11-11 08:34:06.000000000 -0500
@@ -957,11 +957,6 @@ static long do_get_mempolicy(int *policy
 		*policy |= (pol->flags & MPOL_MODE_FLAGS);
 	}
 
-	if (vma) {
-		up_read(&current->mm->mmap_sem);
-		vma = NULL;
-	}
-
 	err = 0;
 	if (nmask) {
 		if (mpol_store_user_nodemask(pol)) {
diff -druNp --no-dereference linux-libre-3.16.49-gnu/mm/mprotect.c linux-libre-3.16.50-gnu/mm/mprotect.c
--- linux-libre-3.16.49-gnu/mm/mprotect.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/mm/mprotect.c	2017-11-11 08:34:06.000000000 -0500
@@ -225,7 +225,7 @@ static unsigned long change_protection_r
 	BUG_ON(addr >= end);
 	pgd = pgd_offset(mm, addr);
 	flush_cache_range(vma, addr, end);
-	set_tlb_flush_pending(mm);
+	inc_tlb_flush_pending(mm);
 	do {
 		next = pgd_addr_end(addr, end);
 		if (pgd_none_or_clear_bad(pgd))
@@ -237,7 +237,7 @@ static unsigned long change_protection_r
 	/* Only flush the TLB if we actually modified any entries: */
 	if (pages)
 		flush_tlb_range(vma, start, end);
-	clear_tlb_flush_pending(mm);
+	dec_tlb_flush_pending(mm);
 
 	return pages;
 }
diff -druNp --no-dereference linux-libre-3.16.49-gnu/mm/page_alloc.c linux-libre-3.16.50-gnu/mm/page_alloc.c
--- linux-libre-3.16.49-gnu/mm/page_alloc.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/mm/page_alloc.c	2017-11-11 08:34:06.000000000 -0500
@@ -61,6 +61,7 @@
 #include <linux/page-debug-flags.h>
 #include <linux/hugetlb.h>
 #include <linux/sched/rt.h>
+#include <linux/nmi.h>
 
 #include <asm/sections.h>
 #include <asm/tlbflush.h>
@@ -1354,9 +1355,14 @@ void drain_all_pages(void)
 
 #ifdef CONFIG_HIBERNATION
 
+/*
+ * Touch the watchdog for every WD_PAGE_COUNT pages.
+ */
+#define WD_PAGE_COUNT	(128*1024)
+
 void mark_free_pages(struct zone *zone)
 {
-	unsigned long pfn, max_zone_pfn;
+	unsigned long pfn, max_zone_pfn, page_count = WD_PAGE_COUNT;
 	unsigned long flags;
 	unsigned int order, t;
 	struct list_head *curr;
@@ -1371,6 +1377,11 @@ void mark_free_pages(struct zone *zone)
 		if (pfn_valid(pfn)) {
 			struct page *page = pfn_to_page(pfn);
 
+			if (!--page_count) {
+				touch_nmi_watchdog();
+				page_count = WD_PAGE_COUNT;
+			}
+
 			if (!swsusp_page_is_forbidden(page))
 				swsusp_unset_page_free(page);
 		}
@@ -1380,8 +1391,13 @@ void mark_free_pages(struct zone *zone)
 			unsigned long i;
 
 			pfn = page_to_pfn(list_entry(curr, struct page, lru));
-			for (i = 0; i < (1UL << order); i++)
+			for (i = 0; i < (1UL << order); i++) {
+				if (!--page_count) {
+					touch_nmi_watchdog();
+					page_count = WD_PAGE_COUNT;
+				}
 				swsusp_set_page_free(pfn_to_page(pfn + i));
+			}
 		}
 	}
 	spin_unlock_irqrestore(&zone->lock, flags);
@@ -5319,15 +5335,18 @@ void __init free_area_init_nodes(unsigne
 				sizeof(arch_zone_lowest_possible_pfn));
 	memset(arch_zone_highest_possible_pfn, 0,
 				sizeof(arch_zone_highest_possible_pfn));
-	arch_zone_lowest_possible_pfn[0] = find_min_pfn_with_active_regions();
-	arch_zone_highest_possible_pfn[0] = max_zone_pfn[0];
-	for (i = 1; i < MAX_NR_ZONES; i++) {
+
+	start_pfn = find_min_pfn_with_active_regions();
+
+	for (i = 0; i < MAX_NR_ZONES; i++) {
 		if (i == ZONE_MOVABLE)
 			continue;
-		arch_zone_lowest_possible_pfn[i] =
-			arch_zone_highest_possible_pfn[i-1];
-		arch_zone_highest_possible_pfn[i] =
-			max(max_zone_pfn[i], arch_zone_lowest_possible_pfn[i]);
+
+		end_pfn = max(max_zone_pfn[i], start_pfn);
+		arch_zone_lowest_possible_pfn[i] = start_pfn;
+		arch_zone_highest_possible_pfn[i] = end_pfn;
+
+		start_pfn = end_pfn;
 	}
 	arch_zone_lowest_possible_pfn[ZONE_MOVABLE] = 0;
 	arch_zone_highest_possible_pfn[ZONE_MOVABLE] = 0;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/batman-adv/translation-table.c linux-libre-3.16.50-gnu/net/batman-adv/translation-table.c
--- linux-libre-3.16.49-gnu/net/batman-adv/translation-table.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/batman-adv/translation-table.c	2017-11-11 08:34:06.000000000 -0500
@@ -1233,9 +1233,41 @@ batadv_tt_global_entry_has_orig(const st
 	return found;
 }
 
+/**
+ * batadv_tt_global_sync_flags - update TT sync flags
+ * @tt_global: the TT global entry to update sync flags in
+ *
+ * Updates the sync flag bits in the tt_global flag attribute with a logical
+ * OR of all sync flags from any of its TT orig entries.
+ */
+static void
+batadv_tt_global_sync_flags(struct batadv_tt_global_entry *tt_global)
+{
+	struct batadv_tt_orig_list_entry *orig_entry;
+	const struct hlist_head *head;
+	u16 flags = BATADV_NO_FLAGS;
+
+	rcu_read_lock();
+	head = &tt_global->orig_list;
+	hlist_for_each_entry_rcu(orig_entry, head, list)
+		flags |= orig_entry->flags;
+	rcu_read_unlock();
+
+	flags |= tt_global->common.flags & (~BATADV_TT_SYNC_MASK);
+	tt_global->common.flags = flags;
+}
+
+/**
+ * batadv_tt_global_orig_entry_add - add or update a TT orig entry
+ * @tt_global: the TT global entry to add an orig entry in
+ * @orig_node: the originator to add an orig entry for
+ * @ttvn: translation table version number of this changeset
+ * @flags: TT sync flags
+ */
 static void
 batadv_tt_global_orig_entry_add(struct batadv_tt_global_entry *tt_global,
-				struct batadv_orig_node *orig_node, int ttvn)
+				struct batadv_orig_node *orig_node, int ttvn,
+				u8 flags)
 {
 	struct batadv_tt_orig_list_entry *orig_entry;
 
@@ -1245,7 +1277,8 @@ batadv_tt_global_orig_entry_add(struct b
 		 * was added during a "temporary client detection"
 		 */
 		orig_entry->ttvn = ttvn;
-		goto out;
+		orig_entry->flags = flags;
+		goto sync_flags;
 	}
 
 	orig_entry = kzalloc(sizeof(*orig_entry), GFP_ATOMIC);
@@ -1257,6 +1290,7 @@ batadv_tt_global_orig_entry_add(struct b
 	batadv_tt_global_size_inc(orig_node, tt_global->common.vid);
 	orig_entry->orig_node = orig_node;
 	orig_entry->ttvn = ttvn;
+	orig_entry->flags = flags;
 	atomic_set(&orig_entry->refcount, 2);
 
 	spin_lock_bh(&tt_global->list_lock);
@@ -1265,6 +1299,8 @@ batadv_tt_global_orig_entry_add(struct b
 	spin_unlock_bh(&tt_global->list_lock);
 	atomic_inc(&tt_global->orig_list_count);
 
+sync_flags:
+	batadv_tt_global_sync_flags(tt_global);
 out:
 	if (orig_entry)
 		batadv_tt_orig_list_entry_free_ref(orig_entry);
@@ -1379,10 +1415,10 @@ static bool batadv_tt_global_add(struct
 		common->flags &= ~BATADV_TT_CLIENT_TEMP;
 
 		/* the change can carry possible "attribute" flags like the
-		 * TT_CLIENT_WIFI, therefore they have to be copied in the
+		 * TT_CLIENT_TEMP, therefore they have to be copied in the
 		 * client entry
 		 */
-		tt_global_entry->common.flags |= flags;
+		tt_global_entry->common.flags |= flags & (~BATADV_TT_SYNC_MASK);
 
 		/* If there is the BATADV_TT_CLIENT_ROAM flag set, there is only
 		 * one originator left in the list and we previously received a
@@ -1399,7 +1435,8 @@ static bool batadv_tt_global_add(struct
 	}
 add_orig_entry:
 	/* add the new orig_entry (if needed) or update it */
-	batadv_tt_global_orig_entry_add(tt_global_entry, orig_node, ttvn);
+	batadv_tt_global_orig_entry_add(tt_global_entry, orig_node, ttvn,
+					flags & BATADV_TT_SYNC_MASK);
 
 	batadv_dbg(BATADV_DBG_TT, bat_priv,
 		   "Creating new global tt entry: %pM (vid: %d, via %pM)\n",
@@ -2045,6 +2082,7 @@ static uint32_t batadv_tt_global_crc(str
 				     unsigned short vid)
 {
 	struct batadv_hashtable *hash = bat_priv->tt.global_hash;
+	struct batadv_tt_orig_list_entry *tt_orig;
 	struct batadv_tt_common_entry *tt_common;
 	struct batadv_tt_global_entry *tt_global;
 	struct hlist_head *head;
@@ -2083,8 +2121,9 @@ static uint32_t batadv_tt_global_crc(str
 			/* find out if this global entry is announced by this
 			 * originator
 			 */
-			if (!batadv_tt_global_entry_has_orig(tt_global,
-							     orig_node))
+			tt_orig = batadv_tt_global_orig_entry_find(tt_global,
+								   orig_node);
+			if (!tt_orig)
 				continue;
 
 			/* use network order to read the VID: this ensures that
@@ -2096,10 +2135,12 @@ static uint32_t batadv_tt_global_crc(str
 			/* compute the CRC on flags that have to be kept in sync
 			 * among nodes
 			 */
-			flags = tt_common->flags & BATADV_TT_SYNC_MASK;
+			flags = tt_orig->flags;
 			crc_tmp = crc32c(crc_tmp, &flags, sizeof(flags));
 
 			crc ^= crc32c(crc_tmp, tt_common->addr, ETH_ALEN);
+
+			batadv_tt_orig_list_entry_free_ref(tt_orig);
 		}
 		rcu_read_unlock();
 	}
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/batman-adv/types.h linux-libre-3.16.50-gnu/net/batman-adv/types.h
--- linux-libre-3.16.49-gnu/net/batman-adv/types.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/batman-adv/types.h	2017-11-11 08:34:06.000000000 -0500
@@ -968,6 +968,7 @@ struct batadv_tt_global_entry {
  * struct batadv_tt_orig_list_entry - orig node announcing a non-mesh client
  * @orig_node: pointer to orig node announcing this non-mesh client
  * @ttvn: translation table version number which added the non-mesh client
+ * @flags: per orig entry TT sync flags
  * @list: list node for batadv_tt_global_entry::orig_list
  * @refcount: number of contexts the object is used
  * @rcu: struct used for freeing in an RCU-safe manner
@@ -975,6 +976,7 @@ struct batadv_tt_global_entry {
 struct batadv_tt_orig_list_entry {
 	struct batadv_orig_node *orig_node;
 	uint8_t ttvn;
+	u8 flags;
 	struct hlist_node list;
 	atomic_t refcount;
 	struct rcu_head rcu;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/bridge/br_device.c linux-libre-3.16.50-gnu/net/bridge/br_device.c
--- linux-libre-3.16.49-gnu/net/bridge/br_device.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/bridge/br_device.c	2017-11-11 08:34:06.000000000 -0500
@@ -31,10 +31,10 @@ static struct lock_class_key bridge_netd
 netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
 {
 	struct net_bridge *br = netdev_priv(dev);
-	const unsigned char *dest = skb->data;
 	struct net_bridge_fdb_entry *dst;
 	struct net_bridge_mdb_entry *mdst;
 	struct pcpu_sw_netstats *brstats = this_cpu_ptr(br->stats);
+	const unsigned char *dest;
 	u16 vid = 0;
 
 	rcu_read_lock();
@@ -59,6 +59,7 @@ netdev_tx_t br_dev_xmit(struct sk_buff *
 	if (!br_allowed_ingress(br, br_get_vlan_info(br), skb, &vid))
 		goto out;
 
+	dest = eth_hdr(skb)->h_dest;
 	if (is_broadcast_ether_addr(dest))
 		br_flood_deliver(br, skb, false);
 	else if (is_multicast_ether_addr(dest)) {
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/bridge/br_input.c linux-libre-3.16.50-gnu/net/bridge/br_input.c
--- linux-libre-3.16.49-gnu/net/bridge/br_input.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/bridge/br_input.c	2017-11-11 08:34:06.000000000 -0500
@@ -60,11 +60,11 @@ static int br_pass_frame_up(struct sk_bu
 /* note: already called with rcu_read_lock */
 int br_handle_frame_finish(struct sk_buff *skb)
 {
-	const unsigned char *dest = eth_hdr(skb)->h_dest;
 	struct net_bridge_port *p = br_port_get_rcu(skb->dev);
 	struct net_bridge *br;
 	struct net_bridge_fdb_entry *dst;
 	struct net_bridge_mdb_entry *mdst;
+	const unsigned char *dest;
 	struct sk_buff *skb2;
 	bool unicast = true;
 	u16 vid = 0;
@@ -80,6 +80,7 @@ int br_handle_frame_finish(struct sk_buf
 	if (p->flags & BR_LEARNING)
 		br_fdb_update(br, p, eth_hdr(skb)->h_source, vid, false);
 
+	dest = eth_hdr(skb)->h_dest;
 	if (!is_broadcast_ether_addr(dest) && is_multicast_ether_addr(dest) &&
 	    br_multicast_rcv(br, p, skb, vid))
 		goto drop;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/bridge/br_netfilter.c linux-libre-3.16.50-gnu/net/bridge/br_netfilter.c
--- linux-libre-3.16.49-gnu/net/bridge/br_netfilter.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/bridge/br_netfilter.c	2017-11-11 08:34:06.000000000 -0500
@@ -155,7 +155,7 @@ static struct dst_ops fake_dst_ops = {
  * ipt_REJECT needs it.  Future netfilter modules might
  * require us to fill additional fields.
  */
-static const u32 br_dst_default_metrics[RTAX_MAX] = {
+static const u32 br_dst_default_metrics[RTAX_MAX] __aligned(DST_METRICS_ALIGNMENT) = {
 	[RTAX_MTU - 1] = 1500,
 };
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/caif/cfpkt_skbuff.c linux-libre-3.16.50-gnu/net/caif/cfpkt_skbuff.c
--- linux-libre-3.16.49-gnu/net/caif/cfpkt_skbuff.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/caif/cfpkt_skbuff.c	2017-11-11 08:34:06.000000000 -0500
@@ -286,7 +286,7 @@ int cfpkt_setlen(struct cfpkt *pkt, u16
 		else
 			skb_trim(skb, len);
 
-			return cfpkt_getlen(pkt);
+		return cfpkt_getlen(pkt);
 	}
 
 	/* Need to expand SKB */
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/ceph/messenger.c linux-libre-3.16.50-gnu/net/ceph/messenger.c
--- linux-libre-3.16.49-gnu/net/ceph/messenger.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/ceph/messenger.c	2017-11-11 08:34:06.000000000 -0500
@@ -3075,8 +3075,10 @@ static struct ceph_msg_data *ceph_msg_da
 		return NULL;
 
 	data = kmem_cache_zalloc(ceph_msg_data_cache, GFP_NOFS);
-	if (data)
-		data->type = type;
+	if (!data)
+		return NULL;
+
+	data->type = type;
 	INIT_LIST_HEAD(&data->links);
 
 	return data;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/core/dev.c linux-libre-3.16.50-gnu/net/core/dev.c
--- linux-libre-3.16.49-gnu/net/core/dev.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/core/dev.c	2017-11-11 08:34:06.000000000 -0500
@@ -2413,9 +2413,10 @@ EXPORT_SYMBOL(skb_mac_gso_segment);
 static inline bool skb_needs_check(struct sk_buff *skb, bool tx_path)
 {
 	if (tx_path)
-		return skb->ip_summed != CHECKSUM_PARTIAL;
-	else
-		return skb->ip_summed == CHECKSUM_NONE;
+		return skb->ip_summed != CHECKSUM_PARTIAL &&
+		       skb->ip_summed != CHECKSUM_UNNECESSARY;
+
+	return skb->ip_summed == CHECKSUM_NONE;
 }
 
 /**
@@ -2432,13 +2433,14 @@ static inline bool skb_needs_check(struc
 struct sk_buff *__skb_gso_segment(struct sk_buff *skb,
 				  netdev_features_t features, bool tx_path)
 {
+	struct sk_buff *segs;
+
 	if (unlikely(skb_needs_check(skb, tx_path))) {
 		int err;
 
-		skb_warn_bad_offload(skb);
-
-		if (skb_header_cloned(skb) &&
-		    (err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC)))
+		/* We're going to init ->check field in TCP or UDP header */
+		err = skb_cow_head(skb, 0);
+		if (err < 0)
 			return ERR_PTR(err);
 	}
 
@@ -2448,7 +2450,12 @@ struct sk_buff *__skb_gso_segment(struct
 	skb_reset_mac_header(skb);
 	skb_reset_mac_len(skb);
 
-	return skb_mac_gso_segment(skb, features);
+	segs = skb_mac_gso_segment(skb, features);
+
+	if (unlikely(skb_needs_check(skb, tx_path)))
+		skb_warn_bad_offload(skb);
+
+	return segs;
 }
 EXPORT_SYMBOL(__skb_gso_segment);
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/core/dst.c linux-libre-3.16.50-gnu/net/core/dst.c
--- linux-libre-3.16.49-gnu/net/core/dst.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/core/dst.c	2017-11-11 08:34:06.000000000 -0500
@@ -149,13 +149,13 @@ int dst_discard_sk(struct sock *sk, stru
 }
 EXPORT_SYMBOL(dst_discard_sk);
 
-const u32 dst_default_metrics[RTAX_MAX + 1] = {
+const struct dst_metrics dst_default_metrics = {
 	/* This initializer is needed to force linker to place this variable
 	 * into const section. Otherwise it might end into bss section.
 	 * We really want to avoid false sharing on this variable, and catch
 	 * any writes on it.
 	 */
-	[RTAX_MAX] = 0xdeadbeef,
+	.refcnt = ATOMIC_INIT(1),
 };
 
 
@@ -176,7 +176,7 @@ void *dst_alloc(struct dst_ops *ops, str
 	if (dev)
 		dev_hold(dev);
 	dst->ops = ops;
-	dst_init_metrics(dst, dst_default_metrics, true);
+	dst_init_metrics(dst, dst_default_metrics.metrics, true);
 	dst->expires = 0UL;
 	dst->path = dst;
 	dst->from = NULL;
@@ -292,27 +292,46 @@ void dst_release(struct dst_entry *dst)
 }
 EXPORT_SYMBOL(dst_release);
 
+static struct kmem_cache *metrics_cache;
+
+void *dst_alloc_metrics(gfp_t flags)
+{
+	return kmem_cache_alloc(metrics_cache, flags);
+}
+EXPORT_SYMBOL(dst_alloc_metrics);
+
+void dst_free_metrics(void *metrics)
+{
+	kmem_cache_free(metrics_cache, metrics);
+}
+EXPORT_SYMBOL(dst_free_metrics);
+
 u32 *dst_cow_metrics_generic(struct dst_entry *dst, unsigned long old)
 {
-	u32 *p = kmalloc(sizeof(u32) * RTAX_MAX, GFP_ATOMIC);
+	struct dst_metrics *p = dst_alloc_metrics(GFP_ATOMIC);
 
 	if (p) {
-		u32 *old_p = __DST_METRICS_PTR(old);
+		struct dst_metrics *old_p = (struct dst_metrics *)__DST_METRICS_PTR(old);
 		unsigned long prev, new;
 
-		memcpy(p, old_p, sizeof(u32) * RTAX_MAX);
+		atomic_set(&p->refcnt, 1);
+		memcpy(p->metrics, old_p->metrics, sizeof(p->metrics));
 
 		new = (unsigned long) p;
 		prev = cmpxchg(&dst->_metrics, old, new);
 
 		if (prev != old) {
-			kfree(p);
-			p = __DST_METRICS_PTR(prev);
+			dst_free_metrics(p);
+			p = (struct dst_metrics *)__DST_METRICS_PTR(prev);
 			if (prev & DST_METRICS_READ_ONLY)
 				p = NULL;
+		} else if (prev & DST_METRICS_REFCOUNTED) {
+			if (atomic_dec_and_test(&old_p->refcnt))
+				dst_free_metrics(old_p);
 		}
 	}
-	return p;
+	BUILD_BUG_ON(offsetof(struct dst_metrics, metrics) != 0);
+	return (u32 *)p;
 }
 EXPORT_SYMBOL(dst_cow_metrics_generic);
 
@@ -321,10 +340,10 @@ void __dst_destroy_metrics_generic(struc
 {
 	unsigned long prev, new;
 
-	new = ((unsigned long) dst_default_metrics) | DST_METRICS_READ_ONLY;
+	new = ((unsigned long) &dst_default_metrics) | DST_METRICS_READ_ONLY;
 	prev = cmpxchg(&dst->_metrics, old, new);
 	if (prev == old)
-		kfree(__DST_METRICS_PTR(old));
+		dst_free_metrics(__DST_METRICS_PTR(old));
 }
 EXPORT_SYMBOL(__dst_destroy_metrics_generic);
 
@@ -419,4 +438,8 @@ static struct notifier_block dst_dev_not
 void __init dst_init(void)
 {
 	register_netdevice_notifier(&dst_dev_notifier);
+	metrics_cache = kmem_cache_create("dst_metrics",
+					  sizeof(struct dst_metrics),
+					  DST_METRICS_ALIGNMENT,
+					  SLAB_PANIC, NULL);
 }
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/core/pktgen.c linux-libre-3.16.50-gnu/net/core/pktgen.c
--- linux-libre-3.16.49-gnu/net/core/pktgen.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/core/pktgen.c	2017-11-11 08:34:06.000000000 -0500
@@ -2502,7 +2502,7 @@ static void mod_cur_headers(struct pktge
 
 
 #ifdef CONFIG_XFRM
-static u32 pktgen_dst_metrics[RTAX_MAX + 1] = {
+static u32 pktgen_dst_metrics[RTAX_MAX + 1] __aligned(DST_METRICS_ALIGNMENT) = {
 
 	[RTAX_HOPLIMIT] = 0x5, /* Set a static hoplimit */
 };
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/ipv4/fib_frontend.c linux-libre-3.16.50-gnu/net/ipv4/fib_frontend.c
--- linux-libre-3.16.49-gnu/net/ipv4/fib_frontend.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/ipv4/fib_frontend.c	2017-11-11 08:34:06.000000000 -0500
@@ -1175,13 +1175,14 @@ static struct pernet_operations fib_net_
 
 void __init ip_fib_init(void)
 {
-	rtnl_register(PF_INET, RTM_NEWROUTE, inet_rtm_newroute, NULL, NULL);
-	rtnl_register(PF_INET, RTM_DELROUTE, inet_rtm_delroute, NULL, NULL);
-	rtnl_register(PF_INET, RTM_GETROUTE, NULL, inet_dump_fib, NULL);
+	fib_trie_init();
 
 	register_pernet_subsys(&fib_net_ops);
+
 	register_netdevice_notifier(&fib_netdev_notifier);
 	register_inetaddr_notifier(&fib_inetaddr_notifier);
 
-	fib_trie_init();
+	rtnl_register(PF_INET, RTM_NEWROUTE, inet_rtm_newroute, NULL, NULL);
+	rtnl_register(PF_INET, RTM_DELROUTE, inet_rtm_delroute, NULL, NULL);
+	rtnl_register(PF_INET, RTM_GETROUTE, NULL, inet_dump_fib, NULL);
 }
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/ipv4/fib_semantics.c linux-libre-3.16.50-gnu/net/ipv4/fib_semantics.c
--- linux-libre-3.16.49-gnu/net/ipv4/fib_semantics.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/ipv4/fib_semantics.c	2017-11-11 08:34:06.000000000 -0500
@@ -201,6 +201,7 @@ static void rt_fibinfo_free_cpus(struct
 static void free_fib_info_rcu(struct rcu_head *head)
 {
 	struct fib_info *fi = container_of(head, struct fib_info, rcu);
+	struct dst_metrics *m;
 
 	change_nexthops(fi) {
 		if (nexthop_nh->nh_dev)
@@ -212,8 +213,9 @@ static void free_fib_info_rcu(struct rcu
 	} endfor_nexthops(fi);
 
 	release_net(fi->fib_net);
-	if (fi->fib_metrics != (u32 *) dst_default_metrics)
-		kfree(fi->fib_metrics);
+	m = fi->fib_metrics;
+	if (m != &dst_default_metrics && atomic_dec_and_test(&m->refcnt))
+		dst_free_metrics(m);
 	kfree(fi);
 }
 
@@ -821,14 +823,17 @@ struct fib_info *fib_create_info(struct
 	fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL);
 	if (fi == NULL)
 		goto failure;
-	fib_info_cnt++;
 	if (cfg->fc_mx) {
-		fi->fib_metrics = kzalloc(sizeof(u32) * RTAX_MAX, GFP_KERNEL);
-		if (!fi->fib_metrics)
-			goto failure;
-	} else
-		fi->fib_metrics = (u32 *) dst_default_metrics;
-
+		fi->fib_metrics = dst_alloc_metrics(GFP_KERNEL | __GFP_ZERO);
+		if (unlikely(!fi->fib_metrics)) {
+			kfree(fi);
+			return ERR_PTR(err);
+		}
+		atomic_set(&fi->fib_metrics->refcnt, 1);
+	} else {
+		fi->fib_metrics = (struct dst_metrics *)&dst_default_metrics;
+	}
+	fib_info_cnt++;
 	fi->fib_net = hold_net(net);
 	fi->fib_protocol = cfg->fc_protocol;
 	fi->fib_scope = cfg->fc_scope;
@@ -864,7 +869,7 @@ struct fib_info *fib_create_info(struct
 					val = 65535 - 15;
 				if (type == RTAX_HOPLIMIT && val > 255)
 					val = 255;
-				fi->fib_metrics[type - 1] = val;
+				fi->fib_metrics->metrics[type - 1] = val;
 			}
 		}
 	}
@@ -1029,7 +1034,7 @@ int fib_dump_info(struct sk_buff *skb, u
 	if (fi->fib_priority &&
 	    nla_put_u32(skb, RTA_PRIORITY, fi->fib_priority))
 		goto nla_put_failure;
-	if (rtnetlink_put_metrics(skb, fi->fib_metrics) < 0)
+	if (rtnetlink_put_metrics(skb, fi->fib_metrics->metrics) < 0)
 		goto nla_put_failure;
 
 	if (fi->fib_prefsrc &&
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/ipv4/netfilter/ipt_CLUSTERIP.c linux-libre-3.16.50-gnu/net/ipv4/netfilter/ipt_CLUSTERIP.c
--- linux-libre-3.16.49-gnu/net/ipv4/netfilter/ipt_CLUSTERIP.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/ipv4/netfilter/ipt_CLUSTERIP.c	2017-11-11 08:34:06.000000000 -0500
@@ -115,7 +115,8 @@ clusterip_config_entry_put(struct cluste
 		 * functions are also incrementing the refcount on their own,
 		 * so it's safe to remove the entry even if it's in use. */
 #ifdef CONFIG_PROC_FS
-		proc_remove(c->pde);
+		if (cn->procdir)
+			proc_remove(c->pde);
 #endif
 		return;
 	}
@@ -735,6 +736,7 @@ static void clusterip_net_exit(struct ne
 #ifdef CONFIG_PROC_FS
 	struct clusterip_net *cn = net_generic(net, clusterip_net_id);
 	proc_remove(cn->procdir);
+	cn->procdir = NULL;
 #endif
 }
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/ipv4/netfilter/nft_reject_ipv4.c linux-libre-3.16.50-gnu/net/ipv4/netfilter/nft_reject_ipv4.c
--- linux-libre-3.16.49-gnu/net/ipv4/netfilter/nft_reject_ipv4.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/ipv4/netfilter/nft_reject_ipv4.c	2017-11-11 08:34:06.000000000 -0500
@@ -33,6 +33,8 @@ void nft_reject_ipv4_eval(const struct n
 	case NFT_REJECT_TCP_RST:
 		nf_send_reset(pkt->skb, pkt->ops->hooknum);
 		break;
+	default:
+		break;
 	}
 
 	data[NFT_REG_VERDICT].verdict = NF_DROP;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/ipv4/route.c linux-libre-3.16.50-gnu/net/ipv4/route.c
--- linux-libre-3.16.49-gnu/net/ipv4/route.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/ipv4/route.c	2017-11-11 08:34:06.000000000 -0500
@@ -1344,8 +1344,12 @@ static void rt_add_uncached_list(struct
 
 static void ipv4_dst_destroy(struct dst_entry *dst)
 {
+	struct dst_metrics *p = (struct dst_metrics *)DST_METRICS_PTR(dst);
 	struct rtable *rt = (struct rtable *) dst;
 
+	if (p != &dst_default_metrics && atomic_dec_and_test(&p->refcnt))
+		dst_free_metrics(p);
+
 	if (!list_empty(&rt->rt_uncached)) {
 		spin_lock_bh(&rt_uncached_lock);
 		list_del(&rt->rt_uncached);
@@ -1392,7 +1396,11 @@ static void rt_set_nexthop(struct rtable
 			rt->rt_gateway = nh->nh_gw;
 			rt->rt_uses_gateway = 1;
 		}
-		dst_init_metrics(&rt->dst, fi->fib_metrics, true);
+		dst_init_metrics(&rt->dst, fi->fib_metrics->metrics, true);
+		if (fi->fib_metrics != &dst_default_metrics) {
+			rt->dst._metrics |= DST_METRICS_REFCOUNTED;
+			atomic_inc(&fi->fib_metrics->refcnt);
+		}
 #ifdef CONFIG_IP_ROUTE_CLASSID
 		rt->dst.tclassid = nh->nh_tclassid;
 #endif
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/ipv4/udp_offload.c linux-libre-3.16.50-gnu/net/ipv4/udp_offload.c
--- linux-libre-3.16.49-gnu/net/ipv4/udp_offload.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/ipv4/udp_offload.c	2017-11-11 08:34:06.000000000 -0500
@@ -93,7 +93,7 @@ static struct sk_buff *udp4_ufo_fragment
 	csum = skb_checksum(skb, offset, skb->len - offset, 0);
 	offset += skb->csum_offset;
 	*(__sum16 *)(skb->data + offset) = csum_fold(csum);
-	skb->ip_summed = CHECKSUM_NONE;
+	skb->ip_summed = CHECKSUM_UNNECESSARY;
 
 	/* Fragment the skb. IP headers of the fragments are updated in
 	 * inet_gso_segment()
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/ipv6/addrconf.c linux-libre-3.16.50-gnu/net/ipv6/addrconf.c
--- linux-libre-3.16.49-gnu/net/ipv6/addrconf.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/ipv6/addrconf.c	2017-11-11 08:34:06.000000000 -0500
@@ -4737,7 +4737,7 @@ static void __ipv6_ifa_notify(int event,
 		 * our DAD process, so we don't need
 		 * to do it again
 		 */
-		if (!(ifp->rt->rt6i_node))
+		if (!rcu_access_pointer(ifp->rt->rt6i_node))
 			ip6_ins_rt(ifp->rt);
 		if (ifp->idev->cnf.forwarding)
 			addrconf_join_anycast(ifp);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/ipv6/ip6_fib.c linux-libre-3.16.50-gnu/net/ipv6/ip6_fib.c
--- linux-libre-3.16.49-gnu/net/ipv6/ip6_fib.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/ipv6/ip6_fib.c	2017-11-11 08:34:06.000000000 -0500
@@ -151,11 +151,23 @@ static __inline__ struct fib6_node *node
 	return fn;
 }
 
-static __inline__ void node_free(struct fib6_node *fn)
+static void node_free_immediate(struct fib6_node *fn)
+{
+	kmem_cache_free(fib6_node_kmem, fn);
+}
+
+static void node_free_rcu(struct rcu_head *head)
 {
+	struct fib6_node *fn = container_of(head, struct fib6_node, rcu);
+
 	kmem_cache_free(fib6_node_kmem, fn);
 }
 
+static void node_free(struct fib6_node *fn)
+{
+	call_rcu(&fn->rcu, node_free_rcu);
+}
+
 static __inline__ void rt6_release(struct rt6_info *rt)
 {
 	if (atomic_dec_and_test(&rt->rt6i_ref))
@@ -551,9 +563,9 @@ insert_above:
 
 		if (!in || !ln) {
 			if (in)
-				node_free(in);
+				node_free_immediate(in);
 			if (ln)
-				node_free(ln);
+				node_free_immediate(ln);
 			return ERR_PTR(-ENOMEM);
 		}
 
@@ -643,7 +655,7 @@ static int fib6_commit_metrics(struct ds
 	if (dst->flags & DST_HOST) {
 		mp = dst_metrics_write_ptr(dst);
 	} else {
-		mp = kzalloc(sizeof(u32) * RTAX_MAX, GFP_ATOMIC);
+		mp = dst_alloc_metrics(GFP_ATOMIC | __GFP_ZERO);
 		if (!mp)
 			return -ENOMEM;
 		dst_init_metrics(dst, mp, 0);
@@ -824,7 +836,7 @@ add:
 		}
 		rt->dst.rt6_next = iter;
 		*ins = rt;
-		rt->rt6i_node = fn;
+		rcu_assign_pointer(rt->rt6i_node, fn);
 		atomic_inc(&rt->rt6i_ref);
 		inet6_rt_notify(RTM_NEWROUTE, rt, info);
 		info->nl_net->ipv6.rt6_stats->fib_rt_entries++;
@@ -849,7 +861,7 @@ add:
 				return err;
 		}
 		*ins = rt;
-		rt->rt6i_node = fn;
+		rcu_assign_pointer(rt->rt6i_node, fn);
 		rt->dst.rt6_next = iter->dst.rt6_next;
 		atomic_inc(&rt->rt6i_ref);
 		inet6_rt_notify(RTM_NEWROUTE, rt, info);
@@ -859,6 +871,8 @@ add:
 		}
 		nsiblings = iter->rt6i_nsiblings;
 		fib6_purge_rt(iter, fn, info->nl_net);
+		if (fn->rr_ptr == iter)
+			fn->rr_ptr = NULL;
 		rt6_release(iter);
 
 		if (nsiblings) {
@@ -871,6 +885,8 @@ add:
 				if (rt6_qualify_for_ecmp(iter)) {
 					*ins = iter->dst.rt6_next;
 					fib6_purge_rt(iter, fn, info->nl_net);
+					if (fn->rr_ptr == iter)
+						fn->rr_ptr = NULL;
 					rt6_release(iter);
 					nsiblings--;
 				} else {
@@ -973,7 +989,7 @@ int fib6_add(struct fib6_node *root, str
 				   root, and then (in st_failure) stale node
 				   in main tree.
 				 */
-				node_free(sfn);
+				node_free_immediate(sfn);
 				err = PTR_ERR(sn);
 				goto st_failure;
 			}
@@ -1397,8 +1413,9 @@ static void fib6_del_route(struct fib6_n
 
 int fib6_del(struct rt6_info *rt, struct nl_info *info)
 {
+	struct fib6_node *fn = rcu_dereference_protected(rt->rt6i_node,
+				    lockdep_is_held(&rt->rt6i_table->tb6_lock));
 	struct net *net = info->nl_net;
-	struct fib6_node *fn = rt->rt6i_node;
 	struct rt6_info **rtp;
 
 #if RT6_DEBUG >= 2
@@ -1577,7 +1594,9 @@ static int fib6_clean_node(struct fib6_w
 			if (res) {
 #if RT6_DEBUG >= 2
 				pr_debug("%s: del failed: rt=%p@%p err=%d\n",
-					 __func__, rt, rt->rt6i_node, res);
+					 __func__, rt,
+					 rcu_access_pointer(rt->rt6i_node),
+					 res);
 #endif
 				continue;
 			}
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/ipv6/ip6_tunnel.c linux-libre-3.16.50-gnu/net/ipv6/ip6_tunnel.c
--- linux-libre-3.16.49-gnu/net/ipv6/ip6_tunnel.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/ipv6/ip6_tunnel.c	2017-11-11 08:34:06.000000000 -0500
@@ -157,7 +157,7 @@ EXPORT_SYMBOL_GPL(ip6_tnl_dst_reset);
 void ip6_tnl_dst_store(struct ip6_tnl *t, struct dst_entry *dst)
 {
 	struct rt6_info *rt = (struct rt6_info *) dst;
-	t->dst_cookie = rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
+	t->dst_cookie = rt6_get_cookie(rt);
 	dst_release(t->dst_cache);
 	t->dst_cache = dst;
 }
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/ipv6/netfilter/nft_reject_ipv6.c linux-libre-3.16.50-gnu/net/ipv6/netfilter/nft_reject_ipv6.c
--- linux-libre-3.16.49-gnu/net/ipv6/netfilter/nft_reject_ipv6.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/ipv6/netfilter/nft_reject_ipv6.c	2017-11-11 08:34:06.000000000 -0500
@@ -34,6 +34,8 @@ void nft_reject_ipv6_eval(const struct n
 	case NFT_REJECT_TCP_RST:
 		nf_send_reset6(net, pkt->skb, pkt->ops->hooknum);
 		break;
+	default:
+		break;
 	}
 
 	data[NFT_REG_VERDICT].verdict = NF_DROP;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/ipv6/output_core.c linux-libre-3.16.50-gnu/net/ipv6/output_core.c
--- linux-libre-3.16.49-gnu/net/ipv6/output_core.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/ipv6/output_core.c	2017-11-11 08:34:06.000000000 -0500
@@ -52,7 +52,6 @@ int ip6_find_1stfragopt(struct sk_buff *
 
 	while (offset <= packet_len) {
 		struct ipv6_opt_hdr *exthdr;
-		unsigned int len;
 
 		switch (**nexthdr) {
 
@@ -78,10 +77,9 @@ int ip6_find_1stfragopt(struct sk_buff *
 
 		exthdr = (struct ipv6_opt_hdr *)(skb_network_header(skb) +
 						 offset);
-		len = ipv6_optlen(exthdr);
-		if (len + offset >= IPV6_MAXPLEN)
+		offset += ipv6_optlen(exthdr);
+		if (offset > IPV6_MAXPLEN)
 			return -EINVAL;
-		offset += len;
 		*nexthdr = &exthdr->nexthdr;
 	}
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/ipv6/route.c linux-libre-3.16.50-gnu/net/ipv6/route.c
--- linux-libre-3.16.49-gnu/net/ipv6/route.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/ipv6/route.c	2017-11-11 08:34:06.000000000 -0500
@@ -247,7 +247,7 @@ static struct dst_ops ip6_dst_blackhole_
 	.neigh_lookup		=	ip6_neigh_lookup,
 };
 
-static const u32 ip6_template_metrics[RTAX_MAX] = {
+static const u32 ip6_template_metrics[RTAX_MAX] __aligned(DST_METRICS_ALIGNMENT) = {
 	[RTAX_HOPLIMIT - 1] = 0,
 };
 
@@ -1090,6 +1090,7 @@ struct dst_entry *ip6_blackhole_route(st
 static struct dst_entry *ip6_dst_check(struct dst_entry *dst, u32 cookie)
 {
 	struct rt6_info *rt;
+	u32 rt_cookie = 0;
 
 	rt = (struct rt6_info *) dst;
 
@@ -1097,7 +1098,7 @@ static struct dst_entry *ip6_dst_check(s
 	 * DST_OBSOLETE_FORCE_CHK which forces validation calls down
 	 * into this function always.
 	 */
-	if (!rt->rt6i_node || (rt->rt6i_node->fn_sernum != cookie))
+	if (!rt6_get_cookie_safe(rt, &rt_cookie) || rt_cookie != cookie)
 		return NULL;
 
 	if (rt6_check_expired(rt))
@@ -1136,8 +1137,14 @@ static void ip6_link_failure(struct sk_b
 			dst_hold(&rt->dst);
 			if (ip6_del_rt(rt))
 				dst_free(&rt->dst);
-		} else if (rt->rt6i_node && (rt->rt6i_flags & RTF_DEFAULT)) {
-			rt->rt6i_node->fn_sernum = -1;
+		} else {
+			struct fib6_node *fn;
+
+			rcu_read_lock();
+			fn = rcu_dereference(rt->rt6i_node);
+			if (fn && (rt->rt6i_flags & RTF_DEFAULT))
+				fn->fn_sernum = -1;
+			rcu_read_unlock();
 		}
 	}
 }
@@ -1843,6 +1850,7 @@ static void rt6_do_redirect(struct dst_e
 	if (on_link)
 		nrt->rt6i_flags &= ~RTF_GATEWAY;
 
+	nrt->rt6i_protocol = RTPROT_REDIRECT;
 	nrt->rt6i_gateway = *(struct in6_addr *)neigh->primary_key;
 
 	if (ip6_ins_rt(nrt))
@@ -1950,6 +1958,7 @@ static struct rt6_info *rt6_add_route_in
 		.fc_dst_len	= prefixlen,
 		.fc_flags	= RTF_GATEWAY | RTF_ADDRCONF | RTF_ROUTEINFO |
 				  RTF_UP | RTF_PREF(pref),
+		.fc_protocol = RTPROT_RA,
 		.fc_nlinfo.portid = 0,
 		.fc_nlinfo.nlh = NULL,
 		.fc_nlinfo.nl_net = net,
@@ -2000,6 +2009,7 @@ struct rt6_info *rt6_add_dflt_router(con
 		.fc_ifindex	= dev->ifindex,
 		.fc_flags	= RTF_GATEWAY | RTF_ADDRCONF | RTF_DEFAULT |
 				  RTF_UP | RTF_EXPIRES | RTF_PREF(pref),
+		.fc_protocol = RTPROT_RA,
 		.fc_nlinfo.portid = 0,
 		.fc_nlinfo.nlh = NULL,
 		.fc_nlinfo.nl_net = dev_net(dev),
@@ -2591,14 +2601,6 @@ static int rt6_fill_node(struct net *net
 	rtm->rtm_flags = 0;
 	rtm->rtm_scope = RT_SCOPE_UNIVERSE;
 	rtm->rtm_protocol = rt->rt6i_protocol;
-	if (rt->rt6i_flags & RTF_DYNAMIC)
-		rtm->rtm_protocol = RTPROT_REDIRECT;
-	else if (rt->rt6i_flags & RTF_ADDRCONF) {
-		if (rt->rt6i_flags & (RTF_DEFAULT | RTF_ROUTEINFO))
-			rtm->rtm_protocol = RTPROT_RA;
-		else
-			rtm->rtm_protocol = RTPROT_KERNEL;
-	}
 
 	if (rt->rt6i_flags & RTF_CACHE)
 		rtm->rtm_flags |= RTM_F_CLONED;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/ipv6/tcp_ipv6.c linux-libre-3.16.50-gnu/net/ipv6/tcp_ipv6.c
--- linux-libre-3.16.49-gnu/net/ipv6/tcp_ipv6.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/ipv6/tcp_ipv6.c	2017-11-11 08:34:06.000000000 -0500
@@ -98,8 +98,7 @@ static void inet6_sk_rx_dst_set(struct s
 	dst_hold(dst);
 	sk->sk_rx_dst = dst;
 	inet_sk(sk)->rx_dst_ifindex = skb->skb_iif;
-	if (rt->rt6i_node)
-		inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
+	inet6_sk(sk)->rx_dst_cookie = rt6_get_cookie(rt);
 }
 
 static void tcp_v6_hash(struct sock *sk)
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/ipv6/udp_offload.c linux-libre-3.16.50-gnu/net/ipv6/udp_offload.c
--- linux-libre-3.16.49-gnu/net/ipv6/udp_offload.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/ipv6/udp_offload.c	2017-11-11 08:34:06.000000000 -0500
@@ -90,7 +90,7 @@ static struct sk_buff *udp6_ufo_fragment
 		csum = skb_checksum(skb, offset, skb->len - offset, 0);
 		offset += skb->csum_offset;
 		*(__sum16 *)(skb->data + offset) = csum_fold(csum);
-		skb->ip_summed = CHECKSUM_NONE;
+		skb->ip_summed = CHECKSUM_UNNECESSARY;
 
 		/* Check if there is enough headroom to insert fragment header. */
 		tnl_hlen = skb_tnl_header_len(skb);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/ipv6/xfrm6_policy.c linux-libre-3.16.50-gnu/net/ipv6/xfrm6_policy.c
--- linux-libre-3.16.49-gnu/net/ipv6/xfrm6_policy.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/ipv6/xfrm6_policy.c	2017-11-11 08:34:06.000000000 -0500
@@ -85,8 +85,7 @@ static int xfrm6_init_path(struct xfrm_d
 {
 	if (dst->ops->family == AF_INET6) {
 		struct rt6_info *rt = (struct rt6_info*)dst;
-		if (rt->rt6i_node)
-			path->path_cookie = rt->rt6i_node->fn_sernum;
+		path->path_cookie = rt6_get_cookie(rt);
 	}
 
 	path->u.rt6.rt6i_nfheader_len = nfheader_len;
@@ -116,8 +115,7 @@ static int xfrm6_fill_dst(struct xfrm_ds
 						   RTF_LOCAL);
 	xdst->u.rt6.rt6i_metric = rt->rt6i_metric;
 	xdst->u.rt6.rt6i_node = rt->rt6i_node;
-	if (rt->rt6i_node)
-		xdst->route_cookie = rt->rt6i_node->fn_sernum;
+	xdst->route_cookie = rt6_get_cookie(rt);
 	xdst->u.rt6.rt6i_gateway = rt->rt6i_gateway;
 	xdst->u.rt6.rt6i_dst = rt->rt6i_dst;
 	xdst->u.rt6.rt6i_src = rt->rt6i_src;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/key/af_key.c linux-libre-3.16.50-gnu/net/key/af_key.c
--- linux-libre-3.16.49-gnu/net/key/af_key.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/key/af_key.c	2017-11-11 08:34:06.000000000 -0500
@@ -224,7 +224,7 @@ static int pfkey_broadcast_one(struct sk
 #define BROADCAST_ONE		1
 #define BROADCAST_REGISTERED	2
 #define BROADCAST_PROMISC_ONLY	4
-static int pfkey_broadcast(struct sk_buff *skb,
+static int pfkey_broadcast(struct sk_buff *skb, gfp_t allocation,
 			   int broadcast_flags, struct sock *one_sk,
 			   struct net *net)
 {
@@ -274,7 +274,7 @@ static int pfkey_broadcast(struct sk_buf
 	rcu_read_unlock();
 
 	if (one_sk != NULL)
-		err = pfkey_broadcast_one(skb, &skb2, GFP_KERNEL, one_sk);
+		err = pfkey_broadcast_one(skb, &skb2, allocation, one_sk);
 
 	kfree_skb(skb2);
 	kfree_skb(skb);
@@ -307,7 +307,7 @@ static int pfkey_do_dump(struct pfkey_so
 		hdr = (struct sadb_msg *) pfk->dump.skb->data;
 		hdr->sadb_msg_seq = 0;
 		hdr->sadb_msg_errno = rc;
-		pfkey_broadcast(pfk->dump.skb, BROADCAST_ONE,
+		pfkey_broadcast(pfk->dump.skb, GFP_ATOMIC, BROADCAST_ONE,
 				&pfk->sk, sock_net(&pfk->sk));
 		pfk->dump.skb = NULL;
 	}
@@ -351,7 +351,7 @@ static int pfkey_error(const struct sadb
 	hdr->sadb_msg_len = (sizeof(struct sadb_msg) /
 			     sizeof(uint64_t));
 
-	pfkey_broadcast(skb, BROADCAST_ONE, sk, sock_net(sk));
+	pfkey_broadcast(skb, GFP_KERNEL, BROADCAST_ONE, sk, sock_net(sk));
 
 	return 0;
 }
@@ -1394,7 +1394,7 @@ static int pfkey_getspi(struct sock *sk,
 
 	xfrm_state_put(x);
 
-	pfkey_broadcast(resp_skb, BROADCAST_ONE, sk, net);
+	pfkey_broadcast(resp_skb, GFP_KERNEL, BROADCAST_ONE, sk, net);
 
 	return 0;
 }
@@ -1481,7 +1481,7 @@ static int key_notify_sa(struct xfrm_sta
 	hdr->sadb_msg_seq = c->seq;
 	hdr->sadb_msg_pid = c->portid;
 
-	pfkey_broadcast(skb, BROADCAST_ALL, NULL, xs_net(x));
+	pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL, xs_net(x));
 
 	return 0;
 }
@@ -1594,7 +1594,7 @@ static int pfkey_get(struct sock *sk, st
 	out_hdr->sadb_msg_reserved = 0;
 	out_hdr->sadb_msg_seq = hdr->sadb_msg_seq;
 	out_hdr->sadb_msg_pid = hdr->sadb_msg_pid;
-	pfkey_broadcast(out_skb, BROADCAST_ONE, sk, sock_net(sk));
+	pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ONE, sk, sock_net(sk));
 
 	return 0;
 }
@@ -1699,8 +1699,8 @@ static int pfkey_register(struct sock *s
 		return -ENOBUFS;
 	}
 
-	pfkey_broadcast(supp_skb, BROADCAST_REGISTERED, sk, sock_net(sk));
-
+	pfkey_broadcast(supp_skb, GFP_KERNEL, BROADCAST_REGISTERED, sk,
+			sock_net(sk));
 	return 0;
 }
 
@@ -1718,7 +1718,8 @@ static int unicast_flush_resp(struct soc
 	hdr->sadb_msg_errno = (uint8_t) 0;
 	hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t));
 
-	return pfkey_broadcast(skb, BROADCAST_ONE, sk, sock_net(sk));
+	return pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ONE, sk,
+			       sock_net(sk));
 }
 
 static int key_notify_sa_flush(const struct km_event *c)
@@ -1739,7 +1740,7 @@ static int key_notify_sa_flush(const str
 	hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t));
 	hdr->sadb_msg_reserved = 0;
 
-	pfkey_broadcast(skb, BROADCAST_ALL, NULL, c->net);
+	pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL, c->net);
 
 	return 0;
 }
@@ -1796,7 +1797,7 @@ static int dump_sa(struct xfrm_state *x,
 	out_hdr->sadb_msg_pid = pfk->dump.msg_portid;
 
 	if (pfk->dump.skb)
-		pfkey_broadcast(pfk->dump.skb, BROADCAST_ONE,
+		pfkey_broadcast(pfk->dump.skb, GFP_ATOMIC, BROADCAST_ONE,
 				&pfk->sk, sock_net(&pfk->sk));
 	pfk->dump.skb = out_skb;
 
@@ -1884,7 +1885,7 @@ static int pfkey_promisc(struct sock *sk
 		new_hdr->sadb_msg_errno = 0;
 	}
 
-	pfkey_broadcast(skb, BROADCAST_ALL, NULL, sock_net(sk));
+	pfkey_broadcast(skb, GFP_KERNEL, BROADCAST_ALL, NULL, sock_net(sk));
 	return 0;
 }
 
@@ -2218,7 +2219,7 @@ static int key_notify_policy(struct xfrm
 	out_hdr->sadb_msg_errno = 0;
 	out_hdr->sadb_msg_seq = c->seq;
 	out_hdr->sadb_msg_pid = c->portid;
-	pfkey_broadcast(out_skb, BROADCAST_ALL, NULL, xp_net(xp));
+	pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ALL, NULL, xp_net(xp));
 	return 0;
 
 }
@@ -2438,7 +2439,7 @@ static int key_pol_get_resp(struct sock
 	out_hdr->sadb_msg_errno = 0;
 	out_hdr->sadb_msg_seq = hdr->sadb_msg_seq;
 	out_hdr->sadb_msg_pid = hdr->sadb_msg_pid;
-	pfkey_broadcast(out_skb, BROADCAST_ONE, sk, xp_net(xp));
+	pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ONE, sk, xp_net(xp));
 	err = 0;
 
 out:
@@ -2692,7 +2693,7 @@ static int dump_sp(struct xfrm_policy *x
 	out_hdr->sadb_msg_pid = pfk->dump.msg_portid;
 
 	if (pfk->dump.skb)
-		pfkey_broadcast(pfk->dump.skb, BROADCAST_ONE,
+		pfkey_broadcast(pfk->dump.skb, GFP_ATOMIC, BROADCAST_ONE,
 				&pfk->sk, sock_net(&pfk->sk));
 	pfk->dump.skb = out_skb;
 
@@ -2749,7 +2750,7 @@ static int key_notify_policy_flush(const
 	hdr->sadb_msg_satype = SADB_SATYPE_UNSPEC;
 	hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t));
 	hdr->sadb_msg_reserved = 0;
-	pfkey_broadcast(skb_out, BROADCAST_ALL, NULL, c->net);
+	pfkey_broadcast(skb_out, GFP_ATOMIC, BROADCAST_ALL, NULL, c->net);
 	return 0;
 
 }
@@ -2811,7 +2812,7 @@ static int pfkey_process(struct sock *sk
 	void *ext_hdrs[SADB_EXT_MAX];
 	int err;
 
-	pfkey_broadcast(skb_clone(skb, GFP_KERNEL),
+	pfkey_broadcast(skb_clone(skb, GFP_KERNEL), GFP_KERNEL,
 			BROADCAST_PROMISC_ONLY, NULL, sock_net(sk));
 
 	memset(ext_hdrs, 0, sizeof(ext_hdrs));
@@ -3033,7 +3034,8 @@ static int key_notify_sa_expire(struct x
 	out_hdr->sadb_msg_seq = 0;
 	out_hdr->sadb_msg_pid = 0;
 
-	pfkey_broadcast(out_skb, BROADCAST_REGISTERED, NULL, xs_net(x));
+	pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_REGISTERED, NULL,
+			xs_net(x));
 	return 0;
 }
 
@@ -3223,7 +3225,8 @@ static int pfkey_send_acquire(struct xfr
 		       xfrm_ctx->ctx_len);
 	}
 
-	return pfkey_broadcast(skb, BROADCAST_REGISTERED, NULL, xs_net(x));
+	return pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_REGISTERED, NULL,
+			       xs_net(x));
 }
 
 static struct xfrm_policy *pfkey_compile_policy(struct sock *sk, int opt,
@@ -3421,7 +3424,8 @@ static int pfkey_send_new_mapping(struct
 	n_port->sadb_x_nat_t_port_port = sport;
 	n_port->sadb_x_nat_t_port_reserved = 0;
 
-	return pfkey_broadcast(skb, BROADCAST_REGISTERED, NULL, xs_net(x));
+	return pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_REGISTERED, NULL,
+			       xs_net(x));
 }
 
 #ifdef CONFIG_NET_KEY_MIGRATE
@@ -3613,7 +3617,7 @@ static int pfkey_send_migrate(const stru
 	}
 
 	/* broadcast migrate message to sockets */
-	pfkey_broadcast(skb, BROADCAST_ALL, NULL, &init_net);
+	pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL, &init_net);
 
 	return 0;
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/l2tp/l2tp_core.c linux-libre-3.16.50-gnu/net/l2tp/l2tp_core.c
--- linux-libre-3.16.49-gnu/net/l2tp/l2tp_core.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/l2tp/l2tp_core.c	2017-11-11 08:34:06.000000000 -0500
@@ -112,53 +112,19 @@ struct l2tp_net {
 	spinlock_t l2tp_session_hlist_lock;
 };
 
-static void l2tp_tunnel_free(struct l2tp_tunnel *tunnel);
 
 static inline struct l2tp_tunnel *l2tp_tunnel(struct sock *sk)
 {
 	return sk->sk_user_data;
 }
 
-static inline struct l2tp_net *l2tp_pernet(struct net *net)
+static inline struct l2tp_net *l2tp_pernet(const struct net *net)
 {
 	BUG_ON(!net);
 
 	return net_generic(net, l2tp_net_id);
 }
 
-/* Tunnel reference counts. Incremented per session that is added to
- * the tunnel.
- */
-static inline void l2tp_tunnel_inc_refcount_1(struct l2tp_tunnel *tunnel)
-{
-	atomic_inc(&tunnel->ref_count);
-}
-
-static inline void l2tp_tunnel_dec_refcount_1(struct l2tp_tunnel *tunnel)
-{
-	if (atomic_dec_and_test(&tunnel->ref_count))
-		l2tp_tunnel_free(tunnel);
-}
-#ifdef L2TP_REFCNT_DEBUG
-#define l2tp_tunnel_inc_refcount(_t)					\
-do {									\
-	pr_debug("l2tp_tunnel_inc_refcount: %s:%d %s: cnt=%d\n",	\
-		 __func__, __LINE__, (_t)->name,			\
-		 atomic_read(&_t->ref_count));				\
-	l2tp_tunnel_inc_refcount_1(_t);					\
-} while (0)
-#define l2tp_tunnel_dec_refcount(_t)
-do {									\
-	pr_debug("l2tp_tunnel_dec_refcount: %s:%d %s: cnt=%d\n",	\
-		 __func__, __LINE__, (_t)->name,			\
-		 atomic_read(&_t->ref_count));				\
-	l2tp_tunnel_dec_refcount_1(_t);					\
-} while (0)
-#else
-#define l2tp_tunnel_inc_refcount(t) l2tp_tunnel_inc_refcount_1(t)
-#define l2tp_tunnel_dec_refcount(t) l2tp_tunnel_dec_refcount_1(t)
-#endif
-
 /* Session hash global list for L2TPv3.
  * The session_id SHOULD be random according to RFC3931, but several
  * L2TP implementations use incrementing session_ids.  So we do a real
@@ -277,10 +243,31 @@ struct l2tp_session *l2tp_session_find(s
 }
 EXPORT_SYMBOL_GPL(l2tp_session_find);
 
+/* Lookup a tunnel. A new reference is held on the returned tunnel. */
+struct l2tp_tunnel *l2tp_tunnel_get(const struct net *net, u32 tunnel_id)
+{
+	const struct l2tp_net *pn = l2tp_pernet(net);
+	struct l2tp_tunnel *tunnel;
+
+	rcu_read_lock_bh();
+	list_for_each_entry_rcu(tunnel, &pn->l2tp_tunnel_list, list) {
+		if (tunnel->tunnel_id == tunnel_id) {
+			l2tp_tunnel_inc_refcount(tunnel);
+			rcu_read_unlock_bh();
+
+			return tunnel;
+		}
+	}
+	rcu_read_unlock_bh();
+
+	return NULL;
+}
+EXPORT_SYMBOL_GPL(l2tp_tunnel_get);
+
 /* Like l2tp_session_find() but takes a reference on the returned session.
  * Optionally calls session->ref() too if do_ref is true.
  */
-struct l2tp_session *l2tp_session_get(struct net *net,
+struct l2tp_session *l2tp_session_get(const struct net *net,
 				      struct l2tp_tunnel *tunnel,
 				      u32 session_id, bool do_ref)
 {
@@ -355,7 +342,8 @@ EXPORT_SYMBOL_GPL(l2tp_session_get_nth);
 /* Lookup a session by interface name.
  * This is very inefficient but is only used by management interfaces.
  */
-struct l2tp_session *l2tp_session_get_by_ifname(struct net *net, char *ifname,
+struct l2tp_session *l2tp_session_get_by_ifname(const struct net *net,
+						const char *ifname,
 						bool do_ref)
 {
 	struct l2tp_net *pn = l2tp_pernet(net);
@@ -1395,17 +1383,6 @@ static void l2tp_udp_encap_destroy(struc
 	}
 }
 
-/* Really kill the tunnel.
- * Come here only when all sessions have been cleared from the tunnel.
- */
-static void l2tp_tunnel_free(struct l2tp_tunnel *tunnel)
-{
-	BUG_ON(atomic_read(&tunnel->ref_count) != 0);
-	BUG_ON(tunnel->sock != NULL);
-	l2tp_info(tunnel, L2TP_MSG_CONTROL, "%s: free...\n", tunnel->name);
-	kfree_rcu(tunnel, rcu);
-}
-
 /* Workqueue tunnel deletion function */
 static void l2tp_tunnel_del_work(struct work_struct *work)
 {
@@ -1929,6 +1906,8 @@ struct l2tp_session *l2tp_session_create
 
 		l2tp_session_set_header_len(session, tunnel->version);
 
+		l2tp_session_inc_refcount(session);
+
 		err = l2tp_session_add_to_tunnel(tunnel, session);
 		if (err) {
 			kfree(session);
@@ -1936,10 +1915,6 @@ struct l2tp_session *l2tp_session_create
 			return ERR_PTR(err);
 		}
 
-		/* Bump the reference count. The session context is deleted
-		 * only when this drops to zero.
-		 */
-		l2tp_session_inc_refcount(session);
 		l2tp_tunnel_inc_refcount(tunnel);
 
 		/* Ensure tunnel socket isn't deleted */
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/l2tp/l2tp_core.h linux-libre-3.16.50-gnu/net/l2tp/l2tp_core.h
--- linux-libre-3.16.49-gnu/net/l2tp/l2tp_core.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/l2tp/l2tp_core.h	2017-11-11 08:34:06.000000000 -0500
@@ -240,7 +240,9 @@ out:
 	return tunnel;
 }
 
-struct l2tp_session *l2tp_session_get(struct net *net,
+struct l2tp_tunnel *l2tp_tunnel_get(const struct net *net, u32 tunnel_id);
+
+struct l2tp_session *l2tp_session_get(const struct net *net,
 				      struct l2tp_tunnel *tunnel,
 				      u32 session_id, bool do_ref);
 struct l2tp_session *l2tp_session_find(struct net *net,
@@ -248,7 +250,8 @@ struct l2tp_session *l2tp_session_find(s
 				       u32 session_id);
 struct l2tp_session *l2tp_session_get_nth(struct l2tp_tunnel *tunnel, int nth,
 					  bool do_ref);
-struct l2tp_session *l2tp_session_get_by_ifname(struct net *net, char *ifname,
+struct l2tp_session *l2tp_session_get_by_ifname(const struct net *net,
+						const char *ifname,
 						bool do_ref);
 struct l2tp_tunnel *l2tp_tunnel_find(struct net *net, u32 tunnel_id);
 struct l2tp_tunnel *l2tp_tunnel_find_nth(struct net *net, int nth);
@@ -280,6 +283,17 @@ int l2tp_nl_register_ops(enum l2tp_pwtyp
 void l2tp_nl_unregister_ops(enum l2tp_pwtype pw_type);
 int l2tp_ioctl(struct sock *sk, int cmd, unsigned long arg);
 
+static inline void l2tp_tunnel_inc_refcount(struct l2tp_tunnel *tunnel)
+{
+	atomic_inc(&tunnel->ref_count);
+}
+
+static inline void l2tp_tunnel_dec_refcount(struct l2tp_tunnel *tunnel)
+{
+	if (atomic_dec_and_test(&tunnel->ref_count))
+		kfree_rcu(tunnel, rcu);
+}
+
 /* Session reference counts. Incremented when code obtains a reference
  * to a session.
  */
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/l2tp/l2tp_netlink.c linux-libre-3.16.50-gnu/net/l2tp/l2tp_netlink.c
--- linux-libre-3.16.49-gnu/net/l2tp/l2tp_netlink.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/l2tp/l2tp_netlink.c	2017-11-11 08:34:06.000000000 -0500
@@ -60,10 +60,12 @@ static struct l2tp_session *l2tp_nl_sess
 		   (info->attrs[L2TP_ATTR_CONN_ID])) {
 		tunnel_id = nla_get_u32(info->attrs[L2TP_ATTR_CONN_ID]);
 		session_id = nla_get_u32(info->attrs[L2TP_ATTR_SESSION_ID]);
-		tunnel = l2tp_tunnel_find(net, tunnel_id);
-		if (tunnel)
+		tunnel = l2tp_tunnel_get(net, tunnel_id);
+		if (tunnel) {
 			session = l2tp_session_get(net, tunnel, session_id,
 						   do_ref);
+			l2tp_tunnel_dec_refcount(tunnel);
+		}
 	}
 
 	return session;
@@ -207,14 +209,16 @@ static int l2tp_nl_cmd_tunnel_delete(str
 	}
 	tunnel_id = nla_get_u32(info->attrs[L2TP_ATTR_CONN_ID]);
 
-	tunnel = l2tp_tunnel_find(net, tunnel_id);
-	if (tunnel == NULL) {
+	tunnel = l2tp_tunnel_get(net, tunnel_id);
+	if (!tunnel) {
 		ret = -ENODEV;
 		goto out;
 	}
 
 	(void) l2tp_tunnel_delete(tunnel);
 
+	l2tp_tunnel_dec_refcount(tunnel);
+
 out:
 	return ret;
 }
@@ -232,8 +236,8 @@ static int l2tp_nl_cmd_tunnel_modify(str
 	}
 	tunnel_id = nla_get_u32(info->attrs[L2TP_ATTR_CONN_ID]);
 
-	tunnel = l2tp_tunnel_find(net, tunnel_id);
-	if (tunnel == NULL) {
+	tunnel = l2tp_tunnel_get(net, tunnel_id);
+	if (!tunnel) {
 		ret = -ENODEV;
 		goto out;
 	}
@@ -241,6 +245,8 @@ static int l2tp_nl_cmd_tunnel_modify(str
 	if (info->attrs[L2TP_ATTR_DEBUG])
 		tunnel->debug = nla_get_u32(info->attrs[L2TP_ATTR_DEBUG]);
 
+	l2tp_tunnel_dec_refcount(tunnel);
+
 out:
 	return ret;
 }
@@ -343,34 +349,37 @@ static int l2tp_nl_cmd_tunnel_get(struct
 
 	if (!info->attrs[L2TP_ATTR_CONN_ID]) {
 		ret = -EINVAL;
-		goto out;
+		goto err;
 	}
 
 	tunnel_id = nla_get_u32(info->attrs[L2TP_ATTR_CONN_ID]);
 
-	tunnel = l2tp_tunnel_find(net, tunnel_id);
-	if (tunnel == NULL) {
-		ret = -ENODEV;
-		goto out;
-	}
-
 	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
 	if (!msg) {
 		ret = -ENOMEM;
-		goto out;
+		goto err;
+	}
+
+	tunnel = l2tp_tunnel_get(net, tunnel_id);
+	if (!tunnel) {
+		ret = -ENODEV;
+		goto err_nlmsg;
 	}
 
 	ret = l2tp_nl_tunnel_send(msg, info->snd_portid, info->snd_seq,
 				  NLM_F_ACK, tunnel);
 	if (ret < 0)
-		goto err_out;
+		goto err_nlmsg_tunnel;
+
+	l2tp_tunnel_dec_refcount(tunnel);
 
 	return genlmsg_unicast(net, msg, info->snd_portid);
 
-err_out:
+err_nlmsg_tunnel:
+	l2tp_tunnel_dec_refcount(tunnel);
+err_nlmsg:
 	nlmsg_free(msg);
-
-out:
+err:
 	return ret;
 }
 
@@ -406,7 +415,6 @@ static int l2tp_nl_cmd_session_create(st
 	u32 peer_session_id;
 	int ret = 0;
 	struct l2tp_tunnel *tunnel;
-	struct l2tp_session *session;
 	struct l2tp_session_cfg cfg = { 0, };
 	struct net *net = genl_info_net(info);
 
@@ -414,8 +422,9 @@ static int l2tp_nl_cmd_session_create(st
 		ret = -EINVAL;
 		goto out;
 	}
+
 	tunnel_id = nla_get_u32(info->attrs[L2TP_ATTR_CONN_ID]);
-	tunnel = l2tp_tunnel_find(net, tunnel_id);
+	tunnel = l2tp_tunnel_get(net, tunnel_id);
 	if (!tunnel) {
 		ret = -ENODEV;
 		goto out;
@@ -423,29 +432,24 @@ static int l2tp_nl_cmd_session_create(st
 
 	if (!info->attrs[L2TP_ATTR_SESSION_ID]) {
 		ret = -EINVAL;
-		goto out;
+		goto out_tunnel;
 	}
 	session_id = nla_get_u32(info->attrs[L2TP_ATTR_SESSION_ID]);
-	session = l2tp_session_find(net, tunnel, session_id);
-	if (session) {
-		ret = -EEXIST;
-		goto out;
-	}
 
 	if (!info->attrs[L2TP_ATTR_PEER_SESSION_ID]) {
 		ret = -EINVAL;
-		goto out;
+		goto out_tunnel;
 	}
 	peer_session_id = nla_get_u32(info->attrs[L2TP_ATTR_PEER_SESSION_ID]);
 
 	if (!info->attrs[L2TP_ATTR_PW_TYPE]) {
 		ret = -EINVAL;
-		goto out;
+		goto out_tunnel;
 	}
 	cfg.pw_type = nla_get_u16(info->attrs[L2TP_ATTR_PW_TYPE]);
 	if (cfg.pw_type >= __L2TP_PWTYPE_MAX) {
 		ret = -EINVAL;
-		goto out;
+		goto out_tunnel;
 	}
 
 	if (tunnel->version > 2) {
@@ -467,7 +471,7 @@ static int l2tp_nl_cmd_session_create(st
 			u16 len = nla_len(info->attrs[L2TP_ATTR_COOKIE]);
 			if (len > 8) {
 				ret = -EINVAL;
-				goto out;
+				goto out_tunnel;
 			}
 			cfg.cookie_len = len;
 			memcpy(&cfg.cookie[0], nla_data(info->attrs[L2TP_ATTR_COOKIE]), len);
@@ -476,7 +480,7 @@ static int l2tp_nl_cmd_session_create(st
 			u16 len = nla_len(info->attrs[L2TP_ATTR_PEER_COOKIE]);
 			if (len > 8) {
 				ret = -EINVAL;
-				goto out;
+				goto out_tunnel;
 			}
 			cfg.peer_cookie_len = len;
 			memcpy(&cfg.peer_cookie[0], nla_data(info->attrs[L2TP_ATTR_PEER_COOKIE]), len);
@@ -512,7 +516,7 @@ static int l2tp_nl_cmd_session_create(st
 	if ((l2tp_nl_cmd_ops[cfg.pw_type] == NULL) ||
 	    (l2tp_nl_cmd_ops[cfg.pw_type]->session_create == NULL)) {
 		ret = -EPROTONOSUPPORT;
-		goto out;
+		goto out_tunnel;
 	}
 
 	/* Check that pseudowire-specific params are present */
@@ -522,7 +526,7 @@ static int l2tp_nl_cmd_session_create(st
 	case L2TP_PWTYPE_ETH_VLAN:
 		if (!info->attrs[L2TP_ATTR_VLAN_ID]) {
 			ret = -EINVAL;
-			goto out;
+			goto out_tunnel;
 		}
 		break;
 	case L2TP_PWTYPE_ETH:
@@ -541,6 +545,8 @@ static int l2tp_nl_cmd_session_create(st
 		ret = (*l2tp_nl_cmd_ops[cfg.pw_type]->session_create)(net, tunnel_id,
 			session_id, peer_session_id, &cfg);
 
+out_tunnel:
+	l2tp_tunnel_dec_refcount(tunnel);
 out:
 	return ret;
 }
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/mac80211/key.c linux-libre-3.16.50-gnu/net/mac80211/key.c
--- linux-libre-3.16.49-gnu/net/mac80211/key.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/mac80211/key.c	2017-11-11 08:34:06.000000000 -0500
@@ -3,6 +3,7 @@
  * Copyright 2005-2006, Devicescape Software, Inc.
  * Copyright 2006-2007	Jiri Benc <jbenc@suse.cz>
  * Copyright 2007-2008	Johannes Berg <johannes@sipsolutions.net>
+ * Copyright 2017	Intel Deutschland GmbH
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -487,9 +488,6 @@ int ieee80211_key_link(struct ieee80211_
 
 	pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE;
 	idx = key->conf.keyidx;
-	key->local = sdata->local;
-	key->sdata = sdata;
-	key->sta = sta;
 
 	mutex_lock(&sdata->local->key_mtx);
 
@@ -500,6 +498,21 @@ int ieee80211_key_link(struct ieee80211_
 	else
 		old_key = key_mtx_dereference(sdata->local, sdata->keys[idx]);
 
+	/*
+	 * Silently accept key re-installation without really installing the
+	 * new version of the key to avoid nonce reuse or replay issues.
+	 */
+	if (old_key && key->conf.keylen == old_key->conf.keylen &&
+	    !memcmp(key->conf.key, old_key->conf.key, key->conf.keylen)) {
+		ieee80211_key_free_unused(key);
+		ret = 0;
+		goto out;
+	}
+
+	key->local = sdata->local;
+	key->sdata = sdata;
+	key->sta = sta;
+
 	increment_tailroom_need_count(sdata);
 
 	ieee80211_key_replace(sdata, sta, pairwise, old_key, key);
@@ -515,6 +528,7 @@ int ieee80211_key_link(struct ieee80211_
 		ret = 0;
 	}
 
+ out:
 	mutex_unlock(&sdata->local->key_mtx);
 
 	return ret;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/netfilter/ipvs/ip_vs_xmit.c linux-libre-3.16.50-gnu/net/netfilter/ipvs/ip_vs_xmit.c
--- linux-libre-3.16.49-gnu/net/netfilter/ipvs/ip_vs_xmit.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/netfilter/ipvs/ip_vs_xmit.c	2017-11-11 08:34:06.000000000 -0500
@@ -373,7 +373,7 @@ __ip_vs_get_out_rt_v6(struct sk_buff *sk
 				goto err_unreach;
 			}
 			rt = (struct rt6_info *) dst;
-			cookie = rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
+			cookie = rt6_get_cookie(rt);
 			__ip_vs_dst_set(dest, dest_dst, &rt->dst, cookie);
 			spin_unlock_bh(&dest->dst_lock);
 			IP_VS_DBG(10, "new dst %pI6, src %pI6, refcnt=%d\n",
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/netfilter/nft_compat.c linux-libre-3.16.50-gnu/net/netfilter/nft_compat.c
--- linux-libre-3.16.49-gnu/net/netfilter/nft_compat.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/netfilter/nft_compat.c	2017-11-11 08:34:06.000000000 -0500
@@ -295,11 +295,11 @@ static void nft_match_eval(const struct
 		return;
 	}
 
-	switch(ret) {
-	case true:
+	switch (ret ? 1 : 0) {
+	case 1:
 		data[NFT_REG_VERDICT].verdict = NFT_CONTINUE;
 		break;
-	case false:
+	case 0:
 		data[NFT_REG_VERDICT].verdict = NFT_BREAK;
 		break;
 	}
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/netfilter/nft_ct.c linux-libre-3.16.50-gnu/net/netfilter/nft_ct.c
--- linux-libre-3.16.49-gnu/net/netfilter/nft_ct.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/netfilter/nft_ct.c	2017-11-11 08:34:06.000000000 -0500
@@ -56,6 +56,8 @@ static void nft_ct_get_eval(const struct
 			state = NF_CT_STATE_BIT(ctinfo);
 		dest->data[0] = state;
 		return;
+	default:
+		break;
 	}
 
 	if (ct == NULL)
@@ -117,6 +119,8 @@ static void nft_ct_get_eval(const struct
 		return;
 	}
 #endif
+	default:
+		break;
 	}
 
 	tuple = &ct->tuplehash[priv->dir].tuple;
@@ -141,6 +145,8 @@ static void nft_ct_get_eval(const struct
 	case NFT_CT_PROTO_DST:
 		dest->data[0] = (__force __u16)tuple->dst.u.all;
 		return;
+	default:
+		break;
 	}
 	return;
 err:
@@ -172,6 +178,8 @@ static void nft_ct_set_eval(const struct
 		}
 		break;
 #endif
+	default:
+		break;
 	}
 }
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/netfilter/nft_reject.c linux-libre-3.16.50-gnu/net/netfilter/nft_reject.c
--- linux-libre-3.16.49-gnu/net/netfilter/nft_reject.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/netfilter/nft_reject.c	2017-11-11 08:34:06.000000000 -0500
@@ -61,6 +61,8 @@ int nft_reject_dump(struct sk_buff *skb,
 		if (nla_put_u8(skb, NFTA_REJECT_ICMP_CODE, priv->icmp_code))
 			goto nla_put_failure;
 		break;
+	default:
+		break;
 	}
 
 	return 0;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/packet/af_packet.c linux-libre-3.16.50-gnu/net/packet/af_packet.c
--- linux-libre-3.16.49-gnu/net/packet/af_packet.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/packet/af_packet.c	2017-11-11 08:34:06.000000000 -0500
@@ -214,6 +214,7 @@ static void prb_clear_rxhash(struct tpac
 static void prb_fill_vlan_info(struct tpacket_kbdq_core *,
 		struct tpacket3_hdr *);
 static void packet_flush_mclist(struct sock *sk);
+static void packet_pick_tx_queue(struct net_device *dev, struct sk_buff *skb);
 
 struct packet_skb_cb {
 	unsigned int origlen;
@@ -266,6 +267,7 @@ static int packet_direct_xmit(struct sk_
 			goto drop;
 	}
 
+	packet_pick_tx_queue(dev, skb);
 	queue_map = skb_get_queue_mapping(skb);
 	txq = netdev_get_tx_queue(dev, queue_map);
 
@@ -1457,10 +1459,6 @@ static int fanout_add(struct sock *sk, u
 
 	mutex_lock(&fanout_mutex);
 
-	err = -EINVAL;
-	if (!po->running)
-		goto out;
-
 	err = -EALREADY;
 	if (po->fanout)
 		goto out;
@@ -1497,7 +1495,10 @@ static int fanout_add(struct sock *sk, u
 		list_add(&match->list, &fanout_list);
 	}
 	err = -EINVAL;
-	if (match->type == type &&
+
+	spin_lock(&po->bind_lock);
+	if (po->running &&
+	    match->type == type &&
 	    match->prot_hook.type == po->prot_hook.type &&
 	    match->prot_hook.dev == po->prot_hook.dev) {
 		err = -ENOSPC;
@@ -1509,6 +1510,13 @@ static int fanout_add(struct sock *sk, u
 			err = 0;
 		}
 	}
+	spin_unlock(&po->bind_lock);
+
+	if (err && !atomic_read(&match->sk_ref)) {
+		list_del(&match->list);
+		kfree(match);
+	}
+
 out:
 	mutex_unlock(&fanout_mutex);
 	return err;
@@ -2343,8 +2351,6 @@ static int tpacket_snd(struct packet_soc
 			}
 		}
 
-		packet_pick_tx_queue(dev, skb);
-
 		skb->destructor = tpacket_destruct_skb;
 		__packet_set_status(po, ph, TP_STATUS_SENDING);
 		packet_inc_pending(&po->tx_ring);
@@ -2551,8 +2557,6 @@ static int packet_snd(struct socket *soc
 	skb->priority = sk->sk_priority;
 	skb->mark = sk->sk_mark;
 
-	packet_pick_tx_queue(dev, skb);
-
 	if (po->has_vnet_hdr) {
 		if (vnet_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
 			if (!skb_partial_csum_set(skb, vnet_hdr.csum_start,
@@ -2692,13 +2696,15 @@ static int packet_do_bind(struct sock *s
 	int ret = 0;
 	bool unlisted = false;
 
-	if (po->fanout)
-		return -EINVAL;
-
 	lock_sock(sk);
 	spin_lock(&po->bind_lock);
 	rcu_read_lock();
 
+	if (po->fanout) {
+		ret = -EINVAL;
+		goto out_unlock;
+	}
+
 	if (name) {
 		dev = dev_get_by_name_rcu(sock_net(sk), name);
 		if (!dev) {
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/sched/sch_api.c linux-libre-3.16.50-gnu/net/sched/sch_api.c
--- linux-libre-3.16.49-gnu/net/sched/sch_api.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/sched/sch_api.c	2017-11-11 08:34:06.000000000 -0500
@@ -978,6 +978,8 @@ qdisc_create(struct net_device *dev, str
 
 		return sch;
 	}
+	/* ops->init() failed, we call ->destroy() like qdisc_create_dflt() */
+	ops->destroy(sch);
 err_out3:
 	dev_put(dev);
 	kfree((char *) sch - sch->padded);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/sched/sch_cbq.c linux-libre-3.16.50-gnu/net/sched/sch_cbq.c
--- linux-libre-3.16.49-gnu/net/sched/sch_cbq.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/sched/sch_cbq.c	2017-11-11 08:34:06.000000000 -0500
@@ -1364,6 +1364,13 @@ static int cbq_init(struct Qdisc *sch, s
 	struct tc_ratespec *r;
 	int err;
 
+	qdisc_watchdog_init(&q->watchdog, sch);
+	hrtimer_init(&q->delay_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED);
+	q->delay_timer.function = cbq_undelay;
+
+	if (!opt)
+		return -EINVAL;
+
 	err = nla_parse_nested(tb, TCA_CBQ_MAX, opt, cbq_policy);
 	if (err < 0)
 		return err;
@@ -1402,9 +1409,6 @@ static int cbq_init(struct Qdisc *sch, s
 	q->link.avpkt = q->link.allot/2;
 	q->link.minidle = -0x7FFFFFFF;
 
-	qdisc_watchdog_init(&q->watchdog, sch);
-	hrtimer_init(&q->delay_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
-	q->delay_timer.function = cbq_undelay;
 	q->toplevel = TC_CBQ_MAXLEVEL;
 	q->now = psched_get_time();
 	q->now_rt = q->now;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/sched/sch_fq_codel.c linux-libre-3.16.50-gnu/net/sched/sch_fq_codel.c
--- linux-libre-3.16.49-gnu/net/sched/sch_fq_codel.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/sched/sch_fq_codel.c	2017-11-11 08:34:06.000000000 -0500
@@ -411,10 +411,8 @@ static int fq_codel_init(struct Qdisc *s
 		if (!q->flows)
 			return -ENOMEM;
 		q->backlogs = fq_codel_zalloc(q->flows_cnt * sizeof(u32));
-		if (!q->backlogs) {
-			fq_codel_free(q->flows);
+		if (!q->backlogs)
 			return -ENOMEM;
-		}
 		for (i = 0; i < q->flows_cnt; i++) {
 			struct fq_codel_flow *flow = q->flows + i;
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/sched/sch_hfsc.c linux-libre-3.16.50-gnu/net/sched/sch_hfsc.c
--- linux-libre-3.16.49-gnu/net/sched/sch_hfsc.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/sched/sch_hfsc.c	2017-11-11 08:34:06.000000000 -0500
@@ -1432,6 +1432,8 @@ hfsc_init_qdisc(struct Qdisc *sch, struc
 	struct tc_hfsc_qopt *qopt;
 	int err;
 
+	qdisc_watchdog_init(&q->watchdog, sch);
+
 	if (opt == NULL || nla_len(opt) < sizeof(*qopt))
 		return -EINVAL;
 	qopt = nla_data(opt);
@@ -1457,8 +1459,6 @@ hfsc_init_qdisc(struct Qdisc *sch, struc
 	qdisc_class_hash_insert(&q->clhash, &q->root.cl_common);
 	qdisc_class_hash_grow(sch, &q->clhash);
 
-	qdisc_watchdog_init(&q->watchdog, sch);
-
 	return 0;
 }
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/sched/sch_hhf.c linux-libre-3.16.50-gnu/net/sched/sch_hhf.c
--- linux-libre-3.16.49-gnu/net/sched/sch_hhf.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/sched/sch_hhf.c	2017-11-11 08:34:06.000000000 -0500
@@ -509,6 +509,9 @@ static void hhf_destroy(struct Qdisc *sc
 		hhf_free(q->hhf_valid_bits[i]);
 	}
 
+	if (!q->hh_flows)
+		return;
+
 	for (i = 0; i < HH_FLOWS_CNT; i++) {
 		struct hh_flow_state *flow, *next;
 		struct list_head *head = &q->hh_flows[i];
@@ -644,7 +647,9 @@ static int hhf_init(struct Qdisc *sch, s
 			q->hhf_arrays[i] = hhf_zalloc(HHF_ARRAYS_LEN *
 						      sizeof(u32));
 			if (!q->hhf_arrays[i]) {
-				hhf_destroy(sch);
+				/* Note: hhf_destroy() will be called
+				 * by our caller.
+				 */
 				return -ENOMEM;
 			}
 		}
@@ -655,7 +660,9 @@ static int hhf_init(struct Qdisc *sch, s
 			q->hhf_valid_bits[i] = hhf_zalloc(HHF_ARRAYS_LEN /
 							  BITS_PER_BYTE);
 			if (!q->hhf_valid_bits[i]) {
-				hhf_destroy(sch);
+				/* Note: hhf_destroy() will be called
+				 * by our caller.
+				 */
 				return -ENOMEM;
 			}
 		}
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/sched/sch_htb.c linux-libre-3.16.50-gnu/net/sched/sch_htb.c
--- linux-libre-3.16.49-gnu/net/sched/sch_htb.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/sched/sch_htb.c	2017-11-11 08:34:06.000000000 -0500
@@ -1025,6 +1025,9 @@ static int htb_init(struct Qdisc *sch, s
 	int err;
 	int i;
 
+	qdisc_watchdog_init(&q->watchdog, sch);
+	INIT_WORK(&q->work, htb_work_func);
+
 	if (!opt)
 		return -EINVAL;
 
@@ -1045,8 +1048,6 @@ static int htb_init(struct Qdisc *sch, s
 	for (i = 0; i < TC_HTB_NUMPRIO; i++)
 		INIT_LIST_HEAD(q->drops + i);
 
-	qdisc_watchdog_init(&q->watchdog, sch);
-	INIT_WORK(&q->work, htb_work_func);
 	skb_queue_head_init(&q->direct_queue);
 
 	if (tb[TCA_HTB_DIRECT_QLEN])
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/sched/sch_mq.c linux-libre-3.16.50-gnu/net/sched/sch_mq.c
--- linux-libre-3.16.49-gnu/net/sched/sch_mq.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/sched/sch_mq.c	2017-11-11 08:34:06.000000000 -0500
@@ -52,7 +52,7 @@ static int mq_init(struct Qdisc *sch, st
 	/* pre-allocate qdiscs, attachment can't fail */
 	priv->qdiscs = kcalloc(dev->num_tx_queues, sizeof(priv->qdiscs[0]),
 			       GFP_KERNEL);
-	if (priv->qdiscs == NULL)
+	if (!priv->qdiscs)
 		return -ENOMEM;
 
 	for (ntx = 0; ntx < dev->num_tx_queues; ntx++) {
@@ -60,18 +60,14 @@ static int mq_init(struct Qdisc *sch, st
 		qdisc = qdisc_create_dflt(dev_queue, default_qdisc_ops,
 					  TC_H_MAKE(TC_H_MAJ(sch->handle),
 						    TC_H_MIN(ntx + 1)));
-		if (qdisc == NULL)
-			goto err;
+		if (!qdisc)
+			return -ENOMEM;
 		priv->qdiscs[ntx] = qdisc;
 		qdisc->flags |= TCQ_F_ONETXQUEUE;
 	}
 
 	sch->flags |= TCQ_F_MQROOT;
 	return 0;
-
-err:
-	mq_destroy(sch);
-	return -ENOMEM;
 }
 
 static void mq_attach(struct Qdisc *sch)
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/sched/sch_mqprio.c linux-libre-3.16.50-gnu/net/sched/sch_mqprio.c
--- linux-libre-3.16.49-gnu/net/sched/sch_mqprio.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/sched/sch_mqprio.c	2017-11-11 08:34:06.000000000 -0500
@@ -117,20 +117,17 @@ static int mqprio_init(struct Qdisc *sch
 	/* pre-allocate qdisc, attachment can't fail */
 	priv->qdiscs = kcalloc(dev->num_tx_queues, sizeof(priv->qdiscs[0]),
 			       GFP_KERNEL);
-	if (priv->qdiscs == NULL) {
-		err = -ENOMEM;
-		goto err;
-	}
+	if (!priv->qdiscs)
+		return -ENOMEM;
 
 	for (i = 0; i < dev->num_tx_queues; i++) {
 		dev_queue = netdev_get_tx_queue(dev, i);
 		qdisc = qdisc_create_dflt(dev_queue, default_qdisc_ops,
 					  TC_H_MAKE(TC_H_MAJ(sch->handle),
 						    TC_H_MIN(i + 1)));
-		if (qdisc == NULL) {
-			err = -ENOMEM;
-			goto err;
-		}
+		if (!qdisc)
+			return -ENOMEM;
+
 		priv->qdiscs[i] = qdisc;
 		qdisc->flags |= TCQ_F_ONETXQUEUE;
 	}
@@ -143,7 +140,7 @@ static int mqprio_init(struct Qdisc *sch
 		priv->hw_owned = 1;
 		err = dev->netdev_ops->ndo_setup_tc(dev, qopt->num_tc);
 		if (err)
-			goto err;
+			return err;
 	} else {
 		netdev_set_num_tc(dev, qopt->num_tc);
 		for (i = 0; i < qopt->num_tc; i++)
@@ -157,10 +154,6 @@ static int mqprio_init(struct Qdisc *sch
 
 	sch->flags |= TCQ_F_MQROOT;
 	return 0;
-
-err:
-	mqprio_destroy(sch);
-	return err;
 }
 
 static void mqprio_attach(struct Qdisc *sch)
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/sched/sch_multiq.c linux-libre-3.16.50-gnu/net/sched/sch_multiq.c
--- linux-libre-3.16.49-gnu/net/sched/sch_multiq.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/sched/sch_multiq.c	2017-11-11 08:34:06.000000000 -0500
@@ -253,7 +253,7 @@ static int multiq_tune(struct Qdisc *sch
 static int multiq_init(struct Qdisc *sch, struct nlattr *opt)
 {
 	struct multiq_sched_data *q = qdisc_priv(sch);
-	int i, err;
+	int i;
 
 	q->queues = NULL;
 
@@ -268,12 +268,7 @@ static int multiq_init(struct Qdisc *sch
 	for (i = 0; i < q->max_bands; i++)
 		q->queues[i] = &noop_qdisc;
 
-	err = multiq_tune(sch, opt);
-
-	if (err)
-		kfree(q->queues);
-
-	return err;
+	return multiq_tune(sch, opt);
 }
 
 static int multiq_dump(struct Qdisc *sch, struct sk_buff *skb)
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/sched/sch_netem.c linux-libre-3.16.50-gnu/net/sched/sch_netem.c
--- linux-libre-3.16.49-gnu/net/sched/sch_netem.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/sched/sch_netem.c	2017-11-11 08:34:06.000000000 -0500
@@ -956,11 +956,11 @@ static int netem_init(struct Qdisc *sch,
 	struct netem_sched_data *q = qdisc_priv(sch);
 	int ret;
 
+	qdisc_watchdog_init(&q->watchdog, sch);
+
 	if (!opt)
 		return -EINVAL;
 
-	qdisc_watchdog_init(&q->watchdog, sch);
-
 	q->loss_model = CLG_RANDOM;
 	ret = netem_change(sch, opt);
 	if (ret)
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/sched/sch_sfq.c linux-libre-3.16.50-gnu/net/sched/sch_sfq.c
--- linux-libre-3.16.49-gnu/net/sched/sch_sfq.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/sched/sch_sfq.c	2017-11-11 08:34:06.000000000 -0500
@@ -460,6 +460,7 @@ congestion_drop:
 		qdisc_drop(head, sch);
 
 		slot_queue_add(slot, skb);
+		qdisc_tree_reduce_backlog(sch, 0, delta);
 		return NET_XMIT_CN;
 	}
 
@@ -491,8 +492,10 @@ enqueue:
 	/* Return Congestion Notification only if we dropped a packet
 	 * from this flow.
 	 */
-	if (qlen != slot->qlen)
+	if (qlen != slot->qlen) {
+		qdisc_tree_reduce_backlog(sch, 0, dropped - qdisc_pkt_len(skb));
 		return NET_XMIT_CN;
+	}
 
 	/* As we dropped a packet, better let upper stack know this */
 	qdisc_tree_reduce_backlog(sch, 1, dropped);
@@ -767,9 +770,10 @@ static int sfq_init(struct Qdisc *sch, s
 	q->ht = sfq_alloc(sizeof(q->ht[0]) * q->divisor);
 	q->slots = sfq_alloc(sizeof(q->slots[0]) * q->maxflows);
 	if (!q->ht || !q->slots) {
-		sfq_destroy(sch);
+		/* Note: sfq_destroy() will be called by our caller */
 		return -ENOMEM;
 	}
+
 	for (i = 0; i < q->divisor; i++)
 		q->ht[i] = SFQ_EMPTY_SLOT;
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/sched/sch_tbf.c linux-libre-3.16.50-gnu/net/sched/sch_tbf.c
--- linux-libre-3.16.49-gnu/net/sched/sch_tbf.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/sched/sch_tbf.c	2017-11-11 08:34:06.000000000 -0500
@@ -431,12 +431,13 @@ static int tbf_init(struct Qdisc *sch, s
 {
 	struct tbf_sched_data *q = qdisc_priv(sch);
 
+	qdisc_watchdog_init(&q->watchdog, sch);
+	q->qdisc = &noop_qdisc;
+
 	if (opt == NULL)
 		return -EINVAL;
 
 	q->t_c = ktime_to_ns(ktime_get());
-	qdisc_watchdog_init(&q->watchdog, sch);
-	q->qdisc = &noop_qdisc;
 
 	return tbf_change(sch, opt);
 }
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/sctp/ipv6.c linux-libre-3.16.50-gnu/net/sctp/ipv6.c
--- linux-libre-3.16.49-gnu/net/sctp/ipv6.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/sctp/ipv6.c	2017-11-11 08:34:06.000000000 -0500
@@ -331,7 +331,7 @@ out:
 
 		rt = (struct rt6_info *)dst;
 		t->dst = dst;
-		t->dst_cookie = rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
+		t->dst_cookie = rt6_get_cookie(rt);
 		pr_debug("rt6_dst:%pI6 rt6_src:%pI6\n", &rt->rt6i_dst.addr,
 			 &fl6->saddr);
 	} else {
diff -druNp --no-dereference linux-libre-3.16.49-gnu/net/xfrm/xfrm_user.c linux-libre-3.16.50-gnu/net/xfrm/xfrm_user.c
--- linux-libre-3.16.49-gnu/net/xfrm/xfrm_user.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/net/xfrm/xfrm_user.c	2017-11-11 08:34:06.000000000 -0500
@@ -1752,6 +1752,7 @@ static int build_aevent(struct sk_buff *
 		return -EMSGSIZE;
 
 	id = nlmsg_data(nlh);
+	memset(&id->sa_id, 0, sizeof(id->sa_id));
 	memcpy(&id->sa_id.daddr, &x->id.daddr, sizeof(x->id.daddr));
 	id->sa_id.spi = x->id.spi;
 	id->sa_id.family = x->props.family;
@@ -2552,6 +2553,7 @@ static int xfrm_notify_sa(struct xfrm_st
 		struct nlattr *attr;
 
 		id = nlmsg_data(nlh);
+		memset(id, 0, sizeof(*id));
 		memcpy(&id->daddr, &x->id.daddr, sizeof(id->daddr));
 		id->spi = x->id.spi;
 		id->family = x->props.family;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/scripts/mod/modpost.c linux-libre-3.16.50-gnu/scripts/mod/modpost.c
--- linux-libre-3.16.49-gnu/scripts/mod/modpost.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/scripts/mod/modpost.c	2017-11-11 08:34:06.000000000 -0500
@@ -798,6 +798,7 @@ static int number_prefix(const char *sym
  *   where the '1' can be any number including several digits.
  *   The $ syntax is for sections where ld append a dot number
  *   to make section name unique.
+ * "*foo*" will match a string that contains "foo"
  */
 static int match(const char *sym, const char * const pat[])
 {
@@ -806,8 +807,17 @@ static int match(const char *sym, const
 		p = *pat++;
 		const char *endp = p + strlen(p) - 1;
 
+		/* "*foo*" */
+		if (*p == '*' && *endp == '*') {
+			char *here, *bare = strndup(p + 1, strlen(p) - 2);
+
+			here = strstr(sym, bare);
+			free(bare);
+			if (here != NULL)
+				return 1;
+		}
 		/* "*foo" */
-		if (*p == '*') {
+		else if (*p == '*') {
 			if (strrcmp(sym, p + 1) == 0)
 				return 1;
 		}
@@ -920,6 +930,10 @@ static const char *init_sections[] = { A
 static const char *init_exit_sections[] =
 	{ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL };
 
+/* all text sections */
+static const char *const text_sections[] = { ALL_INIT_TEXT_SECTIONS,
+				ALL_EXIT_TEXT_SECTIONS, TEXT_SECTIONS, NULL };
+
 /* data section */
 static const char *data_sections[] = { DATA_SECTIONS, NULL };
 
@@ -938,6 +952,7 @@ static const char *data_sections[] = { D
 static const char *head_sections[] = { ".head.text*", NULL };
 static const char *linker_symbols[] =
 	{ "__init_begin", "_sinittext", "_einittext", NULL };
+static const char *const optim_symbols[] = { "*.constprop.*", NULL };
 
 enum mismatch {
 	TEXT_TO_ANY_INIT,
@@ -1095,6 +1110,17 @@ static const struct sectioncheck *sectio
  *   This pattern is identified by
  *   refsymname = __init_begin, _sinittext, _einittext
  *
+ * Pattern 5:
+ *   GCC may optimize static inlines when fed constant arg(s) resulting
+ *   in functions like cpumask_empty() -- generating an associated symbol
+ *   cpumask_empty.constprop.3 that appears in the audit.  If the const that
+ *   is passed in comes from __init, like say nmi_ipi_mask, we get a
+ *   meaningless section warning.  May need to add isra symbols too...
+ *   This pattern is identified by
+ *   tosec   = init section
+ *   fromsec = text section
+ *   refsymname = *.constprop.*
+ *
  **/
 static int secref_whitelist(const struct sectioncheck *mismatch,
 			    const char *fromsec, const char *fromsym,
@@ -1127,6 +1153,12 @@ static int secref_whitelist(const struct
 	if (match(tosym, linker_symbols))
 		return 0;
 
+	/* Check for pattern 5 */
+	if (match(fromsec, text_sections) &&
+	    match(tosec, init_sections) &&
+	    match(fromsym, optim_symbols))
+		return 0;
+
 	return 1;
 }
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/security/keys/key.c linux-libre-3.16.50-gnu/security/keys/key.c
--- linux-libre-3.16.49-gnu/security/keys/key.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/security/keys/key.c	2017-11-11 08:34:06.000000000 -0500
@@ -901,6 +901,16 @@ error:
 	 */
 	__key_link_end(keyring, &index_key, edit);
 
+	key = key_ref_to_ptr(key_ref);
+	if (test_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags)) {
+		ret = wait_for_key_construction(key, true);
+		if (ret < 0) {
+			key_ref_put(key_ref);
+			key_ref = ERR_PTR(ret);
+			goto error_free_prep;
+		}
+	}
+
 	key_ref = __key_update(key_ref, &prep);
 	goto error_free_prep;
 }
diff -druNp --no-dereference linux-libre-3.16.49-gnu/security/keys/keyctl.c linux-libre-3.16.50-gnu/security/keys/keyctl.c
--- linux-libre-3.16.49-gnu/security/keys/keyctl.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/security/keys/keyctl.c	2017-11-11 08:34:06.000000000 -0500
@@ -735,6 +735,11 @@ long keyctl_read_key(key_serial_t keyid,
 
 	key = key_ref_to_ptr(key_ref);
 
+	if (test_bit(KEY_FLAG_NEGATIVE, &key->flags)) {
+		ret = -ENOKEY;
+		goto error2;
+	}
+
 	/* see if we can read it directly */
 	ret = key_permission(key_ref, KEY_NEED_READ);
 	if (ret == 0)
diff -druNp --no-dereference linux-libre-3.16.49-gnu/sound/core/control.c linux-libre-3.16.50-gnu/sound/core/control.c
--- linux-libre-3.16.49-gnu/sound/core/control.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/sound/core/control.c	2017-11-11 08:34:06.000000000 -0500
@@ -1087,7 +1087,7 @@ static int snd_ctl_elem_user_tlv(struct
 		mutex_lock(&ue->card->user_ctl_lock);
 		change = ue->tlv_data_size != size;
 		if (!change)
-			change = memcmp(ue->tlv_data, new_data, size);
+			change = memcmp(ue->tlv_data, new_data, size) != 0;
 		kfree(ue->tlv_data);
 		ue->tlv_data = new_data;
 		ue->tlv_data_size = size;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/sound/core/seq/seq_clientmgr.c linux-libre-3.16.50-gnu/sound/core/seq/seq_clientmgr.c
--- linux-libre-3.16.49-gnu/sound/core/seq/seq_clientmgr.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/sound/core/seq/seq_clientmgr.c	2017-11-11 08:34:06.000000000 -0500
@@ -1260,6 +1260,7 @@ static int snd_seq_ioctl_create_port(str
 	struct snd_seq_client_port *port;
 	struct snd_seq_port_info info;
 	struct snd_seq_port_callback *callback;
+	int port_idx;
 
 	if (copy_from_user(&info, arg, sizeof(info)))
 		return -EFAULT;
@@ -1273,7 +1274,9 @@ static int snd_seq_ioctl_create_port(str
 		return -ENOMEM;
 
 	if (client->type == USER_CLIENT && info.kernel) {
-		snd_seq_delete_port(client, port->addr.port);
+		port_idx = port->addr.port;
+		snd_seq_port_unlock(port);
+		snd_seq_delete_port(client, port_idx);
 		return -EINVAL;
 	}
 	if (client->type == KERNEL_CLIENT) {
@@ -1295,6 +1298,7 @@ static int snd_seq_ioctl_create_port(str
 
 	snd_seq_set_port_info(port, &info);
 	snd_seq_system_client_ev_port_start(port->addr.client, port->addr.port);
+	snd_seq_port_unlock(port);
 
 	if (copy_to_user(arg, &info, sizeof(info)))
 		return -EFAULT;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/sound/core/seq/seq_lock.c linux-libre-3.16.50-gnu/sound/core/seq/seq_lock.c
--- linux-libre-3.16.49-gnu/sound/core/seq/seq_lock.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/sound/core/seq/seq_lock.c	2017-11-11 08:34:06.000000000 -0500
@@ -23,8 +23,6 @@
 #include <sound/core.h>
 #include "seq_lock.h"
 
-#if defined(CONFIG_SMP) || defined(CONFIG_SND_DEBUG)
-
 /* wait until all locks are released */
 void snd_use_lock_sync_helper(snd_use_lock_t *lockp, const char *file, int line)
 {
@@ -42,5 +40,3 @@ void snd_use_lock_sync_helper(snd_use_lo
 }
 
 EXPORT_SYMBOL(snd_use_lock_sync_helper);
-
-#endif
diff -druNp --no-dereference linux-libre-3.16.49-gnu/sound/core/seq/seq_lock.h linux-libre-3.16.50-gnu/sound/core/seq/seq_lock.h
--- linux-libre-3.16.49-gnu/sound/core/seq/seq_lock.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/sound/core/seq/seq_lock.h	2017-11-11 08:34:06.000000000 -0500
@@ -3,8 +3,6 @@
 
 #include <linux/sched.h>
 
-#if defined(CONFIG_SMP) || defined(CONFIG_SND_DEBUG)
-
 typedef atomic_t snd_use_lock_t;
 
 /* initialize lock */
@@ -20,14 +18,4 @@ typedef atomic_t snd_use_lock_t;
 void snd_use_lock_sync_helper(snd_use_lock_t *lock, const char *file, int line);
 #define snd_use_lock_sync(lockp) snd_use_lock_sync_helper(lockp, __BASE_FILE__, __LINE__)
 
-#else /* SMP || CONFIG_SND_DEBUG */
-
-typedef spinlock_t snd_use_lock_t;	/* dummy */
-#define snd_use_lock_init(lockp) /**/
-#define snd_use_lock_use(lockp) /**/
-#define snd_use_lock_free(lockp) /**/
-#define snd_use_lock_sync(lockp) /**/
-
-#endif /* SMP || CONFIG_SND_DEBUG */
-
 #endif /* __SND_SEQ_LOCK_H */
diff -druNp --no-dereference linux-libre-3.16.49-gnu/sound/core/seq/seq_ports.c linux-libre-3.16.50-gnu/sound/core/seq/seq_ports.c
--- linux-libre-3.16.49-gnu/sound/core/seq/seq_ports.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/sound/core/seq/seq_ports.c	2017-11-11 08:34:06.000000000 -0500
@@ -122,7 +122,9 @@ static void port_subs_info_init(struct s
 }
 
 
-/* create a port, port number is returned (-1 on failure) */
+/* create a port, port number is returned (-1 on failure);
+ * the caller needs to unref the port via snd_seq_port_unlock() appropriately
+ */
 struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client,
 						int port)
 {
@@ -151,6 +153,7 @@ struct snd_seq_client_port *snd_seq_crea
 	snd_use_lock_init(&new_port->use_lock);
 	port_subs_info_init(&new_port->c_src);
 	port_subs_info_init(&new_port->c_dest);
+	snd_use_lock_use(&new_port->use_lock);
 
 	num = port >= 0 ? port : 0;
 	mutex_lock(&client->ports_mutex);
@@ -165,9 +168,9 @@ struct snd_seq_client_port *snd_seq_crea
 	list_add_tail(&new_port->list, &p->list);
 	client->num_ports++;
 	new_port->addr.port = num;	/* store the port number in the port */
+	sprintf(new_port->name, "port-%d", num);
 	write_unlock_irqrestore(&client->ports_lock, flags);
 	mutex_unlock(&client->ports_mutex);
-	sprintf(new_port->name, "port-%d", num);
 
 	return new_port;
 }
diff -druNp --no-dereference linux-libre-3.16.49-gnu/sound/pci/hda/patch_conexant.c linux-libre-3.16.50-gnu/sound/pci/hda/patch_conexant.c
--- linux-libre-3.16.49-gnu/sound/pci/hda/patch_conexant.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/sound/pci/hda/patch_conexant.c	2017-11-11 08:34:06.000000000 -0500
@@ -3438,6 +3438,7 @@ static const struct snd_pci_quirk cxt506
 	SND_PCI_QUIRK(0x17aa, 0x390b, "Lenovo G50-80", CXT_FIXUP_STEREO_DMIC),
 	SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC),
 	SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC),
+	SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo G50-70", CXT_FIXUP_STEREO_DMIC),
 	SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC),
 	SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", CXT_FIXUP_THINKPAD_ACPI),
 	SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT_PINCFG_LEMOTE_A1004),
diff -druNp --no-dereference linux-libre-3.16.49-gnu/sound/pci/hda/patch_realtek.c linux-libre-3.16.50-gnu/sound/pci/hda/patch_realtek.c
--- linux-libre-3.16.49-gnu/sound/pci/hda/patch_realtek.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/sound/pci/hda/patch_realtek.c	2017-11-11 08:34:06.000000000 -0500
@@ -2285,6 +2285,7 @@ static const struct snd_pci_quirk alc882
 	SND_PCI_QUIRK(0x1043, 0x8691, "ASUS ROG Ranger VIII", ALC882_FIXUP_GPIO3),
 	SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
 	SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
+	SND_PCI_QUIRK(0x104d, 0x9060, "Sony Vaio VPCL14M1R", ALC882_FIXUP_NO_PRIMARY_HP),
 	SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
 	SND_PCI_QUIRK(0x104d, 0x9044, "Sony VAIO AiO", ALC882_FIXUP_NO_PRIMARY_HP),
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/sound/soc/codecs/adau1977.c linux-libre-3.16.50-gnu/sound/soc/codecs/adau1977.c
--- linux-libre-3.16.49-gnu/sound/soc/codecs/adau1977.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/sound/soc/codecs/adau1977.c	2017-11-11 08:34:06.000000000 -0500
@@ -968,7 +968,7 @@ int adau1977_probe(struct device *dev, s
 	if (adau1977->dvdd_reg)
 		power_off_mask = ~0;
 	else
-		power_off_mask = ~ADAU1977_BLOCK_POWER_SAI_LDO_EN;
+		power_off_mask = (unsigned int)~ADAU1977_BLOCK_POWER_SAI_LDO_EN;
 
 	ret = regmap_update_bits(adau1977->regmap, ADAU1977_REG_BLOCK_POWER_SAI,
 				power_off_mask, 0x00);
diff -druNp --no-dereference linux-libre-3.16.49-gnu/sound/soc/fsl/fsl_sai.c linux-libre-3.16.50-gnu/sound/soc/fsl/fsl_sai.c
--- linux-libre-3.16.49-gnu/sound/soc/fsl/fsl_sai.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/sound/soc/fsl/fsl_sai.c	2017-11-11 08:34:06.000000000 -0500
@@ -333,8 +333,7 @@ static int fsl_sai_trigger(struct snd_pc
 	 * The transmitter bit clock and frame sync are to be
 	 * used by both the transmitter and receiver.
 	 */
-	regmap_update_bits(sai->regmap, FSL_SAI_TCR2, FSL_SAI_CR2_SYNC,
-			   ~FSL_SAI_CR2_SYNC);
+	regmap_update_bits(sai->regmap, FSL_SAI_TCR2, FSL_SAI_CR2_SYNC, 0);
 	regmap_update_bits(sai->regmap, FSL_SAI_RCR2, FSL_SAI_CR2_SYNC,
 			   FSL_SAI_CR2_SYNC);
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/sound/soc/fsl/fsl_ssi.c linux-libre-3.16.50-gnu/sound/soc/fsl/fsl_ssi.c
--- linux-libre-3.16.49-gnu/sound/soc/fsl/fsl_ssi.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/sound/soc/fsl/fsl_ssi.c	2017-11-11 08:34:06.000000000 -0500
@@ -590,8 +590,8 @@ static int fsl_ssi_set_bclk(struct snd_p
 		else
 			clkrate = clk_round_rate(ssi_private->baudclk, tmprate);
 
-		do_div(clkrate, factor);
-		afreq = (u32)clkrate / (i + 1);
+		clkrate /= factor;
+		afreq = clkrate / (i + 1);
 
 		if (freq == afreq)
 			sub = 0;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/sound/soc/fsl/imx-audmux.c linux-libre-3.16.50-gnu/sound/soc/fsl/imx-audmux.c
--- linux-libre-3.16.49-gnu/sound/soc/fsl/imx-audmux.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/sound/soc/fsl/imx-audmux.c	2017-11-11 08:34:06.000000000 -0500
@@ -67,7 +67,7 @@ static ssize_t audmux_read_file(struct f
 {
 	ssize_t ret;
 	char *buf;
-	int port = (int)file->private_data;
+	uintptr_t port = (uintptr_t)file->private_data;
 	u32 pdcr, ptcr;
 
 	if (audmux_clk) {
@@ -147,7 +147,7 @@ static const struct file_operations audm
 
 static void audmux_debugfs_init(void)
 {
-	int i;
+	uintptr_t i;
 	char buf[20];
 
 	audmux_debugfs_root = debugfs_create_dir("audmux", NULL);
@@ -157,10 +157,10 @@ static void audmux_debugfs_init(void)
 	}
 
 	for (i = 0; i < MX31_AUDMUX_PORT7_SSI_PINS_7 + 1; i++) {
-		snprintf(buf, sizeof(buf), "ssi%d", i);
+		snprintf(buf, sizeof(buf), "ssi%lu", i);
 		if (!debugfs_create_file(buf, 0444, audmux_debugfs_root,
 					 (void *)i, &audmux_debugfs_fops))
-			pr_warning("Failed to create AUDMUX port %d debugfs file\n",
+			pr_warning("Failed to create AUDMUX port %lu debugfs file\n",
 				   i);
 	}
 }
diff -druNp --no-dereference linux-libre-3.16.49-gnu/sound/soc/soc-pcm.c linux-libre-3.16.50-gnu/sound/soc/soc-pcm.c
--- linux-libre-3.16.49-gnu/sound/soc/soc-pcm.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/sound/soc/soc-pcm.c	2017-11-11 08:34:06.000000000 -0500
@@ -150,6 +150,10 @@ int dpcm_dapm_stream_event(struct snd_so
 		dev_dbg(be->dev, "ASoC: BE %s event %d dir %d\n",
 				be->dai_link->name, event, dir);
 
+		if ((event == SND_SOC_DAPM_STREAM_STOP) &&
+		    (be->dpcm[dir].users >= 1))
+			continue;
+
 		snd_soc_dapm_stream_event(be, dir, event);
 	}
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/sound/usb/card.c linux-libre-3.16.50-gnu/sound/usb/card.c
--- linux-libre-3.16.49-gnu/sound/usb/card.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/sound/usb/card.c	2017-11-11 08:34:06.000000000 -0500
@@ -219,6 +219,7 @@ static int snd_usb_create_streams(struct
 	struct usb_interface_descriptor *altsd;
 	void *control_header;
 	int i, protocol;
+	int rest_bytes;
 
 	/* find audiocontrol interface */
 	host_iface = &usb_ifnum_to_if(dev, ctrlif)->altsetting[0];
@@ -233,6 +234,15 @@ static int snd_usb_create_streams(struct
 		return -EINVAL;
 	}
 
+	rest_bytes = (void *)(host_iface->extra + host_iface->extralen) -
+		control_header;
+
+	/* just to be sure -- this shouldn't hit at all */
+	if (rest_bytes <= 0) {
+		dev_err(&dev->dev, "invalid control header\n");
+		return -EINVAL;
+	}
+
 	switch (protocol) {
 	default:
 		dev_warn(&dev->dev,
@@ -243,11 +253,21 @@ static int snd_usb_create_streams(struct
 	case UAC_VERSION_1: {
 		struct uac1_ac_header_descriptor *h1 = control_header;
 
+		if (rest_bytes < sizeof(*h1)) {
+			dev_err(&dev->dev, "too short v1 buffer descriptor\n");
+			return -EINVAL;
+		}
+
 		if (!h1->bInCollection) {
 			dev_info(&dev->dev, "skipping empty audio interface (v1)\n");
 			return -EINVAL;
 		}
 
+		if (rest_bytes < h1->bLength) {
+			dev_err(&dev->dev, "invalid buffer length (v1)\n");
+			return -EINVAL;
+		}
+
 		if (h1->bLength < sizeof(*h1) + h1->bInCollection) {
 			dev_err(&dev->dev, "invalid UAC_HEADER (v1)\n");
 			return -EINVAL;
diff -druNp --no-dereference linux-libre-3.16.49-gnu/sound/usb/mixer.c linux-libre-3.16.50-gnu/sound/usb/mixer.c
--- linux-libre-3.16.49-gnu/sound/usb/mixer.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/sound/usb/mixer.c	2017-11-11 08:34:06.000000000 -0500
@@ -533,6 +533,8 @@ int snd_usb_mixer_vol_tlv(struct snd_kco
 
 	if (size < sizeof(scale))
 		return -ENOMEM;
+	if (cval->min_mute)
+		scale[0] = SNDRV_CTL_TLVT_DB_MINMAX_MUTE;
 	scale[2] = cval->dBmin;
 	scale[3] = cval->dBmax;
 	if (copy_to_user(_tlv, scale, sizeof(scale)))
@@ -2156,6 +2158,9 @@ static int parse_audio_unit(struct mixer
 
 static void snd_usb_mixer_free(struct usb_mixer_interface *mixer)
 {
+	/* kill pending URBs */
+	snd_usb_mixer_disconnect(&mixer->list);
+
 	kfree(mixer->id_elems);
 	if (mixer->urb) {
 		kfree(mixer->urb->transfer_buffer);
@@ -2492,8 +2497,13 @@ void snd_usb_mixer_disconnect(struct lis
 	struct usb_mixer_interface *mixer;
 
 	mixer = list_entry(p, struct usb_mixer_interface, list);
-	usb_kill_urb(mixer->urb);
-	usb_kill_urb(mixer->rc_urb);
+	if (mixer->disconnected)
+		return;
+	if (mixer->urb)
+		usb_kill_urb(mixer->urb);
+	if (mixer->rc_urb)
+		usb_kill_urb(mixer->rc_urb);
+	mixer->disconnected = true;
 }
 
 #ifdef CONFIG_PM
diff -druNp --no-dereference linux-libre-3.16.49-gnu/sound/usb/mixer.h linux-libre-3.16.50-gnu/sound/usb/mixer.h
--- linux-libre-3.16.49-gnu/sound/usb/mixer.h	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/sound/usb/mixer.h	2017-11-11 08:34:06.000000000 -0500
@@ -23,6 +23,8 @@ struct usb_mixer_interface {
 
 	u8 audigy2nx_leds[3];
 	u8 xonar_u1_status;
+
+	bool disconnected;
 };
 
 #define MAX_CHANNELS	16	/* max logical channels */
@@ -53,6 +55,7 @@ struct usb_mixer_elem_info {
 	int cached;
 	int cache_val[MAX_CHANNELS];
 	u8 initialized;
+	u8 min_mute;
 };
 
 int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif,
diff -druNp --no-dereference linux-libre-3.16.49-gnu/sound/usb/mixer_quirks.c linux-libre-3.16.50-gnu/sound/usb/mixer_quirks.c
--- linux-libre-3.16.49-gnu/sound/usb/mixer_quirks.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/sound/usb/mixer_quirks.c	2017-11-11 08:34:06.000000000 -0500
@@ -1759,6 +1759,12 @@ void snd_usb_mixer_fu_apply_quirk(struct
 		if (unitid == 7 && cval->control == UAC_FU_VOLUME)
 			snd_dragonfly_quirk_db_scale(mixer, cval, kctl);
 		break;
+	/* lowest playback value is muted on C-Media devices */
+	case USB_ID(0x0d8c, 0x000c):
+	case USB_ID(0x0d8c, 0x0014):
+		if (strstr(kctl->id.name, "Playback"))
+			cval->min_mute = 1;
+		break;
 	}
 }
 
diff -druNp --no-dereference linux-libre-3.16.49-gnu/tools/perf/ui/browser.c linux-libre-3.16.50-gnu/tools/perf/ui/browser.c
--- linux-libre-3.16.49-gnu/tools/perf/ui/browser.c	2017-10-12 10:28:25.000000000 -0400
+++ linux-libre-3.16.50-gnu/tools/perf/ui/browser.c	2017-11-11 08:34:06.000000000 -0500
@@ -670,7 +670,7 @@ static void __ui_browser__line_arrow_dow
 		ui_browser__gotorc(browser, row, column + 1);
 		SLsmg_draw_hline(2);
 
-		if (row++ == 0)
+		if (++row == 0)
 			goto out;
 	} else
 		row = 0;
