diff --git linux-libre-4.14.311-gnu1/Makefile linux-libre-4.14.312-gnu1/Makefile
index b2c056e7b462..fcee845eef5d 100644
--- linux-libre-4.14.311-gnu1/Makefile
+++ linux-libre-4.14.312-gnu1/Makefile
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 VERSION = 4
 PATCHLEVEL = 14
-SUBLEVEL = 311
+SUBLEVEL = 312
 EXTRAVERSION = -gnu1
 NAME = Petit Gorille
 
diff --git linux-libre-4.14.311-gnu1/arch/m68k/kernel/traps.c linux-libre-4.14.312-gnu1/arch/m68k/kernel/traps.c
index 5c72deb117a8..d75c143d99d0 100644
--- linux-libre-4.14.311-gnu1/arch/m68k/kernel/traps.c
+++ linux-libre-4.14.312-gnu1/arch/m68k/kernel/traps.c
@@ -30,6 +30,7 @@
 #include <linux/init.h>
 #include <linux/ptrace.h>
 #include <linux/kallsyms.h>
+#include <linux/extable.h>
 
 #include <asm/setup.h>
 #include <asm/fpu.h>
@@ -550,7 +551,8 @@ static inline void bus_error030 (struct frame *fp)
 			errorcode |= 2;
 
 		if (mmusr & (MMU_I | MMU_WP)) {
-			if (ssw & 4) {
+			/* We might have an exception table for this PC */
+			if (ssw & 4 && !search_exception_tables(fp->ptregs.pc)) {
 				pr_err("Data %s fault at %#010lx in %s (pc=%#lx)\n",
 				       ssw & RW ? "read" : "write",
 				       fp->un.fmtb.daddr,
diff --git linux-libre-4.14.311-gnu1/arch/riscv/include/uapi/asm/setup.h linux-libre-4.14.312-gnu1/arch/riscv/include/uapi/asm/setup.h
new file mode 100644
index 000000000000..66b13a522880
--- /dev/null
+++ linux-libre-4.14.312-gnu1/arch/riscv/include/uapi/asm/setup.h
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
+
+#ifndef _UAPI_ASM_RISCV_SETUP_H
+#define _UAPI_ASM_RISCV_SETUP_H
+
+#define COMMAND_LINE_SIZE	1024
+
+#endif /* _UAPI_ASM_RISCV_SETUP_H */
diff --git linux-libre-4.14.311-gnu1/arch/s390/lib/uaccess.c linux-libre-4.14.312-gnu1/arch/s390/lib/uaccess.c
index 802903c50de1..b11ebcb3d33b 100644
--- linux-libre-4.14.311-gnu1/arch/s390/lib/uaccess.c
+++ linux-libre-4.14.312-gnu1/arch/s390/lib/uaccess.c
@@ -272,7 +272,7 @@ static inline unsigned long clear_user_mvcos(void __user *to, unsigned long size
 		"4: slgr  %0,%0\n"
 		"5:\n"
 		EX_TABLE(0b,2b) EX_TABLE(3b,5b)
-		: "+a" (size), "+a" (to), "+a" (tmp1), "=a" (tmp2)
+		: "+&a" (size), "+&a" (to), "+a" (tmp1), "=&a" (tmp2)
 		: "a" (empty_zero_page), "d" (reg0) : "cc", "memory");
 	return size;
 }
diff --git linux-libre-4.14.311-gnu1/arch/sh/include/asm/processor_32.h linux-libre-4.14.312-gnu1/arch/sh/include/asm/processor_32.h
index 95100d8a0b7b..fc94603724b8 100644
--- linux-libre-4.14.311-gnu1/arch/sh/include/asm/processor_32.h
+++ linux-libre-4.14.312-gnu1/arch/sh/include/asm/processor_32.h
@@ -57,6 +57,7 @@
 #define SR_FD		0x00008000
 #define SR_MD		0x40000000
 
+#define SR_USER_MASK	0x00000303	// M, Q, S, T bits
 /*
  * DSP structure and data
  */
diff --git linux-libre-4.14.311-gnu1/arch/sh/kernel/signal_32.c linux-libre-4.14.312-gnu1/arch/sh/kernel/signal_32.c
index c46c0020ff55..ce93ae78c300 100644
--- linux-libre-4.14.311-gnu1/arch/sh/kernel/signal_32.c
+++ linux-libre-4.14.312-gnu1/arch/sh/kernel/signal_32.c
@@ -116,6 +116,7 @@ static int
 restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *r0_p)
 {
 	unsigned int err = 0;
+	unsigned int sr = regs->sr & ~SR_USER_MASK;
 
 #define COPY(x)		err |= __get_user(regs->x, &sc->sc_##x)
 			COPY(regs[1]);
@@ -131,6 +132,8 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *r0_p
 	COPY(sr);	COPY(pc);
 #undef COPY
 
+	regs->sr = (regs->sr & SR_USER_MASK) | sr;
+
 #ifdef CONFIG_SH_FPU
 	if (boot_cpu_data.flags & CPU_HAS_FPU) {
 		int owned_fp;
diff --git linux-libre-4.14.311-gnu1/drivers/atm/idt77252.c linux-libre-4.14.312-gnu1/drivers/atm/idt77252.c
index 18f386466f94..e7a6b4903f9c 100644
--- linux-libre-4.14.311-gnu1/drivers/atm/idt77252.c
+++ linux-libre-4.14.312-gnu1/drivers/atm/idt77252.c
@@ -2912,6 +2912,7 @@ close_card_oam(struct idt77252_dev *card)
 
 				recycle_rx_pool_skb(card, &vc->rcv.rx_pool);
 			}
+			kfree(vc);
 		}
 	}
 }
@@ -2955,6 +2956,15 @@ open_card_ubr0(struct idt77252_dev *card)
 	return 0;
 }
 
+static void
+close_card_ubr0(struct idt77252_dev *card)
+{
+	struct vc_map *vc = card->vcs[0];
+
+	free_scq(card, vc->scq);
+	kfree(vc);
+}
+
 static int
 idt77252_dev_open(struct idt77252_dev *card)
 {
@@ -3004,6 +3014,7 @@ static void idt77252_dev_close(struct atm_dev *dev)
 	struct idt77252_dev *card = dev->dev_data;
 	u32 conf;
 
+	close_card_ubr0(card);
 	close_card_oam(card);
 
 	conf = SAR_CFG_RXPTH |	/* enable receive path           */
diff --git linux-libre-4.14.311-gnu1/drivers/bluetooth/btqcomsmd.c linux-libre-4.14.312-gnu1/drivers/bluetooth/btqcomsmd.c
index 3a32150104c3..2f372ab7c9b7 100644
--- linux-libre-4.14.311-gnu1/drivers/bluetooth/btqcomsmd.c
+++ linux-libre-4.14.312-gnu1/drivers/bluetooth/btqcomsmd.c
@@ -134,6 +134,21 @@ static int btqcomsmd_setup(struct hci_dev *hdev)
 	return 0;
 }
 
+static int btqcomsmd_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
+{
+	int ret;
+
+	ret = qca_set_bdaddr_rome(hdev, bdaddr);
+	if (ret)
+		return ret;
+
+	/* The firmware stops responding for a while after setting the bdaddr,
+	 * causing timeouts for subsequent commands. Sleep a bit to avoid this.
+	 */
+	usleep_range(1000, 10000);
+	return 0;
+}
+
 static int btqcomsmd_probe(struct platform_device *pdev)
 {
 	struct btqcomsmd *btq;
@@ -174,7 +189,7 @@ static int btqcomsmd_probe(struct platform_device *pdev)
 	hdev->close = btqcomsmd_close;
 	hdev->send = btqcomsmd_send;
 	hdev->setup = btqcomsmd_setup;
-	hdev->set_bdaddr = qca_set_bdaddr_rome;
+	hdev->set_bdaddr = btqcomsmd_set_bdaddr;
 
 	ret = hci_register_dev(hdev);
 	if (ret < 0)
diff --git linux-libre-4.14.311-gnu1/drivers/bluetooth/btsdio.c linux-libre-4.14.312-gnu1/drivers/bluetooth/btsdio.c
index 20142bc77554..bd55bf7a9914 100644
--- linux-libre-4.14.311-gnu1/drivers/bluetooth/btsdio.c
+++ linux-libre-4.14.312-gnu1/drivers/bluetooth/btsdio.c
@@ -353,6 +353,7 @@ static void btsdio_remove(struct sdio_func *func)
 
 	BT_DBG("func %p", func);
 
+	cancel_work_sync(&data->work);
 	if (!data)
 		return;
 
diff --git linux-libre-4.14.311-gnu1/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c linux-libre-4.14.312-gnu1/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
index 880b95511b98..4fa091797656 100644
--- linux-libre-4.14.311-gnu1/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
+++ linux-libre-4.14.312-gnu1/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
@@ -102,7 +102,15 @@ static void *etnaviv_gem_prime_vmap_impl(struct etnaviv_gem_object *etnaviv_obj)
 static int etnaviv_gem_prime_mmap_obj(struct etnaviv_gem_object *etnaviv_obj,
 		struct vm_area_struct *vma)
 {
-	return dma_buf_mmap(etnaviv_obj->base.dma_buf, vma, 0);
+	int ret;
+
+	ret = dma_buf_mmap(etnaviv_obj->base.dma_buf, vma, 0);
+	if (!ret) {
+		/* Drop the reference acquired by drm_gem_mmap_obj(). */
+		drm_gem_object_put(&etnaviv_obj->base);
+	}
+
+	return ret;
 }
 
 static const struct etnaviv_gem_ops etnaviv_gem_prime_ops = {
diff --git linux-libre-4.14.311-gnu1/drivers/hwmon/it87.c linux-libre-4.14.312-gnu1/drivers/hwmon/it87.c
index f8499cb95fec..4e4e151760db 100644
--- linux-libre-4.14.311-gnu1/drivers/hwmon/it87.c
+++ linux-libre-4.14.312-gnu1/drivers/hwmon/it87.c
@@ -495,6 +495,8 @@ static const struct it87_devices it87_devices[] = {
 #define has_pwm_freq2(data)	((data)->features & FEAT_PWM_FREQ2)
 #define has_six_temp(data)	((data)->features & FEAT_SIX_TEMP)
 #define has_vin3_5v(data)	((data)->features & FEAT_VIN3_5V)
+#define has_scaling(data)	((data)->features & (FEAT_12MV_ADC | \
+						     FEAT_10_9MV_ADC))
 
 struct it87_sio_data {
 	int sioaddr;
@@ -3107,7 +3109,7 @@ static int it87_probe(struct platform_device *pdev)
 			 "Detected broken BIOS defaults, disabling PWM interface\n");
 
 	/* Starting with IT8721F, we handle scaling of internal voltages */
-	if (has_12mv_adc(data)) {
+	if (has_scaling(data)) {
 		if (sio_data->internal & BIT(0))
 			data->in_scaled |= BIT(3);	/* in3 is AVCC */
 		if (sio_data->internal & BIT(1))
diff --git linux-libre-4.14.311-gnu1/drivers/i2c/busses/i2c-imx-lpi2c.c linux-libre-4.14.312-gnu1/drivers/i2c/busses/i2c-imx-lpi2c.c
index e86801a63120..ca4d55412657 100644
--- linux-libre-4.14.311-gnu1/drivers/i2c/busses/i2c-imx-lpi2c.c
+++ linux-libre-4.14.312-gnu1/drivers/i2c/busses/i2c-imx-lpi2c.c
@@ -515,10 +515,14 @@ disable:
 static irqreturn_t lpi2c_imx_isr(int irq, void *dev_id)
 {
 	struct lpi2c_imx_struct *lpi2c_imx = dev_id;
+	unsigned int enabled;
 	unsigned int temp;
 
+	enabled = readl(lpi2c_imx->base + LPI2C_MIER);
+
 	lpi2c_imx_intctrl(lpi2c_imx, 0);
 	temp = readl(lpi2c_imx->base + LPI2C_MSR);
+	temp &= enabled;
 
 	if (temp & MSR_RDF)
 		lpi2c_imx_read_rxfifo(lpi2c_imx);
diff --git linux-libre-4.14.311-gnu1/drivers/i2c/busses/i2c-xgene-slimpro.c linux-libre-4.14.312-gnu1/drivers/i2c/busses/i2c-xgene-slimpro.c
index 7e89ba6fcf6f..dd687f5e7c95 100644
--- linux-libre-4.14.311-gnu1/drivers/i2c/busses/i2c-xgene-slimpro.c
+++ linux-libre-4.14.312-gnu1/drivers/i2c/busses/i2c-xgene-slimpro.c
@@ -316,6 +316,9 @@ static int slimpro_i2c_blkwr(struct slimpro_i2c_dev *ctx, u32 chip,
 	u32 msg[3];
 	int rc;
 
+	if (writelen > I2C_SMBUS_BLOCK_MAX)
+		return -EINVAL;
+
 	memcpy(ctx->dma_buffer, data, writelen);
 	paddr = dma_map_single(ctx->dev, ctx->dma_buffer, writelen,
 			       DMA_TO_DEVICE);
diff --git linux-libre-4.14.311-gnu1/drivers/input/mouse/focaltech.c linux-libre-4.14.312-gnu1/drivers/input/mouse/focaltech.c
index a7d39689bbfb..4bd48b81ed98 100644
--- linux-libre-4.14.311-gnu1/drivers/input/mouse/focaltech.c
+++ linux-libre-4.14.312-gnu1/drivers/input/mouse/focaltech.c
@@ -206,8 +206,8 @@ static void focaltech_process_rel_packet(struct psmouse *psmouse,
 	state->pressed = packet[0] >> 7;
 	finger1 = ((packet[0] >> 4) & 0x7) - 1;
 	if (finger1 < FOC_MAX_FINGERS) {
-		state->fingers[finger1].x += (char)packet[1];
-		state->fingers[finger1].y += (char)packet[2];
+		state->fingers[finger1].x += (s8)packet[1];
+		state->fingers[finger1].y += (s8)packet[2];
 	} else {
 		psmouse_err(psmouse, "First finger in rel packet invalid: %d\n",
 			    finger1);
@@ -222,8 +222,8 @@ static void focaltech_process_rel_packet(struct psmouse *psmouse,
 	 */
 	finger2 = ((packet[3] >> 4) & 0x7) - 1;
 	if (finger2 < FOC_MAX_FINGERS) {
-		state->fingers[finger2].x += (char)packet[4];
-		state->fingers[finger2].y += (char)packet[5];
+		state->fingers[finger2].x += (s8)packet[4];
+		state->fingers[finger2].y += (s8)packet[5];
 	}
 }
 
diff --git linux-libre-4.14.311-gnu1/drivers/md/dm-crypt.c linux-libre-4.14.312-gnu1/drivers/md/dm-crypt.c
index 353536ad46f3..7cc4281d5a79 100644
--- linux-libre-4.14.311-gnu1/drivers/md/dm-crypt.c
+++ linux-libre-4.14.312-gnu1/drivers/md/dm-crypt.c
@@ -1669,6 +1669,7 @@ pop_from_list:
 			io = crypt_io_from_node(rb_first(&write_tree));
 			rb_erase(&io->rb_node, &write_tree);
 			kcryptd_io_write(io);
+			cond_resched();
 		} while (!RB_EMPTY_ROOT(&write_tree));
 		blk_finish_plug(&plug);
 	}
diff --git linux-libre-4.14.311-gnu1/drivers/md/dm-stats.c linux-libre-4.14.312-gnu1/drivers/md/dm-stats.c
index 9734f506ecfd..b72448900f5f 100644
--- linux-libre-4.14.311-gnu1/drivers/md/dm-stats.c
+++ linux-libre-4.14.312-gnu1/drivers/md/dm-stats.c
@@ -188,7 +188,7 @@ static int dm_stat_in_flight(struct dm_stat_shared *shared)
 	       atomic_read(&shared->in_flight[WRITE]);
 }
 
-void dm_stats_init(struct dm_stats *stats)
+int dm_stats_init(struct dm_stats *stats)
 {
 	int cpu;
 	struct dm_stats_last_position *last;
@@ -196,11 +196,16 @@ void dm_stats_init(struct dm_stats *stats)
 	mutex_init(&stats->mutex);
 	INIT_LIST_HEAD(&stats->list);
 	stats->last = alloc_percpu(struct dm_stats_last_position);
+	if (!stats->last)
+		return -ENOMEM;
+
 	for_each_possible_cpu(cpu) {
 		last = per_cpu_ptr(stats->last, cpu);
 		last->last_sector = (sector_t)ULLONG_MAX;
 		last->last_rw = UINT_MAX;
 	}
+
+	return 0;
 }
 
 void dm_stats_cleanup(struct dm_stats *stats)
diff --git linux-libre-4.14.311-gnu1/drivers/md/dm-stats.h linux-libre-4.14.312-gnu1/drivers/md/dm-stats.h
index 2ddfae678f32..dcac11fce03b 100644
--- linux-libre-4.14.311-gnu1/drivers/md/dm-stats.h
+++ linux-libre-4.14.312-gnu1/drivers/md/dm-stats.h
@@ -22,7 +22,7 @@ struct dm_stats_aux {
 	unsigned long long duration_ns;
 };
 
-void dm_stats_init(struct dm_stats *st);
+int dm_stats_init(struct dm_stats *st);
 void dm_stats_cleanup(struct dm_stats *st);
 
 struct mapped_device;
diff --git linux-libre-4.14.311-gnu1/drivers/md/dm.c linux-libre-4.14.312-gnu1/drivers/md/dm.c
index e3facf14f614..92f92ea417b9 100644
--- linux-libre-4.14.311-gnu1/drivers/md/dm.c
+++ linux-libre-4.14.312-gnu1/drivers/md/dm.c
@@ -1799,7 +1799,9 @@ static struct mapped_device *alloc_dev(int minor)
 	bio_set_dev(&md->flush_bio, md->bdev);
 	md->flush_bio.bi_opf = REQ_OP_WRITE | REQ_PREFLUSH | REQ_SYNC;
 
-	dm_stats_init(&md->stats);
+	r = dm_stats_init(&md->stats);
+	if (r < 0)
+		goto bad;
 
 	/* Populate the mapping, nobody knows we exist yet */
 	spin_lock(&_minor_lock);
diff --git linux-libre-4.14.311-gnu1/drivers/md/md.c linux-libre-4.14.312-gnu1/drivers/md/md.c
index 880a0ebca866..69d1501d9160 100644
--- linux-libre-4.14.311-gnu1/drivers/md/md.c
+++ linux-libre-4.14.312-gnu1/drivers/md/md.c
@@ -2967,6 +2967,9 @@ slot_store(struct md_rdev *rdev, const char *buf, size_t len)
 		err = kstrtouint(buf, 10, (unsigned int *)&slot);
 		if (err < 0)
 			return err;
+		if (slot < 0)
+			/* overflow */
+			return -ENOSPC;
 	}
 	if (rdev->mddev->pers && slot == -1) {
 		/* Setting 'slot' on an active array requires also
diff --git linux-libre-4.14.311-gnu1/drivers/net/ethernet/intel/i40e/i40e_diag.c linux-libre-4.14.312-gnu1/drivers/net/ethernet/intel/i40e/i40e_diag.c
index f141e78d409e..793dcaae27ef 100644
--- linux-libre-4.14.311-gnu1/drivers/net/ethernet/intel/i40e/i40e_diag.c
+++ linux-libre-4.14.312-gnu1/drivers/net/ethernet/intel/i40e/i40e_diag.c
@@ -65,7 +65,7 @@ static i40e_status i40e_diag_reg_pattern_test(struct i40e_hw *hw,
 	return 0;
 }
 
-struct i40e_diag_reg_test_info i40e_reg_list[] = {
+const struct i40e_diag_reg_test_info i40e_reg_list[] = {
 	/* offset               mask         elements   stride */
 	{I40E_QTX_CTL(0),       0x0000FFBF, 1,
 		I40E_QTX_CTL(1) - I40E_QTX_CTL(0)},
@@ -99,27 +99,28 @@ i40e_status i40e_diag_reg_test(struct i40e_hw *hw)
 {
 	i40e_status ret_code = 0;
 	u32 reg, mask;
+	u32 elements;
 	u32 i, j;
 
 	for (i = 0; i40e_reg_list[i].offset != 0 &&
 					     !ret_code; i++) {
 
+		elements = i40e_reg_list[i].elements;
 		/* set actual reg range for dynamically allocated resources */
 		if (i40e_reg_list[i].offset == I40E_QTX_CTL(0) &&
 		    hw->func_caps.num_tx_qp != 0)
-			i40e_reg_list[i].elements = hw->func_caps.num_tx_qp;
+			elements = hw->func_caps.num_tx_qp;
 		if ((i40e_reg_list[i].offset == I40E_PFINT_ITRN(0, 0) ||
 		     i40e_reg_list[i].offset == I40E_PFINT_ITRN(1, 0) ||
 		     i40e_reg_list[i].offset == I40E_PFINT_ITRN(2, 0) ||
 		     i40e_reg_list[i].offset == I40E_QINT_TQCTL(0) ||
 		     i40e_reg_list[i].offset == I40E_QINT_RQCTL(0)) &&
 		    hw->func_caps.num_msix_vectors != 0)
-			i40e_reg_list[i].elements =
-				hw->func_caps.num_msix_vectors - 1;
+			elements = hw->func_caps.num_msix_vectors - 1;
 
 		/* test register access */
 		mask = i40e_reg_list[i].mask;
-		for (j = 0; j < i40e_reg_list[i].elements && !ret_code; j++) {
+		for (j = 0; j < elements && !ret_code; j++) {
 			reg = i40e_reg_list[i].offset +
 			      (j * i40e_reg_list[i].stride);
 			ret_code = i40e_diag_reg_pattern_test(hw, reg, mask);
diff --git linux-libre-4.14.311-gnu1/drivers/net/ethernet/intel/i40e/i40e_diag.h linux-libre-4.14.312-gnu1/drivers/net/ethernet/intel/i40e/i40e_diag.h
index 0b5911652084..e5af68e770c6 100644
--- linux-libre-4.14.311-gnu1/drivers/net/ethernet/intel/i40e/i40e_diag.h
+++ linux-libre-4.14.312-gnu1/drivers/net/ethernet/intel/i40e/i40e_diag.h
@@ -43,7 +43,7 @@ struct i40e_diag_reg_test_info {
 	u32 stride;	/* bytes between each element */
 };
 
-extern struct i40e_diag_reg_test_info i40e_reg_list[];
+extern const struct i40e_diag_reg_test_info i40e_reg_list[];
 
 i40e_status i40e_diag_reg_test(struct i40e_hw *hw);
 i40e_status i40e_diag_eeprom_test(struct i40e_hw *hw);
diff --git linux-libre-4.14.311-gnu1/drivers/net/ethernet/intel/i40evf/i40e_txrx.c linux-libre-4.14.312-gnu1/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
index d74a307da8f1..d468960bcfd7 100644
--- linux-libre-4.14.311-gnu1/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
+++ linux-libre-4.14.312-gnu1/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
@@ -888,7 +888,7 @@ static inline void i40e_rx_hash(struct i40e_ring *ring,
 		cpu_to_le64((u64)I40E_RX_DESC_FLTSTAT_RSS_HASH <<
 			    I40E_RX_DESC_STATUS_FLTSTAT_SHIFT);
 
-	if (ring->netdev->features & NETIF_F_RXHASH)
+	if (!(ring->netdev->features & NETIF_F_RXHASH))
 		return;
 
 	if ((rx_desc->wb.qword1.status_error_len & rss_mask) == rss_mask) {
diff --git linux-libre-4.14.311-gnu1/drivers/net/ethernet/intel/igb/igb_main.c linux-libre-4.14.312-gnu1/drivers/net/ethernet/intel/igb/igb_main.c
index e6799913ca0b..ab54362c0992 100644
--- linux-libre-4.14.311-gnu1/drivers/net/ethernet/intel/igb/igb_main.c
+++ linux-libre-4.14.312-gnu1/drivers/net/ethernet/intel/igb/igb_main.c
@@ -2990,9 +2990,7 @@ static void igb_remove(struct pci_dev *pdev)
 	igb_release_hw_control(adapter);
 
 #ifdef CONFIG_PCI_IOV
-	rtnl_lock();
 	igb_disable_sriov(pdev);
-	rtnl_unlock();
 #endif
 
 	unregister_netdev(netdev);
diff --git linux-libre-4.14.311-gnu1/drivers/net/ethernet/intel/igbvf/netdev.c linux-libre-4.14.312-gnu1/drivers/net/ethernet/intel/igbvf/netdev.c
index 98fd214f2c42..cc1a608904ab 100644
--- linux-libre-4.14.311-gnu1/drivers/net/ethernet/intel/igbvf/netdev.c
+++ linux-libre-4.14.312-gnu1/drivers/net/ethernet/intel/igbvf/netdev.c
@@ -1093,7 +1093,7 @@ static int igbvf_request_msix(struct igbvf_adapter *adapter)
 			  igbvf_intr_msix_rx, 0, adapter->rx_ring->name,
 			  netdev);
 	if (err)
-		goto out;
+		goto free_irq_tx;
 
 	adapter->rx_ring->itr_register = E1000_EITR(vector);
 	adapter->rx_ring->itr_val = adapter->current_itr;
@@ -1102,10 +1102,14 @@ static int igbvf_request_msix(struct igbvf_adapter *adapter)
 	err = request_irq(adapter->msix_entries[vector].vector,
 			  igbvf_msix_other, 0, netdev->name, netdev);
 	if (err)
-		goto out;
+		goto free_irq_rx;
 
 	igbvf_configure_msix(adapter);
 	return 0;
+free_irq_rx:
+	free_irq(adapter->msix_entries[--vector].vector, netdev);
+free_irq_tx:
+	free_irq(adapter->msix_entries[--vector].vector, netdev);
 out:
 	return err;
 }
diff --git linux-libre-4.14.311-gnu1/drivers/net/ethernet/intel/igbvf/vf.c linux-libre-4.14.312-gnu1/drivers/net/ethernet/intel/igbvf/vf.c
index 9577ccf4b26a..7156684337e5 100644
--- linux-libre-4.14.311-gnu1/drivers/net/ethernet/intel/igbvf/vf.c
+++ linux-libre-4.14.312-gnu1/drivers/net/ethernet/intel/igbvf/vf.c
@@ -24,6 +24,8 @@
 
 *******************************************************************************/
 
+#include <linux/etherdevice.h>
+
 #include "vf.h"
 
 static s32 e1000_check_for_link_vf(struct e1000_hw *hw);
@@ -154,11 +156,16 @@ static s32 e1000_reset_hw_vf(struct e1000_hw *hw)
 		/* set our "perm_addr" based on info provided by PF */
 		ret_val = mbx->ops.read_posted(hw, msgbuf, 3);
 		if (!ret_val) {
-			if (msgbuf[0] == (E1000_VF_RESET |
-					  E1000_VT_MSGTYPE_ACK))
+			switch (msgbuf[0]) {
+			case E1000_VF_RESET | E1000_VT_MSGTYPE_ACK:
 				memcpy(hw->mac.perm_addr, addr, ETH_ALEN);
-			else
+				break;
+			case E1000_VF_RESET | E1000_VT_MSGTYPE_NACK:
+				eth_zero_addr(hw->mac.perm_addr);
+				break;
+			default:
 				ret_val = -E1000_ERR_MAC_INIT;
+			}
 		}
 	}
 
diff --git linux-libre-4.14.311-gnu1/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c linux-libre-4.14.312-gnu1/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
index a5dd99aaf321..9ebd43bcc19a 100644
--- linux-libre-4.14.311-gnu1/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
+++ linux-libre-4.14.312-gnu1/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
@@ -99,12 +99,14 @@ static int mlx5e_dcbnl_ieee_getets(struct net_device *netdev,
 	if (!MLX5_CAP_GEN(priv->mdev, ets))
 		return -EOPNOTSUPP;
 
-	ets->ets_cap = mlx5_max_tc(priv->mdev) + 1;
-	for (i = 0; i < ets->ets_cap; i++) {
+	for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
 		err = mlx5_query_port_prio_tc(mdev, i, &ets->prio_tc[i]);
 		if (err)
 			return err;
+	}
 
+	ets->ets_cap = mlx5_max_tc(priv->mdev) + 1;
+	for (i = 0; i < ets->ets_cap; i++) {
 		err = mlx5_query_port_tc_group(mdev, i, &tc_group[i]);
 		if (err)
 			return err;
diff --git linux-libre-4.14.311-gnu1/drivers/net/ethernet/qlogic/qed/qed_sriov.c linux-libre-4.14.312-gnu1/drivers/net/ethernet/qlogic/qed/qed_sriov.c
index 3dbea6be4e55..ef6c3da38fc6 100644
--- linux-libre-4.14.311-gnu1/drivers/net/ethernet/qlogic/qed/qed_sriov.c
+++ linux-libre-4.14.312-gnu1/drivers/net/ethernet/qlogic/qed/qed_sriov.c
@@ -4285,6 +4285,9 @@ qed_iov_configure_min_tx_rate(struct qed_dev *cdev, int vfid, u32 rate)
 	}
 
 	vf = qed_iov_get_vf_info(QED_LEADING_HWFN(cdev), (u16)vfid, true);
+	if (!vf)
+		return -EINVAL;
+
 	vport_id = vf->vport_id;
 
 	return qed_configure_vport_wfq(cdev, vport_id, rate);
@@ -4922,7 +4925,7 @@ static void qed_iov_handle_trust_change(struct qed_hwfn *hwfn)
 
 		/* Validate that the VF has a configured vport */
 		vf = qed_iov_get_vf_info(hwfn, i, true);
-		if (!vf->vport_instance)
+		if (!vf || !vf->vport_instance)
 			continue;
 
 		memset(&params, 0, sizeof(params));
diff --git linux-libre-4.14.311-gnu1/drivers/net/ethernet/qualcomm/emac/emac.c linux-libre-4.14.312-gnu1/drivers/net/ethernet/qualcomm/emac/emac.c
index cae570f1d7e1..527c4dd25083 100644
--- linux-libre-4.14.311-gnu1/drivers/net/ethernet/qualcomm/emac/emac.c
+++ linux-libre-4.14.312-gnu1/drivers/net/ethernet/qualcomm/emac/emac.c
@@ -758,9 +758,15 @@ static int emac_remove(struct platform_device *pdev)
 	struct net_device *netdev = dev_get_drvdata(&pdev->dev);
 	struct emac_adapter *adpt = netdev_priv(netdev);
 
+	netif_carrier_off(netdev);
+	netif_tx_disable(netdev);
+
 	unregister_netdev(netdev);
 	netif_napi_del(&adpt->rx_q.napi);
 
+	free_irq(adpt->irq.irq, &adpt->irq);
+	cancel_work_sync(&adpt->work_thread);
+
 	emac_clks_teardown(adpt);
 
 	put_device(&adpt->phydev->mdio.dev);
diff --git linux-libre-4.14.311-gnu1/drivers/net/ethernet/toshiba/ps3_gelic_net.c linux-libre-4.14.312-gnu1/drivers/net/ethernet/toshiba/ps3_gelic_net.c
index 75237c81c63d..572294678faf 100644
--- linux-libre-4.14.311-gnu1/drivers/net/ethernet/toshiba/ps3_gelic_net.c
+++ linux-libre-4.14.312-gnu1/drivers/net/ethernet/toshiba/ps3_gelic_net.c
@@ -330,15 +330,17 @@ static int gelic_card_init_chain(struct gelic_card *card,
 
 	/* set up the hardware pointers in each descriptor */
 	for (i = 0; i < no; i++, descr++) {
+		dma_addr_t cpu_addr;
+
 		gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
-		descr->bus_addr =
-			dma_map_single(ctodev(card), descr,
-				       GELIC_DESCR_SIZE,
-				       DMA_BIDIRECTIONAL);
 
-		if (!descr->bus_addr)
+		cpu_addr = dma_map_single(ctodev(card), descr,
+					  GELIC_DESCR_SIZE, DMA_BIDIRECTIONAL);
+
+		if (dma_mapping_error(ctodev(card), cpu_addr))
 			goto iommu_error;
 
+		descr->bus_addr = cpu_to_be32(cpu_addr);
 		descr->next = descr + 1;
 		descr->prev = descr - 1;
 	}
@@ -378,28 +380,30 @@ iommu_error:
  *
  * allocates a new rx skb, iommu-maps it and attaches it to the descriptor.
  * Activate the descriptor state-wise
+ *
+ * Gelic RX sk_buffs must be aligned to GELIC_NET_RXBUF_ALIGN and the length
+ * must be a multiple of GELIC_NET_RXBUF_ALIGN.
  */
 static int gelic_descr_prepare_rx(struct gelic_card *card,
 				  struct gelic_descr *descr)
 {
+	static const unsigned int rx_skb_size =
+		ALIGN(GELIC_NET_MAX_FRAME, GELIC_NET_RXBUF_ALIGN) +
+		GELIC_NET_RXBUF_ALIGN - 1;
+	dma_addr_t cpu_addr;
 	int offset;
-	unsigned int bufsize;
 
 	if (gelic_descr_get_status(descr) !=  GELIC_DESCR_DMA_NOT_IN_USE)
 		dev_info(ctodev(card), "%s: ERROR status\n", __func__);
-	/* we need to round up the buffer size to a multiple of 128 */
-	bufsize = ALIGN(GELIC_NET_MAX_MTU, GELIC_NET_RXBUF_ALIGN);
 
-	/* and we need to have it 128 byte aligned, therefore we allocate a
-	 * bit more */
-	descr->skb = dev_alloc_skb(bufsize + GELIC_NET_RXBUF_ALIGN - 1);
+	descr->skb = netdev_alloc_skb(*card->netdev, rx_skb_size);
 	if (!descr->skb) {
 		descr->buf_addr = 0; /* tell DMAC don't touch memory */
 		dev_info(ctodev(card),
 			 "%s:allocate skb failed !!\n", __func__);
 		return -ENOMEM;
 	}
-	descr->buf_size = cpu_to_be32(bufsize);
+	descr->buf_size = cpu_to_be32(rx_skb_size);
 	descr->dmac_cmd_status = 0;
 	descr->result_size = 0;
 	descr->valid_size = 0;
@@ -410,11 +414,10 @@ static int gelic_descr_prepare_rx(struct gelic_card *card,
 	if (offset)
 		skb_reserve(descr->skb, GELIC_NET_RXBUF_ALIGN - offset);
 	/* io-mmu-map the skb */
-	descr->buf_addr = cpu_to_be32(dma_map_single(ctodev(card),
-						     descr->skb->data,
-						     GELIC_NET_MAX_MTU,
-						     DMA_FROM_DEVICE));
-	if (!descr->buf_addr) {
+	cpu_addr = dma_map_single(ctodev(card), descr->skb->data,
+				  GELIC_NET_MAX_FRAME, DMA_FROM_DEVICE);
+	descr->buf_addr = cpu_to_be32(cpu_addr);
+	if (dma_mapping_error(ctodev(card), cpu_addr)) {
 		dev_kfree_skb_any(descr->skb);
 		descr->skb = NULL;
 		dev_info(ctodev(card),
@@ -794,7 +797,7 @@ static int gelic_descr_prepare_tx(struct gelic_card *card,
 
 	buf = dma_map_single(ctodev(card), skb->data, skb->len, DMA_TO_DEVICE);
 
-	if (!buf) {
+	if (dma_mapping_error(ctodev(card), buf)) {
 		dev_err(ctodev(card),
 			"dma map 2 failed (%p, %i). Dropping packet\n",
 			skb->data, skb->len);
@@ -930,7 +933,7 @@ static void gelic_net_pass_skb_up(struct gelic_descr *descr,
 	data_error = be32_to_cpu(descr->data_error);
 	/* unmap skb buffer */
 	dma_unmap_single(ctodev(card), be32_to_cpu(descr->buf_addr),
-			 GELIC_NET_MAX_MTU,
+			 GELIC_NET_MAX_FRAME,
 			 DMA_FROM_DEVICE);
 
 	skb_put(skb, be32_to_cpu(descr->valid_size)?
diff --git linux-libre-4.14.311-gnu1/drivers/net/ethernet/toshiba/ps3_gelic_net.h linux-libre-4.14.312-gnu1/drivers/net/ethernet/toshiba/ps3_gelic_net.h
index fbbf9b54b173..0e592fc19f6c 100644
--- linux-libre-4.14.311-gnu1/drivers/net/ethernet/toshiba/ps3_gelic_net.h
+++ linux-libre-4.14.312-gnu1/drivers/net/ethernet/toshiba/ps3_gelic_net.h
@@ -32,8 +32,9 @@
 #define GELIC_NET_RX_DESCRIPTORS        128 /* num of descriptors */
 #define GELIC_NET_TX_DESCRIPTORS        128 /* num of descriptors */
 
-#define GELIC_NET_MAX_MTU               VLAN_ETH_FRAME_LEN
-#define GELIC_NET_MIN_MTU               VLAN_ETH_ZLEN
+#define GELIC_NET_MAX_FRAME             2312
+#define GELIC_NET_MAX_MTU               2294
+#define GELIC_NET_MIN_MTU               64
 #define GELIC_NET_RXBUF_ALIGN           128
 #define GELIC_CARD_RX_CSUM_DEFAULT      1 /* hw chksum */
 #define GELIC_NET_WATCHDOG_TIMEOUT      5*HZ
diff --git linux-libre-4.14.311-gnu1/drivers/net/ethernet/xircom/xirc2ps_cs.c linux-libre-4.14.312-gnu1/drivers/net/ethernet/xircom/xirc2ps_cs.c
index fd5288ff53b5..e3438cef5f9c 100644
--- linux-libre-4.14.311-gnu1/drivers/net/ethernet/xircom/xirc2ps_cs.c
+++ linux-libre-4.14.312-gnu1/drivers/net/ethernet/xircom/xirc2ps_cs.c
@@ -503,6 +503,11 @@ static void
 xirc2ps_detach(struct pcmcia_device *link)
 {
     struct net_device *dev = link->priv;
+    struct local_info *local = netdev_priv(dev);
+
+    netif_carrier_off(dev);
+    netif_tx_disable(dev);
+    cancel_work_sync(&local->tx_timeout_task);
 
     dev_dbg(&link->dev, "detach\n");
 
diff --git linux-libre-4.14.311-gnu1/drivers/net/ieee802154/ca8210.c linux-libre-4.14.312-gnu1/drivers/net/ieee802154/ca8210.c
index eff7571dbea2..4ec65582eaf7 100644
--- linux-libre-4.14.311-gnu1/drivers/net/ieee802154/ca8210.c
+++ linux-libre-4.14.312-gnu1/drivers/net/ieee802154/ca8210.c
@@ -1944,10 +1944,9 @@ static int ca8210_skb_tx(
 	struct ca8210_priv  *priv
 )
 {
-	int status;
 	struct ieee802154_hdr header = { 0 };
 	struct secspec secspec;
-	unsigned int mac_len;
+	int mac_len, status;
 
 	dev_dbg(&priv->spi->dev, "ca8210_skb_tx() called\n");
 
@@ -1955,6 +1954,8 @@ static int ca8210_skb_tx(
 	 * packet
 	 */
 	mac_len = ieee802154_hdr_peek_addrs(skb, &header);
+	if (mac_len < 0)
+		return mac_len;
 
 	secspec.security_level = header.sec.level;
 	secspec.key_id_mode = header.sec.key_id_mode;
diff --git linux-libre-4.14.311-gnu1/drivers/net/phy/mdio-thunder.c linux-libre-4.14.312-gnu1/drivers/net/phy/mdio-thunder.c
index c0c922eff760..959bf342133a 100644
--- linux-libre-4.14.311-gnu1/drivers/net/phy/mdio-thunder.c
+++ linux-libre-4.14.312-gnu1/drivers/net/phy/mdio-thunder.c
@@ -107,6 +107,7 @@ static int thunder_mdiobus_pci_probe(struct pci_dev *pdev,
 		if (i >= ARRAY_SIZE(nexus->buses))
 			break;
 	}
+	fwnode_handle_put(fwn);
 	return 0;
 
 err_release_regions:
diff --git linux-libre-4.14.311-gnu1/drivers/net/usb/cdc_mbim.c linux-libre-4.14.312-gnu1/drivers/net/usb/cdc_mbim.c
index 41bac861ca99..72a93dc2df86 100644
--- linux-libre-4.14.311-gnu1/drivers/net/usb/cdc_mbim.c
+++ linux-libre-4.14.312-gnu1/drivers/net/usb/cdc_mbim.c
@@ -665,6 +665,11 @@ static const struct usb_device_id mbim_devs[] = {
 	  .driver_info = (unsigned long)&cdc_mbim_info_avoid_altsetting_toggle,
 	},
 
+	/* Telit FE990 */
+	{ USB_DEVICE_AND_INTERFACE_INFO(0x1bc7, 0x1081, USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE),
+	  .driver_info = (unsigned long)&cdc_mbim_info_avoid_altsetting_toggle,
+	},
+
 	/* default entry */
 	{ USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE),
 	  .driver_info = (unsigned long)&cdc_mbim_info_zlp,
diff --git linux-libre-4.14.311-gnu1/drivers/net/usb/qmi_wwan.c linux-libre-4.14.312-gnu1/drivers/net/usb/qmi_wwan.c
index a2c3f5ee1780..68547724a101 100644
--- linux-libre-4.14.311-gnu1/drivers/net/usb/qmi_wwan.c
+++ linux-libre-4.14.312-gnu1/drivers/net/usb/qmi_wwan.c
@@ -1311,6 +1311,7 @@ static const struct usb_device_id products[] = {
 	{QMI_QUIRK_SET_DTR(0x1bc7, 0x1050, 2)},	/* Telit FN980 */
 	{QMI_QUIRK_SET_DTR(0x1bc7, 0x1060, 2)},	/* Telit LN920 */
 	{QMI_QUIRK_SET_DTR(0x1bc7, 0x1070, 2)},	/* Telit FN990 */
+	{QMI_QUIRK_SET_DTR(0x1bc7, 0x1080, 2)}, /* Telit FE990 */
 	{QMI_FIXED_INTF(0x1bc7, 0x1100, 3)},	/* Telit ME910 */
 	{QMI_FIXED_INTF(0x1bc7, 0x1101, 3)},	/* Telit ME910 dual modem */
 	{QMI_FIXED_INTF(0x1bc7, 0x1200, 5)},	/* Telit LE920 */
diff --git linux-libre-4.14.311-gnu1/drivers/net/usb/smsc95xx.c linux-libre-4.14.312-gnu1/drivers/net/usb/smsc95xx.c
index bc6bcea67bff..b1e3ec3dcac3 100644
--- linux-libre-4.14.311-gnu1/drivers/net/usb/smsc95xx.c
+++ linux-libre-4.14.312-gnu1/drivers/net/usb/smsc95xx.c
@@ -1950,6 +1950,12 @@ static int smsc95xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
 		size = (u16)((header & RX_STS_FL_) >> 16);
 		align_count = (4 - ((size + NET_IP_ALIGN) % 4)) % 4;
 
+		if (unlikely(size > skb->len)) {
+			netif_dbg(dev, rx_err, dev->net,
+				  "size err header=0x%08x\n", header);
+			return 0;
+		}
+
 		if (unlikely(header & RX_STS_ES_)) {
 			netif_dbg(dev, rx_err, dev->net,
 				  "Error header=0x%08x\n", header);
diff --git linux-libre-4.14.311-gnu1/drivers/net/xen-netback/common.h linux-libre-4.14.312-gnu1/drivers/net/xen-netback/common.h
index e5f254500c1c..0207d43640a0 100644
--- linux-libre-4.14.311-gnu1/drivers/net/xen-netback/common.h
+++ linux-libre-4.14.312-gnu1/drivers/net/xen-netback/common.h
@@ -166,7 +166,7 @@ struct xenvif_queue { /* Per-queue data for xenvif */
 	struct pending_tx_info pending_tx_info[MAX_PENDING_REQS];
 	grant_handle_t grant_tx_handle[MAX_PENDING_REQS];
 
-	struct gnttab_copy tx_copy_ops[MAX_PENDING_REQS];
+	struct gnttab_copy tx_copy_ops[2 * MAX_PENDING_REQS];
 	struct gnttab_map_grant_ref tx_map_ops[MAX_PENDING_REQS];
 	struct gnttab_unmap_grant_ref tx_unmap_ops[MAX_PENDING_REQS];
 	/* passed to gnttab_[un]map_refs with pages under (un)mapping */
diff --git linux-libre-4.14.311-gnu1/drivers/net/xen-netback/netback.c linux-libre-4.14.312-gnu1/drivers/net/xen-netback/netback.c
index 9d4bf69ab7b8..252414a9293d 100644
--- linux-libre-4.14.311-gnu1/drivers/net/xen-netback/netback.c
+++ linux-libre-4.14.312-gnu1/drivers/net/xen-netback/netback.c
@@ -327,6 +327,7 @@ static int xenvif_count_requests(struct xenvif_queue *queue,
 struct xenvif_tx_cb {
 	u16 copy_pending_idx[XEN_NETBK_LEGACY_SLOTS_MAX + 1];
 	u8 copy_count;
+	u32 split_mask;
 };
 
 #define XENVIF_TX_CB(skb) ((struct xenvif_tx_cb *)(skb)->cb)
@@ -354,6 +355,8 @@ static inline struct sk_buff *xenvif_alloc_skb(unsigned int size)
 	struct sk_buff *skb =
 		alloc_skb(size + NET_SKB_PAD + NET_IP_ALIGN,
 			  GFP_ATOMIC | __GFP_NOWARN);
+
+	BUILD_BUG_ON(sizeof(*XENVIF_TX_CB(skb)) > sizeof(skb->cb));
 	if (unlikely(skb == NULL))
 		return NULL;
 
@@ -389,11 +392,13 @@ static void xenvif_get_requests(struct xenvif_queue *queue,
 	nr_slots = shinfo->nr_frags + 1;
 
 	copy_count(skb) = 0;
+	XENVIF_TX_CB(skb)->split_mask = 0;
 
 	/* Create copy ops for exactly data_len bytes into the skb head. */
 	__skb_put(skb, data_len);
 	while (data_len > 0) {
 		int amount = data_len > txp->size ? txp->size : data_len;
+		bool split = false;
 
 		cop->source.u.ref = txp->gref;
 		cop->source.domid = queue->vif->domid;
@@ -406,6 +411,13 @@ static void xenvif_get_requests(struct xenvif_queue *queue,
 		cop->dest.u.gmfn = virt_to_gfn(skb->data + skb_headlen(skb)
 				               - data_len);
 
+		/* Don't cross local page boundary! */
+		if (cop->dest.offset + amount > XEN_PAGE_SIZE) {
+			amount = XEN_PAGE_SIZE - cop->dest.offset;
+			XENVIF_TX_CB(skb)->split_mask |= 1U << copy_count(skb);
+			split = true;
+		}
+
 		cop->len = amount;
 		cop->flags = GNTCOPY_source_gref;
 
@@ -413,7 +425,8 @@ static void xenvif_get_requests(struct xenvif_queue *queue,
 		pending_idx = queue->pending_ring[index];
 		callback_param(queue, pending_idx).ctx = NULL;
 		copy_pending_idx(skb, copy_count(skb)) = pending_idx;
-		copy_count(skb)++;
+		if (!split)
+			copy_count(skb)++;
 
 		cop++;
 		data_len -= amount;
@@ -434,7 +447,8 @@ static void xenvif_get_requests(struct xenvif_queue *queue,
 			nr_slots--;
 		} else {
 			/* The copy op partially covered the tx_request.
-			 * The remainder will be mapped.
+			 * The remainder will be mapped or copied in the next
+			 * iteration.
 			 */
 			txp->offset += amount;
 			txp->size -= amount;
@@ -532,6 +546,13 @@ static int xenvif_tx_check_gop(struct xenvif_queue *queue,
 		pending_idx = copy_pending_idx(skb, i);
 
 		newerr = (*gopp_copy)->status;
+
+		/* Split copies need to be handled together. */
+		if (XENVIF_TX_CB(skb)->split_mask & (1U << i)) {
+			(*gopp_copy)++;
+			if (!newerr)
+				newerr = (*gopp_copy)->status;
+		}
 		if (likely(!newerr)) {
 			/* The first frag might still have this slot mapped */
 			if (i < copy_count(skb) - 1 || !sharedslot)
diff --git linux-libre-4.14.311-gnu1/drivers/pinctrl/pinctrl-at91-pio4.c linux-libre-4.14.312-gnu1/drivers/pinctrl/pinctrl-at91-pio4.c
index 78aeb882f1ca..32e863a352a3 100644
--- linux-libre-4.14.311-gnu1/drivers/pinctrl/pinctrl-at91-pio4.c
+++ linux-libre-4.14.312-gnu1/drivers/pinctrl/pinctrl-at91-pio4.c
@@ -1035,7 +1035,6 @@ static int atmel_pinctrl_probe(struct platform_device *pdev)
 		dev_err(dev, "can't add the irq domain\n");
 		return -ENODEV;
 	}
-	atmel_pioctrl->irq_domain->name = "atmel gpio";
 
 	for (i = 0; i < atmel_pioctrl->npins; i++) {
 		int irq = irq_create_mapping(atmel_pioctrl->irq_domain, i);
diff --git linux-libre-4.14.311-gnu1/drivers/power/supply/da9150-charger.c linux-libre-4.14.312-gnu1/drivers/power/supply/da9150-charger.c
index 60099815296e..b2d38eb32288 100644
--- linux-libre-4.14.311-gnu1/drivers/power/supply/da9150-charger.c
+++ linux-libre-4.14.312-gnu1/drivers/power/supply/da9150-charger.c
@@ -666,6 +666,7 @@ static int da9150_charger_remove(struct platform_device *pdev)
 
 	if (!IS_ERR_OR_NULL(charger->usb_phy))
 		usb_unregister_notifier(charger->usb_phy, &charger->otg_nb);
+	cancel_work_sync(&charger->otg_work);
 
 	power_supply_unregister(charger->battery);
 	power_supply_unregister(charger->usb);
diff --git linux-libre-4.14.311-gnu1/drivers/scsi/device_handler/scsi_dh_alua.c linux-libre-4.14.312-gnu1/drivers/scsi/device_handler/scsi_dh_alua.c
index 2cf5579a9ad9..750d57d77be3 100644
--- linux-libre-4.14.311-gnu1/drivers/scsi/device_handler/scsi_dh_alua.c
+++ linux-libre-4.14.312-gnu1/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -1025,10 +1025,12 @@ static int alua_activate(struct scsi_device *sdev,
 	rcu_read_unlock();
 	mutex_unlock(&h->init_mutex);
 
-	if (alua_rtpg_queue(pg, sdev, qdata, true))
+	if (alua_rtpg_queue(pg, sdev, qdata, true)) {
 		fn = NULL;
-	else
+	} else {
+		kfree(qdata);
 		err = SCSI_DH_DEV_OFFLINED;
+	}
 	kref_put(&pg->kref, release_port_group);
 out:
 	if (fn)
diff --git linux-libre-4.14.311-gnu1/drivers/scsi/megaraid/megaraid_sas_fusion.c linux-libre-4.14.312-gnu1/drivers/scsi/megaraid/megaraid_sas_fusion.c
index b13721290f4b..00774b713eeb 100644
--- linux-libre-4.14.311-gnu1/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ linux-libre-4.14.312-gnu1/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -4019,7 +4019,7 @@ int megasas_task_abort_fusion(struct scsi_cmnd *scmd)
 	devhandle = megasas_get_tm_devhandle(scmd->device);
 
 	if (devhandle == (u16)ULONG_MAX) {
-		ret = SUCCESS;
+		ret = FAILED;
 		sdev_printk(KERN_INFO, scmd->device,
 			"task abort issued for invalid devhandle\n");
 		mutex_unlock(&instance->reset_mutex);
@@ -4091,7 +4091,7 @@ int megasas_reset_target_fusion(struct scsi_cmnd *scmd)
 	devhandle = megasas_get_tm_devhandle(scmd->device);
 
 	if (devhandle == (u16)ULONG_MAX) {
-		ret = SUCCESS;
+		ret = FAILED;
 		sdev_printk(KERN_INFO, scmd->device,
 			"target reset issued for invalid devhandle\n");
 		mutex_unlock(&instance->reset_mutex);
diff --git linux-libre-4.14.311-gnu1/drivers/scsi/scsi_devinfo.c linux-libre-4.14.312-gnu1/drivers/scsi/scsi_devinfo.c
index 6748e82c6352..91032ae1b5cf 100644
--- linux-libre-4.14.311-gnu1/drivers/scsi/scsi_devinfo.c
+++ linux-libre-4.14.312-gnu1/drivers/scsi/scsi_devinfo.c
@@ -241,6 +241,7 @@ static struct {
 	{"SGI", "RAID5", "*", BLIST_SPARSELUN},
 	{"SGI", "TP9100", "*", BLIST_REPORTLUN2},
 	{"SGI", "Universal Xport", "*", BLIST_NO_ULD_ATTACH},
+	{"SKhynix", "H28U74301AMR", NULL, BLIST_SKIP_VPD_PAGES},
 	{"IBM", "Universal Xport", "*", BLIST_NO_ULD_ATTACH},
 	{"SUN", "Universal Xport", "*", BLIST_NO_ULD_ATTACH},
 	{"DELL", "Universal Xport", "*", BLIST_NO_ULD_ATTACH},
diff --git linux-libre-4.14.311-gnu1/drivers/scsi/ufs/ufshcd.c linux-libre-4.14.312-gnu1/drivers/scsi/ufs/ufshcd.c
index 694c0fc31fbf..fe7db66ab1f3 100644
--- linux-libre-4.14.311-gnu1/drivers/scsi/ufs/ufshcd.c
+++ linux-libre-4.14.312-gnu1/drivers/scsi/ufs/ufshcd.c
@@ -8087,5 +8087,6 @@ EXPORT_SYMBOL_GPL(ufshcd_init);
 MODULE_AUTHOR("Santosh Yaragnavi <santosh.sy@samsung.com>");
 MODULE_AUTHOR("Vinayak Holikatti <h.vinayak@samsung.com>");
 MODULE_DESCRIPTION("Generic UFS host controller driver Core");
+MODULE_SOFTDEP("pre: governor_simpleondemand");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(UFSHCD_DRIVER_VERSION);
diff --git linux-libre-4.14.311-gnu1/drivers/target/iscsi/iscsi_target_parameters.c linux-libre-4.14.312-gnu1/drivers/target/iscsi/iscsi_target_parameters.c
index caab1045742d..d2c8c4929f93 100644
--- linux-libre-4.14.311-gnu1/drivers/target/iscsi/iscsi_target_parameters.c
+++ linux-libre-4.14.312-gnu1/drivers/target/iscsi/iscsi_target_parameters.c
@@ -1270,18 +1270,20 @@ static struct iscsi_param *iscsi_check_key(
 		return param;
 
 	if (!(param->phase & phase)) {
-		pr_err("Key \"%s\" may not be negotiated during ",
-				param->name);
+		char *phase_name;
+
 		switch (phase) {
 		case PHASE_SECURITY:
-			pr_debug("Security phase.\n");
+			phase_name = "Security";
 			break;
 		case PHASE_OPERATIONAL:
-			pr_debug("Operational phase.\n");
+			phase_name = "Operational";
 			break;
 		default:
-			pr_debug("Unknown phase.\n");
+			phase_name = "Unknown";
 		}
+		pr_err("Key \"%s\" may not be negotiated during %s phase.\n",
+				param->name, phase_name);
 		return NULL;
 	}
 
diff --git linux-libre-4.14.311-gnu1/drivers/thunderbolt/nhi.c linux-libre-4.14.312-gnu1/drivers/thunderbolt/nhi.c
index 8b38e639e880..aa245e584f0e 100644
--- linux-libre-4.14.311-gnu1/drivers/thunderbolt/nhi.c
+++ linux-libre-4.14.312-gnu1/drivers/thunderbolt/nhi.c
@@ -30,7 +30,7 @@
 
 #define NHI_MAILBOX_TIMEOUT	500 /* ms */
 
-static int ring_interrupt_index(struct tb_ring *ring)
+static int ring_interrupt_index(const struct tb_ring *ring)
 {
 	int bit = ring->hop;
 	if (!ring->is_tx)
diff --git linux-libre-4.14.311-gnu1/drivers/tty/hvc/hvc_xen.c linux-libre-4.14.312-gnu1/drivers/tty/hvc/hvc_xen.c
index 625b5660b05f..1031ec4a6fb9 100644
--- linux-libre-4.14.311-gnu1/drivers/tty/hvc/hvc_xen.c
+++ linux-libre-4.14.312-gnu1/drivers/tty/hvc/hvc_xen.c
@@ -56,6 +56,7 @@ struct xencons_info {
 	int irq;
 	int vtermno;
 	grant_ref_t gntref;
+	spinlock_t ring_lock;
 };
 
 static LIST_HEAD(xenconsoles);
@@ -102,12 +103,15 @@ static int __write_console(struct xencons_info *xencons,
 	XENCONS_RING_IDX cons, prod;
 	struct xencons_interface *intf = xencons->intf;
 	int sent = 0;
+	unsigned long flags;
 
+	spin_lock_irqsave(&xencons->ring_lock, flags);
 	cons = intf->out_cons;
 	prod = intf->out_prod;
 	mb();			/* update queue values before going on */
 
 	if ((prod - cons) > sizeof(intf->out)) {
+		spin_unlock_irqrestore(&xencons->ring_lock, flags);
 		pr_err_once("xencons: Illegal ring page indices");
 		return -EINVAL;
 	}
@@ -117,6 +121,7 @@ static int __write_console(struct xencons_info *xencons,
 
 	wmb();			/* write ring before updating pointer */
 	intf->out_prod = prod;
+	spin_unlock_irqrestore(&xencons->ring_lock, flags);
 
 	if (sent)
 		notify_daemon(xencons);
@@ -159,16 +164,19 @@ static int domU_read_console(uint32_t vtermno, char *buf, int len)
 	int recv = 0;
 	struct xencons_info *xencons = vtermno_to_xencons(vtermno);
 	unsigned int eoiflag = 0;
+	unsigned long flags;
 
 	if (xencons == NULL)
 		return -EINVAL;
 	intf = xencons->intf;
 
+	spin_lock_irqsave(&xencons->ring_lock, flags);
 	cons = intf->in_cons;
 	prod = intf->in_prod;
 	mb();			/* get pointers before reading ring */
 
 	if ((prod - cons) > sizeof(intf->in)) {
+		spin_unlock_irqrestore(&xencons->ring_lock, flags);
 		pr_err_once("xencons: Illegal ring page indices");
 		return -EINVAL;
 	}
@@ -192,10 +200,13 @@ static int domU_read_console(uint32_t vtermno, char *buf, int len)
 		xencons->out_cons = intf->out_cons;
 		xencons->out_cons_same = 0;
 	}
+	if (!recv && xencons->out_cons_same++ > 1) {
+		eoiflag = XEN_EOI_FLAG_SPURIOUS;
+	}
+	spin_unlock_irqrestore(&xencons->ring_lock, flags);
+
 	if (recv) {
 		notify_daemon(xencons);
-	} else if (xencons->out_cons_same++ > 1) {
-		eoiflag = XEN_EOI_FLAG_SPURIOUS;
 	}
 
 	xen_irq_lateeoi(xencons->irq, eoiflag);
@@ -252,6 +263,7 @@ static int xen_hvm_console_init(void)
 		info = kzalloc(sizeof(struct xencons_info), GFP_KERNEL);
 		if (!info)
 			return -ENOMEM;
+		spin_lock_init(&info->ring_lock);
 	} else if (info->intf != NULL) {
 		/* already configured */
 		return 0;
@@ -288,6 +300,7 @@ err:
 
 static int xencons_info_pv_init(struct xencons_info *info, int vtermno)
 {
+	spin_lock_init(&info->ring_lock);
 	info->evtchn = xen_start_info->console.domU.evtchn;
 	/* GFN == MFN for PV guest */
 	info->intf = gfn_to_virt(xen_start_info->console.domU.mfn);
@@ -338,6 +351,7 @@ static int xen_initial_domain_console_init(void)
 		info = kzalloc(sizeof(struct xencons_info), GFP_KERNEL);
 		if (!info)
 			return -ENOMEM;
+		spin_lock_init(&info->ring_lock);
 	}
 
 	info->irq = bind_virq_to_irq(VIRQ_CONSOLE, 0, false);
@@ -495,6 +509,7 @@ static int xencons_probe(struct xenbus_device *dev,
 	info = kzalloc(sizeof(struct xencons_info), GFP_KERNEL);
 	if (!info)
 		return -ENOMEM;
+	spin_lock_init(&info->ring_lock);
 	dev_set_drvdata(&dev->dev, info);
 	info->xbdev = dev;
 	info->vtermno = xenbus_devid_to_vtermno(devid);
diff --git linux-libre-4.14.311-gnu1/drivers/usb/chipidea/ci.h linux-libre-4.14.312-gnu1/drivers/usb/chipidea/ci.h
index 6743f85b1b7a..1c23936441cc 100644
--- linux-libre-4.14.311-gnu1/drivers/usb/chipidea/ci.h
+++ linux-libre-4.14.312-gnu1/drivers/usb/chipidea/ci.h
@@ -205,6 +205,7 @@ struct hw_bank {
  * @in_lpm: if the core in low power mode
  * @wakeup_int: if wakeup interrupt occur
  * @rev: The revision number for controller
+ * @mutex: protect code from concorrent running when doing role switch
  */
 struct ci_hdrc {
 	struct device			*dev;
@@ -259,6 +260,7 @@ struct ci_hdrc {
 	bool				in_lpm;
 	bool				wakeup_int;
 	enum ci_revision		rev;
+	struct mutex                    mutex;
 };
 
 static inline struct ci_role_driver *ci_role(struct ci_hdrc *ci)
diff --git linux-libre-4.14.311-gnu1/drivers/usb/chipidea/core.c linux-libre-4.14.312-gnu1/drivers/usb/chipidea/core.c
index 7142baf654bc..48fbb6302e60 100644
--- linux-libre-4.14.311-gnu1/drivers/usb/chipidea/core.c
+++ linux-libre-4.14.312-gnu1/drivers/usb/chipidea/core.c
@@ -875,9 +875,16 @@ static ssize_t ci_role_store(struct device *dev,
 			     strlen(ci->roles[role]->name)))
 			break;
 
-	if (role == CI_ROLE_END || role == ci->role)
+	if (role == CI_ROLE_END)
 		return -EINVAL;
 
+	mutex_lock(&ci->mutex);
+
+	if (role == ci->role) {
+		mutex_unlock(&ci->mutex);
+		return n;
+	}
+
 	pm_runtime_get_sync(dev);
 	disable_irq(ci->irq);
 	ci_role_stop(ci);
@@ -886,6 +893,7 @@ static ssize_t ci_role_store(struct device *dev,
 		ci_handle_vbus_change(ci);
 	enable_irq(ci->irq);
 	pm_runtime_put_sync(dev);
+	mutex_unlock(&ci->mutex);
 
 	return (ret == 0) ? n : ret;
 }
@@ -924,6 +932,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	spin_lock_init(&ci->lock);
+	mutex_init(&ci->mutex);
 	ci->dev = dev;
 	ci->platdata = dev_get_platdata(dev);
 	ci->imx28_write_fix = !!(ci->platdata->flags &
diff --git linux-libre-4.14.311-gnu1/drivers/usb/chipidea/otg.c linux-libre-4.14.312-gnu1/drivers/usb/chipidea/otg.c
index 8bf4032226ed..e73933dcfc34 100644
--- linux-libre-4.14.311-gnu1/drivers/usb/chipidea/otg.c
+++ linux-libre-4.14.312-gnu1/drivers/usb/chipidea/otg.c
@@ -167,8 +167,10 @@ static int hw_wait_vbus_lower_bsv(struct ci_hdrc *ci)
 
 static void ci_handle_id_switch(struct ci_hdrc *ci)
 {
-	enum ci_role role = ci_otg_role(ci);
+	enum ci_role role;
 
+	mutex_lock(&ci->mutex);
+	role = ci_otg_role(ci);
 	if (role != ci->role) {
 		dev_dbg(ci->dev, "switching from %s to %s\n",
 			ci_role(ci)->name, ci->roles[role]->name);
@@ -191,6 +193,7 @@ static void ci_handle_id_switch(struct ci_hdrc *ci)
 		if (role == CI_ROLE_GADGET)
 			ci_handle_vbus_change(ci);
 	}
+	mutex_unlock(&ci->mutex);
 }
 /**
  * ci_otg_work - perform otg (vbus/id) event handle
diff --git linux-libre-4.14.311-gnu1/drivers/usb/gadget/function/u_audio.c linux-libre-4.14.312-gnu1/drivers/usb/gadget/function/u_audio.c
index af6339ff6d2f..48661e9a7404 100644
--- linux-libre-4.14.311-gnu1/drivers/usb/gadget/function/u_audio.c
+++ linux-libre-4.14.312-gnu1/drivers/usb/gadget/function/u_audio.c
@@ -635,7 +635,7 @@ void g_audio_cleanup(struct g_audio *g_audio)
 	uac = g_audio->uac;
 	card = uac->card;
 	if (card)
-		snd_card_free(card);
+		snd_card_free_when_closed(card);
 
 	kfree(uac->p_prm.ureq);
 	kfree(uac->c_prm.ureq);
diff --git linux-libre-4.14.311-gnu1/drivers/usb/host/ohci-pxa27x.c linux-libre-4.14.312-gnu1/drivers/usb/host/ohci-pxa27x.c
index 21c010ffb03c..ebd437c43f83 100644
--- linux-libre-4.14.311-gnu1/drivers/usb/host/ohci-pxa27x.c
+++ linux-libre-4.14.312-gnu1/drivers/usb/host/ohci-pxa27x.c
@@ -147,7 +147,7 @@ static int pxa27x_ohci_select_pmm(struct pxa27x_ohci *pxa_ohci, int mode)
 		uhcrhda |= RH_A_NPS;
 		break;
 	case PMM_GLOBAL_MODE:
-		uhcrhda &= ~(RH_A_NPS & RH_A_PSM);
+		uhcrhda &= ~(RH_A_NPS | RH_A_PSM);
 		break;
 	case PMM_PERPORT_MODE:
 		uhcrhda &= ~(RH_A_NPS);
diff --git linux-libre-4.14.311-gnu1/drivers/usb/storage/unusual_uas.h linux-libre-4.14.312-gnu1/drivers/usb/storage/unusual_uas.h
index eed0422abbe5..a6ed40aeecaf 100644
--- linux-libre-4.14.311-gnu1/drivers/usb/storage/unusual_uas.h
+++ linux-libre-4.14.312-gnu1/drivers/usb/storage/unusual_uas.h
@@ -180,6 +180,13 @@ UNUSUAL_DEV(0x152d, 0x0578, 0x0000, 0x9999,
 		USB_SC_DEVICE, USB_PR_DEVICE, NULL,
 		US_FL_BROKEN_FUA),
 
+/* Reported by: Yaroslav Furman <yaro330@gmail.com> */
+UNUSUAL_DEV(0x152d, 0x0583, 0x0000, 0x9999,
+		"JMicron",
+		"JMS583Gen 2",
+		USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+		US_FL_NO_REPORT_OPCODES),
+
 /* Reported-by: Thinh Nguyen <thinhn@synopsys.com> */
 UNUSUAL_DEV(0x154b, 0xf00b, 0x0000, 0x9999,
 		"PNY",
diff --git linux-libre-4.14.311-gnu1/drivers/video/fbdev/au1200fb.c linux-libre-4.14.312-gnu1/drivers/video/fbdev/au1200fb.c
index 6c542d0ca076..e17a083f849a 100644
--- linux-libre-4.14.311-gnu1/drivers/video/fbdev/au1200fb.c
+++ linux-libre-4.14.312-gnu1/drivers/video/fbdev/au1200fb.c
@@ -1039,6 +1039,9 @@ static int au1200fb_fb_check_var(struct fb_var_screeninfo *var,
 	u32 pixclock;
 	int screen_size, plane;
 
+	if (!var->pixclock)
+		return -EINVAL;
+
 	plane = fbdev->plane;
 
 	/* Make sure that the mode respect all LCD controller and
diff --git linux-libre-4.14.311-gnu1/drivers/video/fbdev/geode/lxfb_core.c linux-libre-4.14.312-gnu1/drivers/video/fbdev/geode/lxfb_core.c
index 138da6cb6cbc..4345246b4c79 100644
--- linux-libre-4.14.311-gnu1/drivers/video/fbdev/geode/lxfb_core.c
+++ linux-libre-4.14.312-gnu1/drivers/video/fbdev/geode/lxfb_core.c
@@ -247,6 +247,9 @@ static void get_modedb(struct fb_videomode **modedb, unsigned int *size)
 
 static int lxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
 {
+	if (!var->pixclock)
+		return -EINVAL;
+
 	if (var->xres > 1920 || var->yres > 1440)
 		return -EINVAL;
 
diff --git linux-libre-4.14.311-gnu1/drivers/video/fbdev/intelfb/intelfbdrv.c linux-libre-4.14.312-gnu1/drivers/video/fbdev/intelfb/intelfbdrv.c
index d7463a2a5d83..c97c0c851480 100644
--- linux-libre-4.14.311-gnu1/drivers/video/fbdev/intelfb/intelfbdrv.c
+++ linux-libre-4.14.312-gnu1/drivers/video/fbdev/intelfb/intelfbdrv.c
@@ -1215,6 +1215,9 @@ static int intelfb_check_var(struct fb_var_screeninfo *var,
 
 	dinfo = GET_DINFO(info);
 
+	if (!var->pixclock)
+		return -EINVAL;
+
 	/* update the pitch */
 	if (intelfbhw_validate_mode(dinfo, var) != 0)
 		return -EINVAL;
diff --git linux-libre-4.14.311-gnu1/drivers/video/fbdev/nvidia/nvidia.c linux-libre-4.14.312-gnu1/drivers/video/fbdev/nvidia/nvidia.c
index 418a2d0d06a9..68e4bcdd3871 100644
--- linux-libre-4.14.311-gnu1/drivers/video/fbdev/nvidia/nvidia.c
+++ linux-libre-4.14.312-gnu1/drivers/video/fbdev/nvidia/nvidia.c
@@ -766,6 +766,8 @@ static int nvidiafb_check_var(struct fb_var_screeninfo *var,
 	int pitch, err = 0;
 
 	NVTRACE_ENTER();
+	if (!var->pixclock)
+		return -EINVAL;
 
 	var->transp.offset = 0;
 	var->transp.length = 0;
diff --git linux-libre-4.14.311-gnu1/drivers/video/fbdev/tgafb.c linux-libre-4.14.312-gnu1/drivers/video/fbdev/tgafb.c
index 65ba9921506e..9d2912947eef 100644
--- linux-libre-4.14.311-gnu1/drivers/video/fbdev/tgafb.c
+++ linux-libre-4.14.312-gnu1/drivers/video/fbdev/tgafb.c
@@ -166,6 +166,9 @@ tgafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
 {
 	struct tga_par *par = (struct tga_par *)info->par;
 
+	if (!var->pixclock)
+		return -EINVAL;
+
 	if (par->tga_type == TGA_TYPE_8PLANE) {
 		if (var->bits_per_pixel != 8)
 			return -EINVAL;
diff --git linux-libre-4.14.311-gnu1/fs/cifs/cifsfs.h linux-libre-4.14.312-gnu1/fs/cifs/cifsfs.h
index 5a10e566f0e6..cabc22962ab1 100644
--- linux-libre-4.14.311-gnu1/fs/cifs/cifsfs.h
+++ linux-libre-4.14.312-gnu1/fs/cifs/cifsfs.h
@@ -122,7 +122,10 @@ extern const struct dentry_operations cifs_ci_dentry_ops;
 #ifdef CONFIG_CIFS_DFS_UPCALL
 extern struct vfsmount *cifs_dfs_d_automount(struct path *path);
 #else
-#define cifs_dfs_d_automount NULL
+static inline struct vfsmount *cifs_dfs_d_automount(struct path *path)
+{
+	return ERR_PTR(-EREMOTE);
+}
 #endif
 
 /* Functions related to symlinks */
diff --git linux-libre-4.14.311-gnu1/fs/ext4/inode.c linux-libre-4.14.312-gnu1/fs/ext4/inode.c
index 69360b08db73..35c72f8fee75 100644
--- linux-libre-4.14.311-gnu1/fs/ext4/inode.c
+++ linux-libre-4.14.312-gnu1/fs/ext4/inode.c
@@ -1425,7 +1425,8 @@ static int ext4_write_end(struct file *file,
 	int inline_data = ext4_has_inline_data(inode);
 
 	trace_ext4_write_end(inode, pos, len, copied);
-	if (inline_data) {
+	if (inline_data &&
+	    ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA)) {
 		ret = ext4_write_inline_data_end(inode, pos, len,
 						 copied, page);
 		if (ret < 0) {
diff --git linux-libre-4.14.311-gnu1/fs/nilfs2/ioctl.c linux-libre-4.14.312-gnu1/fs/nilfs2/ioctl.c
index e79a29334539..fe420bce6ab6 100644
--- linux-libre-4.14.311-gnu1/fs/nilfs2/ioctl.c
+++ linux-libre-4.14.312-gnu1/fs/nilfs2/ioctl.c
@@ -79,7 +79,7 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs,
 	if (argv->v_index > ~(__u64)0 - argv->v_nmembs)
 		return -EINVAL;
 
-	buf = (void *)__get_free_pages(GFP_NOFS, 0);
+	buf = (void *)get_zeroed_page(GFP_NOFS);
 	if (unlikely(!buf))
 		return -ENOMEM;
 	maxmembs = PAGE_SIZE / argv->v_size;
diff --git linux-libre-4.14.311-gnu1/fs/ocfs2/aops.c linux-libre-4.14.312-gnu1/fs/ocfs2/aops.c
index ca2b575a1e46..ed921c8bf660 100644
--- linux-libre-4.14.311-gnu1/fs/ocfs2/aops.c
+++ linux-libre-4.14.312-gnu1/fs/ocfs2/aops.c
@@ -2001,11 +2001,25 @@ int ocfs2_write_end_nolock(struct address_space *mapping,
 	}
 
 	if (unlikely(copied < len) && wc->w_target_page) {
+		loff_t new_isize;
+
 		if (!PageUptodate(wc->w_target_page))
 			copied = 0;
 
-		ocfs2_zero_new_buffers(wc->w_target_page, start+copied,
-				       start+len);
+		new_isize = max_t(loff_t, i_size_read(inode), pos + copied);
+		if (new_isize > page_offset(wc->w_target_page))
+			ocfs2_zero_new_buffers(wc->w_target_page, start+copied,
+					       start+len);
+		else {
+			/*
+			 * When page is fully beyond new isize (data copy
+			 * failed), do not bother zeroing the page. Invalidate
+			 * it instead so that writeback does not get confused
+			 * put page & buffer dirty bits into inconsistent
+			 * state.
+			 */
+			block_invalidatepage(wc->w_target_page, 0, PAGE_SIZE);
+		}
 	}
 	if (wc->w_target_page)
 		flush_dcache_page(wc->w_target_page);
diff --git linux-libre-4.14.311-gnu1/kernel/bpf/core.c linux-libre-4.14.312-gnu1/kernel/bpf/core.c
index 2ca36bb440de..1f586204673d 100644
--- linux-libre-4.14.311-gnu1/kernel/bpf/core.c
+++ linux-libre-4.14.312-gnu1/kernel/bpf/core.c
@@ -555,7 +555,7 @@ static int __init bpf_jit_charge_init(void)
 {
 	/* Only used as heuristic here to derive limit. */
 	bpf_jit_limit_max = bpf_jit_alloc_exec_limit();
-	bpf_jit_limit = min_t(u64, round_up(bpf_jit_limit_max >> 2,
+	bpf_jit_limit = min_t(u64, round_up(bpf_jit_limit_max >> 1,
 					    PAGE_SIZE), LONG_MAX);
 	return 0;
 }
diff --git linux-libre-4.14.311-gnu1/kernel/compat.c linux-libre-4.14.312-gnu1/kernel/compat.c
index 45ae3ace49c2..63d10b91f80f 100644
--- linux-libre-4.14.311-gnu1/kernel/compat.c
+++ linux-libre-4.14.312-gnu1/kernel/compat.c
@@ -351,7 +351,7 @@ COMPAT_SYSCALL_DEFINE3(sched_getaffinity, compat_pid_t,  pid, unsigned int, len,
 	if (len & (sizeof(compat_ulong_t)-1))
 		return -EINVAL;
 
-	if (!alloc_cpumask_var(&mask, GFP_KERNEL))
+	if (!zalloc_cpumask_var(&mask, GFP_KERNEL))
 		return -ENOMEM;
 
 	ret = sched_getaffinity(pid, mask);
diff --git linux-libre-4.14.311-gnu1/kernel/sched/core.c linux-libre-4.14.312-gnu1/kernel/sched/core.c
index 5dc66377864a..e3bda201f639 100644
--- linux-libre-4.14.311-gnu1/kernel/sched/core.c
+++ linux-libre-4.14.312-gnu1/kernel/sched/core.c
@@ -776,6 +776,9 @@ static inline void dequeue_task(struct rq *rq, struct task_struct *p, int flags)
 
 void activate_task(struct rq *rq, struct task_struct *p, int flags)
 {
+	if (task_on_rq_migrating(p))
+		flags |= ENQUEUE_MIGRATED;
+
 	if (task_contributes_to_load(p))
 		rq->nr_uninterruptible--;
 
@@ -4791,14 +4794,14 @@ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
 	if (len & (sizeof(unsigned long)-1))
 		return -EINVAL;
 
-	if (!alloc_cpumask_var(&mask, GFP_KERNEL))
+	if (!zalloc_cpumask_var(&mask, GFP_KERNEL))
 		return -ENOMEM;
 
 	ret = sched_getaffinity(pid, mask);
 	if (ret == 0) {
 		size_t retlen = min_t(size_t, len, cpumask_size());
 
-		if (copy_to_user(user_mask_ptr, mask, retlen))
+		if (copy_to_user(user_mask_ptr, cpumask_bits(mask), retlen))
 			ret = -EFAULT;
 		else
 			ret = retlen;
diff --git linux-libre-4.14.311-gnu1/kernel/sched/fair.c linux-libre-4.14.312-gnu1/kernel/sched/fair.c
index 3ff60230710c..259996d2dcf7 100644
--- linux-libre-4.14.311-gnu1/kernel/sched/fair.c
+++ linux-libre-4.14.312-gnu1/kernel/sched/fair.c
@@ -3611,6 +3611,29 @@ static void check_spread(struct cfs_rq *cfs_rq, struct sched_entity *se)
 #endif
 }
 
+static inline bool entity_is_long_sleeper(struct sched_entity *se)
+{
+	struct cfs_rq *cfs_rq;
+	u64 sleep_time;
+
+	if (se->exec_start == 0)
+		return false;
+
+	cfs_rq = cfs_rq_of(se);
+
+	sleep_time = rq_clock_task(rq_of(cfs_rq));
+
+	/* Happen while migrating because of clock task divergence */
+	if (sleep_time <= se->exec_start)
+		return false;
+
+	sleep_time -= se->exec_start;
+	if (sleep_time > ((1ULL << 63) / scale_load_down(NICE_0_LOAD)))
+		return true;
+
+	return false;
+}
+
 static void
 place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial)
 {
@@ -3639,8 +3662,29 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial)
 		vruntime -= thresh;
 	}
 
-	/* ensure we never gain time by being placed backwards. */
-	se->vruntime = max_vruntime(se->vruntime, vruntime);
+	/*
+	 * Pull vruntime of the entity being placed to the base level of
+	 * cfs_rq, to prevent boosting it if placed backwards.
+	 * However, min_vruntime can advance much faster than real time, with
+	 * the extreme being when an entity with the minimal weight always runs
+	 * on the cfs_rq. If the waking entity slept for a long time, its
+	 * vruntime difference from min_vruntime may overflow s64 and their
+	 * comparison may get inversed, so ignore the entity's original
+	 * vruntime in that case.
+	 * The maximal vruntime speedup is given by the ratio of normal to
+	 * minimal weight: scale_load_down(NICE_0_LOAD) / MIN_SHARES.
+	 * When placing a migrated waking entity, its exec_start has been set
+	 * from a different rq. In order to take into account a possible
+	 * divergence between new and prev rq's clocks task because of irq and
+	 * stolen time, we take an additional margin.
+	 * So, cutting off on the sleep time of
+	 *     2^63 / scale_load_down(NICE_0_LOAD) ~ 104 days
+	 * should be safe.
+	 */
+	if (entity_is_long_sleeper(se))
+		se->vruntime = vruntime;
+	else
+		se->vruntime = max_vruntime(se->vruntime, vruntime);
 }
 
 static void check_enqueue_throttle(struct cfs_rq *cfs_rq);
@@ -3735,6 +3779,9 @@ enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
 
 	if (flags & ENQUEUE_WAKEUP)
 		place_entity(cfs_rq, se, 0);
+	/* Entity has migrated, no longer consider this task hot */
+	if (flags & ENQUEUE_MIGRATED)
+		se->exec_start = 0;
 
 	check_schedstat_required();
 	update_stats_enqueue(cfs_rq, se, flags);
@@ -6089,9 +6136,6 @@ static void migrate_task_rq_fair(struct task_struct *p)
 
 	/* Tell new CPU we are migrated */
 	p->se.avg.last_update_time = 0;
-
-	/* We have migrated, no longer consider this task hot */
-	p->se.exec_start = 0;
 }
 
 static void task_dead_fair(struct task_struct *p)
diff --git linux-libre-4.14.311-gnu1/net/can/bcm.c linux-libre-4.14.312-gnu1/net/can/bcm.c
index 89b955ef75d1..32db244ba2c0 100644
--- linux-libre-4.14.311-gnu1/net/can/bcm.c
+++ linux-libre-4.14.312-gnu1/net/can/bcm.c
@@ -981,6 +981,8 @@ static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
 
 			cf = op->frames + op->cfsiz * i;
 			err = memcpy_from_msg((u8 *)cf, msg, op->cfsiz);
+			if (err < 0)
+				goto free_op;
 
 			if (op->flags & CAN_FD_FRAME) {
 				if (cf->len > 64)
@@ -990,12 +992,8 @@ static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
 					err = -EINVAL;
 			}
 
-			if (err < 0) {
-				if (op->frames != &op->sframe)
-					kfree(op->frames);
-				kfree(op);
-				return err;
-			}
+			if (err < 0)
+				goto free_op;
 
 			if (msg_head->flags & TX_CP_CAN_ID) {
 				/* copy can_id into frame */
@@ -1068,6 +1066,12 @@ static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
 		bcm_tx_start_timer(op);
 
 	return msg_head->nframes * op->cfsiz + MHSIZ;
+
+free_op:
+	if (op->frames != &op->sframe)
+		kfree(op->frames);
+	kfree(op);
+	return err;
 }
 
 /*
diff --git linux-libre-4.14.311-gnu1/net/sched/sch_cbq.c linux-libre-4.14.312-gnu1/net/sched/sch_cbq.c
index dea125d8aac7..8b75a9572d1f 100644
--- linux-libre-4.14.311-gnu1/net/sched/sch_cbq.c
+++ linux-libre-4.14.312-gnu1/net/sched/sch_cbq.c
@@ -236,6 +236,8 @@ cbq_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr)
 		result = tcf_classify(skb, fl, &res, true);
 		if (!fl || result < 0)
 			goto fallback;
+		if (result == TC_ACT_SHOT)
+			return NULL;
 
 		cl = (void *)res.class;
 		if (!cl) {
@@ -255,8 +257,6 @@ cbq_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr)
 		case TC_ACT_STOLEN:
 		case TC_ACT_TRAP:
 			*qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
-		case TC_ACT_SHOT:
-			return NULL;
 		case TC_ACT_RECLASSIFY:
 			return cbq_reclassify(skb, cl);
 		}
diff --git linux-libre-4.14.311-gnu1/sound/pci/asihpi/hpi6205.c linux-libre-4.14.312-gnu1/sound/pci/asihpi/hpi6205.c
index 8d5abfa4e24b..bc694a69b4b7 100644
--- linux-libre-4.14.311-gnu1/sound/pci/asihpi/hpi6205.c
+++ linux-libre-4.14.312-gnu1/sound/pci/asihpi/hpi6205.c
@@ -441,7 +441,7 @@ void HPI_6205(struct hpi_message *phm, struct hpi_response *phr)
 		pao = hpi_find_adapter(phm->adapter_index);
 	} else {
 		/* subsys messages don't address an adapter */
-		_HPI_6205(NULL, phm, phr);
+		phr->error = HPI_ERROR_INVALID_OBJ_INDEX;
 		return;
 	}
 
diff --git linux-libre-4.14.311-gnu1/sound/pci/hda/patch_ca0132.c linux-libre-4.14.312-gnu1/sound/pci/hda/patch_ca0132.c
index 0f21be2ea58b..da3dfd5a1b7f 100644
--- linux-libre-4.14.311-gnu1/sound/pci/hda/patch_ca0132.c
+++ linux-libre-4.14.312-gnu1/sound/pci/hda/patch_ca0132.c
@@ -2943,8 +2943,10 @@ static int tuning_ctl_set(struct hda_codec *codec, hda_nid_t nid,
 
 	for (i = 0; i < TUNING_CTLS_COUNT; i++)
 		if (nid == ca0132_tuning_ctls[i].nid)
-			break;
+			goto found;
 
+	return -EINVAL;
+found:
 	snd_hda_power_up(codec);
 	dspio_set_param(codec, ca0132_tuning_ctls[i].mid,
 			ca0132_tuning_ctls[i].req,
diff --git linux-libre-4.14.311-gnu1/sound/pci/hda/patch_conexant.c linux-libre-4.14.312-gnu1/sound/pci/hda/patch_conexant.c
index 62c694f5b3ec..9263cb56df7d 100644
--- linux-libre-4.14.311-gnu1/sound/pci/hda/patch_conexant.c
+++ linux-libre-4.14.312-gnu1/sound/pci/hda/patch_conexant.c
@@ -986,7 +986,10 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {
 	SND_PCI_QUIRK(0x17aa, 0x3905, "Lenovo G50-30", CXT_FIXUP_STEREO_DMIC),
 	SND_PCI_QUIRK(0x17aa, 0x390b, "Lenovo G50-80", CXT_FIXUP_STEREO_DMIC),
 	SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC),
-	SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_PINCFG_LENOVO_NOTEBOOK),
+	/* NOTE: we'd need to extend the quirk for 17aa:3977 as the same
+	 * PCI SSID is used on multiple Lenovo models
+	 */
+	SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC),
 	SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo G50-70", CXT_FIXUP_STEREO_DMIC),
 	SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC),
 	SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", CXT_FIXUP_THINKPAD_ACPI),
@@ -1007,6 +1010,7 @@ static const struct hda_model_fixup cxt5066_fixup_models[] = {
 	{ .id = CXT_FIXUP_MUTE_LED_EAPD, .name = "mute-led-eapd" },
 	{ .id = CXT_FIXUP_HP_DOCK, .name = "hp-dock" },
 	{ .id = CXT_FIXUP_MUTE_LED_GPIO, .name = "mute-led-gpio" },
+	{ .id = CXT_PINCFG_LENOVO_NOTEBOOK, .name = "lenovo-20149" },
 	{}
 };
 
diff --git linux-libre-4.14.311-gnu1/sound/usb/format.c linux-libre-4.14.312-gnu1/sound/usb/format.c
index 56b5baee6552..3a0f8cb7e831 100644
--- linux-libre-4.14.311-gnu1/sound/usb/format.c
+++ linux-libre-4.14.312-gnu1/sound/usb/format.c
@@ -52,8 +52,12 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip,
 	case UAC_VERSION_1:
 	default: {
 		struct uac_format_type_i_discrete_descriptor *fmt = _fmt;
-		if (format >= 64)
-			return 0; /* invalid format */
+		if (format >= 64) {
+			usb_audio_info(chip,
+				       "%u:%d: invalid format type %#x is detected, processed as PCM\n",
+				       fp->iface, fp->altsetting, format);
+			format = UAC_FORMAT_TYPE_I_PCM;
+		}
 		sample_width = fmt->bBitResolution;
 		sample_bytes = fmt->bSubframeSize;
 		format = 1 << format;
