diff -druNp --no-dereference linux-libre-4.4.138-gnu/arch/arm/include/asm/kgdb.h linux-libre-4.4.139-gnu/arch/arm/include/asm/kgdb.h
--- linux-libre-4.4.138-gnu/arch/arm/include/asm/kgdb.h	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/arch/arm/include/asm/kgdb.h	2018-07-03 05:21:35.000000000 -0400
@@ -76,7 +76,7 @@ extern int kgdb_fault_expected;
 
 #define KGDB_MAX_NO_CPUS	1
 #define BUFMAX			400
-#define NUMREGBYTES		(DBG_MAX_REG_NUM << 2)
+#define NUMREGBYTES		(GDB_MAX_REGS << 2)
 #define NUMCRITREGBYTES		(32 << 2)
 
 #define _R0			0
diff -druNp --no-dereference linux-libre-4.4.138-gnu/arch/m68k/mm/kmap.c linux-libre-4.4.139-gnu/arch/m68k/mm/kmap.c
--- linux-libre-4.4.138-gnu/arch/m68k/mm/kmap.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/arch/m68k/mm/kmap.c	2018-07-03 05:21:35.000000000 -0400
@@ -88,7 +88,8 @@ static inline void free_io_area(void *ad
 	for (p = &iolist ; (tmp = *p) ; p = &tmp->next) {
 		if (tmp->addr == addr) {
 			*p = tmp->next;
-			__iounmap(tmp->addr, tmp->size);
+			/* remove gap added in get_io_area() */
+			__iounmap(tmp->addr, tmp->size - IO_SIZE);
 			kfree(tmp);
 			return;
 		}
diff -druNp --no-dereference linux-libre-4.4.138-gnu/arch/mips/bcm47xx/setup.c linux-libre-4.4.139-gnu/arch/mips/bcm47xx/setup.c
--- linux-libre-4.4.138-gnu/arch/mips/bcm47xx/setup.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/arch/mips/bcm47xx/setup.c	2018-07-03 05:21:35.000000000 -0400
@@ -249,6 +249,12 @@ static int __init bcm47xx_cpu_fixes(void
 		 */
 		if (bcm47xx_bus.bcma.bus.chipinfo.id == BCMA_CHIP_ID_BCM4706)
 			cpu_wait = NULL;
+
+		/*
+		 * BCM47XX Erratum "R10: PCIe Transactions Periodically Fail"
+		 * Enable ExternalSync for sync instruction to take effect
+		 */
+		set_c0_config7(MIPS_CONF7_ES);
 		break;
 #endif
 	}
diff -druNp --no-dereference linux-libre-4.4.138-gnu/arch/mips/include/asm/io.h linux-libre-4.4.139-gnu/arch/mips/include/asm/io.h
--- linux-libre-4.4.138-gnu/arch/mips/include/asm/io.h	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/arch/mips/include/asm/io.h	2018-07-03 05:21:35.000000000 -0400
@@ -411,6 +411,8 @@ static inline type pfx##in##bwlq##p(unsi
 	__val = *__addr;						\
 	slow;								\
 									\
+	/* prevent prefetching of coherent DMA data prematurely */	\
+	rmb();								\
 	return pfx##ioswab##bwlq(__addr, __val);			\
 }
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/arch/mips/include/asm/mipsregs.h linux-libre-4.4.139-gnu/arch/mips/include/asm/mipsregs.h
--- linux-libre-4.4.138-gnu/arch/mips/include/asm/mipsregs.h	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/arch/mips/include/asm/mipsregs.h	2018-07-03 05:21:35.000000000 -0400
@@ -605,6 +605,8 @@
 #define MIPS_CONF7_WII		(_ULCAST_(1) << 31)
 
 #define MIPS_CONF7_RPS		(_ULCAST_(1) << 2)
+/* ExternalSync */
+#define MIPS_CONF7_ES		(_ULCAST_(1) << 8)
 
 #define MIPS_CONF7_IAR		(_ULCAST_(1) << 10)
 #define MIPS_CONF7_AR		(_ULCAST_(1) << 16)
@@ -2012,6 +2014,7 @@ __BUILD_SET_C0(status)
 __BUILD_SET_C0(cause)
 __BUILD_SET_C0(config)
 __BUILD_SET_C0(config5)
+__BUILD_SET_C0(config7)
 __BUILD_SET_C0(intcontrol)
 __BUILD_SET_C0(intctl)
 __BUILD_SET_C0(srsmap)
diff -druNp --no-dereference linux-libre-4.4.138-gnu/arch/mips/kernel/mcount.S linux-libre-4.4.139-gnu/arch/mips/kernel/mcount.S
--- linux-libre-4.4.138-gnu/arch/mips/kernel/mcount.S	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/arch/mips/kernel/mcount.S	2018-07-03 05:21:35.000000000 -0400
@@ -116,10 +116,20 @@ ftrace_stub:
 NESTED(_mcount, PT_SIZE, ra)
 	PTR_LA	t1, ftrace_stub
 	PTR_L	t2, ftrace_trace_function /* Prepare t2 for (1) */
-	bne	t1, t2, static_trace
+	beq	t1, t2, fgraph_trace
 	 nop
 
+	MCOUNT_SAVE_REGS
+
+	move	a0, ra		/* arg1: self return address */
+	jalr	t2		/* (1) call *ftrace_trace_function */
+	 move	a1, AT		/* arg2: parent's return address */
+
+	MCOUNT_RESTORE_REGS
+
+fgraph_trace:
 #ifdef	CONFIG_FUNCTION_GRAPH_TRACER
+	PTR_LA	t1, ftrace_stub
 	PTR_L	t3, ftrace_graph_return
 	bne	t1, t3, ftrace_graph_caller
 	 nop
@@ -128,24 +138,11 @@ NESTED(_mcount, PT_SIZE, ra)
 	bne	t1, t3, ftrace_graph_caller
 	 nop
 #endif
-	b	ftrace_stub
-#ifdef CONFIG_32BIT
-	 addiu sp, sp, 8
-#else
-	 nop
-#endif
-
-static_trace:
-	MCOUNT_SAVE_REGS
 
-	move	a0, ra		/* arg1: self return address */
-	jalr	t2		/* (1) call *ftrace_trace_function */
-	 move	a1, AT		/* arg2: parent's return address */
-
-	MCOUNT_RESTORE_REGS
 #ifdef CONFIG_32BIT
 	addiu sp, sp, 8
 #endif
+
 	.globl ftrace_stub
 ftrace_stub:
 	RETURN_BACK
diff -druNp --no-dereference linux-libre-4.4.138-gnu/arch/powerpc/kernel/entry_64.S linux-libre-4.4.139-gnu/arch/powerpc/kernel/entry_64.S
--- linux-libre-4.4.138-gnu/arch/powerpc/kernel/entry_64.S	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/arch/powerpc/kernel/entry_64.S	2018-07-03 05:21:35.000000000 -0400
@@ -574,6 +574,7 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEG
 	 * actually hit this code path.
 	 */
 
+	isync
 	slbie	r6
 	slbie	r6		/* Workaround POWER5 < DD2.1 issue */
 	slbmte	r7,r0
diff -druNp --no-dereference linux-libre-4.4.138-gnu/arch/powerpc/kernel/fadump.c linux-libre-4.4.139-gnu/arch/powerpc/kernel/fadump.c
--- linux-libre-4.4.138-gnu/arch/powerpc/kernel/fadump.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/arch/powerpc/kernel/fadump.c	2018-07-03 05:21:35.000000000 -0400
@@ -1025,6 +1025,9 @@ void fadump_cleanup(void)
 		init_fadump_mem_struct(&fdm,
 			be64_to_cpu(fdm_active->cpu_state_data.destination_address));
 		fadump_invalidate_dump(&fdm);
+	} else if (fw_dump.dump_registered) {
+		/* Un-register Firmware-assisted dump if it was registered. */
+		fadump_unregister_dump(&fdm);
 	}
 }
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/arch/powerpc/kernel/hw_breakpoint.c linux-libre-4.4.139-gnu/arch/powerpc/kernel/hw_breakpoint.c
--- linux-libre-4.4.138-gnu/arch/powerpc/kernel/hw_breakpoint.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/arch/powerpc/kernel/hw_breakpoint.c	2018-07-03 05:21:35.000000000 -0400
@@ -174,8 +174,8 @@ int arch_validate_hwbkpt_settings(struct
 	if (cpu_has_feature(CPU_FTR_DAWR)) {
 		length_max = 512 ; /* 64 doublewords */
 		/* DAWR region can't cross 512 boundary */
-		if ((bp->attr.bp_addr >> 10) != 
-		    ((bp->attr.bp_addr + bp->attr.bp_len - 1) >> 10))
+		if ((bp->attr.bp_addr >> 9) !=
+		    ((bp->attr.bp_addr + bp->attr.bp_len - 1) >> 9))
 			return -EINVAL;
 	}
 	if (info->len >
diff -druNp --no-dereference linux-libre-4.4.138-gnu/arch/powerpc/kernel/ptrace.c linux-libre-4.4.139-gnu/arch/powerpc/kernel/ptrace.c
--- linux-libre-4.4.138-gnu/arch/powerpc/kernel/ptrace.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/arch/powerpc/kernel/ptrace.c	2018-07-03 05:21:35.000000000 -0400
@@ -1004,6 +1004,7 @@ static int ptrace_set_debugreg(struct ta
 	/* Create a new breakpoint request if one doesn't exist already */
 	hw_breakpoint_init(&attr);
 	attr.bp_addr = hw_brk.address;
+	attr.bp_len = 8;
 	arch_bp_generic_fields(hw_brk.type,
 			       &attr.bp_type);
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/arch/x86/include/asm/barrier.h linux-libre-4.4.139-gnu/arch/x86/include/asm/barrier.h
--- linux-libre-4.4.138-gnu/arch/x86/include/asm/barrier.h	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/arch/x86/include/asm/barrier.h	2018-07-03 05:21:35.000000000 -0400
@@ -38,7 +38,7 @@ static inline unsigned long array_index_
 {
 	unsigned long mask;
 
-	asm ("cmp %1,%2; sbb %0,%0;"
+	asm volatile ("cmp %1,%2; sbb %0,%0;"
 			:"=r" (mask)
 			:"r"(size),"r" (index)
 			:"cc");
diff -druNp --no-dereference linux-libre-4.4.138-gnu/arch/xtensa/kernel/traps.c linux-libre-4.4.139-gnu/arch/xtensa/kernel/traps.c
--- linux-libre-4.4.138-gnu/arch/xtensa/kernel/traps.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/arch/xtensa/kernel/traps.c	2018-07-03 05:21:35.000000000 -0400
@@ -309,7 +309,7 @@ do_unaligned_user (struct pt_regs *regs)
 	info.si_errno = 0;
 	info.si_code = BUS_ADRALN;
 	info.si_addr = (void *) regs->excvaddr;
-	force_sig_info(SIGSEGV, &info, current);
+	force_sig_info(SIGBUS, &info, current);
 
 }
 #endif
diff -druNp --no-dereference linux-libre-4.4.138-gnu/Documentation/printk-formats.txt linux-libre-4.4.139-gnu/Documentation/printk-formats.txt
--- linux-libre-4.4.138-gnu/Documentation/printk-formats.txt	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/Documentation/printk-formats.txt	2018-07-03 05:21:35.000000000 -0400
@@ -273,11 +273,10 @@ struct clk:
 
 	%pC	pll1
 	%pCn	pll1
-	%pCr	1560000000
 
 	For printing struct clk structures. '%pC' and '%pCn' print the name
 	(Common Clock Framework) or address (legacy clock framework) of the
-	structure; '%pCr' prints the current clock rate.
+	structure.
 
 	Passed by reference.
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/ata/libata-core.c linux-libre-4.4.139-gnu/drivers/ata/libata-core.c
--- linux-libre-4.4.138-gnu/drivers/ata/libata-core.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/ata/libata-core.c	2018-07-03 05:21:35.000000000 -0400
@@ -4247,9 +4247,6 @@ static const struct ata_blacklist_entry
 						ATA_HORKAGE_ZERO_AFTER_TRIM |
 						ATA_HORKAGE_NOLPM, },
 
-	/* Sandisk devices which are known to not handle LPM well */
-	{ "SanDisk SD7UB3Q*G1001",	NULL,	ATA_HORKAGE_NOLPM, },
-
 	/* devices that don't properly handle queued TRIM commands */
 	{ "Micron_M500IT_*",		"MU01",	ATA_HORKAGE_NO_NCQ_TRIM |
 						ATA_HORKAGE_ZERO_AFTER_TRIM, },
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/ata/libata-zpodd.c linux-libre-4.4.139-gnu/drivers/ata/libata-zpodd.c
--- linux-libre-4.4.138-gnu/drivers/ata/libata-zpodd.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/ata/libata-zpodd.c	2018-07-03 05:21:35.000000000 -0400
@@ -34,7 +34,7 @@ struct zpodd {
 static int eject_tray(struct ata_device *dev)
 {
 	struct ata_taskfile tf;
-	const char cdb[] = {  GPCMD_START_STOP_UNIT,
+	static const char cdb[ATAPI_CDB_LEN] = {  GPCMD_START_STOP_UNIT,
 		0, 0, 0,
 		0x02,     /* LoEj */
 		0, 0, 0, 0, 0, 0, 0,
@@ -55,7 +55,7 @@ static enum odd_mech_type zpodd_get_mech
 	unsigned int ret;
 	struct rm_feature_desc *desc = (void *)(buf + 8);
 	struct ata_taskfile tf;
-	char cdb[] = {  GPCMD_GET_CONFIGURATION,
+	static const char cdb[] = {  GPCMD_GET_CONFIGURATION,
 			2,      /* only 1 feature descriptor requested */
 			0, 3,   /* 3, removable medium feature */
 			0, 0, 0,/* reserved */
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/atm/zatm.c linux-libre-4.4.139-gnu/drivers/atm/zatm.c
--- linux-libre-4.4.138-gnu/drivers/atm/zatm.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/atm/zatm.c	2018-07-03 05:21:35.000000000 -0400
@@ -1149,8 +1149,8 @@ static void eprom_get_byte(struct zatm_d
 }
 
 
-static unsigned char eprom_try_esi(struct atm_dev *dev, unsigned short cmd,
-				   int offset, int swap)
+static int eprom_try_esi(struct atm_dev *dev, unsigned short cmd, int offset,
+			 int swap)
 {
 	unsigned char buf[ZEPROM_SIZE];
 	struct zatm_dev *zatm_dev;
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/base/core.c linux-libre-4.4.139-gnu/drivers/base/core.c
--- linux-libre-4.4.138-gnu/drivers/base/core.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/base/core.c	2018-07-03 05:21:35.000000000 -0400
@@ -759,7 +759,7 @@ class_dir_create_and_add(struct class *c
 
 	dir = kzalloc(sizeof(*dir), GFP_KERNEL);
 	if (!dir)
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 
 	dir->class = class;
 	kobject_init(&dir->kobj, &class_dir_ktype);
@@ -769,7 +769,7 @@ class_dir_create_and_add(struct class *c
 	retval = kobject_add(&dir->kobj, parent_kobj, "%s", class->name);
 	if (retval < 0) {
 		kobject_put(&dir->kobj);
-		return NULL;
+		return ERR_PTR(retval);
 	}
 	return &dir->kobj;
 }
@@ -1076,6 +1076,10 @@ int device_add(struct device *dev)
 
 	parent = get_device(dev->parent);
 	kobj = get_device_parent(dev, parent);
+	if (IS_ERR(kobj)) {
+		error = PTR_ERR(kobj);
+		goto parent_error;
+	}
 	if (kobj)
 		dev->kobj.parent = kobj;
 
@@ -1174,6 +1178,7 @@ done:
 	kobject_del(&dev->kobj);
  Error:
 	cleanup_glue_dir(dev, glue_dir);
+parent_error:
 	put_device(parent);
 name_error:
 	kfree(dev->p);
@@ -1990,6 +1995,11 @@ int device_move(struct device *dev, stru
 	device_pm_lock();
 	new_parent = get_device(new_parent);
 	new_parent_kobj = get_device_parent(dev, new_parent);
+	if (IS_ERR(new_parent_kobj)) {
+		error = PTR_ERR(new_parent_kobj);
+		put_device(new_parent);
+		goto out;
+	}
 
 	pr_debug("device: '%s': %s: moving to '%s'\n", dev_name(dev),
 		 __func__, new_parent ? dev_name(new_parent) : "<NULL>");
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/bluetooth/hci_qca.c linux-libre-4.4.139-gnu/drivers/bluetooth/hci_qca.c
--- linux-libre-4.4.138-gnu/drivers/bluetooth/hci_qca.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/bluetooth/hci_qca.c	2018-07-03 05:21:35.000000000 -0400
@@ -939,6 +939,12 @@ static int qca_setup(struct hci_uart *hu
 	} else if (ret == -ENOENT) {
 		/* No patch/nvm-config found, run with original fw/config */
 		ret = 0;
+	} else if (ret == -EAGAIN) {
+		/*
+		 * Userspace firmware loader will return -EAGAIN in case no
+		 * patch/nvm-config is found, so run with original fw/config.
+		 */
+		ret = 0;
 	}
 
 	/* Setup bdaddr */
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/char/ipmi/ipmi_bt_sm.c linux-libre-4.4.139-gnu/drivers/char/ipmi/ipmi_bt_sm.c
--- linux-libre-4.4.138-gnu/drivers/char/ipmi/ipmi_bt_sm.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/char/ipmi/ipmi_bt_sm.c	2018-07-03 05:21:35.000000000 -0400
@@ -522,11 +522,12 @@ static enum si_sm_result bt_event(struct
 		if (status & BT_H_BUSY)		/* clear a leftover H_BUSY */
 			BT_CONTROL(BT_H_BUSY);
 
+		bt->timeout = bt->BT_CAP_req2rsp;
+
 		/* Read BT capabilities if it hasn't been done yet */
 		if (!bt->BT_CAP_outreqs)
 			BT_STATE_CHANGE(BT_STATE_CAPABILITIES_BEGIN,
 					SI_SM_CALL_WITHOUT_DELAY);
-		bt->timeout = bt->BT_CAP_req2rsp;
 		BT_SI_SM_RETURN(SI_SM_IDLE);
 
 	case BT_STATE_XACTION_START:
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/cpufreq/cpufreq.c linux-libre-4.4.139-gnu/drivers/cpufreq/cpufreq.c
--- linux-libre-4.4.138-gnu/drivers/cpufreq/cpufreq.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/cpufreq/cpufreq.c	2018-07-03 05:21:35.000000000 -0400
@@ -603,6 +603,8 @@ static ssize_t store_##file_name					\
 	struct cpufreq_policy new_policy;				\
 									\
 	memcpy(&new_policy, policy, sizeof(*policy));			\
+	new_policy.min = policy->user_policy.min;			\
+	new_policy.max = policy->user_policy.max;			\
 									\
 	ret = sscanf(buf, "%u", &new_policy.object);			\
 	if (ret != 1)							\
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/cpuidle/cpuidle-powernv.c linux-libre-4.4.139-gnu/drivers/cpuidle/cpuidle-powernv.c
--- linux-libre-4.4.138-gnu/drivers/cpuidle/cpuidle-powernv.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/cpuidle/cpuidle-powernv.c	2018-07-03 05:21:35.000000000 -0400
@@ -29,9 +29,31 @@ struct cpuidle_driver powernv_idle_drive
 
 static int max_idle_state;
 static struct cpuidle_state *cpuidle_state_table;
-static u64 snooze_timeout;
+static u64 default_snooze_timeout;
 static bool snooze_timeout_en;
 
+static u64 get_snooze_timeout(struct cpuidle_device *dev,
+			      struct cpuidle_driver *drv,
+			      int index)
+{
+	int i;
+
+	if (unlikely(!snooze_timeout_en))
+		return default_snooze_timeout;
+
+	for (i = index + 1; i < drv->state_count; i++) {
+		struct cpuidle_state *s = &drv->states[i];
+		struct cpuidle_state_usage *su = &dev->states_usage[i];
+
+		if (s->disabled || su->disable)
+			continue;
+
+		return s->target_residency * tb_ticks_per_usec;
+	}
+
+	return default_snooze_timeout;
+}
+
 static int snooze_loop(struct cpuidle_device *dev,
 			struct cpuidle_driver *drv,
 			int index)
@@ -41,7 +63,7 @@ static int snooze_loop(struct cpuidle_de
 	local_irq_enable();
 	set_thread_flag(TIF_POLLING_NRFLAG);
 
-	snooze_exit_time = get_tb() + snooze_timeout;
+	snooze_exit_time = get_tb() + get_snooze_timeout(dev, drv, index);
 	ppc64_runlatch_off();
 	while (!need_resched()) {
 		HMT_low();
@@ -286,11 +308,9 @@ static int powernv_idle_probe(void)
 		cpuidle_state_table = powernv_states;
 		/* Device tree can indicate more idle states */
 		max_idle_state = powernv_add_idle_states();
-		if (max_idle_state > 1) {
+		default_snooze_timeout = TICK_USEC * tb_ticks_per_usec;
+		if (max_idle_state > 1)
 			snooze_timeout_en = true;
-			snooze_timeout = powernv_states[1].target_residency *
-					 tb_ticks_per_usec;
-		}
  	} else
  		return -ENODEV;
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/iio/buffer/kfifo_buf.c linux-libre-4.4.139-gnu/drivers/iio/buffer/kfifo_buf.c
--- linux-libre-4.4.138-gnu/drivers/iio/buffer/kfifo_buf.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/iio/buffer/kfifo_buf.c	2018-07-03 05:21:35.000000000 -0400
@@ -19,7 +19,7 @@ struct iio_kfifo {
 #define iio_to_kfifo(r) container_of(r, struct iio_kfifo, buffer)
 
 static inline int __iio_allocate_kfifo(struct iio_kfifo *buf,
-				int bytes_per_datum, int length)
+			size_t bytes_per_datum, unsigned int length)
 {
 	if ((length == 0) || (bytes_per_datum == 0))
 		return -EINVAL;
@@ -71,7 +71,7 @@ static int iio_set_bytes_per_datum_kfifo
 	return 0;
 }
 
-static int iio_set_length_kfifo(struct iio_buffer *r, int length)
+static int iio_set_length_kfifo(struct iio_buffer *r, unsigned int length)
 {
 	/* Avoid an invalid state */
 	if (length < 2)
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/infiniband/hw/mlx4/mad.c linux-libre-4.4.139-gnu/drivers/infiniband/hw/mlx4/mad.c
--- linux-libre-4.4.138-gnu/drivers/infiniband/hw/mlx4/mad.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/infiniband/hw/mlx4/mad.c	2018-07-03 05:21:35.000000000 -0400
@@ -1780,7 +1780,6 @@ static void mlx4_ib_sqp_comp_worker(stru
 					       "buf:%lld\n", wc.wr_id);
 				break;
 			default:
-				BUG_ON(1);
 				break;
 			}
 		} else  {
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/infiniband/hw/qib/qib_file_ops.c linux-libre-4.4.139-gnu/drivers/infiniband/hw/qib/qib_file_ops.c
--- linux-libre-4.4.138-gnu/drivers/infiniband/hw/qib/qib_file_ops.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/infiniband/hw/qib/qib_file_ops.c	2018-07-03 05:21:35.000000000 -0400
@@ -364,6 +364,8 @@ static int qib_tid_update(struct qib_ctx
 		goto done;
 	}
 	for (i = 0; i < cnt; i++, vaddr += PAGE_SIZE) {
+		dma_addr_t daddr;
+
 		for (; ntids--; tid++) {
 			if (tid == tidcnt)
 				tid = 0;
@@ -380,12 +382,14 @@ static int qib_tid_update(struct qib_ctx
 			ret = -ENOMEM;
 			break;
 		}
+		ret = qib_map_page(dd->pcidev, pagep[i], &daddr);
+		if (ret)
+			break;
+
 		tidlist[i] = tid + tidoff;
 		/* we "know" system pages and TID pages are same size */
 		dd->pageshadow[ctxttid + tid] = pagep[i];
-		dd->physshadow[ctxttid + tid] =
-			qib_map_page(dd->pcidev, pagep[i], 0, PAGE_SIZE,
-				     PCI_DMA_FROMDEVICE);
+		dd->physshadow[ctxttid + tid] = daddr;
 		/*
 		 * don't need atomic or it's overhead
 		 */
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/infiniband/hw/qib/qib.h linux-libre-4.4.139-gnu/drivers/infiniband/hw/qib/qib.h
--- linux-libre-4.4.138-gnu/drivers/infiniband/hw/qib/qib.h	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/infiniband/hw/qib/qib.h	2018-07-03 05:21:35.000000000 -0400
@@ -1451,8 +1451,7 @@ u64 qib_sps_ints(void);
 /*
  * dma_addr wrappers - all 0's invalid for hw
  */
-dma_addr_t qib_map_page(struct pci_dev *, struct page *, unsigned long,
-			  size_t, int);
+int qib_map_page(struct pci_dev *d, struct page *p, dma_addr_t *daddr);
 const char *qib_get_unit_name(int unit);
 
 /*
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/infiniband/hw/qib/qib_user_pages.c linux-libre-4.4.139-gnu/drivers/infiniband/hw/qib/qib_user_pages.c
--- linux-libre-4.4.138-gnu/drivers/infiniband/hw/qib/qib_user_pages.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/infiniband/hw/qib/qib_user_pages.c	2018-07-03 05:21:35.000000000 -0400
@@ -98,23 +98,27 @@ bail:
  *
  * I'm sure we won't be so lucky with other iommu's, so FIXME.
  */
-dma_addr_t qib_map_page(struct pci_dev *hwdev, struct page *page,
-			unsigned long offset, size_t size, int direction)
+int qib_map_page(struct pci_dev *hwdev, struct page *page, dma_addr_t *daddr)
 {
 	dma_addr_t phys;
 
-	phys = pci_map_page(hwdev, page, offset, size, direction);
+	phys = pci_map_page(hwdev, page, 0, PAGE_SIZE, PCI_DMA_FROMDEVICE);
+	if (pci_dma_mapping_error(hwdev, phys))
+		return -ENOMEM;
 
-	if (phys == 0) {
-		pci_unmap_page(hwdev, phys, size, direction);
-		phys = pci_map_page(hwdev, page, offset, size, direction);
+	if (!phys) {
+		pci_unmap_page(hwdev, phys, PAGE_SIZE, PCI_DMA_FROMDEVICE);
+		phys = pci_map_page(hwdev, page, 0, PAGE_SIZE,
+				    PCI_DMA_FROMDEVICE);
+		if (pci_dma_mapping_error(hwdev, phys))
+			return -ENOMEM;
 		/*
 		 * FIXME: If we get 0 again, we should keep this page,
 		 * map another, then free the 0 page.
 		 */
 	}
-
-	return phys;
+	*daddr = phys;
+	return 0;
 }
 
 /**
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/input/mouse/elan_i2c_core.c linux-libre-4.4.139-gnu/drivers/input/mouse/elan_i2c_core.c
--- linux-libre-4.4.138-gnu/drivers/input/mouse/elan_i2c_core.c	2018-06-16 13:16:08.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/input/mouse/elan_i2c_core.c	2018-07-03 13:39:02.000000000 -0400
@@ -595,7 +595,7 @@ static ssize_t calibrate_store(struct de
 	int tries = 20;
 	int retval;
 	int error;
-	u8 val[3];
+	u8 val[ETP_CALIBRATE_MAX_LEN];
 
 	retval = mutex_lock_interruptible(&data->sysfs_mutex);
 	if (retval)
@@ -1250,6 +1250,7 @@ static const struct acpi_device_id elan_
 	{ "ELAN060C", 0 },
 	{ "ELAN0611", 0 },
 	{ "ELAN0612", 0 },
+	{ "ELAN0618", 0 },
 	{ "ELAN1000", 0 },
 	{ }
 };
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/input/mouse/elan_i2c.h linux-libre-4.4.139-gnu/drivers/input/mouse/elan_i2c.h
--- linux-libre-4.4.138-gnu/drivers/input/mouse/elan_i2c.h	2018-06-16 13:16:10.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/input/mouse/elan_i2c.h	2018-07-03 13:39:04.000000000 -0400
@@ -27,6 +27,8 @@
 #define ETP_DISABLE_POWER	0x0001
 #define ETP_PRESSURE_OFFSET	25
 
+#define ETP_CALIBRATE_MAX_LEN	3
+
 /* IAP Firmware handling */
 #define ETP_PRODUCT_ID_FORMAT_STRING	"%d.0"
 #define ETP_FW_NAME		"/*(DEBLOBBED)*/"
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/input/mouse/elan_i2c_smbus.c linux-libre-4.4.139-gnu/drivers/input/mouse/elan_i2c_smbus.c
--- linux-libre-4.4.138-gnu/drivers/input/mouse/elan_i2c_smbus.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/input/mouse/elan_i2c_smbus.c	2018-07-03 05:21:35.000000000 -0400
@@ -56,7 +56,7 @@
 static int elan_smbus_initialize(struct i2c_client *client)
 {
 	u8 check[ETP_SMBUS_HELLOPACKET_LEN] = { 0x55, 0x55, 0x55, 0x55, 0x55 };
-	u8 values[ETP_SMBUS_HELLOPACKET_LEN] = { 0, 0, 0, 0, 0 };
+	u8 values[I2C_SMBUS_BLOCK_MAX] = {0};
 	int len, error;
 
 	/* Get hello packet */
@@ -117,12 +117,16 @@ static int elan_smbus_calibrate(struct i
 static int elan_smbus_calibrate_result(struct i2c_client *client, u8 *val)
 {
 	int error;
+	u8 buf[I2C_SMBUS_BLOCK_MAX] = {0};
+
+	BUILD_BUG_ON(ETP_CALIBRATE_MAX_LEN > sizeof(buf));
 
 	error = i2c_smbus_read_block_data(client,
-					  ETP_SMBUS_CALIBRATE_QUERY, val);
+					  ETP_SMBUS_CALIBRATE_QUERY, buf);
 	if (error < 0)
 		return error;
 
+	memcpy(val, buf, ETP_CALIBRATE_MAX_LEN);
 	return 0;
 }
 
@@ -466,6 +470,8 @@ static int elan_smbus_get_report(struct
 {
 	int len;
 
+	BUILD_BUG_ON(I2C_SMBUS_BLOCK_MAX > ETP_SMBUS_REPORT_LEN);
+
 	len = i2c_smbus_read_block_data(client,
 					ETP_SMBUS_PACKET_QUERY,
 					&report[ETP_SMBUS_REPORT_OFFSET]);
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/input/mouse/elantech.c linux-libre-4.4.139-gnu/drivers/input/mouse/elantech.c
--- linux-libre-4.4.138-gnu/drivers/input/mouse/elantech.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/input/mouse/elantech.c	2018-07-03 05:21:35.000000000 -0400
@@ -804,7 +804,7 @@ static int elantech_packet_check_v4(stru
 	else if (ic_version == 7 && etd->samples[1] == 0x2A)
 		sanity_check = ((packet[3] & 0x1c) == 0x10);
 	else
-		sanity_check = ((packet[0] & 0x0c) == 0x04 &&
+		sanity_check = ((packet[0] & 0x08) == 0x00 &&
 				(packet[3] & 0x1c) == 0x10);
 
 	if (!sanity_check)
@@ -1177,6 +1177,12 @@ static const struct dmi_system_id elante
 	{ }
 };
 
+static const char * const middle_button_pnp_ids[] = {
+	"LEN2131", /* ThinkPad P52 w/ NFC */
+	"LEN2132", /* ThinkPad P52 */
+	NULL
+};
+
 /*
  * Set the appropriate event bits for the input subsystem
  */
@@ -1196,7 +1202,8 @@ static int elantech_set_input_params(str
 	__clear_bit(EV_REL, dev->evbit);
 
 	__set_bit(BTN_LEFT, dev->keybit);
-	if (dmi_check_system(elantech_dmi_has_middle_button))
+	if (dmi_check_system(elantech_dmi_has_middle_button) ||
+			psmouse_matches_pnp_id(psmouse, middle_button_pnp_ids))
 		__set_bit(BTN_MIDDLE, dev->keybit);
 	__set_bit(BTN_RIGHT, dev->keybit);
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/md/dm-thin.c linux-libre-4.4.139-gnu/drivers/md/dm-thin.c
--- linux-libre-4.4.138-gnu/drivers/md/dm-thin.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/md/dm-thin.c	2018-07-03 05:21:35.000000000 -0400
@@ -1299,6 +1299,8 @@ static void schedule_external_copy(struc
 
 static void set_pool_mode(struct pool *pool, enum pool_mode new_mode);
 
+static void requeue_bios(struct pool *pool);
+
 static void check_for_space(struct pool *pool)
 {
 	int r;
@@ -1311,8 +1313,10 @@ static void check_for_space(struct pool
 	if (r)
 		return;
 
-	if (nr_free)
+	if (nr_free) {
 		set_pool_mode(pool, PM_WRITE);
+		requeue_bios(pool);
+	}
 }
 
 /*
@@ -1389,7 +1393,10 @@ static int alloc_data_block(struct thin_
 
 	r = dm_pool_alloc_data_block(pool->pmd, result);
 	if (r) {
-		metadata_operation_failed(pool, "dm_pool_alloc_data_block", r);
+		if (r == -ENOSPC)
+			set_pool_mode(pool, PM_OUT_OF_DATA_SPACE);
+		else
+			metadata_operation_failed(pool, "dm_pool_alloc_data_block", r);
 		return r;
 	}
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/md/md.c linux-libre-4.4.139-gnu/drivers/md/md.c
--- linux-libre-4.4.138-gnu/drivers/md/md.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/md/md.c	2018-07-03 05:21:35.000000000 -0400
@@ -2690,7 +2690,8 @@ state_store(struct md_rdev *rdev, const
 			err = 0;
 		}
 	} else if (cmd_match(buf, "re-add")) {
-		if (test_bit(Faulty, &rdev->flags) && (rdev->raid_disk == -1)) {
+		if (test_bit(Faulty, &rdev->flags) && (rdev->raid_disk == -1) &&
+			rdev->saved_raid_disk >= 0) {
 			/* clear_bit is performed _after_ all the devices
 			 * have their local Faulty bit cleared. If any writes
 			 * happen in the meantime in the local node, they
@@ -8153,6 +8154,7 @@ static int remove_and_add_spares(struct
 			if (mddev->pers->hot_remove_disk(
 				    mddev, rdev) == 0) {
 				sysfs_unlink_rdev(mddev, rdev);
+				rdev->saved_raid_disk = rdev->raid_disk;
 				rdev->raid_disk = -1;
 				removed++;
 			}
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/media/dvb-core/dvb_frontend.c linux-libre-4.4.139-gnu/drivers/media/dvb-core/dvb_frontend.c
--- linux-libre-4.4.138-gnu/drivers/media/dvb-core/dvb_frontend.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/media/dvb-core/dvb_frontend.c	2018-07-03 05:21:35.000000000 -0400
@@ -230,8 +230,20 @@ static void dvb_frontend_add_event(struc
 	wake_up_interruptible (&events->wait_queue);
 }
 
+static int dvb_frontend_test_event(struct dvb_frontend_private *fepriv,
+				   struct dvb_fe_events *events)
+{
+	int ret;
+
+	up(&fepriv->sem);
+	ret = events->eventw != events->eventr;
+	down(&fepriv->sem);
+
+	return ret;
+}
+
 static int dvb_frontend_get_event(struct dvb_frontend *fe,
-			    struct dvb_frontend_event *event, int flags)
+			          struct dvb_frontend_event *event, int flags)
 {
 	struct dvb_frontend_private *fepriv = fe->frontend_priv;
 	struct dvb_fe_events *events = &fepriv->events;
@@ -249,13 +261,8 @@ static int dvb_frontend_get_event(struct
 		if (flags & O_NONBLOCK)
 			return -EWOULDBLOCK;
 
-		up(&fepriv->sem);
-
-		ret = wait_event_interruptible (events->wait_queue,
-						events->eventw != events->eventr);
-
-		if (down_interruptible (&fepriv->sem))
-			return -ERESTARTSYS;
+		ret = wait_event_interruptible(events->wait_queue,
+					       dvb_frontend_test_event(fepriv, events));
 
 		if (ret < 0)
 			return ret;
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/media/usb/cx231xx/cx231xx-cards.c linux-libre-4.4.139-gnu/drivers/media/usb/cx231xx/cx231xx-cards.c
--- linux-libre-4.4.138-gnu/drivers/media/usb/cx231xx/cx231xx-cards.c	2018-06-16 13:02:47.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/media/usb/cx231xx/cx231xx-cards.c	2018-07-03 13:24:42.000000000 -0400
@@ -864,6 +864,9 @@ struct usb_device_id cx231xx_id_table[]
 	 .driver_info = CX231XX_BOARD_CNXT_RDE_250},
 	{USB_DEVICE(0x0572, 0x58A0),
 	 .driver_info = CX231XX_BOARD_CNXT_RDU_250},
+	/* AverMedia DVD EZMaker 7 */
+	{USB_DEVICE(0x07ca, 0xc039),
+	 .driver_info = CX231XX_BOARD_CNXT_VIDEO_GRABBER},
 	{USB_DEVICE(0x2040, 0xb110),
 	 .driver_info = CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL},
 	{USB_DEVICE(0x2040, 0xb111),
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/media/v4l2-core/v4l2-compat-ioctl32.c linux-libre-4.4.139-gnu/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
--- linux-libre-4.4.138-gnu/drivers/media/v4l2-core/v4l2-compat-ioctl32.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/media/v4l2-core/v4l2-compat-ioctl32.c	2018-07-03 05:21:35.000000000 -0400
@@ -864,7 +864,7 @@ static int put_v4l2_ext_controls32(struc
 	    get_user(kcontrols, &kp->controls))
 		return -EFAULT;
 
-	if (!count)
+	if (!count || count > (U32_MAX/sizeof(*ucontrols)))
 		return 0;
 	if (get_user(p, &up->controls))
 		return -EFAULT;
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/mfd/intel-lpss.c linux-libre-4.4.139-gnu/drivers/mfd/intel-lpss.c
--- linux-libre-4.4.138-gnu/drivers/mfd/intel-lpss.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/mfd/intel-lpss.c	2018-07-03 05:21:35.000000000 -0400
@@ -269,11 +269,11 @@ static void intel_lpss_init_dev(const st
 
 	intel_lpss_deassert_reset(lpss);
 
+	intel_lpss_set_remap_addr(lpss);
+
 	if (!intel_lpss_has_idma(lpss))
 		return;
 
-	intel_lpss_set_remap_addr(lpss);
-
 	/* Make sure that SPI multiblock DMA transfers are re-enabled */
 	if (lpss->type == LPSS_DEV_SPI)
 		writel(value, lpss->priv + LPSS_PRIV_SSP_REG);
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/mtd/chips/cfi_cmdset_0002.c linux-libre-4.4.139-gnu/drivers/mtd/chips/cfi_cmdset_0002.c
--- linux-libre-4.4.138-gnu/drivers/mtd/chips/cfi_cmdset_0002.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/mtd/chips/cfi_cmdset_0002.c	2018-07-03 05:21:35.000000000 -0400
@@ -1878,7 +1878,7 @@ static int __xipram do_write_buffer(stru
 		if (time_after(jiffies, timeo) && !chip_ready(map, adr))
 			break;
 
-		if (chip_ready(map, adr)) {
+		if (chip_good(map, adr, datum)) {
 			xip_enable(map, chip, adr);
 			goto op_done;
 		}
@@ -2533,7 +2533,7 @@ static int cfi_atmel_unlock(struct mtd_i
 
 struct ppb_lock {
 	struct flchip *chip;
-	loff_t offset;
+	unsigned long adr;
 	int locked;
 };
 
@@ -2551,8 +2551,9 @@ static int __maybe_unused do_ppb_xxlock(
 	unsigned long timeo;
 	int ret;
 
+	adr += chip->start;
 	mutex_lock(&chip->mutex);
-	ret = get_chip(map, chip, adr + chip->start, FL_LOCKING);
+	ret = get_chip(map, chip, adr, FL_LOCKING);
 	if (ret) {
 		mutex_unlock(&chip->mutex);
 		return ret;
@@ -2570,8 +2571,8 @@ static int __maybe_unused do_ppb_xxlock(
 
 	if (thunk == DO_XXLOCK_ONEBLOCK_LOCK) {
 		chip->state = FL_LOCKING;
-		map_write(map, CMD(0xA0), chip->start + adr);
-		map_write(map, CMD(0x00), chip->start + adr);
+		map_write(map, CMD(0xA0), adr);
+		map_write(map, CMD(0x00), adr);
 	} else if (thunk == DO_XXLOCK_ONEBLOCK_UNLOCK) {
 		/*
 		 * Unlocking of one specific sector is not supported, so we
@@ -2609,7 +2610,7 @@ static int __maybe_unused do_ppb_xxlock(
 	map_write(map, CMD(0x00), chip->start);
 
 	chip->state = FL_READY;
-	put_chip(map, chip, adr + chip->start);
+	put_chip(map, chip, adr);
 	mutex_unlock(&chip->mutex);
 
 	return ret;
@@ -2666,9 +2667,9 @@ static int __maybe_unused cfi_ppb_unlock
 		 * sectors shall be unlocked, so lets keep their locking
 		 * status at "unlocked" (locked=0) for the final re-locking.
 		 */
-		if ((adr < ofs) || (adr >= (ofs + len))) {
+		if ((offset < ofs) || (offset >= (ofs + len))) {
 			sect[sectors].chip = &cfi->chips[chipnum];
-			sect[sectors].offset = offset;
+			sect[sectors].adr = adr;
 			sect[sectors].locked = do_ppb_xxlock(
 				map, &cfi->chips[chipnum], adr, 0,
 				DO_XXLOCK_ONEBLOCK_GETLOCK);
@@ -2682,6 +2683,8 @@ static int __maybe_unused cfi_ppb_unlock
 			i++;
 
 		if (adr >> cfi->chipshift) {
+			if (offset >= (ofs + len))
+				break;
 			adr = 0;
 			chipnum++;
 
@@ -2712,7 +2715,7 @@ static int __maybe_unused cfi_ppb_unlock
 	 */
 	for (i = 0; i < sectors; i++) {
 		if (sect[i].locked)
-			do_ppb_xxlock(map, sect[i].chip, sect[i].offset, 0,
+			do_ppb_xxlock(map, sect[i].chip, sect[i].adr, 0,
 				      DO_XXLOCK_ONEBLOCK_LOCK);
 	}
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/mtd/ubi/build.c linux-libre-4.4.139-gnu/drivers/mtd/ubi/build.c
--- linux-libre-4.4.138-gnu/drivers/mtd/ubi/build.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/mtd/ubi/build.c	2018-07-03 05:21:35.000000000 -0400
@@ -1132,6 +1132,9 @@ int ubi_detach_mtd_dev(int ubi_num, int
 	 */
 	get_device(&ubi->dev);
 
+#ifdef CONFIG_MTD_UBI_FASTMAP
+	cancel_work_sync(&ubi->fm_work);
+#endif
 	ubi_debugfs_exit_dev(ubi);
 	uif_close(ubi);
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/mtd/ubi/wl.c linux-libre-4.4.139-gnu/drivers/mtd/ubi/wl.c
--- linux-libre-4.4.138-gnu/drivers/mtd/ubi/wl.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/mtd/ubi/wl.c	2018-07-03 05:21:35.000000000 -0400
@@ -1479,6 +1479,7 @@ int ubi_thread(void *u)
 	}
 
 	dbg_wl("background thread \"%s\" is killed", ubi->bgt_name);
+	ubi->thread_enabled = 0;
 	return 0;
 }
 
@@ -1488,9 +1489,6 @@ int ubi_thread(void *u)
  */
 static void shutdown_work(struct ubi_device *ubi)
 {
-#ifdef CONFIG_MTD_UBI_FASTMAP
-	flush_work(&ubi->fm_work);
-#endif
 	while (!list_empty(&ubi->works)) {
 		struct ubi_work *wrk;
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/net/bonding/bond_options.c linux-libre-4.4.139-gnu/drivers/net/bonding/bond_options.c
--- linux-libre-4.4.138-gnu/drivers/net/bonding/bond_options.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/net/bonding/bond_options.c	2018-07-03 05:21:35.000000000 -0400
@@ -1115,6 +1115,7 @@ static int bond_option_primary_set(struc
 				    slave->dev->name);
 			rcu_assign_pointer(bond->primary_slave, slave);
 			strcpy(bond->params.primary, slave->dev->name);
+			bond->force_primary = true;
 			bond_select_active_slave(bond);
 			goto out;
 		}
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/net/ethernet/natsemi/sonic.c linux-libre-4.4.139-gnu/drivers/net/ethernet/natsemi/sonic.c
--- linux-libre-4.4.138-gnu/drivers/net/ethernet/natsemi/sonic.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/net/ethernet/natsemi/sonic.c	2018-07-03 05:21:35.000000000 -0400
@@ -71,7 +71,7 @@ static int sonic_open(struct net_device
 	for (i = 0; i < SONIC_NUM_RRS; i++) {
 		dma_addr_t laddr = dma_map_single(lp->device, skb_put(lp->rx_skb[i], SONIC_RBSIZE),
 		                                  SONIC_RBSIZE, DMA_FROM_DEVICE);
-		if (!laddr) {
+		if (dma_mapping_error(lp->device, laddr)) {
 			while(i > 0) { /* free any that were mapped successfully */
 				i--;
 				dma_unmap_single(lp->device, lp->rx_laddr[i], SONIC_RBSIZE, DMA_FROM_DEVICE);
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/net/usb/cdc_ncm.c linux-libre-4.4.139-gnu/drivers/net/usb/cdc_ncm.c
--- linux-libre-4.4.138-gnu/drivers/net/usb/cdc_ncm.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/net/usb/cdc_ncm.c	2018-07-03 05:21:35.000000000 -0400
@@ -1075,7 +1075,7 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev
 	 * accordingly. Otherwise, we should check here.
 	 */
 	if (ctx->drvflags & CDC_NCM_FLAG_NDP_TO_END)
-		delayed_ndp_size = ctx->max_ndp_size;
+		delayed_ndp_size = ALIGN(ctx->max_ndp_size, ctx->tx_ndp_modulus);
 	else
 		delayed_ndp_size = 0;
 
@@ -1208,7 +1208,7 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev
 	/* If requested, put NDP at end of frame. */
 	if (ctx->drvflags & CDC_NCM_FLAG_NDP_TO_END) {
 		nth16 = (struct usb_cdc_ncm_nth16 *)skb_out->data;
-		cdc_ncm_align_tail(skb_out, ctx->tx_ndp_modulus, 0, ctx->tx_max);
+		cdc_ncm_align_tail(skb_out, ctx->tx_ndp_modulus, 0, ctx->tx_max - ctx->max_ndp_size);
 		nth16->wNdpIndex = cpu_to_le16(skb_out->len);
 		memcpy(skb_put(skb_out, ctx->max_ndp_size), ctx->delayed_ndp16, ctx->max_ndp_size);
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/net/usb/qmi_wwan.c linux-libre-4.4.139-gnu/drivers/net/usb/qmi_wwan.c
--- linux-libre-4.4.138-gnu/drivers/net/usb/qmi_wwan.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/net/usb/qmi_wwan.c	2018-07-03 05:21:35.000000000 -0400
@@ -635,6 +635,7 @@ static const struct usb_device_id produc
 	{QMI_FIXED_INTF(0x05c6, 0x920d, 0)},
 	{QMI_FIXED_INTF(0x05c6, 0x920d, 5)},
 	{QMI_FIXED_INTF(0x0846, 0x68a2, 8)},
+	{QMI_FIXED_INTF(0x0846, 0x68d3, 8)},	/* Netgear Aircard 779S */
 	{QMI_FIXED_INTF(0x12d1, 0x140c, 1)},	/* Huawei E173 */
 	{QMI_FIXED_INTF(0x12d1, 0x14ac, 1)},	/* Huawei E1820 */
 	{QMI_FIXED_INTF(0x1435, 0xd181, 3)},	/* Wistron NeWeb D18Q1 */
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/nvdimm/bus.c linux-libre-4.4.139-gnu/drivers/nvdimm/bus.c
--- linux-libre-4.4.138-gnu/drivers/nvdimm/bus.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/nvdimm/bus.c	2018-07-03 05:21:35.000000000 -0400
@@ -237,14 +237,18 @@ int nvdimm_revalidate_disk(struct gendis
 {
 	struct device *dev = disk->driverfs_dev;
 	struct nd_region *nd_region = to_nd_region(dev->parent);
-	const char *pol = nd_region->ro ? "only" : "write";
+	int disk_ro = get_disk_ro(disk);
 
-	if (nd_region->ro == get_disk_ro(disk))
+	/*
+	 * Upgrade to read-only if the region is read-only preserve as
+	 * read-only if the disk is already read-only.
+	 */
+	if (disk_ro || nd_region->ro == disk_ro)
 		return 0;
 
-	dev_info(dev, "%s read-%s, marking %s read-%s\n",
-			dev_name(&nd_region->dev), pol, disk->disk_name, pol);
-	set_disk_ro(disk, nd_region->ro);
+	dev_info(dev, "%s read-only, marking %s read-only\n",
+			dev_name(&nd_region->dev), disk->disk_name);
+	set_disk_ro(disk, 1);
 
 	return 0;
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/of/unittest.c linux-libre-4.4.139-gnu/drivers/of/unittest.c
--- linux-libre-4.4.138-gnu/drivers/of/unittest.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/of/unittest.c	2018-07-03 05:21:35.000000000 -0400
@@ -156,20 +156,20 @@ static void __init of_unittest_dynamic(v
 	/* Add a new property - should pass*/
 	prop->name = "new-property";
 	prop->value = "new-property-data";
-	prop->length = strlen(prop->value);
+	prop->length = strlen(prop->value) + 1;
 	unittest(of_add_property(np, prop) == 0, "Adding a new property failed\n");
 
 	/* Try to add an existing property - should fail */
 	prop++;
 	prop->name = "new-property";
 	prop->value = "new-property-data-should-fail";
-	prop->length = strlen(prop->value);
+	prop->length = strlen(prop->value) + 1;
 	unittest(of_add_property(np, prop) != 0,
 		 "Adding an existing property should have failed\n");
 
 	/* Try to modify an existing property - should pass */
 	prop->value = "modify-property-data-should-pass";
-	prop->length = strlen(prop->value);
+	prop->length = strlen(prop->value) + 1;
 	unittest(of_update_property(np, prop) == 0,
 		 "Updating an existing property should have passed\n");
 
@@ -177,7 +177,7 @@ static void __init of_unittest_dynamic(v
 	prop++;
 	prop->name = "modify-property";
 	prop->value = "modify-missing-property-data-should-pass";
-	prop->length = strlen(prop->value);
+	prop->length = strlen(prop->value) + 1;
 	unittest(of_update_property(np, prop) == 0,
 		 "Updating a missing property should have passed\n");
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/pci/hotplug/pciehp_core.c linux-libre-4.4.139-gnu/drivers/pci/hotplug/pciehp_core.c
--- linux-libre-4.4.138-gnu/drivers/pci/hotplug/pciehp_core.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/pci/hotplug/pciehp_core.c	2018-07-03 05:21:35.000000000 -0400
@@ -295,7 +295,7 @@ static int pciehp_resume(struct pcie_dev
 	ctrl = get_service_data(dev);
 
 	/* reinitialize the chipset's event detection logic */
-	pcie_enable_notification(ctrl);
+	pcie_reenable_notification(ctrl);
 
 	slot = ctrl->slot;
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/pci/hotplug/pciehp.h linux-libre-4.4.139-gnu/drivers/pci/hotplug/pciehp.h
--- linux-libre-4.4.138-gnu/drivers/pci/hotplug/pciehp.h	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/pci/hotplug/pciehp.h	2018-07-03 05:21:35.000000000 -0400
@@ -134,7 +134,7 @@ struct controller *pcie_init(struct pcie
 int pcie_init_notification(struct controller *ctrl);
 int pciehp_enable_slot(struct slot *p_slot);
 int pciehp_disable_slot(struct slot *p_slot);
-void pcie_enable_notification(struct controller *ctrl);
+void pcie_reenable_notification(struct controller *ctrl);
 int pciehp_power_on_slot(struct slot *slot);
 void pciehp_power_off_slot(struct slot *slot);
 void pciehp_get_power_status(struct slot *slot, u8 *status);
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/pci/hotplug/pciehp_hpc.c linux-libre-4.4.139-gnu/drivers/pci/hotplug/pciehp_hpc.c
--- linux-libre-4.4.138-gnu/drivers/pci/hotplug/pciehp_hpc.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/pci/hotplug/pciehp_hpc.c	2018-07-03 05:21:35.000000000 -0400
@@ -628,7 +628,7 @@ static irqreturn_t pcie_isr(int irq, voi
 	return IRQ_HANDLED;
 }
 
-void pcie_enable_notification(struct controller *ctrl)
+static void pcie_enable_notification(struct controller *ctrl)
 {
 	u16 cmd, mask;
 
@@ -666,6 +666,17 @@ void pcie_enable_notification(struct con
 		 pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, cmd);
 }
 
+void pcie_reenable_notification(struct controller *ctrl)
+{
+	/*
+	 * Clear both Presence and Data Link Layer Changed to make sure
+	 * those events still fire after we have re-enabled them.
+	 */
+	pcie_capability_write_word(ctrl->pcie->port, PCI_EXP_SLTSTA,
+				   PCI_EXP_SLTSTA_PDC | PCI_EXP_SLTSTA_DLLSC);
+	pcie_enable_notification(ctrl);
+}
+
 static void pcie_disable_notification(struct controller *ctrl)
 {
 	u16 mask;
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/s390/scsi/zfcp_dbf.c linux-libre-4.4.139-gnu/drivers/s390/scsi/zfcp_dbf.c
--- linux-libre-4.4.138-gnu/drivers/s390/scsi/zfcp_dbf.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/s390/scsi/zfcp_dbf.c	2018-07-03 05:21:35.000000000 -0400
@@ -625,6 +625,46 @@ void zfcp_dbf_scsi(char *tag, int level,
 	spin_unlock_irqrestore(&dbf->scsi_lock, flags);
 }
 
+/**
+ * zfcp_dbf_scsi_eh() - Trace event for special cases of scsi_eh callbacks.
+ * @tag: Identifier for event.
+ * @adapter: Pointer to zfcp adapter as context for this event.
+ * @scsi_id: SCSI ID/target to indicate scope of task management function (TMF).
+ * @ret: Return value of calling function.
+ *
+ * This SCSI trace variant does not depend on any of:
+ * scsi_cmnd, zfcp_fsf_req, scsi_device.
+ */
+void zfcp_dbf_scsi_eh(char *tag, struct zfcp_adapter *adapter,
+		      unsigned int scsi_id, int ret)
+{
+	struct zfcp_dbf *dbf = adapter->dbf;
+	struct zfcp_dbf_scsi *rec = &dbf->scsi_buf;
+	unsigned long flags;
+	static int const level = 1;
+
+	if (unlikely(!debug_level_enabled(adapter->dbf->scsi, level)))
+		return;
+
+	spin_lock_irqsave(&dbf->scsi_lock, flags);
+	memset(rec, 0, sizeof(*rec));
+
+	memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN);
+	rec->id = ZFCP_DBF_SCSI_CMND;
+	rec->scsi_result = ret; /* re-use field, int is 4 bytes and fits */
+	rec->scsi_retries = ~0;
+	rec->scsi_allowed = ~0;
+	rec->fcp_rsp_info = ~0;
+	rec->scsi_id = scsi_id;
+	rec->scsi_lun = (u32)ZFCP_DBF_INVALID_LUN;
+	rec->scsi_lun_64_hi = (u32)(ZFCP_DBF_INVALID_LUN >> 32);
+	rec->host_scribble = ~0;
+	memset(rec->scsi_opcode, 0xff, ZFCP_DBF_SCSI_OPCODE);
+
+	debug_event(dbf->scsi, level, rec, sizeof(*rec));
+	spin_unlock_irqrestore(&dbf->scsi_lock, flags);
+}
+
 static debug_info_t *zfcp_dbf_reg(const char *name, int size, int rec_size)
 {
 	struct debug_info *d;
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/s390/scsi/zfcp_erp.c linux-libre-4.4.139-gnu/drivers/s390/scsi/zfcp_erp.c
--- linux-libre-4.4.138-gnu/drivers/s390/scsi/zfcp_erp.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/s390/scsi/zfcp_erp.c	2018-07-03 05:21:35.000000000 -0400
@@ -34,11 +34,28 @@ enum zfcp_erp_steps {
 	ZFCP_ERP_STEP_LUN_OPENING	= 0x2000,
 };
 
+/**
+ * enum zfcp_erp_act_type - Type of ERP action object.
+ * @ZFCP_ERP_ACTION_REOPEN_LUN: LUN recovery.
+ * @ZFCP_ERP_ACTION_REOPEN_PORT: Port recovery.
+ * @ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: Forced port recovery.
+ * @ZFCP_ERP_ACTION_REOPEN_ADAPTER: Adapter recovery.
+ * @ZFCP_ERP_ACTION_NONE: Eyecatcher pseudo flag to bitwise or-combine with
+ *			  either of the first four enum values.
+ *			  Used to indicate that an ERP action could not be
+ *			  set up despite a detected need for some recovery.
+ * @ZFCP_ERP_ACTION_FAILED: Eyecatcher pseudo flag to bitwise or-combine with
+ *			    either of the first four enum values.
+ *			    Used to indicate that ERP not needed because
+ *			    the object has ZFCP_STATUS_COMMON_ERP_FAILED.
+ */
 enum zfcp_erp_act_type {
 	ZFCP_ERP_ACTION_REOPEN_LUN         = 1,
 	ZFCP_ERP_ACTION_REOPEN_PORT	   = 2,
 	ZFCP_ERP_ACTION_REOPEN_PORT_FORCED = 3,
 	ZFCP_ERP_ACTION_REOPEN_ADAPTER     = 4,
+	ZFCP_ERP_ACTION_NONE		   = 0xc0,
+	ZFCP_ERP_ACTION_FAILED		   = 0xe0,
 };
 
 enum zfcp_erp_act_state {
@@ -125,6 +142,49 @@ static void zfcp_erp_action_dismiss_adap
 	}
 }
 
+static int zfcp_erp_handle_failed(int want, struct zfcp_adapter *adapter,
+				  struct zfcp_port *port,
+				  struct scsi_device *sdev)
+{
+	int need = want;
+	struct zfcp_scsi_dev *zsdev;
+
+	switch (want) {
+	case ZFCP_ERP_ACTION_REOPEN_LUN:
+		zsdev = sdev_to_zfcp(sdev);
+		if (atomic_read(&zsdev->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
+			need = 0;
+		break;
+	case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
+		if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
+			need = 0;
+		break;
+	case ZFCP_ERP_ACTION_REOPEN_PORT:
+		if (atomic_read(&port->status) &
+		    ZFCP_STATUS_COMMON_ERP_FAILED) {
+			need = 0;
+			/* ensure propagation of failed status to new devices */
+			zfcp_erp_set_port_status(
+				port, ZFCP_STATUS_COMMON_ERP_FAILED);
+		}
+		break;
+	case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
+		if (atomic_read(&adapter->status) &
+		    ZFCP_STATUS_COMMON_ERP_FAILED) {
+			need = 0;
+			/* ensure propagation of failed status to new devices */
+			zfcp_erp_set_adapter_status(
+				adapter, ZFCP_STATUS_COMMON_ERP_FAILED);
+		}
+		break;
+	default:
+		need = 0;
+		break;
+	}
+
+	return need;
+}
+
 static int zfcp_erp_required_act(int want, struct zfcp_adapter *adapter,
 				 struct zfcp_port *port,
 				 struct scsi_device *sdev)
@@ -248,16 +308,27 @@ static int zfcp_erp_action_enqueue(int w
 	int retval = 1, need;
 	struct zfcp_erp_action *act;
 
-	if (!adapter->erp_thread)
-		return -EIO;
+	need = zfcp_erp_handle_failed(want, adapter, port, sdev);
+	if (!need) {
+		need = ZFCP_ERP_ACTION_FAILED; /* marker for trace */
+		goto out;
+	}
+
+	if (!adapter->erp_thread) {
+		need = ZFCP_ERP_ACTION_NONE; /* marker for trace */
+		retval = -EIO;
+		goto out;
+	}
 
 	need = zfcp_erp_required_act(want, adapter, port, sdev);
 	if (!need)
 		goto out;
 
 	act = zfcp_erp_setup_act(need, act_status, adapter, port, sdev);
-	if (!act)
+	if (!act) {
+		need |= ZFCP_ERP_ACTION_NONE; /* marker for trace */
 		goto out;
+	}
 	atomic_or(ZFCP_STATUS_ADAPTER_ERP_PENDING, &adapter->status);
 	++adapter->erp_total_count;
 	list_add_tail(&act->list, &adapter->erp_ready_head);
@@ -268,18 +339,32 @@ static int zfcp_erp_action_enqueue(int w
 	return retval;
 }
 
+void zfcp_erp_port_forced_no_port_dbf(char *id, struct zfcp_adapter *adapter,
+				      u64 port_name, u32 port_id)
+{
+	unsigned long flags;
+	static /* don't waste stack */ struct zfcp_port tmpport;
+
+	write_lock_irqsave(&adapter->erp_lock, flags);
+	/* Stand-in zfcp port with fields just good enough for
+	 * zfcp_dbf_rec_trig() and zfcp_dbf_set_common().
+	 * Under lock because tmpport is static.
+	 */
+	atomic_set(&tmpport.status, -1); /* unknown */
+	tmpport.wwpn = port_name;
+	tmpport.d_id = port_id;
+	zfcp_dbf_rec_trig(id, adapter, &tmpport, NULL,
+			  ZFCP_ERP_ACTION_REOPEN_PORT_FORCED,
+			  ZFCP_ERP_ACTION_NONE);
+	write_unlock_irqrestore(&adapter->erp_lock, flags);
+}
+
 static int _zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter,
 				    int clear_mask, char *id)
 {
 	zfcp_erp_adapter_block(adapter, clear_mask);
 	zfcp_scsi_schedule_rports_block(adapter);
 
-	/* ensure propagation of failed status to new devices */
-	if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_FAILED) {
-		zfcp_erp_set_adapter_status(adapter,
-					    ZFCP_STATUS_COMMON_ERP_FAILED);
-		return -EIO;
-	}
 	return zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_ADAPTER,
 				       adapter, NULL, NULL, id, 0);
 }
@@ -298,12 +383,8 @@ void zfcp_erp_adapter_reopen(struct zfcp
 	zfcp_scsi_schedule_rports_block(adapter);
 
 	write_lock_irqsave(&adapter->erp_lock, flags);
-	if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
-		zfcp_erp_set_adapter_status(adapter,
-					    ZFCP_STATUS_COMMON_ERP_FAILED);
-	else
-		zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_ADAPTER, adapter,
-					NULL, NULL, id, 0);
+	zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_ADAPTER, adapter,
+				NULL, NULL, id, 0);
 	write_unlock_irqrestore(&adapter->erp_lock, flags);
 }
 
@@ -344,9 +425,6 @@ static void _zfcp_erp_port_forced_reopen
 	zfcp_erp_port_block(port, clear);
 	zfcp_scsi_schedule_rport_block(port);
 
-	if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
-		return;
-
 	zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT_FORCED,
 				port->adapter, port, NULL, id, 0);
 }
@@ -372,12 +450,6 @@ static int _zfcp_erp_port_reopen(struct
 	zfcp_erp_port_block(port, clear);
 	zfcp_scsi_schedule_rport_block(port);
 
-	if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED) {
-		/* ensure propagation of failed status to new devices */
-		zfcp_erp_set_port_status(port, ZFCP_STATUS_COMMON_ERP_FAILED);
-		return -EIO;
-	}
-
 	return zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT,
 				       port->adapter, port, NULL, id, 0);
 }
@@ -417,9 +489,6 @@ static void _zfcp_erp_lun_reopen(struct
 
 	zfcp_erp_lun_block(sdev, clear);
 
-	if (atomic_read(&zfcp_sdev->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
-		return;
-
 	zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_LUN, adapter,
 				zfcp_sdev->port, sdev, id, act_status);
 }
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/s390/scsi/zfcp_ext.h linux-libre-4.4.139-gnu/drivers/s390/scsi/zfcp_ext.h
--- linux-libre-4.4.138-gnu/drivers/s390/scsi/zfcp_ext.h	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/s390/scsi/zfcp_ext.h	2018-07-03 05:21:35.000000000 -0400
@@ -52,10 +52,15 @@ extern void zfcp_dbf_san_res(char *, str
 extern void zfcp_dbf_san_in_els(char *, struct zfcp_fsf_req *);
 extern void zfcp_dbf_scsi(char *, int, struct scsi_cmnd *,
 			  struct zfcp_fsf_req *);
+extern void zfcp_dbf_scsi_eh(char *tag, struct zfcp_adapter *adapter,
+			     unsigned int scsi_id, int ret);
 
 /* zfcp_erp.c */
 extern void zfcp_erp_set_adapter_status(struct zfcp_adapter *, u32);
 extern void zfcp_erp_clear_adapter_status(struct zfcp_adapter *, u32);
+extern void zfcp_erp_port_forced_no_port_dbf(char *id,
+					     struct zfcp_adapter *adapter,
+					     u64 port_name, u32 port_id);
 extern void zfcp_erp_adapter_reopen(struct zfcp_adapter *, int, char *);
 extern void zfcp_erp_adapter_shutdown(struct zfcp_adapter *, int, char *);
 extern void zfcp_erp_set_port_status(struct zfcp_port *, u32);
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/s390/scsi/zfcp_scsi.c linux-libre-4.4.139-gnu/drivers/s390/scsi/zfcp_scsi.c
--- linux-libre-4.4.138-gnu/drivers/s390/scsi/zfcp_scsi.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/s390/scsi/zfcp_scsi.c	2018-07-03 05:21:35.000000000 -0400
@@ -180,6 +180,7 @@ static int zfcp_scsi_eh_abort_handler(st
 		if (abrt_req)
 			break;
 
+		zfcp_dbf_scsi_abort("abrt_wt", scpnt, NULL);
 		zfcp_erp_wait(adapter);
 		ret = fc_block_scsi_eh(scpnt);
 		if (ret) {
@@ -276,6 +277,7 @@ static int zfcp_task_mgmt_function(struc
 		if (fsf_req)
 			break;
 
+		zfcp_dbf_scsi_devreset("wait", scpnt, tm_flags, NULL);
 		zfcp_erp_wait(adapter);
 		ret = fc_block_scsi_eh(scpnt);
 		if (ret) {
@@ -322,15 +324,16 @@ static int zfcp_scsi_eh_host_reset_handl
 {
 	struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(scpnt->device);
 	struct zfcp_adapter *adapter = zfcp_sdev->port->adapter;
-	int ret;
+	int ret = SUCCESS, fc_ret;
 
 	zfcp_erp_adapter_reopen(adapter, 0, "schrh_1");
 	zfcp_erp_wait(adapter);
-	ret = fc_block_scsi_eh(scpnt);
-	if (ret)
-		return ret;
+	fc_ret = fc_block_scsi_eh(scpnt);
+	if (fc_ret)
+		ret = fc_ret;
 
-	return SUCCESS;
+	zfcp_dbf_scsi_eh("schrh_r", adapter, ~0, ret);
+	return ret;
 }
 
 struct scsi_transport_template *zfcp_scsi_transport_template;
@@ -600,6 +603,11 @@ static void zfcp_scsi_terminate_rport_io
 	if (port) {
 		zfcp_erp_port_forced_reopen(port, 0, "sctrpi1");
 		put_device(&port->dev);
+	} else {
+		zfcp_erp_port_forced_no_port_dbf(
+			"sctrpin", adapter,
+			rport->port_name /* zfcp_scsi_rport_register */,
+			rport->port_id /* zfcp_scsi_rport_register */);
 	}
 }
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/scsi/qla2xxx/qla_init.c linux-libre-4.4.139-gnu/drivers/scsi/qla2xxx/qla_init.c
--- linux-libre-4.4.138-gnu/drivers/scsi/qla2xxx/qla_init.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/scsi/qla2xxx/qla_init.c	2018-07-03 05:21:35.000000000 -0400
@@ -3261,7 +3261,8 @@ qla2x00_iidma_fcport(scsi_qla_host_t *vh
 		return;
 
 	if (fcport->fp_speed == PORT_SPEED_UNKNOWN ||
-	    fcport->fp_speed > ha->link_data_rate)
+	    fcport->fp_speed > ha->link_data_rate ||
+	    !ha->flags.gpsc_supported)
 		return;
 
 	rval = qla2x00_set_idma_speed(vha, fcport->loop_id, fcport->fp_speed,
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/spi/spi.c linux-libre-4.4.139-gnu/drivers/spi/spi.c
--- linux-libre-4.4.138-gnu/drivers/spi/spi.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/spi/spi.c	2018-07-03 05:21:35.000000000 -0400
@@ -707,8 +707,14 @@ static int spi_map_buf(struct spi_master
 	for (i = 0; i < sgs; i++) {
 
 		if (vmalloced_buf) {
-			min = min_t(size_t,
-				    len, desc_len - offset_in_page(buf));
+			/*
+			 * Next scatterlist entry size is the minimum between
+			 * the desc_len and the remaining buffer length that
+			 * fits in a page.
+			 */
+			min = min_t(size_t, desc_len,
+				    min_t(size_t, len,
+					  PAGE_SIZE - offset_in_page(buf)));
 			vm_page = vmalloc_to_page(buf);
 			if (!vm_page) {
 				sg_free_table(sgt);
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/tty/serial/sh-sci.c linux-libre-4.4.139-gnu/drivers/tty/serial/sh-sci.c
--- linux-libre-4.4.138-gnu/drivers/tty/serial/sh-sci.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/tty/serial/sh-sci.c	2018-07-03 05:21:35.000000000 -0400
@@ -2419,13 +2419,12 @@ static void serial_console_write(struct
 	unsigned long flags;
 	int locked = 1;
 
-	local_irq_save(flags);
 	if (port->sysrq)
 		locked = 0;
 	else if (oops_in_progress)
-		locked = spin_trylock(&port->lock);
+		locked = spin_trylock_irqsave(&port->lock, flags);
 	else
-		spin_lock(&port->lock);
+		spin_lock_irqsave(&port->lock, flags);
 
 	/* first save the SCSCR then disable the interrupts */
 	ctrl = serial_port_in(port, SCSCR);
@@ -2442,8 +2441,7 @@ static void serial_console_write(struct
 	serial_port_out(port, SCSCR, ctrl);
 
 	if (locked)
-		spin_unlock(&port->lock);
-	local_irq_restore(flags);
+		spin_unlock_irqrestore(&port->lock, flags);
 }
 
 static int serial_console_setup(struct console *co, char *options)
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/usb/core/hub.c linux-libre-4.4.139-gnu/drivers/usb/core/hub.c
--- linux-libre-4.4.138-gnu/drivers/usb/core/hub.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/usb/core/hub.c	2018-07-03 05:21:35.000000000 -0400
@@ -4442,7 +4442,9 @@ hub_port_init(struct usb_hub *hub, struc
 				 * reset. But only on the first attempt,
 				 * lest we get into a time out/reset loop
 				 */
-				if (r == 0  || (r == -ETIMEDOUT && retries == 0))
+				if (r == 0 || (r == -ETIMEDOUT &&
+						retries == 0 &&
+						udev->speed > USB_SPEED_FULL))
 					break;
 			}
 			udev->descriptor.bMaxPacketSize0 =
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/usb/musb/musb_host.c linux-libre-4.4.139-gnu/drivers/usb/musb/musb_host.c
--- linux-libre-4.4.138-gnu/drivers/usb/musb/musb_host.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/usb/musb/musb_host.c	2018-07-03 05:21:35.000000000 -0400
@@ -2580,8 +2580,11 @@ static int musb_bus_suspend(struct usb_h
 {
 	struct musb	*musb = hcd_to_musb(hcd);
 	u8		devctl;
+	int		ret;
 
-	musb_port_suspend(musb, true);
+	ret = musb_port_suspend(musb, true);
+	if (ret)
+		return ret;
 
 	if (!is_host_active(musb))
 		return 0;
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/usb/musb/musb_host.h linux-libre-4.4.139-gnu/drivers/usb/musb/musb_host.h
--- linux-libre-4.4.138-gnu/drivers/usb/musb/musb_host.h	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/usb/musb/musb_host.h	2018-07-03 05:21:35.000000000 -0400
@@ -92,7 +92,7 @@ extern void musb_host_rx(struct musb *,
 extern void musb_root_disconnect(struct musb *musb);
 extern void musb_host_resume_root_hub(struct musb *musb);
 extern void musb_host_poke_root_hub(struct musb *musb);
-extern void musb_port_suspend(struct musb *musb, bool do_suspend);
+extern int musb_port_suspend(struct musb *musb, bool do_suspend);
 extern void musb_port_reset(struct musb *musb, bool do_reset);
 extern void musb_host_finish_resume(struct work_struct *work);
 #else
@@ -124,7 +124,10 @@ static inline void musb_root_disconnect(
 static inline void musb_host_resume_root_hub(struct musb *musb)	{}
 static inline void musb_host_poll_rh_status(struct musb *musb)	{}
 static inline void musb_host_poke_root_hub(struct musb *musb)	{}
-static inline void musb_port_suspend(struct musb *musb, bool do_suspend) {}
+static inline int musb_port_suspend(struct musb *musb, bool do_suspend)
+{
+	return 0;
+}
 static inline void musb_port_reset(struct musb *musb, bool do_reset) {}
 static inline void musb_host_finish_resume(struct work_struct *work) {}
 #endif
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/usb/musb/musb_virthub.c linux-libre-4.4.139-gnu/drivers/usb/musb/musb_virthub.c
--- linux-libre-4.4.138-gnu/drivers/usb/musb/musb_virthub.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/usb/musb/musb_virthub.c	2018-07-03 05:21:35.000000000 -0400
@@ -74,14 +74,14 @@ void musb_host_finish_resume(struct work
 	spin_unlock_irqrestore(&musb->lock, flags);
 }
 
-void musb_port_suspend(struct musb *musb, bool do_suspend)
+int musb_port_suspend(struct musb *musb, bool do_suspend)
 {
 	struct usb_otg	*otg = musb->xceiv->otg;
 	u8		power;
 	void __iomem	*mbase = musb->mregs;
 
 	if (!is_host_active(musb))
-		return;
+		return 0;
 
 	/* NOTE:  this doesn't necessarily put PHY into low power mode,
 	 * turning off its clock; that's a function of PHY integration and
@@ -92,16 +92,20 @@ void musb_port_suspend(struct musb *musb
 	if (do_suspend) {
 		int retries = 10000;
 
-		power &= ~MUSB_POWER_RESUME;
-		power |= MUSB_POWER_SUSPENDM;
-		musb_writeb(mbase, MUSB_POWER, power);
+		if (power & MUSB_POWER_RESUME)
+			return -EBUSY;
 
-		/* Needed for OPT A tests */
-		power = musb_readb(mbase, MUSB_POWER);
-		while (power & MUSB_POWER_SUSPENDM) {
+		if (!(power & MUSB_POWER_SUSPENDM)) {
+			power |= MUSB_POWER_SUSPENDM;
+			musb_writeb(mbase, MUSB_POWER, power);
+
+			/* Needed for OPT A tests */
 			power = musb_readb(mbase, MUSB_POWER);
-			if (retries-- < 1)
-				break;
+			while (power & MUSB_POWER_SUSPENDM) {
+				power = musb_readb(mbase, MUSB_POWER);
+				if (retries-- < 1)
+					break;
+			}
 		}
 
 		dev_dbg(musb->controller, "Root port suspended, power %02x\n", power);
@@ -138,6 +142,7 @@ void musb_port_suspend(struct musb *musb
 		schedule_delayed_work(&musb->finish_resume_work,
 				      msecs_to_jiffies(USB_RESUME_TIMEOUT));
 	}
+	return 0;
 }
 
 void musb_port_reset(struct musb *musb, bool do_reset)
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/video/backlight/as3711_bl.c linux-libre-4.4.139-gnu/drivers/video/backlight/as3711_bl.c
--- linux-libre-4.4.138-gnu/drivers/video/backlight/as3711_bl.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/video/backlight/as3711_bl.c	2018-07-03 05:21:35.000000000 -0400
@@ -262,10 +262,10 @@ static int as3711_bl_register(struct pla
 static int as3711_backlight_parse_dt(struct device *dev)
 {
 	struct as3711_bl_pdata *pdata = dev_get_platdata(dev);
-	struct device_node *bl =
-		of_find_node_by_name(dev->parent->of_node, "backlight"), *fb;
+	struct device_node *bl, *fb;
 	int ret;
 
+	bl = of_get_child_by_name(dev->parent->of_node, "backlight");
 	if (!bl) {
 		dev_dbg(dev, "backlight node not found\n");
 		return -ENODEV;
@@ -279,7 +279,7 @@ static int as3711_backlight_parse_dt(str
 		if (pdata->su1_max_uA <= 0)
 			ret = -EINVAL;
 		if (ret < 0)
-			return ret;
+			goto err_put_bl;
 	}
 
 	fb = of_parse_phandle(bl, "su2-dev", 0);
@@ -292,7 +292,7 @@ static int as3711_backlight_parse_dt(str
 		if (pdata->su2_max_uA <= 0)
 			ret = -EINVAL;
 		if (ret < 0)
-			return ret;
+			goto err_put_bl;
 
 		if (of_find_property(bl, "su2-feedback-voltage", NULL)) {
 			pdata->su2_feedback = AS3711_SU2_VOLTAGE;
@@ -314,8 +314,10 @@ static int as3711_backlight_parse_dt(str
 			pdata->su2_feedback = AS3711_SU2_CURR_AUTO;
 			count++;
 		}
-		if (count != 1)
-			return -EINVAL;
+		if (count != 1) {
+			ret = -EINVAL;
+			goto err_put_bl;
+		}
 
 		count = 0;
 		if (of_find_property(bl, "su2-fbprot-lx-sd4", NULL)) {
@@ -334,8 +336,10 @@ static int as3711_backlight_parse_dt(str
 			pdata->su2_fbprot = AS3711_SU2_GPIO4;
 			count++;
 		}
-		if (count != 1)
-			return -EINVAL;
+		if (count != 1) {
+			ret = -EINVAL;
+			goto err_put_bl;
+		}
 
 		count = 0;
 		if (of_find_property(bl, "su2-auto-curr1", NULL)) {
@@ -355,11 +359,20 @@ static int as3711_backlight_parse_dt(str
 		 * At least one su2-auto-curr* must be specified iff
 		 * AS3711_SU2_CURR_AUTO is used
 		 */
-		if (!count ^ (pdata->su2_feedback != AS3711_SU2_CURR_AUTO))
-			return -EINVAL;
+		if (!count ^ (pdata->su2_feedback != AS3711_SU2_CURR_AUTO)) {
+			ret = -EINVAL;
+			goto err_put_bl;
+		}
 	}
 
+	of_node_put(bl);
+
 	return 0;
+
+err_put_bl:
+	of_node_put(bl);
+
+	return ret;
 }
 
 static int as3711_backlight_probe(struct platform_device *pdev)
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/video/backlight/max8925_bl.c linux-libre-4.4.139-gnu/drivers/video/backlight/max8925_bl.c
--- linux-libre-4.4.138-gnu/drivers/video/backlight/max8925_bl.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/video/backlight/max8925_bl.c	2018-07-03 05:21:35.000000000 -0400
@@ -116,7 +116,7 @@ static void max8925_backlight_dt_init(st
 	if (!pdata)
 		return;
 
-	np = of_find_node_by_name(nproot, "backlight");
+	np = of_get_child_by_name(nproot, "backlight");
 	if (!np) {
 		dev_err(&pdev->dev, "failed to find backlight node\n");
 		return;
@@ -125,6 +125,8 @@ static void max8925_backlight_dt_init(st
 	if (!of_property_read_u32(np, "maxim,max8925-dual-string", &val))
 		pdata->dual_string = val;
 
+	of_node_put(np);
+
 	pdev->dev.platform_data = pdata;
 }
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/video/backlight/tps65217_bl.c linux-libre-4.4.139-gnu/drivers/video/backlight/tps65217_bl.c
--- linux-libre-4.4.138-gnu/drivers/video/backlight/tps65217_bl.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/video/backlight/tps65217_bl.c	2018-07-03 05:21:35.000000000 -0400
@@ -184,11 +184,11 @@ static struct tps65217_bl_pdata *
 tps65217_bl_parse_dt(struct platform_device *pdev)
 {
 	struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent);
-	struct device_node *node = of_node_get(tps->dev->of_node);
+	struct device_node *node;
 	struct tps65217_bl_pdata *pdata, *err;
 	u32 val;
 
-	node = of_find_node_by_name(node, "backlight");
+	node = of_get_child_by_name(tps->dev->of_node, "backlight");
 	if (!node)
 		return ERR_PTR(-ENODEV);
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/video/fbdev/uvesafb.c linux-libre-4.4.139-gnu/drivers/video/fbdev/uvesafb.c
--- linux-libre-4.4.138-gnu/drivers/video/fbdev/uvesafb.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/video/fbdev/uvesafb.c	2018-07-03 05:21:35.000000000 -0400
@@ -1059,7 +1059,8 @@ static int uvesafb_setcmap(struct fb_cma
 		    info->cmap.len || cmap->start < info->cmap.start)
 			return -EINVAL;
 
-		entries = kmalloc(sizeof(*entries) * cmap->len, GFP_KERNEL);
+		entries = kmalloc_array(cmap->len, sizeof(*entries),
+					GFP_KERNEL);
 		if (!entries)
 			return -ENOMEM;
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/w1/masters/mxc_w1.c linux-libre-4.4.139-gnu/drivers/w1/masters/mxc_w1.c
--- linux-libre-4.4.138-gnu/drivers/w1/masters/mxc_w1.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/w1/masters/mxc_w1.c	2018-07-03 05:21:35.000000000 -0400
@@ -113,6 +113,10 @@ static int mxc_w1_probe(struct platform_
 	if (IS_ERR(mdev->clk))
 		return PTR_ERR(mdev->clk);
 
+	err = clk_prepare_enable(mdev->clk);
+	if (err)
+		return err;
+
 	clkrate = clk_get_rate(mdev->clk);
 	if (clkrate < 10000000)
 		dev_warn(&pdev->dev,
@@ -126,12 +130,10 @@ static int mxc_w1_probe(struct platform_
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	mdev->regs = devm_ioremap_resource(&pdev->dev, res);
-	if (IS_ERR(mdev->regs))
-		return PTR_ERR(mdev->regs);
-
-	err = clk_prepare_enable(mdev->clk);
-	if (err)
-		return err;
+	if (IS_ERR(mdev->regs)) {
+		err = PTR_ERR(mdev->regs);
+		goto out_disable_clk;
+	}
 
 	/* Software reset 1-Wire module */
 	writeb(MXC_W1_RESET_RST, mdev->regs + MXC_W1_RESET);
@@ -147,8 +149,12 @@ static int mxc_w1_probe(struct platform_
 
 	err = w1_add_master_device(&mdev->bus_master);
 	if (err)
-		clk_disable_unprepare(mdev->clk);
+		goto out_disable_clk;
+
+	return 0;
 
+out_disable_clk:
+	clk_disable_unprepare(mdev->clk);
 	return err;
 }
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/w1/w1.c linux-libre-4.4.139-gnu/drivers/w1/w1.c
--- linux-libre-4.4.138-gnu/drivers/w1/w1.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/w1/w1.c	2018-07-03 05:21:35.000000000 -0400
@@ -741,7 +741,7 @@ int w1_attach_slave_device(struct w1_mas
 
 	/* slave modules need to be loaded in a context with unlocked mutex */
 	mutex_unlock(&dev->mutex);
-	request_module("w1-family-0x%02x", rn->family);
+	request_module("w1-family-0x%02X", rn->family);
 	mutex_lock(&dev->mutex);
 
 	spin_lock(&w1_flock);
diff -druNp --no-dereference linux-libre-4.4.138-gnu/drivers/xen/events/events_base.c linux-libre-4.4.139-gnu/drivers/xen/events/events_base.c
--- linux-libre-4.4.138-gnu/drivers/xen/events/events_base.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/drivers/xen/events/events_base.c	2018-07-03 05:21:35.000000000 -0400
@@ -637,8 +637,6 @@ static void __unbind_from_irq(unsigned i
 		xen_irq_info_cleanup(info);
 	}
 
-	BUG_ON(info_for_irq(irq)->type == IRQT_UNBOUND);
-
 	xen_free_irq(irq);
 }
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/fs/binfmt_misc.c linux-libre-4.4.139-gnu/fs/binfmt_misc.c
--- linux-libre-4.4.138-gnu/fs/binfmt_misc.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/fs/binfmt_misc.c	2018-07-03 05:21:35.000000000 -0400
@@ -369,8 +369,13 @@ static Node *create_entry(const char __u
 		s = strchr(p, del);
 		if (!s)
 			goto einval;
-		*s++ = '\0';
-		e->offset = simple_strtoul(p, &p, 10);
+		*s = '\0';
+		if (p != s) {
+			int r = kstrtoint(p, 10, &e->offset);
+			if (r != 0 || e->offset < 0)
+				goto einval;
+		}
+		p = s;
 		if (*p++)
 			goto einval;
 		pr_debug("register: offset: %#x\n", e->offset);
@@ -410,7 +415,8 @@ static Node *create_entry(const char __u
 		if (e->mask &&
 		    string_unescape_inplace(e->mask, UNESCAPE_HEX) != e->size)
 			goto einval;
-		if (e->size + e->offset > BINPRM_BUF_SIZE)
+		if (e->size > BINPRM_BUF_SIZE ||
+		    BINPRM_BUF_SIZE - e->size < e->offset)
 			goto einval;
 		pr_debug("register: magic/mask length: %i\n", e->size);
 		if (USE_DEBUG) {
diff -druNp --no-dereference linux-libre-4.4.138-gnu/fs/btrfs/inode.c linux-libre-4.4.139-gnu/fs/btrfs/inode.c
--- linux-libre-4.4.138-gnu/fs/btrfs/inode.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/fs/btrfs/inode.c	2018-07-03 05:21:35.000000000 -0400
@@ -1202,6 +1202,8 @@ static noinline int csum_exist_in_range(
 		list_del(&sums->list);
 		kfree(sums);
 	}
+	if (ret < 0)
+		return ret;
 	return 1;
 }
 
@@ -1351,10 +1353,23 @@ next_slot:
 				goto out_check;
 			if (btrfs_extent_readonly(root, disk_bytenr))
 				goto out_check;
-			if (btrfs_cross_ref_exist(trans, root, ino,
+			ret = btrfs_cross_ref_exist(trans, root, ino,
 						  found_key.offset -
-						  extent_offset, disk_bytenr))
+						  extent_offset, disk_bytenr);
+			if (ret) {
+				/*
+				 * ret could be -EIO if the above fails to read
+				 * metadata.
+				 */
+				if (ret < 0) {
+					if (cow_start != (u64)-1)
+						cur_offset = cow_start;
+					goto error;
+				}
+
+				WARN_ON_ONCE(nolock);
 				goto out_check;
+			}
 			disk_bytenr += extent_offset;
 			disk_bytenr += cur_offset - found_key.offset;
 			num_bytes = min(end + 1, extent_end) - cur_offset;
@@ -1372,8 +1387,20 @@ next_slot:
 			 * this ensure that csum for a given extent are
 			 * either valid or do not exist.
 			 */
-			if (csum_exist_in_range(root, disk_bytenr, num_bytes))
+			ret = csum_exist_in_range(root, disk_bytenr, num_bytes);
+			if (ret) {
+				/*
+				 * ret could be -EIO if the above fails to read
+				 * metadata.
+				 */
+				if (ret < 0) {
+					if (cow_start != (u64)-1)
+						cur_offset = cow_start;
+					goto error;
+				}
+				WARN_ON_ONCE(nolock);
 				goto out_check;
+			}
 			nocow = 1;
 		} else if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
 			extent_end = found_key.offset +
diff -druNp --no-dereference linux-libre-4.4.138-gnu/fs/btrfs/ioctl.c linux-libre-4.4.139-gnu/fs/btrfs/ioctl.c
--- linux-libre-4.4.138-gnu/fs/btrfs/ioctl.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/fs/btrfs/ioctl.c	2018-07-03 05:21:35.000000000 -0400
@@ -3923,11 +3923,6 @@ static noinline long btrfs_ioctl_clone(s
 	if (!(src_file.file->f_mode & FMODE_READ))
 		goto out_fput;
 
-	/* don't make the dst file partly checksummed */
-	if ((BTRFS_I(src)->flags & BTRFS_INODE_NODATASUM) !=
-	    (BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM))
-		goto out_fput;
-
 	ret = -EISDIR;
 	if (S_ISDIR(src->i_mode) || S_ISDIR(inode->i_mode))
 		goto out_fput;
@@ -3942,6 +3937,13 @@ static noinline long btrfs_ioctl_clone(s
 		mutex_lock(&src->i_mutex);
 	}
 
+	/* don't make the dst file partly checksummed */
+	if ((BTRFS_I(src)->flags & BTRFS_INODE_NODATASUM) !=
+	    (BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) {
+		ret = -EINVAL;
+		goto out_unlock;
+	}
+
 	/* determine range to clone */
 	ret = -EINVAL;
 	if (off + len > src->i_size || off + len < off)
diff -druNp --no-dereference linux-libre-4.4.138-gnu/fs/btrfs/scrub.c linux-libre-4.4.139-gnu/fs/btrfs/scrub.c
--- linux-libre-4.4.138-gnu/fs/btrfs/scrub.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/fs/btrfs/scrub.c	2018-07-03 05:21:35.000000000 -0400
@@ -2513,7 +2513,7 @@ static int scrub_extent(struct scrub_ctx
 			have_csum = scrub_find_csum(sctx, logical, csum);
 			if (have_csum == 0)
 				++sctx->stat.no_csum;
-			if (sctx->is_dev_replace && !have_csum) {
+			if (0 && sctx->is_dev_replace && !have_csum) {
 				ret = copy_nocow_pages(sctx, logical, l,
 						       mirror_num,
 						      physical_for_dev_replace);
diff -druNp --no-dereference linux-libre-4.4.138-gnu/fs/ext4/inode.c linux-libre-4.4.139-gnu/fs/ext4/inode.c
--- linux-libre-4.4.138-gnu/fs/ext4/inode.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/fs/ext4/inode.c	2018-07-03 05:21:35.000000000 -0400
@@ -3787,28 +3787,28 @@ int ext4_punch_hole(struct inode *inode,
 		EXT4_BLOCK_SIZE_BITS(sb);
 	stop_block = (offset + length) >> EXT4_BLOCK_SIZE_BITS(sb);
 
-	/* If there are no blocks to remove, return now */
-	if (first_block >= stop_block)
-		goto out_stop;
+	/* If there are blocks to remove, do it */
+	if (stop_block > first_block) {
 
-	down_write(&EXT4_I(inode)->i_data_sem);
-	ext4_discard_preallocations(inode);
+		down_write(&EXT4_I(inode)->i_data_sem);
+		ext4_discard_preallocations(inode);
 
-	ret = ext4_es_remove_extent(inode, first_block,
-				    stop_block - first_block);
-	if (ret) {
-		up_write(&EXT4_I(inode)->i_data_sem);
-		goto out_stop;
-	}
+		ret = ext4_es_remove_extent(inode, first_block,
+					    stop_block - first_block);
+		if (ret) {
+			up_write(&EXT4_I(inode)->i_data_sem);
+			goto out_stop;
+		}
 
-	if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
-		ret = ext4_ext_remove_space(inode, first_block,
-					    stop_block - 1);
-	else
-		ret = ext4_ind_remove_space(handle, inode, first_block,
-					    stop_block);
+		if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
+			ret = ext4_ext_remove_space(inode, first_block,
+						    stop_block - 1);
+		else
+			ret = ext4_ind_remove_space(handle, inode, first_block,
+						    stop_block);
 
-	up_write(&EXT4_I(inode)->i_data_sem);
+		up_write(&EXT4_I(inode)->i_data_sem);
+	}
 	if (IS_SYNC(inode))
 		ext4_handle_sync(handle);
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/fs/ext4/resize.c linux-libre-4.4.139-gnu/fs/ext4/resize.c
--- linux-libre-4.4.138-gnu/fs/ext4/resize.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/fs/ext4/resize.c	2018-07-03 05:21:35.000000000 -0400
@@ -1903,7 +1903,7 @@ retry:
 		return 0;
 
 	n_group = ext4_get_group_number(sb, n_blocks_count - 1);
-	if (n_group > (0xFFFFFFFFUL / EXT4_INODES_PER_GROUP(sb))) {
+	if (n_group >= (0xFFFFFFFFUL / EXT4_INODES_PER_GROUP(sb))) {
 		ext4_warning(sb, "resize would cause inodes_count overflow");
 		return -EINVAL;
 	}
diff -druNp --no-dereference linux-libre-4.4.138-gnu/fs/fuse/control.c linux-libre-4.4.139-gnu/fs/fuse/control.c
--- linux-libre-4.4.138-gnu/fs/fuse/control.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/fs/fuse/control.c	2018-07-03 05:21:35.000000000 -0400
@@ -211,10 +211,11 @@ static struct dentry *fuse_ctl_add_dentr
 	if (!dentry)
 		return NULL;
 
-	fc->ctl_dentry[fc->ctl_ndents++] = dentry;
 	inode = new_inode(fuse_control_sb);
-	if (!inode)
+	if (!inode) {
+		dput(dentry);
 		return NULL;
+	}
 
 	inode->i_ino = get_next_ino();
 	inode->i_mode = mode;
@@ -228,6 +229,9 @@ static struct dentry *fuse_ctl_add_dentr
 	set_nlink(inode, nlink);
 	inode->i_private = fc;
 	d_add(dentry, inode);
+
+	fc->ctl_dentry[fc->ctl_ndents++] = dentry;
+
 	return dentry;
 }
 
@@ -284,7 +288,10 @@ void fuse_ctl_remove_conn(struct fuse_co
 	for (i = fc->ctl_ndents - 1; i >= 0; i--) {
 		struct dentry *dentry = fc->ctl_dentry[i];
 		d_inode(dentry)->i_private = NULL;
-		d_drop(dentry);
+		if (!i) {
+			/* Get rid of submounts: */
+			d_invalidate(dentry);
+		}
 		dput(dentry);
 	}
 	drop_nlink(d_inode(fuse_control_sb->s_root));
diff -druNp --no-dereference linux-libre-4.4.138-gnu/fs/fuse/dir.c linux-libre-4.4.139-gnu/fs/fuse/dir.c
--- linux-libre-4.4.138-gnu/fs/fuse/dir.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/fs/fuse/dir.c	2018-07-03 05:21:35.000000000 -0400
@@ -1609,8 +1609,19 @@ int fuse_do_setattr(struct inode *inode,
 		return err;
 
 	if (attr->ia_valid & ATTR_OPEN) {
-		if (fc->atomic_o_trunc)
+		/* This is coming from open(..., ... | O_TRUNC); */
+		WARN_ON(!(attr->ia_valid & ATTR_SIZE));
+		WARN_ON(attr->ia_size != 0);
+		if (fc->atomic_o_trunc) {
+			/*
+			 * No need to send request to userspace, since actual
+			 * truncation has already been done by OPEN.  But still
+			 * need to truncate page cache.
+			 */
+			i_size_write(inode, 0);
+			truncate_pagecache(inode, 0);
 			return 0;
+		}
 		file = NULL;
 	}
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/fs/fuse/inode.c linux-libre-4.4.139-gnu/fs/fuse/inode.c
--- linux-libre-4.4.138-gnu/fs/fuse/inode.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/fs/fuse/inode.c	2018-07-03 05:21:35.000000000 -0400
@@ -1158,6 +1158,7 @@ static int fuse_fill_super(struct super_
  err_put_conn:
 	fuse_bdi_destroy(fc);
 	fuse_conn_put(fc);
+	sb->s_fs_info = NULL;
  err_fput:
 	fput(file);
  err:
diff -druNp --no-dereference linux-libre-4.4.138-gnu/fs/nfs/nfs4idmap.c linux-libre-4.4.139-gnu/fs/nfs/nfs4idmap.c
--- linux-libre-4.4.138-gnu/fs/nfs/nfs4idmap.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/fs/nfs/nfs4idmap.c	2018-07-03 05:21:35.000000000 -0400
@@ -343,7 +343,7 @@ static ssize_t nfs_idmap_lookup_name(__u
 	int id_len;
 	ssize_t ret;
 
-	id_len = snprintf(id_str, sizeof(id_str), "%u", id);
+	id_len = nfs_map_numeric_to_string(id, id_str, sizeof(id_str));
 	ret = nfs_idmap_get_key(id_str, id_len, type, buf, buflen, idmap);
 	if (ret < 0)
 		return -EINVAL;
@@ -626,7 +626,8 @@ static int nfs_idmap_read_and_verify_mes
 		if (strcmp(upcall->im_name, im->im_name) != 0)
 			break;
 		/* Note: here we store the NUL terminator too */
-		len = sprintf(id_str, "%d", im->im_id) + 1;
+		len = 1 + nfs_map_numeric_to_string(im->im_id, id_str,
+						    sizeof(id_str));
 		ret = nfs_idmap_instantiate(key, authkey, id_str, len);
 		break;
 	case IDMAP_CONV_IDTONAME:
diff -druNp --no-dereference linux-libre-4.4.138-gnu/fs/nfsd/nfs4xdr.c linux-libre-4.4.139-gnu/fs/nfsd/nfs4xdr.c
--- linux-libre-4.4.138-gnu/fs/nfsd/nfs4xdr.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/fs/nfsd/nfs4xdr.c	2018-07-03 05:21:35.000000000 -0400
@@ -3595,7 +3595,8 @@ nfsd4_encode_readdir(struct nfsd4_compou
 		nfserr = nfserr_resource;
 		goto err_no_verf;
 	}
-	maxcount = min_t(u32, readdir->rd_maxcount, INT_MAX);
+	maxcount = svc_max_payload(resp->rqstp);
+	maxcount = min_t(u32, readdir->rd_maxcount, maxcount);
 	/*
 	 * Note the rfc defines rd_maxcount as the size of the
 	 * READDIR4resok structure, which includes the verifier above
@@ -3609,7 +3610,7 @@ nfsd4_encode_readdir(struct nfsd4_compou
 
 	/* RFC 3530 14.2.24 allows us to ignore dircount when it's 0: */
 	if (!readdir->rd_dircount)
-		readdir->rd_dircount = INT_MAX;
+		readdir->rd_dircount = svc_max_payload(resp->rqstp);
 
 	readdir->xdr = xdr;
 	readdir->rd_maxcount = maxcount;
diff -druNp --no-dereference linux-libre-4.4.138-gnu/fs/ubifs/journal.c linux-libre-4.4.139-gnu/fs/ubifs/journal.c
--- linux-libre-4.4.138-gnu/fs/ubifs/journal.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/fs/ubifs/journal.c	2018-07-03 05:21:35.000000000 -0400
@@ -1107,7 +1107,7 @@ static int recomp_data_node(const struct
 	int err, len, compr_type, out_len;
 
 	out_len = le32_to_cpu(dn->size);
-	buf = kmalloc(out_len * WORST_COMPR_FACTOR, GFP_NOFS);
+	buf = kmalloc_array(out_len, WORST_COMPR_FACTOR, GFP_NOFS);
 	if (!buf)
 		return -ENOMEM;
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/fs/udf/directory.c linux-libre-4.4.139-gnu/fs/udf/directory.c
--- linux-libre-4.4.138-gnu/fs/udf/directory.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/fs/udf/directory.c	2018-07-03 05:21:35.000000000 -0400
@@ -150,6 +150,9 @@ struct fileIdentDesc *udf_fileident_read
 			       sizeof(struct fileIdentDesc));
 		}
 	}
+	/* Got last entry outside of dir size - fs is corrupted! */
+	if (*nf_pos > dir->i_size)
+		return NULL;
 	return fi;
 }
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/include/linux/blkdev.h linux-libre-4.4.139-gnu/include/linux/blkdev.h
--- linux-libre-4.4.138-gnu/include/linux/blkdev.h	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/include/linux/blkdev.h	2018-07-03 05:21:35.000000000 -0400
@@ -882,8 +882,8 @@ static inline unsigned int blk_max_size_
 	if (!q->limits.chunk_sectors)
 		return q->limits.max_sectors;
 
-	return q->limits.chunk_sectors -
-			(offset & (q->limits.chunk_sectors - 1));
+	return min(q->limits.max_sectors, (unsigned int)(q->limits.chunk_sectors -
+			(offset & (q->limits.chunk_sectors - 1))));
 }
 
 static inline unsigned int blk_rq_get_max_sectors(struct request *rq)
diff -druNp --no-dereference linux-libre-4.4.138-gnu/include/linux/compiler.h linux-libre-4.4.139-gnu/include/linux/compiler.h
--- linux-libre-4.4.138-gnu/include/linux/compiler.h	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/include/linux/compiler.h	2018-07-03 05:21:35.000000000 -0400
@@ -111,7 +111,7 @@ void ftrace_likely_update(struct ftrace_
 #define unlikely_notrace(x)	__builtin_expect(!!(x), 0)
 
 #define __branch_check__(x, expect) ({					\
-			int ______r;					\
+			long ______r;					\
 			static struct ftrace_branch_data		\
 				__attribute__((__aligned__(4)))		\
 				__attribute__((section("_ftrace_annotated_branch"))) \
diff -druNp --no-dereference linux-libre-4.4.138-gnu/include/linux/iio/buffer.h linux-libre-4.4.139-gnu/include/linux/iio/buffer.h
--- linux-libre-4.4.138-gnu/include/linux/iio/buffer.h	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/include/linux/iio/buffer.h	2018-07-03 05:21:35.000000000 -0400
@@ -49,7 +49,7 @@ struct iio_buffer_access_funcs {
 	int (*request_update)(struct iio_buffer *buffer);
 
 	int (*set_bytes_per_datum)(struct iio_buffer *buffer, size_t bpd);
-	int (*set_length)(struct iio_buffer *buffer, int length);
+	int (*set_length)(struct iio_buffer *buffer, unsigned int length);
 
 	void (*release)(struct iio_buffer *buffer);
 
@@ -78,8 +78,8 @@ struct iio_buffer_access_funcs {
  * @watermark:		[INTERN] number of datums to wait for poll/read.
  */
 struct iio_buffer {
-	int					length;
-	int					bytes_per_datum;
+	unsigned int				length;
+	size_t					bytes_per_datum;
 	struct attribute_group			*scan_el_attrs;
 	long					*scan_mask;
 	bool					scan_timestamp;
diff -druNp --no-dereference linux-libre-4.4.138-gnu/include/net/bluetooth/hci_core.h linux-libre-4.4.139-gnu/include/net/bluetooth/hci_core.h
--- linux-libre-4.4.138-gnu/include/net/bluetooth/hci_core.h	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/include/net/bluetooth/hci_core.h	2018-07-03 05:21:35.000000000 -0400
@@ -878,7 +878,7 @@ struct hci_conn *hci_connect_le_scan(str
 				     u16 conn_timeout, u8 role);
 struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
 				u8 dst_type, u8 sec_level, u16 conn_timeout,
-				u8 role);
+				u8 role, bdaddr_t *direct_rpa);
 struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst,
 				 u8 sec_level, u8 auth_type);
 struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, bdaddr_t *dst,
diff -druNp --no-dereference linux-libre-4.4.138-gnu/kernel/time/time.c linux-libre-4.4.139-gnu/kernel/time/time.c
--- linux-libre-4.4.138-gnu/kernel/time/time.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/kernel/time/time.c	2018-07-03 05:21:35.000000000 -0400
@@ -28,6 +28,7 @@
  */
 
 #include <linux/export.h>
+#include <linux/kernel.h>
 #include <linux/timex.h>
 #include <linux/capability.h>
 #include <linux/timekeeper_internal.h>
@@ -258,9 +259,10 @@ unsigned int jiffies_to_msecs(const unsi
 	return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC);
 #else
 # if BITS_PER_LONG == 32
-	return (HZ_TO_MSEC_MUL32 * j) >> HZ_TO_MSEC_SHR32;
+	return (HZ_TO_MSEC_MUL32 * j + (1ULL << HZ_TO_MSEC_SHR32) - 1) >>
+	       HZ_TO_MSEC_SHR32;
 # else
-	return (j * HZ_TO_MSEC_NUM) / HZ_TO_MSEC_DEN;
+	return DIV_ROUND_UP(j * HZ_TO_MSEC_NUM, HZ_TO_MSEC_DEN);
 # endif
 #endif
 }
diff -druNp --no-dereference linux-libre-4.4.138-gnu/lib/vsprintf.c linux-libre-4.4.139-gnu/lib/vsprintf.c
--- linux-libre-4.4.138-gnu/lib/vsprintf.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/lib/vsprintf.c	2018-07-03 05:21:35.000000000 -0400
@@ -1345,9 +1345,6 @@ char *clock(char *buf, char *end, struct
 		return string(buf, end, NULL, spec);
 
 	switch (fmt[1]) {
-	case 'r':
-		return number(buf, end, clk_get_rate(clk), spec);
-
 	case 'n':
 	default:
 #ifdef CONFIG_COMMON_CLK
diff -druNp --no-dereference linux-libre-4.4.138-gnu/Makefile linux-libre-4.4.139-gnu/Makefile
--- linux-libre-4.4.138-gnu/Makefile	2018-06-16 12:59:16.000000000 -0400
+++ linux-libre-4.4.139-gnu/Makefile	2018-07-03 13:18:29.000000000 -0400
@@ -1,6 +1,6 @@
 VERSION = 4
 PATCHLEVEL = 4
-SUBLEVEL = 138
+SUBLEVEL = 139
 EXTRAVERSION = -gnu
 NAME = Blurry Fish Butt
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/net/bluetooth/hci_conn.c linux-libre-4.4.139-gnu/net/bluetooth/hci_conn.c
--- linux-libre-4.4.138-gnu/net/bluetooth/hci_conn.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/net/bluetooth/hci_conn.c	2018-07-03 05:21:35.000000000 -0400
@@ -708,7 +708,8 @@ done:
 }
 
 static void hci_req_add_le_create_conn(struct hci_request *req,
-				       struct hci_conn *conn)
+				       struct hci_conn *conn,
+				       bdaddr_t *direct_rpa)
 {
 	struct hci_cp_le_create_conn cp;
 	struct hci_dev *hdev = conn->hdev;
@@ -716,11 +717,23 @@ static void hci_req_add_le_create_conn(s
 
 	memset(&cp, 0, sizeof(cp));
 
-	/* Update random address, but set require_privacy to false so
-	 * that we never connect with an non-resolvable address.
+	/* If direct address was provided we use it instead of current
+	 * address.
 	 */
-	if (hci_update_random_address(req, false, &own_addr_type))
-		return;
+	if (direct_rpa) {
+		if (bacmp(&req->hdev->random_addr, direct_rpa))
+			hci_req_add(req, HCI_OP_LE_SET_RANDOM_ADDR, 6,
+								direct_rpa);
+
+		/* direct address is always RPA */
+		own_addr_type = ADDR_LE_DEV_RANDOM;
+	} else {
+		/* Update random address, but set require_privacy to false so
+		 * that we never connect with an non-resolvable address.
+		 */
+		if (hci_update_random_address(req, false, &own_addr_type))
+			return;
+	}
 
 	/* Set window to be the same value as the interval to enable
 	 * continuous scanning.
@@ -782,7 +795,7 @@ static void hci_req_directed_advertising
 
 struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
 				u8 dst_type, u8 sec_level, u16 conn_timeout,
-				u8 role)
+				u8 role, bdaddr_t *direct_rpa)
 {
 	struct hci_conn_params *params;
 	struct hci_conn *conn, *conn_unfinished;
@@ -913,7 +926,7 @@ struct hci_conn *hci_connect_le(struct h
 		hci_dev_set_flag(hdev, HCI_LE_SCAN_INTERRUPTED);
 	}
 
-	hci_req_add_le_create_conn(&req, conn);
+	hci_req_add_le_create_conn(&req, conn, direct_rpa);
 
 create_conn:
 	err = hci_req_run(&req, create_le_conn_complete);
diff -druNp --no-dereference linux-libre-4.4.138-gnu/net/bluetooth/hci_event.c linux-libre-4.4.139-gnu/net/bluetooth/hci_event.c
--- linux-libre-4.4.138-gnu/net/bluetooth/hci_event.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/net/bluetooth/hci_event.c	2018-07-03 05:21:35.000000000 -0400
@@ -4632,7 +4632,8 @@ static void hci_le_conn_update_complete_
 /* This function requires the caller holds hdev->lock */
 static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev,
 					      bdaddr_t *addr,
-					      u8 addr_type, u8 adv_type)
+					      u8 addr_type, u8 adv_type,
+					      bdaddr_t *direct_rpa)
 {
 	struct hci_conn *conn;
 	struct hci_conn_params *params;
@@ -4683,7 +4684,8 @@ static struct hci_conn *check_pending_le
 	}
 
 	conn = hci_connect_le(hdev, addr, addr_type, BT_SECURITY_LOW,
-			      HCI_LE_AUTOCONN_TIMEOUT, HCI_ROLE_MASTER);
+			      HCI_LE_AUTOCONN_TIMEOUT, HCI_ROLE_MASTER,
+			      direct_rpa);
 	if (!IS_ERR(conn)) {
 		/* If HCI_AUTO_CONN_EXPLICIT is set, conn is already owned
 		 * by higher layer that tried to connect, if no then
@@ -4780,8 +4782,13 @@ static void process_adv_report(struct hc
 		bdaddr_type = irk->addr_type;
 	}
 
-	/* Check if we have been requested to connect to this device */
-	conn = check_pending_le_conn(hdev, bdaddr, bdaddr_type, type);
+	/* Check if we have been requested to connect to this device.
+	 *
+	 * direct_addr is set only for directed advertising reports (it is NULL
+	 * for advertising reports) and is already verified to be RPA above.
+	 */
+	conn = check_pending_le_conn(hdev, bdaddr, bdaddr_type, type,
+								direct_addr);
 	if (conn && type == LE_ADV_IND) {
 		/* Store report for later inclusion by
 		 * mgmt_device_connected
diff -druNp --no-dereference linux-libre-4.4.138-gnu/net/bridge/netfilter/ebtables.c linux-libre-4.4.139-gnu/net/bridge/netfilter/ebtables.c
--- linux-libre-4.4.138-gnu/net/bridge/netfilter/ebtables.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/net/bridge/netfilter/ebtables.c	2018-07-03 05:21:35.000000000 -0400
@@ -1912,7 +1912,8 @@ static int compat_mtw_from_user(struct c
 	int off, pad = 0;
 	unsigned int size_kern, match_size = mwt->match_size;
 
-	strlcpy(name, mwt->u.name, sizeof(name));
+	if (strscpy(name, mwt->u.name, sizeof(name)) < 0)
+		return -EINVAL;
 
 	if (state->buf_kern_start)
 		dst = state->buf_kern_start + state->buf_kern_offset;
diff -druNp --no-dereference linux-libre-4.4.138-gnu/net/ipv4/tcp_input.c linux-libre-4.4.139-gnu/net/ipv4/tcp_input.c
--- linux-libre-4.4.138-gnu/net/ipv4/tcp_input.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/net/ipv4/tcp_input.c	2018-07-03 05:21:35.000000000 -0400
@@ -612,7 +612,7 @@ void tcp_rcv_space_adjust(struct sock *s
 			sk->sk_rcvbuf = rcvbuf;
 
 			/* Make the window clamp follow along.  */
-			tp->window_clamp = rcvwin;
+			tp->window_clamp = tcp_win_from_space(rcvbuf);
 		}
 	}
 	tp->rcvq_space.space = copied;
diff -druNp --no-dereference linux-libre-4.4.138-gnu/net/ipv4/tcp_ipv4.c linux-libre-4.4.139-gnu/net/ipv4/tcp_ipv4.c
--- linux-libre-4.4.138-gnu/net/ipv4/tcp_ipv4.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/net/ipv4/tcp_ipv4.c	2018-07-03 05:21:35.000000000 -0400
@@ -1627,6 +1627,10 @@ process:
 			reqsk_put(req);
 			goto discard_it;
 		}
+		if (tcp_checksum_complete(skb)) {
+			reqsk_put(req);
+			goto csum_error;
+		}
 		if (unlikely(sk->sk_state != TCP_LISTEN)) {
 			inet_csk_reqsk_queue_drop_and_put(sk, req);
 			goto lookup;
diff -druNp --no-dereference linux-libre-4.4.138-gnu/net/ipv6/tcp_ipv6.c linux-libre-4.4.139-gnu/net/ipv6/tcp_ipv6.c
--- linux-libre-4.4.138-gnu/net/ipv6/tcp_ipv6.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/net/ipv6/tcp_ipv6.c	2018-07-03 05:21:35.000000000 -0400
@@ -1415,6 +1415,10 @@ process:
 			reqsk_put(req);
 			goto discard_it;
 		}
+		if (tcp_checksum_complete(skb)) {
+			reqsk_put(req);
+			goto csum_error;
+		}
 		if (unlikely(sk->sk_state != TCP_LISTEN)) {
 			inet_csk_reqsk_queue_drop_and_put(sk, req);
 			goto lookup;
diff -druNp --no-dereference linux-libre-4.4.138-gnu/net/ipv6/xfrm6_policy.c linux-libre-4.4.139-gnu/net/ipv6/xfrm6_policy.c
--- linux-libre-4.4.138-gnu/net/ipv6/xfrm6_policy.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/net/ipv6/xfrm6_policy.c	2018-07-03 05:21:35.000000000 -0400
@@ -121,7 +121,7 @@ _decode_session6(struct sk_buff *skb, st
 	struct flowi6 *fl6 = &fl->u.ip6;
 	int onlyproto = 0;
 	const struct ipv6hdr *hdr = ipv6_hdr(skb);
-	u16 offset = sizeof(*hdr);
+	u32 offset = sizeof(*hdr);
 	struct ipv6_opt_hdr *exthdr;
 	const unsigned char *nh = skb_network_header(skb);
 	u16 nhoff = IP6CB(skb)->nhoff;
diff -druNp --no-dereference linux-libre-4.4.138-gnu/net/netfilter/ipvs/ip_vs_ctl.c linux-libre-4.4.139-gnu/net/netfilter/ipvs/ip_vs_ctl.c
--- linux-libre-4.4.138-gnu/net/netfilter/ipvs/ip_vs_ctl.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/net/netfilter/ipvs/ip_vs_ctl.c	2018-07-03 05:21:35.000000000 -0400
@@ -2349,8 +2349,10 @@ do_ip_vs_set_ctl(struct sock *sk, int cm
 			struct ipvs_sync_daemon_cfg cfg;
 
 			memset(&cfg, 0, sizeof(cfg));
-			strlcpy(cfg.mcast_ifn, dm->mcast_ifn,
-				sizeof(cfg.mcast_ifn));
+			ret = -EINVAL;
+			if (strscpy(cfg.mcast_ifn, dm->mcast_ifn,
+				    sizeof(cfg.mcast_ifn)) <= 0)
+				goto out_dec;
 			cfg.syncid = dm->syncid;
 			ret = start_sync_thread(ipvs, &cfg, dm->state);
 		} else {
@@ -2388,12 +2390,19 @@ do_ip_vs_set_ctl(struct sock *sk, int cm
 		}
 	}
 
+	if ((cmd == IP_VS_SO_SET_ADD || cmd == IP_VS_SO_SET_EDIT) &&
+	    strnlen(usvc.sched_name, IP_VS_SCHEDNAME_MAXLEN) ==
+	    IP_VS_SCHEDNAME_MAXLEN) {
+		ret = -EINVAL;
+		goto out_unlock;
+	}
+
 	/* Check for valid protocol: TCP or UDP or SCTP, even for fwmark!=0 */
 	if (usvc.protocol != IPPROTO_TCP && usvc.protocol != IPPROTO_UDP &&
 	    usvc.protocol != IPPROTO_SCTP) {
-		pr_err("set_ctl: invalid protocol: %d %pI4:%d %s\n",
+		pr_err("set_ctl: invalid protocol: %d %pI4:%d\n",
 		       usvc.protocol, &usvc.addr.ip,
-		       ntohs(usvc.port), usvc.sched_name);
+		       ntohs(usvc.port));
 		ret = -EFAULT;
 		goto out_unlock;
 	}
@@ -2822,7 +2831,7 @@ static const struct nla_policy ip_vs_cmd
 static const struct nla_policy ip_vs_daemon_policy[IPVS_DAEMON_ATTR_MAX + 1] = {
 	[IPVS_DAEMON_ATTR_STATE]	= { .type = NLA_U32 },
 	[IPVS_DAEMON_ATTR_MCAST_IFN]	= { .type = NLA_NUL_STRING,
-					    .len = IP_VS_IFNAME_MAXLEN },
+					    .len = IP_VS_IFNAME_MAXLEN - 1 },
 	[IPVS_DAEMON_ATTR_SYNC_ID]	= { .type = NLA_U32 },
 	[IPVS_DAEMON_ATTR_SYNC_MAXLEN]	= { .type = NLA_U16 },
 	[IPVS_DAEMON_ATTR_MCAST_GROUP]	= { .type = NLA_U32 },
@@ -2840,7 +2849,7 @@ static const struct nla_policy ip_vs_svc
 	[IPVS_SVC_ATTR_PORT]		= { .type = NLA_U16 },
 	[IPVS_SVC_ATTR_FWMARK]		= { .type = NLA_U32 },
 	[IPVS_SVC_ATTR_SCHED_NAME]	= { .type = NLA_NUL_STRING,
-					    .len = IP_VS_SCHEDNAME_MAXLEN },
+					    .len = IP_VS_SCHEDNAME_MAXLEN - 1 },
 	[IPVS_SVC_ATTR_PE_NAME]		= { .type = NLA_NUL_STRING,
 					    .len = IP_VS_PENAME_MAXLEN },
 	[IPVS_SVC_ATTR_FLAGS]		= { .type = NLA_BINARY,
diff -druNp --no-dereference linux-libre-4.4.138-gnu/net/xfrm/xfrm_policy.c linux-libre-4.4.139-gnu/net/xfrm/xfrm_policy.c
--- linux-libre-4.4.138-gnu/net/xfrm/xfrm_policy.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/net/xfrm/xfrm_policy.c	2018-07-03 05:21:35.000000000 -0400
@@ -626,6 +626,11 @@ static void xfrm_hash_rebuild(struct wor
 
 	/* re-insert all policies by order of creation */
 	list_for_each_entry_reverse(policy, &net->xfrm.policy_all, walk.all) {
+		if (policy->walk.dead ||
+		    xfrm_policy_id2dir(policy->index) >= XFRM_POLICY_MAX) {
+			/* skip socket policies */
+			continue;
+		}
 		newpos = NULL;
 		chain = policy_hash_bysel(net, &policy->selector,
 					  policy->family,
diff -druNp --no-dereference linux-libre-4.4.138-gnu/sound/pci/hda/hda_controller.c linux-libre-4.4.139-gnu/sound/pci/hda/hda_controller.c
--- linux-libre-4.4.138-gnu/sound/pci/hda/hda_controller.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/sound/pci/hda/hda_controller.c	2018-07-03 05:21:35.000000000 -0400
@@ -547,8 +547,10 @@ int snd_hda_attach_pcm_stream(struct hda
 		return err;
 	strlcpy(pcm->name, cpcm->name, sizeof(pcm->name));
 	apcm = kzalloc(sizeof(*apcm), GFP_KERNEL);
-	if (apcm == NULL)
+	if (apcm == NULL) {
+		snd_device_free(chip->card, pcm);
 		return -ENOMEM;
+	}
 	apcm->chip = chip;
 	apcm->pcm = pcm;
 	apcm->codec = codec;
diff -druNp --no-dereference linux-libre-4.4.138-gnu/sound/pci/hda/patch_conexant.c linux-libre-4.4.139-gnu/sound/pci/hda/patch_conexant.c
--- linux-libre-4.4.138-gnu/sound/pci/hda/patch_conexant.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/sound/pci/hda/patch_conexant.c	2018-07-03 05:21:35.000000000 -0400
@@ -851,6 +851,8 @@ static const struct snd_pci_quirk cxt506
 	SND_PCI_QUIRK(0x103c, 0x8079, "HP EliteBook 840 G3", CXT_FIXUP_HP_DOCK),
 	SND_PCI_QUIRK(0x103c, 0x807C, "HP EliteBook 820 G3", CXT_FIXUP_HP_DOCK),
 	SND_PCI_QUIRK(0x103c, 0x80FD, "HP ProBook 640 G2", CXT_FIXUP_HP_DOCK),
+	SND_PCI_QUIRK(0x103c, 0x83b3, "HP EliteBook 830 G5", CXT_FIXUP_HP_DOCK),
+	SND_PCI_QUIRK(0x103c, 0x83d3, "HP ProBook 640 G4", CXT_FIXUP_HP_DOCK),
 	SND_PCI_QUIRK(0x103c, 0x8174, "HP Spectre x360", CXT_FIXUP_HP_SPECTRE),
 	SND_PCI_QUIRK(0x103c, 0x8115, "HP Z1 Gen3", CXT_FIXUP_HP_GATE_MIC),
 	SND_PCI_QUIRK(0x1043, 0x138d, "Asus", CXT_FIXUP_HEADPHONE_MIC_PIN),
diff -druNp --no-dereference linux-libre-4.4.138-gnu/sound/pci/hda/patch_realtek.c linux-libre-4.4.139-gnu/sound/pci/hda/patch_realtek.c
--- linux-libre-4.4.138-gnu/sound/pci/hda/patch_realtek.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/sound/pci/hda/patch_realtek.c	2018-07-03 05:21:35.000000000 -0400
@@ -2447,6 +2447,7 @@ static const struct snd_pci_quirk alc262
 	SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110),
 	SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
 	SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
+	SND_PCI_QUIRK(0x1734, 0x1141, "FSC ESPRIMO U9210", ALC262_FIXUP_FSC_H270),
 	SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
 	SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
 	SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
diff -druNp --no-dereference linux-libre-4.4.138-gnu/sound/soc/cirrus/edb93xx.c linux-libre-4.4.139-gnu/sound/soc/cirrus/edb93xx.c
--- linux-libre-4.4.138-gnu/sound/soc/cirrus/edb93xx.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/sound/soc/cirrus/edb93xx.c	2018-07-03 05:21:35.000000000 -0400
@@ -67,7 +67,7 @@ static struct snd_soc_dai_link edb93xx_d
 	.cpu_dai_name	= "ep93xx-i2s",
 	.codec_name	= "spi0.0",
 	.codec_dai_name	= "cs4271-hifi",
-	.dai_fmt	= SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_IF |
+	.dai_fmt	= SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
 			  SND_SOC_DAIFMT_CBS_CFS,
 	.ops		= &edb93xx_ops,
 };
diff -druNp --no-dereference linux-libre-4.4.138-gnu/sound/soc/cirrus/ep93xx-i2s.c linux-libre-4.4.139-gnu/sound/soc/cirrus/ep93xx-i2s.c
--- linux-libre-4.4.138-gnu/sound/soc/cirrus/ep93xx-i2s.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/sound/soc/cirrus/ep93xx-i2s.c	2018-07-03 05:21:35.000000000 -0400
@@ -51,7 +51,9 @@
 #define EP93XX_I2S_WRDLEN_24		(1 << 0)
 #define EP93XX_I2S_WRDLEN_32		(2 << 0)
 
-#define EP93XX_I2S_LINCTRLDATA_R_JUST	(1 << 2) /* Right justify */
+#define EP93XX_I2S_RXLINCTRLDATA_R_JUST	BIT(1) /* Right justify */
+
+#define EP93XX_I2S_TXLINCTRLDATA_R_JUST	BIT(2) /* Right justify */
 
 #define EP93XX_I2S_CLKCFG_LRS		(1 << 0) /* lrclk polarity */
 #define EP93XX_I2S_CLKCFG_CKP		(1 << 1) /* Bit clock polarity */
@@ -170,25 +172,25 @@ static int ep93xx_i2s_set_dai_fmt(struct
 				  unsigned int fmt)
 {
 	struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(cpu_dai);
-	unsigned int clk_cfg, lin_ctrl;
+	unsigned int clk_cfg;
+	unsigned int txlin_ctrl = 0;
+	unsigned int rxlin_ctrl = 0;
 
 	clk_cfg  = ep93xx_i2s_read_reg(info, EP93XX_I2S_RXCLKCFG);
-	lin_ctrl = ep93xx_i2s_read_reg(info, EP93XX_I2S_RXLINCTRLDATA);
 
 	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
 	case SND_SOC_DAIFMT_I2S:
 		clk_cfg |= EP93XX_I2S_CLKCFG_REL;
-		lin_ctrl &= ~EP93XX_I2S_LINCTRLDATA_R_JUST;
 		break;
 
 	case SND_SOC_DAIFMT_LEFT_J:
 		clk_cfg &= ~EP93XX_I2S_CLKCFG_REL;
-		lin_ctrl &= ~EP93XX_I2S_LINCTRLDATA_R_JUST;
 		break;
 
 	case SND_SOC_DAIFMT_RIGHT_J:
 		clk_cfg &= ~EP93XX_I2S_CLKCFG_REL;
-		lin_ctrl |= EP93XX_I2S_LINCTRLDATA_R_JUST;
+		rxlin_ctrl |= EP93XX_I2S_RXLINCTRLDATA_R_JUST;
+		txlin_ctrl |= EP93XX_I2S_TXLINCTRLDATA_R_JUST;
 		break;
 
 	default:
@@ -213,32 +215,32 @@ static int ep93xx_i2s_set_dai_fmt(struct
 	switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
 	case SND_SOC_DAIFMT_NB_NF:
 		/* Negative bit clock, lrclk low on left word */
-		clk_cfg &= ~(EP93XX_I2S_CLKCFG_CKP | EP93XX_I2S_CLKCFG_REL);
+		clk_cfg &= ~(EP93XX_I2S_CLKCFG_CKP | EP93XX_I2S_CLKCFG_LRS);
 		break;
 
 	case SND_SOC_DAIFMT_NB_IF:
 		/* Negative bit clock, lrclk low on right word */
 		clk_cfg &= ~EP93XX_I2S_CLKCFG_CKP;
-		clk_cfg |= EP93XX_I2S_CLKCFG_REL;
+		clk_cfg |= EP93XX_I2S_CLKCFG_LRS;
 		break;
 
 	case SND_SOC_DAIFMT_IB_NF:
 		/* Positive bit clock, lrclk low on left word */
 		clk_cfg |= EP93XX_I2S_CLKCFG_CKP;
-		clk_cfg &= ~EP93XX_I2S_CLKCFG_REL;
+		clk_cfg &= ~EP93XX_I2S_CLKCFG_LRS;
 		break;
 
 	case SND_SOC_DAIFMT_IB_IF:
 		/* Positive bit clock, lrclk low on right word */
-		clk_cfg |= EP93XX_I2S_CLKCFG_CKP | EP93XX_I2S_CLKCFG_REL;
+		clk_cfg |= EP93XX_I2S_CLKCFG_CKP | EP93XX_I2S_CLKCFG_LRS;
 		break;
 	}
 
 	/* Write new register values */
 	ep93xx_i2s_write_reg(info, EP93XX_I2S_RXCLKCFG, clk_cfg);
 	ep93xx_i2s_write_reg(info, EP93XX_I2S_TXCLKCFG, clk_cfg);
-	ep93xx_i2s_write_reg(info, EP93XX_I2S_RXLINCTRLDATA, lin_ctrl);
-	ep93xx_i2s_write_reg(info, EP93XX_I2S_TXLINCTRLDATA, lin_ctrl);
+	ep93xx_i2s_write_reg(info, EP93XX_I2S_RXLINCTRLDATA, rxlin_ctrl);
+	ep93xx_i2s_write_reg(info, EP93XX_I2S_TXLINCTRLDATA, txlin_ctrl);
 	return 0;
 }
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/sound/soc/cirrus/snappercl15.c linux-libre-4.4.139-gnu/sound/soc/cirrus/snappercl15.c
--- linux-libre-4.4.138-gnu/sound/soc/cirrus/snappercl15.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/sound/soc/cirrus/snappercl15.c	2018-07-03 05:21:35.000000000 -0400
@@ -72,7 +72,7 @@ static struct snd_soc_dai_link snappercl
 	.codec_dai_name	= "tlv320aic23-hifi",
 	.codec_name	= "tlv320aic23-codec.0-001a",
 	.platform_name	= "ep93xx-i2s",
-	.dai_fmt	= SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_IF |
+	.dai_fmt	= SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
 			  SND_SOC_DAIFMT_CBS_CFS,
 	.ops		= &snappercl15_ops,
 };
diff -druNp --no-dereference linux-libre-4.4.138-gnu/sound/soc/soc-dapm.c linux-libre-4.4.139-gnu/sound/soc/soc-dapm.c
--- linux-libre-4.4.138-gnu/sound/soc/soc-dapm.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/sound/soc/soc-dapm.c	2018-07-03 05:21:35.000000000 -0400
@@ -425,6 +425,8 @@ err_data:
 static void dapm_kcontrol_free(struct snd_kcontrol *kctl)
 {
 	struct dapm_kcontrol_data *data = snd_kcontrol_chip(kctl);
+
+	list_del(&data->paths);
 	kfree(data->wlist);
 	kfree(data);
 }
diff -druNp --no-dereference linux-libre-4.4.138-gnu/tools/perf/util/dso.c linux-libre-4.4.139-gnu/tools/perf/util/dso.c
--- linux-libre-4.4.138-gnu/tools/perf/util/dso.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/tools/perf/util/dso.c	2018-07-03 05:21:35.000000000 -0400
@@ -249,6 +249,8 @@ int __kmod_path__parse(struct kmod_path
 		if ((strncmp(name, "[kernel.kallsyms]", 17) == 0) ||
 		    (strncmp(name, "[guest.kernel.kallsyms", 22) == 0) ||
 		    (strncmp(name, "[vdso]", 6) == 0) ||
+		    (strncmp(name, "[vdso32]", 8) == 0) ||
+		    (strncmp(name, "[vdsox32]", 9) == 0) ||
 		    (strncmp(name, "[vsyscall]", 10) == 0)) {
 			m->kmod = false;
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/tools/perf/util/intel-pt.c linux-libre-4.4.139-gnu/tools/perf/util/intel-pt.c
--- linux-libre-4.4.138-gnu/tools/perf/util/intel-pt.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/tools/perf/util/intel-pt.c	2018-07-03 05:21:35.000000000 -0400
@@ -676,6 +676,7 @@ static struct intel_pt_queue *intel_pt_a
 						   unsigned int queue_nr)
 {
 	struct intel_pt_params params = { .get_trace = 0, };
+	struct perf_env *env = pt->machine->env;
 	struct intel_pt_queue *ptq;
 
 	ptq = zalloc(sizeof(struct intel_pt_queue));
@@ -753,6 +754,9 @@ static struct intel_pt_queue *intel_pt_a
 		}
 	}
 
+	if (env->cpuid && !strncmp(env->cpuid, "GenuineIntel,6,92,", 18))
+		params.flags |= INTEL_PT_FUP_WITH_NLIP;
+
 	ptq->decoder = intel_pt_decoder_new(&params);
 	if (!ptq->decoder)
 		goto out_free;
@@ -1246,6 +1250,7 @@ static int intel_pt_sample(struct intel_
 
 	if (intel_pt_is_switch_ip(ptq, state->to_ip)) {
 		switch (ptq->switch_state) {
+		case INTEL_PT_SS_NOT_TRACING:
 		case INTEL_PT_SS_UNKNOWN:
 		case INTEL_PT_SS_EXPECTING_SWITCH_IP:
 			err = intel_pt_next_tid(pt, ptq);
diff -druNp --no-dereference linux-libre-4.4.138-gnu/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c linux-libre-4.4.139-gnu/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
--- linux-libre-4.4.138-gnu/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c	2018-07-03 05:21:35.000000000 -0400
@@ -111,6 +111,7 @@ struct intel_pt_decoder {
 	bool have_cyc;
 	bool fixup_last_mtc;
 	bool have_last_ip;
+	enum intel_pt_param_flags flags;
 	uint64_t pos;
 	uint64_t last_ip;
 	uint64_t ip;
@@ -213,6 +214,8 @@ struct intel_pt_decoder *intel_pt_decode
 	decoder->data               = params->data;
 	decoder->return_compression = params->return_compression;
 
+	decoder->flags              = params->flags;
+
 	decoder->period             = params->period;
 	decoder->period_type        = params->period_type;
 
@@ -1010,6 +1013,15 @@ out_no_progress:
 	return err;
 }
 
+static inline bool intel_pt_fup_with_nlip(struct intel_pt_decoder *decoder,
+					  struct intel_pt_insn *intel_pt_insn,
+					  uint64_t ip, int err)
+{
+	return decoder->flags & INTEL_PT_FUP_WITH_NLIP && !err &&
+	       intel_pt_insn->branch == INTEL_PT_BR_INDIRECT &&
+	       ip == decoder->ip + intel_pt_insn->length;
+}
+
 static int intel_pt_walk_fup(struct intel_pt_decoder *decoder)
 {
 	struct intel_pt_insn intel_pt_insn;
@@ -1022,7 +1034,8 @@ static int intel_pt_walk_fup(struct inte
 		err = intel_pt_walk_insn(decoder, &intel_pt_insn, ip);
 		if (err == INTEL_PT_RETURN)
 			return 0;
-		if (err == -EAGAIN) {
+		if (err == -EAGAIN ||
+		    intel_pt_fup_with_nlip(decoder, &intel_pt_insn, ip, err)) {
 			if (decoder->set_fup_tx_flags) {
 				decoder->set_fup_tx_flags = false;
 				decoder->tx_flags = decoder->fup_tx_flags;
@@ -1032,7 +1045,7 @@ static int intel_pt_walk_fup(struct inte
 				decoder->state.flags = decoder->fup_tx_flags;
 				return 0;
 			}
-			return err;
+			return -EAGAIN;
 		}
 		decoder->set_fup_tx_flags = false;
 		if (err)
@@ -1268,7 +1281,6 @@ static int intel_pt_overflow(struct inte
 {
 	intel_pt_log("ERROR: Buffer overflow\n");
 	intel_pt_clear_tx_flags(decoder);
-	decoder->have_tma = false;
 	decoder->cbr = 0;
 	decoder->timestamp_insn_cnt = 0;
 	decoder->pkt_state = INTEL_PT_STATE_ERR_RESYNC;
@@ -1487,7 +1499,6 @@ static int intel_pt_walk_fup_tip(struct
 		case INTEL_PT_PSB:
 		case INTEL_PT_TSC:
 		case INTEL_PT_TMA:
-		case INTEL_PT_CBR:
 		case INTEL_PT_MODE_TSX:
 		case INTEL_PT_BAD:
 		case INTEL_PT_PSBEND:
@@ -1496,6 +1507,10 @@ static int intel_pt_walk_fup_tip(struct
 			decoder->pkt_step = 0;
 			return -ENOENT;
 
+		case INTEL_PT_CBR:
+			intel_pt_calc_cbr(decoder);
+			break;
+
 		case INTEL_PT_OVF:
 			return intel_pt_overflow(decoder);
 
diff -druNp --no-dereference linux-libre-4.4.138-gnu/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h linux-libre-4.4.139-gnu/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h
--- linux-libre-4.4.138-gnu/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h	2018-07-03 05:21:35.000000000 -0400
@@ -53,6 +53,14 @@ enum {
 	INTEL_PT_ERR_MAX,
 };
 
+enum intel_pt_param_flags {
+	/*
+	 * FUP packet can contain next linear instruction pointer instead of
+	 * current linear instruction pointer.
+	 */
+	INTEL_PT_FUP_WITH_NLIP	= 1 << 0,
+};
+
 struct intel_pt_state {
 	enum intel_pt_sample_type type;
 	int err;
@@ -91,6 +99,7 @@ struct intel_pt_params {
 	unsigned int mtc_period;
 	uint32_t tsc_ctc_ratio_n;
 	uint32_t tsc_ctc_ratio_d;
+	enum intel_pt_param_flags flags;
 };
 
 struct intel_pt_decoder;
diff -druNp --no-dereference linux-libre-4.4.138-gnu/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c linux-libre-4.4.139-gnu/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
--- linux-libre-4.4.138-gnu/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c	2018-06-16 03:54:27.000000000 -0400
+++ linux-libre-4.4.139-gnu/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c	2018-07-03 05:21:35.000000000 -0400
@@ -281,7 +281,7 @@ static int intel_pt_get_cyc(unsigned int
 		if (len < offs)
 			return INTEL_PT_NEED_MORE_BYTES;
 		byte = buf[offs++];
-		payload |= (byte >> 1) << shift;
+		payload |= ((uint64_t)byte >> 1) << shift;
 	}
 
 	packet->type = INTEL_PT_CYC;
