commit: 5829d907f1f0a3ef05e7a0339159b485cc84bb50 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org> AuthorDate: Sat Dec 8 13:20:38 2018 +0000 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org> CommitDate: Sat Dec 8 13:20:38 2018 +0000 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=5829d907
proj/linux-patches: Linux patch 4.14.87 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org> 0000_README | 4 + 1086_linux-4.14.87.patch | 2334 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 2338 insertions(+) diff --git a/0000_README b/0000_README index b0b15a3..b64e7d4 100644 --- a/0000_README +++ b/0000_README @@ -387,6 +387,10 @@ Patch: 1085_4.14.86.patch From: http://www.kernel.org Desc: Linux 4.14.86 +Patch: 1086_4.14.87.patch +From: http://www.kernel.org +Desc: Linux 4.14.87 + Patch: 1500_XATTR_USER_PREFIX.patch From: https://bugs.gentoo.org/show_bug.cgi?id=470644 Desc: Support for namespace user.pax.* on tmpfs. diff --git a/1086_linux-4.14.87.patch b/1086_linux-4.14.87.patch new file mode 100644 index 0000000..89e0a61 --- /dev/null +++ b/1086_linux-4.14.87.patch @@ -0,0 +1,2334 @@ +diff --git a/Makefile b/Makefile +index 572bd98d2344..322484348f3e 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,7 +1,7 @@ + # SPDX-License-Identifier: GPL-2.0 + VERSION = 4 + PATCHLEVEL = 14 +-SUBLEVEL = 86 ++SUBLEVEL = 87 + EXTRAVERSION = + NAME = Petit Gorille + +@@ -803,6 +803,9 @@ KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) + # disable pointer signed / unsigned warnings in gcc 4.0 + KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign) + ++# disable stringop warnings in gcc 8+ ++KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation) ++ + # disable invalid "can't wrap" optimizations for signed / pointers + KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow) + +diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig +index 8ff066090680..9d06c9478a0d 100644 +--- a/arch/arc/Kconfig ++++ b/arch/arc/Kconfig +@@ -109,7 +109,7 @@ endmenu + + choice + prompt "ARC Instruction Set" +- default ISA_ARCOMPACT ++ default ISA_ARCV2 + + config ISA_ARCOMPACT + bool "ARCompact ISA" +diff --git a/arch/arc/Makefile b/arch/arc/Makefile +index 7c6c97782022..2917f56f0ea4 100644 +--- a/arch/arc/Makefile ++++ b/arch/arc/Makefile +@@ -6,7 +6,7 @@ + # published by the Free Software Foundation. + # + +-KBUILD_DEFCONFIG := nsim_700_defconfig ++KBUILD_DEFCONFIG := nsim_hs_defconfig + + cflags-y += -fno-common -pipe -fno-builtin -mmedium-calls -D__linux__ + cflags-$(CONFIG_ISA_ARCOMPACT) += -mA7 +diff --git a/arch/arc/configs/axs101_defconfig b/arch/arc/configs/axs101_defconfig +index ece78630d711..5d5ba2104ba7 100644 +--- a/arch/arc/configs/axs101_defconfig ++++ b/arch/arc/configs/axs101_defconfig +@@ -15,6 +15,7 @@ CONFIG_PERF_EVENTS=y + # CONFIG_VM_EVENT_COUNTERS is not set + # CONFIG_SLUB_DEBUG is not set + # CONFIG_COMPAT_BRK is not set ++CONFIG_ISA_ARCOMPACT=y + CONFIG_MODULES=y + CONFIG_MODULE_FORCE_LOAD=y + CONFIG_MODULE_UNLOAD=y +@@ -98,6 +99,7 @@ CONFIG_VFAT_FS=y + CONFIG_NTFS_FS=y + CONFIG_TMPFS=y + CONFIG_NFS_FS=y ++CONFIG_NFS_V3_ACL=y + CONFIG_NLS_CODEPAGE_437=y + CONFIG_NLS_ISO8859_1=y + # CONFIG_ENABLE_WARN_DEPRECATED is not set +diff --git a/arch/arc/configs/axs103_defconfig b/arch/arc/configs/axs103_defconfig +index 240c9251a7d4..0874db2d48a8 100644 +--- a/arch/arc/configs/axs103_defconfig ++++ b/arch/arc/configs/axs103_defconfig +@@ -97,6 +97,7 @@ CONFIG_VFAT_FS=y + CONFIG_NTFS_FS=y + CONFIG_TMPFS=y + CONFIG_NFS_FS=y ++CONFIG_NFS_V3_ACL=y + CONFIG_NLS_CODEPAGE_437=y + CONFIG_NLS_ISO8859_1=y + # CONFIG_ENABLE_WARN_DEPRECATED is not set +diff --git a/arch/arc/configs/axs103_smp_defconfig b/arch/arc/configs/axs103_smp_defconfig +index af54b96abee0..cf5df0e1cb08 100644 +--- a/arch/arc/configs/axs103_smp_defconfig ++++ b/arch/arc/configs/axs103_smp_defconfig +@@ -100,6 +100,7 @@ CONFIG_VFAT_FS=y + CONFIG_NTFS_FS=y + CONFIG_TMPFS=y + CONFIG_NFS_FS=y ++CONFIG_NFS_V3_ACL=y + CONFIG_NLS_CODEPAGE_437=y + CONFIG_NLS_ISO8859_1=y + # CONFIG_ENABLE_WARN_DEPRECATED is not set +diff --git a/arch/arc/configs/hsdk_defconfig b/arch/arc/configs/hsdk_defconfig +index 762b1fcd93dc..083560e9e571 100644 +--- a/arch/arc/configs/hsdk_defconfig ++++ b/arch/arc/configs/hsdk_defconfig +@@ -66,6 +66,7 @@ CONFIG_EXT3_FS=y + CONFIG_VFAT_FS=y + CONFIG_TMPFS=y + CONFIG_NFS_FS=y ++CONFIG_NFS_V3_ACL=y + CONFIG_NLS_CODEPAGE_437=y + CONFIG_NLS_ISO8859_1=y + # CONFIG_ENABLE_WARN_DEPRECATED is not set +diff --git a/arch/arc/configs/nps_defconfig b/arch/arc/configs/nps_defconfig +index 7c9c706ae7f6..9121c6ba15d0 100644 +--- a/arch/arc/configs/nps_defconfig ++++ b/arch/arc/configs/nps_defconfig +@@ -15,6 +15,7 @@ CONFIG_SYSCTL_SYSCALL=y + CONFIG_EMBEDDED=y + CONFIG_PERF_EVENTS=y + # CONFIG_COMPAT_BRK is not set ++CONFIG_ISA_ARCOMPACT=y + CONFIG_KPROBES=y + CONFIG_MODULES=y + CONFIG_MODULE_FORCE_LOAD=y +@@ -74,6 +75,7 @@ CONFIG_PROC_KCORE=y + CONFIG_TMPFS=y + # CONFIG_MISC_FILESYSTEMS is not set + CONFIG_NFS_FS=y ++CONFIG_NFS_V3_ACL=y + CONFIG_ROOT_NFS=y + CONFIG_DEBUG_INFO=y + # CONFIG_ENABLE_WARN_DEPRECATED is not set +diff --git a/arch/arc/configs/nsim_700_defconfig b/arch/arc/configs/nsim_700_defconfig +index b1a78222699c..cdb06417d3d9 100644 +--- a/arch/arc/configs/nsim_700_defconfig ++++ b/arch/arc/configs/nsim_700_defconfig +@@ -16,6 +16,7 @@ CONFIG_EMBEDDED=y + CONFIG_PERF_EVENTS=y + # CONFIG_SLUB_DEBUG is not set + # CONFIG_COMPAT_BRK is not set ++CONFIG_ISA_ARCOMPACT=y + CONFIG_KPROBES=y + CONFIG_MODULES=y + # CONFIG_LBDAF is not set +diff --git a/arch/arc/configs/nsimosci_defconfig b/arch/arc/configs/nsimosci_defconfig +index 14377b8234f7..c4577bd9196c 100644 +--- a/arch/arc/configs/nsimosci_defconfig ++++ b/arch/arc/configs/nsimosci_defconfig +@@ -16,6 +16,7 @@ CONFIG_EMBEDDED=y + CONFIG_PERF_EVENTS=y + # CONFIG_SLUB_DEBUG is not set + # CONFIG_COMPAT_BRK is not set ++CONFIG_ISA_ARCOMPACT=y + CONFIG_KPROBES=y + CONFIG_MODULES=y + # CONFIG_LBDAF is not set +@@ -69,5 +70,6 @@ CONFIG_EXT2_FS_XATTR=y + CONFIG_TMPFS=y + # CONFIG_MISC_FILESYSTEMS is not set + CONFIG_NFS_FS=y ++CONFIG_NFS_V3_ACL=y + # CONFIG_ENABLE_WARN_DEPRECATED is not set + # CONFIG_ENABLE_MUST_CHECK is not set +diff --git a/arch/arc/configs/nsimosci_hs_defconfig b/arch/arc/configs/nsimosci_hs_defconfig +index 7e61c923a3cd..b20692c82d3c 100644 +--- a/arch/arc/configs/nsimosci_hs_defconfig ++++ b/arch/arc/configs/nsimosci_hs_defconfig +@@ -68,5 +68,6 @@ CONFIG_EXT2_FS_XATTR=y + CONFIG_TMPFS=y + # CONFIG_MISC_FILESYSTEMS is not set + CONFIG_NFS_FS=y ++CONFIG_NFS_V3_ACL=y + # CONFIG_ENABLE_WARN_DEPRECATED is not set + # CONFIG_ENABLE_MUST_CHECK is not set +diff --git a/arch/arc/configs/nsimosci_hs_smp_defconfig b/arch/arc/configs/nsimosci_hs_smp_defconfig +index 299fbe8003b2..5ad4949af6d0 100644 +--- a/arch/arc/configs/nsimosci_hs_smp_defconfig ++++ b/arch/arc/configs/nsimosci_hs_smp_defconfig +@@ -79,6 +79,7 @@ CONFIG_EXT2_FS_XATTR=y + CONFIG_TMPFS=y + # CONFIG_MISC_FILESYSTEMS is not set + CONFIG_NFS_FS=y ++CONFIG_NFS_V3_ACL=y + # CONFIG_ENABLE_WARN_DEPRECATED is not set + # CONFIG_ENABLE_MUST_CHECK is not set + CONFIG_FTRACE=y +diff --git a/arch/arc/configs/tb10x_defconfig b/arch/arc/configs/tb10x_defconfig +index f30182549395..0130e29eeca1 100644 +--- a/arch/arc/configs/tb10x_defconfig ++++ b/arch/arc/configs/tb10x_defconfig +@@ -19,6 +19,7 @@ CONFIG_KALLSYMS_ALL=y + # CONFIG_AIO is not set + CONFIG_EMBEDDED=y + # CONFIG_COMPAT_BRK is not set ++CONFIG_ISA_ARCOMPACT=y + CONFIG_SLAB=y + CONFIG_MODULES=y + CONFIG_MODULE_FORCE_LOAD=y +diff --git a/arch/arc/configs/vdk_hs38_defconfig b/arch/arc/configs/vdk_hs38_defconfig +index 4fcf4f2503f6..4587c9af5afe 100644 +--- a/arch/arc/configs/vdk_hs38_defconfig ++++ b/arch/arc/configs/vdk_hs38_defconfig +@@ -88,6 +88,7 @@ CONFIG_NTFS_FS=y + CONFIG_TMPFS=y + CONFIG_JFFS2_FS=y + CONFIG_NFS_FS=y ++CONFIG_NFS_V3_ACL=y + CONFIG_NLS_CODEPAGE_437=y + CONFIG_NLS_ISO8859_1=y + # CONFIG_ENABLE_WARN_DEPRECATED is not set +diff --git a/arch/arc/configs/vdk_hs38_smp_defconfig b/arch/arc/configs/vdk_hs38_smp_defconfig +index 7b71464f6c2f..1855aa995bc9 100644 +--- a/arch/arc/configs/vdk_hs38_smp_defconfig ++++ b/arch/arc/configs/vdk_hs38_smp_defconfig +@@ -92,6 +92,7 @@ CONFIG_NTFS_FS=y + CONFIG_TMPFS=y + CONFIG_JFFS2_FS=y + CONFIG_NFS_FS=y ++CONFIG_NFS_V3_ACL=y + CONFIG_NLS_CODEPAGE_437=y + CONFIG_NLS_ISO8859_1=y + # CONFIG_ENABLE_WARN_DEPRECATED is not set +diff --git a/arch/mips/include/asm/syscall.h b/arch/mips/include/asm/syscall.h +index 7c713025b23f..53ee82b1efa7 100644 +--- a/arch/mips/include/asm/syscall.h ++++ b/arch/mips/include/asm/syscall.h +@@ -51,7 +51,7 @@ static inline unsigned long mips_get_syscall_arg(unsigned long *arg, + #ifdef CONFIG_64BIT + case 4: case 5: case 6: case 7: + #ifdef CONFIG_MIPS32_O32 +- if (test_thread_flag(TIF_32BIT_REGS)) ++ if (test_tsk_thread_flag(task, TIF_32BIT_REGS)) + return get_user(*arg, (int *)usp + n); + else + #endif +diff --git a/arch/mips/ralink/mt7620.c b/arch/mips/ralink/mt7620.c +index 41b71c4352c2..c1ce6f43642b 100644 +--- a/arch/mips/ralink/mt7620.c ++++ b/arch/mips/ralink/mt7620.c +@@ -84,7 +84,7 @@ static struct rt2880_pmx_func pcie_rst_grp[] = { + }; + static struct rt2880_pmx_func nd_sd_grp[] = { + FUNC("nand", MT7620_GPIO_MODE_NAND, 45, 15), +- FUNC("sd", MT7620_GPIO_MODE_SD, 45, 15) ++ FUNC("sd", MT7620_GPIO_MODE_SD, 47, 13) + }; + + static struct rt2880_pmx_group mt7620a_pinmux_data[] = { +diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c +index 17f08db34547..4dc79d139810 100644 +--- a/arch/x86/kvm/svm.c ++++ b/arch/x86/kvm/svm.c +@@ -1399,20 +1399,23 @@ static u64 *avic_get_physical_id_entry(struct kvm_vcpu *vcpu, + static int avic_init_access_page(struct kvm_vcpu *vcpu) + { + struct kvm *kvm = vcpu->kvm; +- int ret; ++ int ret = 0; + ++ mutex_lock(&kvm->slots_lock); + if (kvm->arch.apic_access_page_done) +- return 0; ++ goto out; + +- ret = x86_set_memory_region(kvm, +- APIC_ACCESS_PAGE_PRIVATE_MEMSLOT, +- APIC_DEFAULT_PHYS_BASE, +- PAGE_SIZE); ++ ret = __x86_set_memory_region(kvm, ++ APIC_ACCESS_PAGE_PRIVATE_MEMSLOT, ++ APIC_DEFAULT_PHYS_BASE, ++ PAGE_SIZE); + if (ret) +- return ret; ++ goto out; + + kvm->arch.apic_access_page_done = true; +- return 0; ++out: ++ mutex_unlock(&kvm->slots_lock); ++ return ret; + } + + static int avic_init_backing_page(struct kvm_vcpu *vcpu) +diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c +index dac355812adc..373700c05a00 100644 +--- a/drivers/gpu/drm/ast/ast_main.c ++++ b/drivers/gpu/drm/ast/ast_main.c +@@ -583,7 +583,8 @@ void ast_driver_unload(struct drm_device *dev) + drm_mode_config_cleanup(dev); + + ast_mm_fini(ast); +- pci_iounmap(dev->pdev, ast->ioregs); ++ if (ast->ioregs != ast->regs + AST_IO_MM_OFFSET) ++ pci_iounmap(dev->pdev, ast->ioregs); + pci_iounmap(dev->pdev, ast->regs); + kfree(ast); + } +diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c +index 7ff697389d74..fe85d041d0ba 100644 +--- a/drivers/gpu/drm/drm_auth.c ++++ b/drivers/gpu/drm/drm_auth.c +@@ -133,6 +133,7 @@ static int drm_new_set_master(struct drm_device *dev, struct drm_file *fpriv) + + lockdep_assert_held_once(&dev->master_mutex); + ++ WARN_ON(fpriv->is_master); + old_master = fpriv->master; + fpriv->master = drm_master_create(dev); + if (!fpriv->master) { +@@ -161,6 +162,7 @@ out_err: + /* drop references and restore old master on failure */ + drm_master_put(&fpriv->master); + fpriv->master = old_master; ++ fpriv->is_master = 0; + + return ret; + } +diff --git a/drivers/gpu/drm/gma500/mdfld_intel_display.c b/drivers/gpu/drm/gma500/mdfld_intel_display.c +index 531e4450c000..5c066448be5b 100644 +--- a/drivers/gpu/drm/gma500/mdfld_intel_display.c ++++ b/drivers/gpu/drm/gma500/mdfld_intel_display.c +@@ -99,7 +99,7 @@ void mdfldWaitForPipeEnable(struct drm_device *dev, int pipe) + /* Wait for for the pipe enable to take effect. */ + for (count = 0; count < COUNT_MAX; count++) { + temp = REG_READ(map->conf); +- if ((temp & PIPEACONF_PIPE_STATE) == 1) ++ if (temp & PIPEACONF_PIPE_STATE) + break; + } + } +diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c +index cef414466f9f..e5f7a7cf48fa 100644 +--- a/drivers/gpu/drm/meson/meson_dw_hdmi.c ++++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c +@@ -697,6 +697,7 @@ static const struct regmap_config meson_dw_hdmi_regmap_config = { + .reg_read = meson_dw_hdmi_reg_read, + .reg_write = meson_dw_hdmi_reg_write, + .max_register = 0x10000, ++ .fast_io = true, + }; + + static bool meson_hdmi_connector_is_available(struct device *dev) +diff --git a/drivers/gpu/drm/meson/meson_viu.c b/drivers/gpu/drm/meson/meson_viu.c +index 6bcfa527c180..26a0857878bf 100644 +--- a/drivers/gpu/drm/meson/meson_viu.c ++++ b/drivers/gpu/drm/meson/meson_viu.c +@@ -184,18 +184,18 @@ void meson_viu_set_osd_lut(struct meson_drm *priv, enum viu_lut_sel_e lut_sel, + if (lut_sel == VIU_LUT_OSD_OETF) { + writel(0, priv->io_base + _REG(addr_port)); + +- for (i = 0; i < 20; i++) ++ for (i = 0; i < (OSD_OETF_LUT_SIZE / 2); i++) + writel(r_map[i * 2] | (r_map[i * 2 + 1] << 16), + priv->io_base + _REG(data_port)); + + writel(r_map[OSD_OETF_LUT_SIZE - 1] | (g_map[0] << 16), + priv->io_base + _REG(data_port)); + +- for (i = 0; i < 20; i++) ++ for (i = 0; i < (OSD_OETF_LUT_SIZE / 2); i++) + writel(g_map[i * 2 + 1] | (g_map[i * 2 + 2] << 16), + priv->io_base + _REG(data_port)); + +- for (i = 0; i < 20; i++) ++ for (i = 0; i < (OSD_OETF_LUT_SIZE / 2); i++) + writel(b_map[i * 2] | (b_map[i * 2 + 1] << 16), + priv->io_base + _REG(data_port)); + +@@ -211,18 +211,18 @@ void meson_viu_set_osd_lut(struct meson_drm *priv, enum viu_lut_sel_e lut_sel, + } else if (lut_sel == VIU_LUT_OSD_EOTF) { + writel(0, priv->io_base + _REG(addr_port)); + +- for (i = 0; i < 20; i++) ++ for (i = 0; i < (OSD_EOTF_LUT_SIZE / 2); i++) + writel(r_map[i * 2] | (r_map[i * 2 + 1] << 16), + priv->io_base + _REG(data_port)); + + writel(r_map[OSD_EOTF_LUT_SIZE - 1] | (g_map[0] << 16), + priv->io_base + _REG(data_port)); + +- for (i = 0; i < 20; i++) ++ for (i = 0; i < (OSD_EOTF_LUT_SIZE / 2); i++) + writel(g_map[i * 2 + 1] | (g_map[i * 2 + 2] << 16), + priv->io_base + _REG(data_port)); + +- for (i = 0; i < 20; i++) ++ for (i = 0; i < (OSD_EOTF_LUT_SIZE / 2); i++) + writel(b_map[i * 2] | (b_map[i * 2 + 1] << 16), + priv->io_base + _REG(data_port)); + +diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c +index c75c4df4bc39..2c379774d3f2 100644 +--- a/drivers/gpu/drm/msm/adreno/adreno_device.c ++++ b/drivers/gpu/drm/msm/adreno/adreno_device.c +@@ -223,8 +223,7 @@ static int adreno_get_legacy_pwrlevels(struct device *dev) + struct device_node *child, *node; + int ret; + +- node = of_find_compatible_node(dev->of_node, NULL, +- "qcom,gpu-pwrlevels"); ++ node = of_get_compatible_child(dev->of_node, "qcom,gpu-pwrlevels"); + if (!node) { + dev_err(dev, "Could not find the GPU powerlevels\n"); + return -ENXIO; +@@ -245,6 +244,8 @@ static int adreno_get_legacy_pwrlevels(struct device *dev) + dev_pm_opp_add(dev, val, 0); + } + ++ of_node_put(node); ++ + return 0; + } + +diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c +index c3a4f5d92391..13a92062e9ca 100644 +--- a/drivers/infiniband/hw/mlx5/main.c ++++ b/drivers/infiniband/hw/mlx5/main.c +@@ -869,31 +869,26 @@ enum mlx5_ib_width { + MLX5_IB_WIDTH_12X = 1 << 4 + }; + +-static int translate_active_width(struct ib_device *ibdev, u8 active_width, ++static void translate_active_width(struct ib_device *ibdev, u8 active_width, + u8 *ib_width) + { + struct mlx5_ib_dev *dev = to_mdev(ibdev); +- int err = 0; + +- if (active_width & MLX5_IB_WIDTH_1X) { ++ if (active_width & MLX5_IB_WIDTH_1X) + *ib_width = IB_WIDTH_1X; +- } else if (active_width & MLX5_IB_WIDTH_2X) { +- mlx5_ib_dbg(dev, "active_width %d is not supported by IB spec\n", +- (int)active_width); +- err = -EINVAL; +- } else if (active_width & MLX5_IB_WIDTH_4X) { ++ else if (active_width & MLX5_IB_WIDTH_4X) + *ib_width = IB_WIDTH_4X; +- } else if (active_width & MLX5_IB_WIDTH_8X) { ++ else if (active_width & MLX5_IB_WIDTH_8X) + *ib_width = IB_WIDTH_8X; +- } else if (active_width & MLX5_IB_WIDTH_12X) { ++ else if (active_width & MLX5_IB_WIDTH_12X) + *ib_width = IB_WIDTH_12X; +- } else { +- mlx5_ib_dbg(dev, "Invalid active_width %d\n", ++ else { ++ mlx5_ib_dbg(dev, "Invalid active_width %d, setting width to default value: 4x\n", + (int)active_width); +- err = -EINVAL; ++ *ib_width = IB_WIDTH_4X; + } + +- return err; ++ return; + } + + static int mlx5_mtu_to_ib_mtu(int mtu) +@@ -1001,10 +996,8 @@ static int mlx5_query_hca_port(struct ib_device *ibdev, u8 port, + if (err) + goto out; + +- err = translate_active_width(ibdev, ib_link_width_oper, +- &props->active_width); +- if (err) +- goto out; ++ translate_active_width(ibdev, ib_link_width_oper, &props->active_width); ++ + err = mlx5_query_port_ib_proto_oper(mdev, &props->active_speed, port); + if (err) + goto out; +diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c +index 55a73b0ed4c6..e28a5d713d1a 100644 +--- a/drivers/infiniband/ulp/iser/iser_verbs.c ++++ b/drivers/infiniband/ulp/iser/iser_verbs.c +@@ -1108,7 +1108,9 @@ u8 iser_check_task_pi_status(struct iscsi_iser_task *iser_task, + IB_MR_CHECK_SIG_STATUS, &mr_status); + if (ret) { + pr_err("ib_check_mr_status failed, ret %d\n", ret); +- goto err; ++ /* Not a lot we can do, return ambiguous guard error */ ++ *sector = 0; ++ return 0x1; + } + + if (mr_status.fail_status & IB_MR_CHECK_SIG_STATUS) { +@@ -1136,9 +1138,6 @@ u8 iser_check_task_pi_status(struct iscsi_iser_task *iser_task, + } + + return 0; +-err: +- /* Not alot we can do here, return ambiguous guard error */ +- return 0x1; + } + + void iser_err_comp(struct ib_wc *wc, const char *type) +diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c +index 2e52015634f9..f55dcdf99bc5 100644 +--- a/drivers/input/joystick/xpad.c ++++ b/drivers/input/joystick/xpad.c +@@ -483,18 +483,18 @@ static const u8 xboxone_hori_init[] = { + }; + + /* +- * This packet is required for some of the PDP pads to start ++ * This packet is required for most (all?) of the PDP pads to start + * sending input reports. These pads include: (0x0e6f:0x02ab), +- * (0x0e6f:0x02a4). ++ * (0x0e6f:0x02a4), (0x0e6f:0x02a6). + */ + static const u8 xboxone_pdp_init1[] = { + 0x0a, 0x20, 0x00, 0x03, 0x00, 0x01, 0x14 + }; + + /* +- * This packet is required for some of the PDP pads to start ++ * This packet is required for most (all?) of the PDP pads to start + * sending input reports. These pads include: (0x0e6f:0x02ab), +- * (0x0e6f:0x02a4). ++ * (0x0e6f:0x02a4), (0x0e6f:0x02a6). + */ + static const u8 xboxone_pdp_init2[] = { + 0x06, 0x20, 0x00, 0x02, 0x01, 0x00 +@@ -530,12 +530,8 @@ static const struct xboxone_init_packet xboxone_init_packets[] = { + XBOXONE_INIT_PKT(0x0e6f, 0x0165, xboxone_hori_init), + XBOXONE_INIT_PKT(0x0f0d, 0x0067, xboxone_hori_init), + XBOXONE_INIT_PKT(0x0000, 0x0000, xboxone_fw2015_init), +- XBOXONE_INIT_PKT(0x0e6f, 0x02ab, xboxone_pdp_init1), +- XBOXONE_INIT_PKT(0x0e6f, 0x02ab, xboxone_pdp_init2), +- XBOXONE_INIT_PKT(0x0e6f, 0x02a4, xboxone_pdp_init1), +- XBOXONE_INIT_PKT(0x0e6f, 0x02a4, xboxone_pdp_init2), +- XBOXONE_INIT_PKT(0x0e6f, 0x02a6, xboxone_pdp_init1), +- XBOXONE_INIT_PKT(0x0e6f, 0x02a6, xboxone_pdp_init2), ++ XBOXONE_INIT_PKT(0x0e6f, 0x0000, xboxone_pdp_init1), ++ XBOXONE_INIT_PKT(0x0e6f, 0x0000, xboxone_pdp_init2), + XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_rumblebegin_init), + XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_rumblebegin_init), + XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_rumblebegin_init), +diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c +index 79eb29550c34..0993b3f12df6 100644 +--- a/drivers/input/keyboard/cros_ec_keyb.c ++++ b/drivers/input/keyboard/cros_ec_keyb.c +@@ -506,7 +506,8 @@ static int cros_ec_keyb_register_bs(struct cros_ec_keyb *ckdev) + for (i = 0; i < ARRAY_SIZE(cros_ec_keyb_bs); i++) { + const struct cros_ec_bs_map *map = &cros_ec_keyb_bs[i]; + +- if (buttons & BIT(map->bit)) ++ if ((map->ev_type == EV_KEY && (buttons & BIT(map->bit))) || ++ (map->ev_type == EV_SW && (switches & BIT(map->bit)))) + input_set_capability(idev, map->ev_type, map->code); + } + +diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c +index 41614c185918..782dda68d93a 100644 +--- a/drivers/input/keyboard/matrix_keypad.c ++++ b/drivers/input/keyboard/matrix_keypad.c +@@ -407,7 +407,7 @@ matrix_keypad_parse_dt(struct device *dev) + struct matrix_keypad_platform_data *pdata; + struct device_node *np = dev->of_node; + unsigned int *gpios; +- int i, nrow, ncol; ++ int ret, i, nrow, ncol; + + if (!np) { + dev_err(dev, "device lacks DT data\n"); +@@ -452,12 +452,19 @@ matrix_keypad_parse_dt(struct device *dev) + return ERR_PTR(-ENOMEM); + } + +- for (i = 0; i < pdata->num_row_gpios; i++) +- gpios[i] = of_get_named_gpio(np, "row-gpios", i); ++ for (i = 0; i < nrow; i++) { ++ ret = of_get_named_gpio(np, "row-gpios", i); ++ if (ret < 0) ++ return ERR_PTR(ret); ++ gpios[i] = ret; ++ } + +- for (i = 0; i < pdata->num_col_gpios; i++) +- gpios[pdata->num_row_gpios + i] = +- of_get_named_gpio(np, "col-gpios", i); ++ for (i = 0; i < ncol; i++) { ++ ret = of_get_named_gpio(np, "col-gpios", i); ++ if (ret < 0) ++ return ERR_PTR(ret); ++ gpios[nrow + i] = ret; ++ } + + pdata->row_gpios = gpios; + pdata->col_gpios = &gpios[pdata->num_row_gpios]; +@@ -484,10 +491,8 @@ static int matrix_keypad_probe(struct platform_device *pdev) + pdata = dev_get_platdata(&pdev->dev); + if (!pdata) { + pdata = matrix_keypad_parse_dt(&pdev->dev); +- if (IS_ERR(pdata)) { +- dev_err(&pdev->dev, "no platform data defined\n"); ++ if (IS_ERR(pdata)) + return PTR_ERR(pdata); +- } + } else if (!pdata->keymap_data) { + dev_err(&pdev->dev, "no keymap data defined\n"); + return -EINVAL; +diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c +index 766d30a7b085..368871a398a5 100644 +--- a/drivers/input/mouse/elan_i2c_core.c ++++ b/drivers/input/mouse/elan_i2c_core.c +@@ -1264,6 +1264,9 @@ static const struct acpi_device_id elan_acpi_id[] = { + { "ELAN0618", 0 }, + { "ELAN061C", 0 }, + { "ELAN061D", 0 }, ++ { "ELAN061E", 0 }, ++ { "ELAN0620", 0 }, ++ { "ELAN0621", 0 }, + { "ELAN0622", 0 }, + { "ELAN1000", 0 }, + { } +diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c +index 6f36e2d01e2e..65c9095eb517 100644 +--- a/drivers/input/mouse/synaptics.c ++++ b/drivers/input/mouse/synaptics.c +@@ -170,6 +170,7 @@ static const char * const smbus_pnp_ids[] = { + "LEN0048", /* X1 Carbon 3 */ + "LEN0046", /* X250 */ + "LEN004a", /* W541 */ ++ "LEN005b", /* P50 */ + "LEN0071", /* T480 */ + "LEN0072", /* X1 Carbon Gen 5 (2017) - Elan/ALPS trackpoint */ + "LEN0073", /* X1 Carbon G5 (Elantech) */ +diff --git a/drivers/net/ethernet/qlogic/qed/qed_debug.c b/drivers/net/ethernet/qlogic/qed/qed_debug.c +index 03c3cf77aaff..99f32202a85c 100644 +--- a/drivers/net/ethernet/qlogic/qed/qed_debug.c ++++ b/drivers/net/ethernet/qlogic/qed/qed_debug.c +@@ -3590,10 +3590,8 @@ static u32 qed_grc_dump_big_ram(struct qed_hwfn *p_hwfn, + total_blocks = big_ram->num_of_blocks[dev_data->chip_id]; + ram_size = total_blocks * BIG_RAM_BLOCK_SIZE_DWORDS; + +- strncpy(type_name, big_ram->instance_name, +- strlen(big_ram->instance_name)); +- strncpy(mem_name, big_ram->instance_name, +- strlen(big_ram->instance_name)); ++ strscpy(type_name, big_ram->instance_name, sizeof(type_name)); ++ strscpy(mem_name, big_ram->instance_name, sizeof(mem_name)); + + /* Dump memory header */ + offset += qed_grc_dump_mem_hdr(p_hwfn, +diff --git a/drivers/reset/core.c b/drivers/reset/core.c +index 1d21c6f7d56c..da4292e9de97 100644 +--- a/drivers/reset/core.c ++++ b/drivers/reset/core.c +@@ -566,17 +566,18 @@ EXPORT_SYMBOL_GPL(__devm_reset_control_get); + * device_reset - find reset controller associated with the device + * and perform reset + * @dev: device to be reset by the controller ++ * @optional: whether it is optional to reset the device + * +- * Convenience wrapper for reset_control_get() and reset_control_reset(). ++ * Convenience wrapper for __reset_control_get() and reset_control_reset(). + * This is useful for the common case of devices with single, dedicated reset + * lines. + */ +-int device_reset(struct device *dev) ++int __device_reset(struct device *dev, bool optional) + { + struct reset_control *rstc; + int ret; + +- rstc = reset_control_get(dev, NULL); ++ rstc = __reset_control_get(dev, NULL, 0, 0, optional); + if (IS_ERR(rstc)) + return PTR_ERR(rstc); + +@@ -586,7 +587,7 @@ int device_reset(struct device *dev) + + return ret; + } +-EXPORT_SYMBOL_GPL(device_reset); ++EXPORT_SYMBOL_GPL(__device_reset); + + /** + * APIs to manage an array of reset controls. +diff --git a/drivers/scsi/bfa/bfa_fcbuild.c b/drivers/scsi/bfa/bfa_fcbuild.c +index b8dadc9cc993..d3b00a475aeb 100644 +--- a/drivers/scsi/bfa/bfa_fcbuild.c ++++ b/drivers/scsi/bfa/bfa_fcbuild.c +@@ -1250,8 +1250,8 @@ fc_rspnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id, + memset(rspnid, 0, sizeof(struct fcgs_rspnid_req_s)); + + rspnid->dap = s_id; +- rspnid->spn_len = (u8) strlen((char *)name); +- strncpy((char *)rspnid->spn, (char *)name, rspnid->spn_len); ++ strlcpy(rspnid->spn, name, sizeof(rspnid->spn)); ++ rspnid->spn_len = (u8) strlen(rspnid->spn); + + return sizeof(struct fcgs_rspnid_req_s) + sizeof(struct ct_hdr_s); + } +@@ -1271,8 +1271,8 @@ fc_rsnn_nn_build(struct fchs_s *fchs, void *pyld, u32 s_id, + memset(rsnn_nn, 0, sizeof(struct fcgs_rsnn_nn_req_s)); + + rsnn_nn->node_name = node_name; +- rsnn_nn->snn_len = (u8) strlen((char *)name); +- strncpy((char *)rsnn_nn->snn, (char *)name, rsnn_nn->snn_len); ++ strlcpy(rsnn_nn->snn, name, sizeof(rsnn_nn->snn)); ++ rsnn_nn->snn_len = (u8) strlen(rsnn_nn->snn); + + return sizeof(struct fcgs_rsnn_nn_req_s) + sizeof(struct ct_hdr_s); + } +diff --git a/drivers/scsi/bfa/bfa_fcs.c b/drivers/scsi/bfa/bfa_fcs.c +index 4aa61e20e82d..932feb0ed4da 100644 +--- a/drivers/scsi/bfa/bfa_fcs.c ++++ b/drivers/scsi/bfa/bfa_fcs.c +@@ -769,23 +769,23 @@ bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric) + bfa_ioc_get_adapter_model(&fabric->fcs->bfa->ioc, model); + + /* Model name/number */ +- strncpy((char *)&port_cfg->sym_name, model, +- BFA_FCS_PORT_SYMBNAME_MODEL_SZ); +- strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR, +- sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); ++ strlcpy(port_cfg->sym_name.symname, model, ++ BFA_SYMNAME_MAXLEN); ++ strlcat(port_cfg->sym_name.symname, BFA_FCS_PORT_SYMBNAME_SEPARATOR, ++ BFA_SYMNAME_MAXLEN); + + /* Driver Version */ +- strncat((char *)&port_cfg->sym_name, (char *)driver_info->version, +- BFA_FCS_PORT_SYMBNAME_VERSION_SZ); +- strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR, +- sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); ++ strlcat(port_cfg->sym_name.symname, driver_info->version, ++ BFA_SYMNAME_MAXLEN); ++ strlcat(port_cfg->sym_name.symname, BFA_FCS_PORT_SYMBNAME_SEPARATOR, ++ BFA_SYMNAME_MAXLEN); + + /* Host machine name */ +- strncat((char *)&port_cfg->sym_name, +- (char *)driver_info->host_machine_name, +- BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ); +- strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR, +- sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); ++ strlcat(port_cfg->sym_name.symname, ++ driver_info->host_machine_name, ++ BFA_SYMNAME_MAXLEN); ++ strlcat(port_cfg->sym_name.symname, BFA_FCS_PORT_SYMBNAME_SEPARATOR, ++ BFA_SYMNAME_MAXLEN); + + /* + * Host OS Info : +@@ -793,24 +793,24 @@ bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric) + * OS name string and instead copy the entire OS info string (64 bytes). + */ + if (driver_info->host_os_patch[0] == '\0') { +- strncat((char *)&port_cfg->sym_name, +- (char *)driver_info->host_os_name, +- BFA_FCS_OS_STR_LEN); +- strncat((char *)&port_cfg->sym_name, ++ strlcat(port_cfg->sym_name.symname, ++ driver_info->host_os_name, ++ BFA_SYMNAME_MAXLEN); ++ strlcat(port_cfg->sym_name.symname, + BFA_FCS_PORT_SYMBNAME_SEPARATOR, +- sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); ++ BFA_SYMNAME_MAXLEN); + } else { +- strncat((char *)&port_cfg->sym_name, +- (char *)driver_info->host_os_name, +- BFA_FCS_PORT_SYMBNAME_OSINFO_SZ); +- strncat((char *)&port_cfg->sym_name, ++ strlcat(port_cfg->sym_name.symname, ++ driver_info->host_os_name, ++ BFA_SYMNAME_MAXLEN); ++ strlcat(port_cfg->sym_name.symname, + BFA_FCS_PORT_SYMBNAME_SEPARATOR, +- sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); ++ BFA_SYMNAME_MAXLEN); + + /* Append host OS Patch Info */ +- strncat((char *)&port_cfg->sym_name, +- (char *)driver_info->host_os_patch, +- BFA_FCS_PORT_SYMBNAME_OSPATCH_SZ); ++ strlcat(port_cfg->sym_name.symname, ++ driver_info->host_os_patch, ++ BFA_SYMNAME_MAXLEN); + } + + /* null terminate */ +@@ -830,26 +830,26 @@ bfa_fcs_fabric_nsymb_init(struct bfa_fcs_fabric_s *fabric) + bfa_ioc_get_adapter_model(&fabric->fcs->bfa->ioc, model); + + /* Model name/number */ +- strncpy((char *)&port_cfg->node_sym_name, model, +- BFA_FCS_PORT_SYMBNAME_MODEL_SZ); +- strncat((char *)&port_cfg->node_sym_name, ++ strlcpy(port_cfg->node_sym_name.symname, model, ++ BFA_SYMNAME_MAXLEN); ++ strlcat(port_cfg->node_sym_name.symname, + BFA_FCS_PORT_SYMBNAME_SEPARATOR, +- sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); ++ BFA_SYMNAME_MAXLEN); + + /* Driver Version */ +- strncat((char *)&port_cfg->node_sym_name, (char *)driver_info->version, +- BFA_FCS_PORT_SYMBNAME_VERSION_SZ); +- strncat((char *)&port_cfg->node_sym_name, ++ strlcat(port_cfg->node_sym_name.symname, (char *)driver_info->version, ++ BFA_SYMNAME_MAXLEN); ++ strlcat(port_cfg->node_sym_name.symname, + BFA_FCS_PORT_SYMBNAME_SEPARATOR, +- sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); ++ BFA_SYMNAME_MAXLEN); + + /* Host machine name */ +- strncat((char *)&port_cfg->node_sym_name, +- (char *)driver_info->host_machine_name, +- BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ); +- strncat((char *)&port_cfg->node_sym_name, ++ strlcat(port_cfg->node_sym_name.symname, ++ driver_info->host_machine_name, ++ BFA_SYMNAME_MAXLEN); ++ strlcat(port_cfg->node_sym_name.symname, + BFA_FCS_PORT_SYMBNAME_SEPARATOR, +- sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); ++ BFA_SYMNAME_MAXLEN); + + /* null terminate */ + port_cfg->node_sym_name.symname[BFA_SYMNAME_MAXLEN - 1] = 0; +diff --git a/drivers/scsi/bfa/bfa_fcs_lport.c b/drivers/scsi/bfa/bfa_fcs_lport.c +index 638c0a2857f7..b4f2c1d8742e 100644 +--- a/drivers/scsi/bfa/bfa_fcs_lport.c ++++ b/drivers/scsi/bfa/bfa_fcs_lport.c +@@ -2642,10 +2642,10 @@ bfa_fcs_fdmi_get_hbaattr(struct bfa_fcs_lport_fdmi_s *fdmi, + bfa_ioc_get_adapter_fw_ver(&port->fcs->bfa->ioc, + hba_attr->fw_version); + +- strncpy(hba_attr->driver_version, (char *)driver_info->version, ++ strlcpy(hba_attr->driver_version, (char *)driver_info->version, + sizeof(hba_attr->driver_version)); + +- strncpy(hba_attr->os_name, driver_info->host_os_name, ++ strlcpy(hba_attr->os_name, driver_info->host_os_name, + sizeof(hba_attr->os_name)); + + /* +@@ -2653,23 +2653,23 @@ bfa_fcs_fdmi_get_hbaattr(struct bfa_fcs_lport_fdmi_s *fdmi, + * to the os name along with a separator + */ + if (driver_info->host_os_patch[0] != '\0') { +- strncat(hba_attr->os_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR, +- sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR)); +- strncat(hba_attr->os_name, driver_info->host_os_patch, +- sizeof(driver_info->host_os_patch)); ++ strlcat(hba_attr->os_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR, ++ sizeof(hba_attr->os_name)); ++ strlcat(hba_attr->os_name, driver_info->host_os_patch, ++ sizeof(hba_attr->os_name)); + } + + /* Retrieve the max frame size from the port attr */ + bfa_fcs_fdmi_get_portattr(fdmi, &fcs_port_attr); + hba_attr->max_ct_pyld = fcs_port_attr.max_frm_size; + +- strncpy(hba_attr->node_sym_name.symname, ++ strlcpy(hba_attr->node_sym_name.symname, + port->port_cfg.node_sym_name.symname, BFA_SYMNAME_MAXLEN); + strcpy(hba_attr->vendor_info, "QLogic"); + hba_attr->num_ports = + cpu_to_be32(bfa_ioc_get_nports(&port->fcs->bfa->ioc)); + hba_attr->fabric_name = port->fabric->lps->pr_nwwn; +- strncpy(hba_attr->bios_ver, hba_attr->option_rom_ver, BFA_VERSION_LEN); ++ strlcpy(hba_attr->bios_ver, hba_attr->option_rom_ver, BFA_VERSION_LEN); + + } + +@@ -2736,20 +2736,20 @@ bfa_fcs_fdmi_get_portattr(struct bfa_fcs_lport_fdmi_s *fdmi, + /* + * OS device Name + */ +- strncpy(port_attr->os_device_name, (char *)driver_info->os_device_name, ++ strlcpy(port_attr->os_device_name, driver_info->os_device_name, + sizeof(port_attr->os_device_name)); + + /* + * Host name + */ +- strncpy(port_attr->host_name, (char *)driver_info->host_machine_name, ++ strlcpy(port_attr->host_name, driver_info->host_machine_name, + sizeof(port_attr->host_name)); + + port_attr->node_name = bfa_fcs_lport_get_nwwn(port); + port_attr->port_name = bfa_fcs_lport_get_pwwn(port); + +- strncpy(port_attr->port_sym_name.symname, +- (char *)&bfa_fcs_lport_get_psym_name(port), BFA_SYMNAME_MAXLEN); ++ strlcpy(port_attr->port_sym_name.symname, ++ bfa_fcs_lport_get_psym_name(port).symname, BFA_SYMNAME_MAXLEN); + bfa_fcs_lport_get_attr(port, &lport_attr); + port_attr->port_type = cpu_to_be32(lport_attr.port_type); + port_attr->scos = pport_attr.cos_supported; +@@ -3229,7 +3229,7 @@ bfa_fcs_lport_ms_gmal_response(void *fcsarg, struct bfa_fcxp_s *fcxp, + rsp_str[gmal_entry->len-1] = 0; + + /* copy IP Address to fabric */ +- strncpy(bfa_fcs_lport_get_fabric_ipaddr(port), ++ strlcpy(bfa_fcs_lport_get_fabric_ipaddr(port), + gmal_entry->ip_addr, + BFA_FCS_FABRIC_IPADDR_SZ); + break; +@@ -4667,21 +4667,13 @@ bfa_fcs_lport_ns_send_rspn_id(void *ns_cbarg, struct bfa_fcxp_s *fcxp_alloced) + * to that of the base port. + */ + +- strncpy((char *)psymbl, +- (char *) & +- (bfa_fcs_lport_get_psym_name ++ strlcpy(symbl, ++ (char *)&(bfa_fcs_lport_get_psym_name + (bfa_fcs_get_base_port(port->fcs))), +- strlen((char *) & +- bfa_fcs_lport_get_psym_name(bfa_fcs_get_base_port +- (port->fcs)))); +- +- /* Ensure we have a null terminating string. */ +- ((char *)psymbl)[strlen((char *) & +- bfa_fcs_lport_get_psym_name(bfa_fcs_get_base_port +- (port->fcs)))] = 0; +- strncat((char *)psymbl, +- (char *) &(bfa_fcs_lport_get_psym_name(port)), +- strlen((char *) &bfa_fcs_lport_get_psym_name(port))); ++ sizeof(symbl)); ++ ++ strlcat(symbl, (char *)&(bfa_fcs_lport_get_psym_name(port)), ++ sizeof(symbl)); + } else { + psymbl = (u8 *) &(bfa_fcs_lport_get_psym_name(port)); + } +@@ -5173,7 +5165,6 @@ bfa_fcs_lport_ns_util_send_rspn_id(void *cbarg, struct bfa_fcxp_s *fcxp_alloced) + struct fchs_s fchs; + struct bfa_fcxp_s *fcxp; + u8 symbl[256]; +- u8 *psymbl = &symbl[0]; + int len; + + /* Avoid sending RSPN in the following states. */ +@@ -5203,22 +5194,17 @@ bfa_fcs_lport_ns_util_send_rspn_id(void *cbarg, struct bfa_fcxp_s *fcxp_alloced) + * For Vports, we append the vport's port symbolic name + * to that of the base port. + */ +- strncpy((char *)psymbl, (char *)&(bfa_fcs_lport_get_psym_name ++ strlcpy(symbl, (char *)&(bfa_fcs_lport_get_psym_name + (bfa_fcs_get_base_port(port->fcs))), +- strlen((char *)&bfa_fcs_lport_get_psym_name( +- bfa_fcs_get_base_port(port->fcs)))); +- +- /* Ensure we have a null terminating string. */ +- ((char *)psymbl)[strlen((char *)&bfa_fcs_lport_get_psym_name( +- bfa_fcs_get_base_port(port->fcs)))] = 0; ++ sizeof(symbl)); + +- strncat((char *)psymbl, ++ strlcat(symbl, + (char *)&(bfa_fcs_lport_get_psym_name(port)), +- strlen((char *)&bfa_fcs_lport_get_psym_name(port))); ++ sizeof(symbl)); + } + + len = fc_rspnid_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), +- bfa_fcs_lport_get_fcid(port), 0, psymbl); ++ bfa_fcs_lport_get_fcid(port), 0, symbl); + + bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE, + FC_CLASS_3, len, &fchs, NULL, NULL, FC_MAX_PDUSZ, 0); +diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c +index 256f4afaccf9..a1a183ece093 100644 +--- a/drivers/scsi/bfa/bfa_ioc.c ++++ b/drivers/scsi/bfa/bfa_ioc.c +@@ -2803,7 +2803,7 @@ void + bfa_ioc_get_adapter_manufacturer(struct bfa_ioc_s *ioc, char *manufacturer) + { + memset((void *)manufacturer, 0, BFA_ADAPTER_MFG_NAME_LEN); +- strncpy(manufacturer, BFA_MFG_NAME, BFA_ADAPTER_MFG_NAME_LEN); ++ strlcpy(manufacturer, BFA_MFG_NAME, BFA_ADAPTER_MFG_NAME_LEN); + } + + void +diff --git a/drivers/scsi/bfa/bfa_svc.c b/drivers/scsi/bfa/bfa_svc.c +index e640223bab3c..7356fdec79f5 100644 +--- a/drivers/scsi/bfa/bfa_svc.c ++++ b/drivers/scsi/bfa/bfa_svc.c +@@ -350,8 +350,8 @@ bfa_plog_str(struct bfa_plog_s *plog, enum bfa_plog_mid mid, + lp.eid = event; + lp.log_type = BFA_PL_LOG_TYPE_STRING; + lp.misc = misc; +- strncpy(lp.log_entry.string_log, log_str, +- BFA_PL_STRING_LOG_SZ - 1); ++ strlcpy(lp.log_entry.string_log, log_str, ++ BFA_PL_STRING_LOG_SZ); + lp.log_entry.string_log[BFA_PL_STRING_LOG_SZ - 1] = '\0'; + bfa_plog_add(plog, &lp); + } +diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c +index 5caf5f3ff642..ae37010af50f 100644 +--- a/drivers/scsi/bfa/bfad.c ++++ b/drivers/scsi/bfa/bfad.c +@@ -983,20 +983,20 @@ bfad_start_ops(struct bfad_s *bfad) { + + /* Fill the driver_info info to fcs*/ + memset(&driver_info, 0, sizeof(driver_info)); +- strncpy(driver_info.version, BFAD_DRIVER_VERSION, +- sizeof(driver_info.version) - 1); ++ strlcpy(driver_info.version, BFAD_DRIVER_VERSION, ++ sizeof(driver_info.version)); + if (host_name) +- strncpy(driver_info.host_machine_name, host_name, +- sizeof(driver_info.host_machine_name) - 1); ++ strlcpy(driver_info.host_machine_name, host_name, ++ sizeof(driver_info.host_machine_name)); + if (os_name) +- strncpy(driver_info.host_os_name, os_name, +- sizeof(driver_info.host_os_name) - 1); ++ strlcpy(driver_info.host_os_name, os_name, ++ sizeof(driver_info.host_os_name)); + if (os_patch) +- strncpy(driver_info.host_os_patch, os_patch, +- sizeof(driver_info.host_os_patch) - 1); ++ strlcpy(driver_info.host_os_patch, os_patch, ++ sizeof(driver_info.host_os_patch)); + +- strncpy(driver_info.os_device_name, bfad->pci_name, +- sizeof(driver_info.os_device_name) - 1); ++ strlcpy(driver_info.os_device_name, bfad->pci_name, ++ sizeof(driver_info.os_device_name)); + + /* FCS driver info init */ + spin_lock_irqsave(&bfad->bfad_lock, flags); +diff --git a/drivers/scsi/bfa/bfad_attr.c b/drivers/scsi/bfa/bfad_attr.c +index 13db3b7bc873..d0a504af5b4f 100644 +--- a/drivers/scsi/bfa/bfad_attr.c ++++ b/drivers/scsi/bfa/bfad_attr.c +@@ -843,7 +843,7 @@ bfad_im_symbolic_name_show(struct device *dev, struct device_attribute *attr, + char symname[BFA_SYMNAME_MAXLEN]; + + bfa_fcs_lport_get_attr(&bfad->bfa_fcs.fabric.bport, &port_attr); +- strncpy(symname, port_attr.port_cfg.sym_name.symname, ++ strlcpy(symname, port_attr.port_cfg.sym_name.symname, + BFA_SYMNAME_MAXLEN); + return snprintf(buf, PAGE_SIZE, "%s\n", symname); + } +diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c +index 1aa46d0763a0..9081a5f93aae 100644 +--- a/drivers/scsi/bfa/bfad_bsg.c ++++ b/drivers/scsi/bfa/bfad_bsg.c +@@ -127,7 +127,7 @@ bfad_iocmd_ioc_get_attr(struct bfad_s *bfad, void *cmd) + + /* fill in driver attr info */ + strcpy(iocmd->ioc_attr.driver_attr.driver, BFAD_DRIVER_NAME); +- strncpy(iocmd->ioc_attr.driver_attr.driver_ver, ++ strlcpy(iocmd->ioc_attr.driver_attr.driver_ver, + BFAD_DRIVER_VERSION, BFA_VERSION_LEN); + strcpy(iocmd->ioc_attr.driver_attr.fw_ver, + iocmd->ioc_attr.adapter_attr.fw_ver); +@@ -315,9 +315,9 @@ bfad_iocmd_port_get_attr(struct bfad_s *bfad, void *cmd) + iocmd->attr.port_type = port_attr.port_type; + iocmd->attr.loopback = port_attr.loopback; + iocmd->attr.authfail = port_attr.authfail; +- strncpy(iocmd->attr.port_symname.symname, ++ strlcpy(iocmd->attr.port_symname.symname, + port_attr.port_cfg.sym_name.symname, +- sizeof(port_attr.port_cfg.sym_name.symname)); ++ sizeof(iocmd->attr.port_symname.symname)); + + iocmd->status = BFA_STATUS_OK; + return 0; +diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c +index ea947a7c2596..6b594bc7d94a 100644 +--- a/drivers/scsi/scsi_devinfo.c ++++ b/drivers/scsi/scsi_devinfo.c +@@ -34,7 +34,6 @@ struct scsi_dev_info_list_table { + }; + + +-static const char spaces[] = " "; /* 16 of them */ + static unsigned scsi_default_dev_flags; + static LIST_HEAD(scsi_dev_info_list); + static char scsi_dev_flags[256]; +@@ -296,20 +295,13 @@ static void scsi_strcpy_devinfo(char *name, char *to, size_t to_length, + size_t from_length; + + from_length = strlen(from); +- strncpy(to, from, min(to_length, from_length)); +- if (from_length < to_length) { +- if (compatible) { +- /* +- * NUL terminate the string if it is short. +- */ +- to[from_length] = '\0'; +- } else { +- /* +- * space pad the string if it is short. +- */ +- strncpy(&to[from_length], spaces, +- to_length - from_length); +- } ++ /* this zero-pads the destination */ ++ strncpy(to, from, to_length); ++ if (from_length < to_length && !compatible) { ++ /* ++ * space pad the string if it is short. ++ */ ++ memset(&to[from_length], ' ', to_length - from_length); + } + if (from_length > to_length) + printk(KERN_WARNING "%s: %s string '%s' is too long\n", +diff --git a/drivers/staging/rts5208/sd.c b/drivers/staging/rts5208/sd.c +index d98d5fe25a17..0421dd9277a8 100644 +--- a/drivers/staging/rts5208/sd.c ++++ b/drivers/staging/rts5208/sd.c +@@ -4125,12 +4125,6 @@ RTY_SEND_CMD: + rtsx_trace(chip); + return STATUS_FAIL; + } +- +- } else if (rsp_type == SD_RSP_TYPE_R0) { +- if ((ptr[3] & 0x1E) != 0x03) { +- rtsx_trace(chip); +- return STATUS_FAIL; +- } + } + } + } +diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c +index 6d8906d65476..7c5d4647cb5e 100644 +--- a/drivers/thermal/hisi_thermal.c ++++ b/drivers/thermal/hisi_thermal.c +@@ -26,9 +26,12 @@ + + #include "thermal_core.h" + ++#define TEMP0_LAG (0x0) + #define TEMP0_TH (0x4) + #define TEMP0_RST_TH (0x8) + #define TEMP0_CFG (0xC) ++#define TEMP0_CFG_SS_MSK (0xF000) ++#define TEMP0_CFG_HDAK_MSK (0x30) + #define TEMP0_EN (0x10) + #define TEMP0_INT_EN (0x14) + #define TEMP0_INT_CLR (0x18) +@@ -38,8 +41,10 @@ + #define HISI_TEMP_BASE (-60000) + #define HISI_TEMP_RESET (100000) + #define HISI_TEMP_STEP (784) ++#define HISI_TEMP_LAG (3500) + + #define HISI_MAX_SENSORS 4 ++#define HISI_DEFAULT_SENSOR 2 + + struct hisi_thermal_sensor { + struct hisi_thermal_data *thermal; +@@ -54,11 +59,8 @@ struct hisi_thermal_data { + struct mutex thermal_lock; /* protects register data */ + struct platform_device *pdev; + struct clk *clk; +- struct hisi_thermal_sensor sensors[HISI_MAX_SENSORS]; +- +- int irq, irq_bind_sensor; +- bool irq_enabled; +- ++ struct hisi_thermal_sensor sensors; ++ int irq; + void __iomem *regs; + }; + +@@ -96,72 +98,107 @@ static inline long hisi_thermal_round_temp(int temp) + hisi_thermal_temp_to_step(temp)); + } + +-static long hisi_thermal_get_sensor_temp(struct hisi_thermal_data *data, +- struct hisi_thermal_sensor *sensor) ++/* ++ * The lag register contains 5 bits encoding the temperature in steps. ++ * ++ * Each time the temperature crosses the threshold boundary, an ++ * interrupt is raised. It could be when the temperature is going ++ * above the threshold or below. However, if the temperature is ++ * fluctuating around this value due to the load, we can receive ++ * several interrupts which may not desired. ++ * ++ * We can setup a temperature representing the delta between the ++ * threshold and the current temperature when the temperature is ++ * decreasing. ++ * ++ * For instance: the lag register is 5°C, the threshold is 65°C, when ++ * the temperature reaches 65°C an interrupt is raised and when the ++ * temperature decrease to 65°C - 5°C another interrupt is raised. ++ * ++ * A very short lag can lead to an interrupt storm, a long lag ++ * increase the latency to react to the temperature changes. In our ++ * case, that is not really a problem as we are polling the ++ * temperature. ++ * ++ * [0:4] : lag register ++ * ++ * The temperature is coded in steps, cf. HISI_TEMP_STEP. ++ * ++ * Min : 0x00 : 0.0 °C ++ * Max : 0x1F : 24.3 °C ++ * ++ * The 'value' parameter is in milliCelsius. ++ */ ++static inline void hisi_thermal_set_lag(void __iomem *addr, int value) + { +- long val; +- +- mutex_lock(&data->thermal_lock); +- +- /* disable interrupt */ +- writel(0x0, data->regs + TEMP0_INT_EN); +- writel(0x1, data->regs + TEMP0_INT_CLR); +- +- /* disable module firstly */ +- writel(0x0, data->regs + TEMP0_EN); +- +- /* select sensor id */ +- writel((sensor->id << 12), data->regs + TEMP0_CFG); +- +- /* enable module */ +- writel(0x1, data->regs + TEMP0_EN); +- +- usleep_range(3000, 5000); +- +- val = readl(data->regs + TEMP0_VALUE); +- val = hisi_thermal_step_to_temp(val); +- +- mutex_unlock(&data->thermal_lock); +- +- return val; ++ writel((value / HISI_TEMP_STEP) & 0x1F, addr + TEMP0_LAG); + } + +-static void hisi_thermal_enable_bind_irq_sensor +- (struct hisi_thermal_data *data) ++static inline void hisi_thermal_alarm_clear(void __iomem *addr, int value) + { +- struct hisi_thermal_sensor *sensor; +- +- mutex_lock(&data->thermal_lock); +- +- sensor = &data->sensors[data->irq_bind_sensor]; +- +- /* setting the hdak time */ +- writel(0x0, data->regs + TEMP0_CFG); ++ writel(value, addr + TEMP0_INT_CLR); ++} + +- /* disable module firstly */ +- writel(0x0, data->regs + TEMP0_RST_MSK); +- writel(0x0, data->regs + TEMP0_EN); ++static inline void hisi_thermal_alarm_enable(void __iomem *addr, int value) ++{ ++ writel(value, addr + TEMP0_INT_EN); ++} + +- /* select sensor id */ +- writel((sensor->id << 12), data->regs + TEMP0_CFG); ++static inline void hisi_thermal_alarm_set(void __iomem *addr, int temp) ++{ ++ writel(hisi_thermal_temp_to_step(temp) | 0x0FFFFFF00, addr + TEMP0_TH); ++} + +- /* enable for interrupt */ +- writel(hisi_thermal_temp_to_step(sensor->thres_temp) | 0x0FFFFFF00, +- data->regs + TEMP0_TH); ++static inline void hisi_thermal_reset_set(void __iomem *addr, int temp) ++{ ++ writel(hisi_thermal_temp_to_step(temp), addr + TEMP0_RST_TH); ++} + +- writel(hisi_thermal_temp_to_step(HISI_TEMP_RESET), +- data->regs + TEMP0_RST_TH); ++static inline void hisi_thermal_reset_enable(void __iomem *addr, int value) ++{ ++ writel(value, addr + TEMP0_RST_MSK); ++} + +- /* enable module */ +- writel(0x1, data->regs + TEMP0_RST_MSK); +- writel(0x1, data->regs + TEMP0_EN); ++static inline void hisi_thermal_enable(void __iomem *addr, int value) ++{ ++ writel(value, addr + TEMP0_EN); ++} + +- writel(0x0, data->regs + TEMP0_INT_CLR); +- writel(0x1, data->regs + TEMP0_INT_EN); ++static inline int hisi_thermal_get_temperature(void __iomem *addr) ++{ ++ return hisi_thermal_step_to_temp(readl(addr + TEMP0_VALUE)); ++} + +- usleep_range(3000, 5000); ++/* ++ * Temperature configuration register - Sensor selection ++ * ++ * Bits [19:12] ++ * ++ * 0x0: local sensor (default) ++ * 0x1: remote sensor 1 (ACPU cluster 1) ++ * 0x2: remote sensor 2 (ACPU cluster 0) ++ * 0x3: remote sensor 3 (G3D) ++ */ ++static inline void hisi_thermal_sensor_select(void __iomem *addr, int sensor) ++{ ++ writel((readl(addr + TEMP0_CFG) & ~TEMP0_CFG_SS_MSK) | ++ (sensor << 12), addr + TEMP0_CFG); ++} + +- mutex_unlock(&data->thermal_lock); ++/* ++ * Temperature configuration register - Hdak conversion polling interval ++ * ++ * Bits [5:4] ++ * ++ * 0x0 : 0.768 ms ++ * 0x1 : 6.144 ms ++ * 0x2 : 49.152 ms ++ * 0x3 : 393.216 ms ++ */ ++static inline void hisi_thermal_hdak_set(void __iomem *addr, int value) ++{ ++ writel((readl(addr + TEMP0_CFG) & ~TEMP0_CFG_HDAK_MSK) | ++ (value << 4), addr + TEMP0_CFG); + } + + static void hisi_thermal_disable_sensor(struct hisi_thermal_data *data) +@@ -169,9 +206,9 @@ static void hisi_thermal_disable_sensor(struct hisi_thermal_data *data) + mutex_lock(&data->thermal_lock); + + /* disable sensor module */ +- writel(0x0, data->regs + TEMP0_INT_EN); +- writel(0x0, data->regs + TEMP0_RST_MSK); +- writel(0x0, data->regs + TEMP0_EN); ++ hisi_thermal_enable(data->regs, 0); ++ hisi_thermal_alarm_enable(data->regs, 0); ++ hisi_thermal_reset_enable(data->regs, 0); + + mutex_unlock(&data->thermal_lock); + } +@@ -181,48 +218,10 @@ static int hisi_thermal_get_temp(void *_sensor, int *temp) + struct hisi_thermal_sensor *sensor = _sensor; + struct hisi_thermal_data *data = sensor->thermal; + +- int sensor_id = -1, i; +- long max_temp = 0; ++ *temp = hisi_thermal_get_temperature(data->regs); + +- *temp = hisi_thermal_get_sensor_temp(data, sensor); +- +- sensor->sensor_temp = *temp; +- +- for (i = 0; i < HISI_MAX_SENSORS; i++) { +- if (!data->sensors[i].tzd) +- continue; +- +- if (data->sensors[i].sensor_temp >= max_temp) { +- max_temp = data->sensors[i].sensor_temp; +- sensor_id = i; +- } +- } +- +- /* If no sensor has been enabled, then skip to enable irq */ +- if (sensor_id == -1) +- return 0; +- +- mutex_lock(&data->thermal_lock); +- data->irq_bind_sensor = sensor_id; +- mutex_unlock(&data->thermal_lock); +- +- dev_dbg(&data->pdev->dev, "id=%d, irq=%d, temp=%d, thres=%d\n", +- sensor->id, data->irq_enabled, *temp, sensor->thres_temp); +- /* +- * Bind irq to sensor for two cases: +- * Reenable alarm IRQ if temperature below threshold; +- * if irq has been enabled, always set it; +- */ +- if (data->irq_enabled) { +- hisi_thermal_enable_bind_irq_sensor(data); +- return 0; +- } +- +- if (max_temp < sensor->thres_temp) { +- data->irq_enabled = true; +- hisi_thermal_enable_bind_irq_sensor(data); +- enable_irq(data->irq); +- } ++ dev_dbg(&data->pdev->dev, "id=%d, temp=%d, thres=%d\n", ++ sensor->id, *temp, sensor->thres_temp); + + return 0; + } +@@ -231,35 +230,26 @@ static const struct thermal_zone_of_device_ops hisi_of_thermal_ops = { + .get_temp = hisi_thermal_get_temp, + }; + +-static irqreturn_t hisi_thermal_alarm_irq(int irq, void *dev) +-{ +- struct hisi_thermal_data *data = dev; +- +- disable_irq_nosync(irq); +- data->irq_enabled = false; +- +- return IRQ_WAKE_THREAD; +-} +- + static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) + { + struct hisi_thermal_data *data = dev; +- struct hisi_thermal_sensor *sensor; +- int i; ++ struct hisi_thermal_sensor *sensor = &data->sensors; ++ int temp; + +- mutex_lock(&data->thermal_lock); +- sensor = &data->sensors[data->irq_bind_sensor]; ++ hisi_thermal_alarm_clear(data->regs, 1); + +- dev_crit(&data->pdev->dev, "THERMAL ALARM: T > %d\n", +- sensor->thres_temp); +- mutex_unlock(&data->thermal_lock); ++ temp = hisi_thermal_get_temperature(data->regs); + +- for (i = 0; i < HISI_MAX_SENSORS; i++) { +- if (!data->sensors[i].tzd) +- continue; ++ if (temp >= sensor->thres_temp) { ++ dev_crit(&data->pdev->dev, "THERMAL ALARM: %d > %d\n", ++ temp, sensor->thres_temp); + +- thermal_zone_device_update(data->sensors[i].tzd, ++ thermal_zone_device_update(data->sensors.tzd, + THERMAL_EVENT_UNSPECIFIED); ++ ++ } else if (temp < sensor->thres_temp) { ++ dev_crit(&data->pdev->dev, "THERMAL ALARM stopped: %d < %d\n", ++ temp, sensor->thres_temp); + } + + return IRQ_HANDLED; +@@ -313,11 +303,44 @@ static void hisi_thermal_toggle_sensor(struct hisi_thermal_sensor *sensor, + on ? THERMAL_DEVICE_ENABLED : THERMAL_DEVICE_DISABLED); + } + ++static int hisi_thermal_setup(struct hisi_thermal_data *data) ++{ ++ struct hisi_thermal_sensor *sensor; ++ ++ sensor = &data->sensors; ++ ++ /* disable module firstly */ ++ hisi_thermal_reset_enable(data->regs, 0); ++ hisi_thermal_enable(data->regs, 0); ++ ++ /* select sensor id */ ++ hisi_thermal_sensor_select(data->regs, sensor->id); ++ ++ /* setting the hdak time */ ++ hisi_thermal_hdak_set(data->regs, 0); ++ ++ /* setting lag value between current temp and the threshold */ ++ hisi_thermal_set_lag(data->regs, HISI_TEMP_LAG); ++ ++ /* enable for interrupt */ ++ hisi_thermal_alarm_set(data->regs, sensor->thres_temp); ++ ++ hisi_thermal_reset_set(data->regs, HISI_TEMP_RESET); ++ ++ /* enable module */ ++ hisi_thermal_reset_enable(data->regs, 1); ++ hisi_thermal_enable(data->regs, 1); ++ ++ hisi_thermal_alarm_clear(data->regs, 0); ++ hisi_thermal_alarm_enable(data->regs, 1); ++ ++ return 0; ++} ++ + static int hisi_thermal_probe(struct platform_device *pdev) + { + struct hisi_thermal_data *data; + struct resource *res; +- int i; + int ret; + + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); +@@ -356,29 +379,30 @@ static int hisi_thermal_probe(struct platform_device *pdev) + return ret; + } + +- hisi_thermal_enable_bind_irq_sensor(data); +- data->irq_enabled = true; ++ ret = hisi_thermal_register_sensor(pdev, data, ++ &data->sensors, ++ HISI_DEFAULT_SENSOR); ++ if (ret) { ++ dev_err(&pdev->dev, "failed to register thermal sensor: %d\n", ++ ret); ++ return ret; ++ } + +- for (i = 0; i < HISI_MAX_SENSORS; ++i) { +- ret = hisi_thermal_register_sensor(pdev, data, +- &data->sensors[i], i); +- if (ret) +- dev_err(&pdev->dev, +- "failed to register thermal sensor: %d\n", ret); +- else +- hisi_thermal_toggle_sensor(&data->sensors[i], true); ++ ret = hisi_thermal_setup(data); ++ if (ret) { ++ dev_err(&pdev->dev, "Failed to setup the sensor: %d\n", ret); ++ return ret; + } + +- ret = devm_request_threaded_irq(&pdev->dev, data->irq, +- hisi_thermal_alarm_irq, ++ ret = devm_request_threaded_irq(&pdev->dev, data->irq, NULL, + hisi_thermal_alarm_irq_thread, +- 0, "hisi_thermal", data); ++ IRQF_ONESHOT, "hisi_thermal", data); + if (ret < 0) { + dev_err(&pdev->dev, "failed to request alarm irq: %d\n", ret); + return ret; + } + +- enable_irq(data->irq); ++ hisi_thermal_toggle_sensor(&data->sensors, true); + + return 0; + } +@@ -386,17 +410,9 @@ static int hisi_thermal_probe(struct platform_device *pdev) + static int hisi_thermal_remove(struct platform_device *pdev) + { + struct hisi_thermal_data *data = platform_get_drvdata(pdev); +- int i; +- +- for (i = 0; i < HISI_MAX_SENSORS; i++) { +- struct hisi_thermal_sensor *sensor = &data->sensors[i]; +- +- if (!sensor->tzd) +- continue; +- +- hisi_thermal_toggle_sensor(sensor, false); +- } ++ struct hisi_thermal_sensor *sensor = &data->sensors; + ++ hisi_thermal_toggle_sensor(sensor, false); + hisi_thermal_disable_sensor(data); + clk_disable_unprepare(data->clk); + +@@ -409,7 +425,6 @@ static int hisi_thermal_suspend(struct device *dev) + struct hisi_thermal_data *data = dev_get_drvdata(dev); + + hisi_thermal_disable_sensor(data); +- data->irq_enabled = false; + + clk_disable_unprepare(data->clk); + +@@ -425,8 +440,7 @@ static int hisi_thermal_resume(struct device *dev) + if (ret) + return ret; + +- data->irq_enabled = true; +- hisi_thermal_enable_bind_irq_sensor(data); ++ hisi_thermal_setup(data); + + return 0; + } +diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c +index 2db68dfe497d..c448225ef5ca 100644 +--- a/drivers/tty/serial/kgdboc.c ++++ b/drivers/tty/serial/kgdboc.c +@@ -131,24 +131,6 @@ static void kgdboc_unregister_kbd(void) + #define kgdboc_restore_input() + #endif /* ! CONFIG_KDB_KEYBOARD */ + +-static int kgdboc_option_setup(char *opt) +-{ +- if (!opt) { +- pr_err("kgdboc: config string not provided\n"); +- return -EINVAL; +- } +- +- if (strlen(opt) >= MAX_CONFIG_LEN) { +- printk(KERN_ERR "kgdboc: config string too long\n"); +- return -ENOSPC; +- } +- strcpy(config, opt); +- +- return 0; +-} +- +-__setup("kgdboc=", kgdboc_option_setup); +- + static void cleanup_kgdboc(void) + { + if (kgdb_unregister_nmi_console()) +@@ -162,15 +144,13 @@ static int configure_kgdboc(void) + { + struct tty_driver *p; + int tty_line = 0; +- int err; ++ int err = -ENODEV; + char *cptr = config; + struct console *cons; + +- err = kgdboc_option_setup(config); +- if (err || !strlen(config) || isspace(config[0])) ++ if (!strlen(config) || isspace(config[0])) + goto noconfig; + +- err = -ENODEV; + kgdboc_io_ops.is_console = 0; + kgdb_tty_driver = NULL; + +@@ -318,6 +298,25 @@ static struct kgdb_io kgdboc_io_ops = { + }; + + #ifdef CONFIG_KGDB_SERIAL_CONSOLE ++static int kgdboc_option_setup(char *opt) ++{ ++ if (!opt) { ++ pr_err("config string not provided\n"); ++ return -EINVAL; ++ } ++ ++ if (strlen(opt) >= MAX_CONFIG_LEN) { ++ pr_err("config string too long\n"); ++ return -ENOSPC; ++ } ++ strcpy(config, opt); ++ ++ return 0; ++} ++ ++__setup("kgdboc=", kgdboc_option_setup); ++ ++ + /* This is only available if kgdboc is a built in for early debugging */ + static int __init kgdboc_early_init(char *opt) + { +diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c +index e42673477c25..858d5812eb8f 100644 +--- a/fs/btrfs/disk-io.c ++++ b/fs/btrfs/disk-io.c +@@ -451,9 +451,9 @@ static int btree_read_extent_buffer_pages(struct btrfs_fs_info *fs_info, + int mirror_num = 0; + int failed_mirror = 0; + +- clear_bit(EXTENT_BUFFER_CORRUPT, &eb->bflags); + io_tree = &BTRFS_I(fs_info->btree_inode)->io_tree; + while (1) { ++ clear_bit(EXTENT_BUFFER_CORRUPT, &eb->bflags); + ret = read_extent_buffer_pages(io_tree, eb, WAIT_COMPLETE, + btree_get_extent, mirror_num); + if (!ret) { +@@ -464,14 +464,6 @@ static int btree_read_extent_buffer_pages(struct btrfs_fs_info *fs_info, + ret = -EIO; + } + +- /* +- * This buffer's crc is fine, but its contents are corrupted, so +- * there is no reason to read the other copies, they won't be +- * any less wrong. +- */ +- if (test_bit(EXTENT_BUFFER_CORRUPT, &eb->bflags)) +- break; +- + num_copies = btrfs_num_copies(fs_info, + eb->start, eb->len); + if (num_copies == 1) +diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c +index f206aec1525d..ebc882281b39 100644 +--- a/fs/btrfs/tree-checker.c ++++ b/fs/btrfs/tree-checker.c +@@ -348,13 +348,11 @@ static int check_block_group_item(struct btrfs_fs_info *fs_info, + + /* + * Here we don't really care about alignment since extent allocator can +- * handle it. We care more about the size, as if one block group is +- * larger than maximum size, it's must be some obvious corruption. ++ * handle it. We care more about the size. + */ +- if (key->offset > BTRFS_MAX_DATA_CHUNK_SIZE || key->offset == 0) { ++ if (key->offset == 0) { + block_group_err(fs_info, leaf, slot, +- "invalid block group size, have %llu expect (0, %llu]", +- key->offset, BTRFS_MAX_DATA_CHUNK_SIZE); ++ "invalid block group size 0"); + return -EUCLEAN; + } + +diff --git a/fs/kernfs/symlink.c b/fs/kernfs/symlink.c +index 08ccabd7047f..5145ae2f0572 100644 +--- a/fs/kernfs/symlink.c ++++ b/fs/kernfs/symlink.c +@@ -88,7 +88,7 @@ static int kernfs_get_target_path(struct kernfs_node *parent, + int slen = strlen(kn->name); + + len -= slen; +- strncpy(s + len, kn->name, slen); ++ memcpy(s + len, kn->name, slen); + if (len) + s[--len] = '/'; + +diff --git a/fs/udf/super.c b/fs/udf/super.c +index 9b0d6562d0a1..242d960df9a1 100644 +--- a/fs/udf/super.c ++++ b/fs/udf/super.c +@@ -922,16 +922,20 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block) + } + + ret = udf_dstrCS0toUTF8(outstr, 31, pvoldesc->volIdent, 32); +- if (ret < 0) +- goto out_bh; +- +- strncpy(UDF_SB(sb)->s_volume_ident, outstr, ret); ++ if (ret < 0) { ++ strcpy(UDF_SB(sb)->s_volume_ident, "InvalidName"); ++ pr_warn("incorrect volume identification, setting to " ++ "'InvalidName'\n"); ++ } else { ++ strncpy(UDF_SB(sb)->s_volume_ident, outstr, ret); ++ } + udf_debug("volIdent[] = '%s'\n", UDF_SB(sb)->s_volume_ident); + + ret = udf_dstrCS0toUTF8(outstr, 127, pvoldesc->volSetIdent, 128); +- if (ret < 0) ++ if (ret < 0) { ++ ret = 0; + goto out_bh; +- ++ } + outstr[ret] = 0; + udf_debug("volSetIdent[] = '%s'\n", outstr); + +diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c +index 3a3be23689b3..61a1738895b7 100644 +--- a/fs/udf/unicode.c ++++ b/fs/udf/unicode.c +@@ -341,6 +341,11 @@ try_again: + return u_len; + } + ++/* ++ * Convert CS0 dstring to output charset. Warning: This function may truncate ++ * input string if it is too long as it is used for informational strings only ++ * and it is better to truncate the string than to refuse mounting a media. ++ */ + int udf_dstrCS0toUTF8(uint8_t *utf_o, int o_len, + const uint8_t *ocu_i, int i_len) + { +@@ -349,9 +354,12 @@ int udf_dstrCS0toUTF8(uint8_t *utf_o, int o_len, + if (i_len > 0) { + s_len = ocu_i[i_len - 1]; + if (s_len >= i_len) { +- pr_err("incorrect dstring lengths (%d/%d)\n", +- s_len, i_len); +- return -EINVAL; ++ pr_warn("incorrect dstring lengths (%d/%d)," ++ " truncating\n", s_len, i_len); ++ s_len = i_len - 1; ++ /* 2-byte encoding? Need to round properly... */ ++ if (ocu_i[0] == 16) ++ s_len -= (s_len - 1) & 2; + } + } + +diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c +index 3eda623e4cb4..f92e1f2fc846 100644 +--- a/fs/userfaultfd.c ++++ b/fs/userfaultfd.c +@@ -1362,6 +1362,19 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx, + ret = -EINVAL; + if (!vma_can_userfault(cur)) + goto out_unlock; ++ ++ /* ++ * UFFDIO_COPY will fill file holes even without ++ * PROT_WRITE. This check enforces that if this is a ++ * MAP_SHARED, the process has write permission to the backing ++ * file. If VM_MAYWRITE is set it also enforces that on a ++ * MAP_SHARED vma: there is no F_WRITE_SEAL and no further ++ * F_WRITE_SEAL can be taken until the vma is destroyed. ++ */ ++ ret = -EPERM; ++ if (unlikely(!(cur->vm_flags & VM_MAYWRITE))) ++ goto out_unlock; ++ + /* + * If this vma contains ending address, and huge pages + * check alignment. +@@ -1407,6 +1420,7 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx, + BUG_ON(!vma_can_userfault(vma)); + BUG_ON(vma->vm_userfaultfd_ctx.ctx && + vma->vm_userfaultfd_ctx.ctx != ctx); ++ WARN_ON(!(vma->vm_flags & VM_MAYWRITE)); + + /* + * Nothing to do: this vma is already registered into this +@@ -1553,6 +1567,7 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx, + cond_resched(); + + BUG_ON(!vma_can_userfault(vma)); ++ WARN_ON(!(vma->vm_flags & VM_MAYWRITE)); + + /* + * Nothing to do: this vma is already registered into this +diff --git a/include/linux/reset.h b/include/linux/reset.h +index 4c7871ddf3c6..ed6fb0290797 100644 +--- a/include/linux/reset.h ++++ b/include/linux/reset.h +@@ -20,22 +20,16 @@ struct reset_control *__reset_control_get(struct device *dev, const char *id, + int index, bool shared, + bool optional); + void reset_control_put(struct reset_control *rstc); ++int __device_reset(struct device *dev, bool optional); + struct reset_control *__devm_reset_control_get(struct device *dev, + const char *id, int index, bool shared, + bool optional); + +-int __must_check device_reset(struct device *dev); +- + struct reset_control *devm_reset_control_array_get(struct device *dev, + bool shared, bool optional); + struct reset_control *of_reset_control_array_get(struct device_node *np, + bool shared, bool optional); + +-static inline int device_reset_optional(struct device *dev) +-{ +- return device_reset(dev); +-} +- + #else + + static inline int reset_control_reset(struct reset_control *rstc) +@@ -62,15 +56,9 @@ static inline void reset_control_put(struct reset_control *rstc) + { + } + +-static inline int __must_check device_reset(struct device *dev) +-{ +- WARN_ON(1); +- return -ENOTSUPP; +-} +- +-static inline int device_reset_optional(struct device *dev) ++static inline int __device_reset(struct device *dev, bool optional) + { +- return -ENOTSUPP; ++ return optional ? 0 : -ENOTSUPP; + } + + static inline struct reset_control *__of_reset_control_get( +@@ -109,6 +97,16 @@ of_reset_control_array_get(struct device_node *np, bool shared, bool optional) + + #endif /* CONFIG_RESET_CONTROLLER */ + ++static inline int __must_check device_reset(struct device *dev) ++{ ++ return __device_reset(dev, false); ++} ++ ++static inline int device_reset_optional(struct device *dev) ++{ ++ return __device_reset(dev, true); ++} ++ + /** + * reset_control_get_exclusive - Lookup and obtain an exclusive reference + * to a reset controller. +@@ -127,9 +125,6 @@ of_reset_control_array_get(struct device_node *np, bool shared, bool optional) + static inline struct reset_control * + __must_check reset_control_get_exclusive(struct device *dev, const char *id) + { +-#ifndef CONFIG_RESET_CONTROLLER +- WARN_ON(1); +-#endif + return __reset_control_get(dev, id, 0, false, false); + } + +@@ -275,9 +270,6 @@ static inline struct reset_control * + __must_check devm_reset_control_get_exclusive(struct device *dev, + const char *id) + { +-#ifndef CONFIG_RESET_CONTROLLER +- WARN_ON(1); +-#endif + return __devm_reset_control_get(dev, id, 0, false, false); + } + +diff --git a/kernel/debug/kdb/kdb_support.c b/kernel/debug/kdb/kdb_support.c +index 014f6fbb3832..b14b0925c184 100644 +--- a/kernel/debug/kdb/kdb_support.c ++++ b/kernel/debug/kdb/kdb_support.c +@@ -129,13 +129,13 @@ int kdbnearsym(unsigned long addr, kdb_symtab_t *symtab) + } + if (i >= ARRAY_SIZE(kdb_name_table)) { + debug_kfree(kdb_name_table[0]); +- memcpy(kdb_name_table, kdb_name_table+1, ++ memmove(kdb_name_table, kdb_name_table+1, + sizeof(kdb_name_table[0]) * + (ARRAY_SIZE(kdb_name_table)-1)); + } else { + debug_kfree(knt1); + knt1 = kdb_name_table[i]; +- memcpy(kdb_name_table+i, kdb_name_table+i+1, ++ memmove(kdb_name_table+i, kdb_name_table+i+1, + sizeof(kdb_name_table[0]) * + (ARRAY_SIZE(kdb_name_table)-i-1)); + } +diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c +index 267f6ef91d97..01941cffa9c2 100644 +--- a/kernel/events/uprobes.c ++++ b/kernel/events/uprobes.c +@@ -616,7 +616,7 @@ static int prepare_uprobe(struct uprobe *uprobe, struct file *file, + BUG_ON((uprobe->offset & ~PAGE_MASK) + + UPROBE_SWBP_INSN_SIZE > PAGE_SIZE); + +- smp_wmb(); /* pairs with rmb() in find_active_uprobe() */ ++ smp_wmb(); /* pairs with the smp_rmb() in handle_swbp() */ + set_bit(UPROBE_COPY_INSN, &uprobe->flags); + + out: +@@ -1910,10 +1910,18 @@ static void handle_swbp(struct pt_regs *regs) + * After we hit the bp, _unregister + _register can install the + * new and not-yet-analyzed uprobe at the same address, restart. + */ +- smp_rmb(); /* pairs with wmb() in install_breakpoint() */ + if (unlikely(!test_bit(UPROBE_COPY_INSN, &uprobe->flags))) + goto out; + ++ /* ++ * Pairs with the smp_wmb() in prepare_uprobe(). ++ * ++ * Guarantees that if we see the UPROBE_COPY_INSN bit set, then ++ * we must also see the stores to &uprobe->arch performed by the ++ * prepare_uprobe() call. ++ */ ++ smp_rmb(); ++ + /* Tracing handlers use ->utask to communicate with fetch methods */ + if (!get_utask()) + goto out; +diff --git a/lib/kobject.c b/lib/kobject.c +index 34f847252c02..bbbb067de8ec 100644 +--- a/lib/kobject.c ++++ b/lib/kobject.c +@@ -127,7 +127,7 @@ static void fill_kobj_path(struct kobject *kobj, char *path, int length) + int cur = strlen(kobject_name(parent)); + /* back up enough to print this name with '/' */ + length -= cur; +- strncpy(path + length, kobject_name(parent), cur); ++ memcpy(path + length, kobject_name(parent), cur); + *(path + --length) = '/'; + } + +diff --git a/lib/test_hexdump.c b/lib/test_hexdump.c +index 3f415d8101f3..1c3c513add77 100644 +--- a/lib/test_hexdump.c ++++ b/lib/test_hexdump.c +@@ -81,7 +81,7 @@ static void __init test_hexdump_prepare_test(size_t len, int rowsize, + const char *q = *result++; + size_t amount = strlen(q); + +- strncpy(p, q, amount); ++ memcpy(p, q, amount); + p += amount; + + *p++ = ' '; +diff --git a/mm/hugetlb.c b/mm/hugetlb.c +index f46040aed2da..224cdd953a79 100644 +--- a/mm/hugetlb.c ++++ b/mm/hugetlb.c +@@ -4037,7 +4037,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, + + /* fallback to copy_from_user outside mmap_sem */ + if (unlikely(ret)) { +- ret = -EFAULT; ++ ret = -ENOENT; + *pagep = page; + /* don't free the page */ + goto out; +diff --git a/mm/shmem.c b/mm/shmem.c +index ab7ff0aeae2d..6c10f1d92251 100644 +--- a/mm/shmem.c ++++ b/mm/shmem.c +@@ -2244,6 +2244,7 @@ static int shmem_mfill_atomic_pte(struct mm_struct *dst_mm, + struct page *page; + pte_t _dst_pte, *dst_pte; + int ret; ++ pgoff_t offset, max_off; + + ret = -ENOMEM; + if (!shmem_inode_acct_block(inode, 1)) +@@ -2266,7 +2267,7 @@ static int shmem_mfill_atomic_pte(struct mm_struct *dst_mm, + *pagep = page; + shmem_inode_unacct_blocks(inode, 1); + /* don't free the page */ +- return -EFAULT; ++ return -ENOENT; + } + } else { /* mfill_zeropage_atomic */ + clear_highpage(page); +@@ -2281,6 +2282,12 @@ static int shmem_mfill_atomic_pte(struct mm_struct *dst_mm, + __SetPageSwapBacked(page); + __SetPageUptodate(page); + ++ ret = -EFAULT; ++ offset = linear_page_index(dst_vma, dst_addr); ++ max_off = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE); ++ if (unlikely(offset >= max_off)) ++ goto out_release; ++ + ret = mem_cgroup_try_charge(page, dst_mm, gfp, &memcg, false); + if (ret) + goto out_release; +@@ -2298,9 +2305,25 @@ static int shmem_mfill_atomic_pte(struct mm_struct *dst_mm, + _dst_pte = mk_pte(page, dst_vma->vm_page_prot); + if (dst_vma->vm_flags & VM_WRITE) + _dst_pte = pte_mkwrite(pte_mkdirty(_dst_pte)); ++ else { ++ /* ++ * We don't set the pte dirty if the vma has no ++ * VM_WRITE permission, so mark the page dirty or it ++ * could be freed from under us. We could do it ++ * unconditionally before unlock_page(), but doing it ++ * only if VM_WRITE is not set is faster. ++ */ ++ set_page_dirty(page); ++ } + +- ret = -EEXIST; + dst_pte = pte_offset_map_lock(dst_mm, dst_pmd, dst_addr, &ptl); ++ ++ ret = -EFAULT; ++ max_off = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE); ++ if (unlikely(offset >= max_off)) ++ goto out_release_uncharge_unlock; ++ ++ ret = -EEXIST; + if (!pte_none(*dst_pte)) + goto out_release_uncharge_unlock; + +@@ -2318,13 +2341,15 @@ static int shmem_mfill_atomic_pte(struct mm_struct *dst_mm, + + /* No need to invalidate - it was non-present before */ + update_mmu_cache(dst_vma, dst_addr, dst_pte); +- unlock_page(page); + pte_unmap_unlock(dst_pte, ptl); ++ unlock_page(page); + ret = 0; + out: + return ret; + out_release_uncharge_unlock: + pte_unmap_unlock(dst_pte, ptl); ++ ClearPageDirty(page); ++ delete_from_page_cache(page); + out_release_uncharge: + mem_cgroup_cancel_charge(page, memcg, false); + out_release: +diff --git a/mm/truncate.c b/mm/truncate.c +index 2330223841fb..d3a2737cc188 100644 +--- a/mm/truncate.c ++++ b/mm/truncate.c +@@ -471,9 +471,13 @@ void truncate_inode_pages_final(struct address_space *mapping) + */ + spin_lock_irq(&mapping->tree_lock); + spin_unlock_irq(&mapping->tree_lock); +- +- truncate_inode_pages(mapping, 0); + } ++ ++ /* ++ * Cleancache needs notification even if there are no pages or shadow ++ * entries. ++ */ ++ truncate_inode_pages(mapping, 0); + } + EXPORT_SYMBOL(truncate_inode_pages_final); + +diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c +index 81192701964d..5d70fdbd8bc0 100644 +--- a/mm/userfaultfd.c ++++ b/mm/userfaultfd.c +@@ -34,6 +34,8 @@ static int mcopy_atomic_pte(struct mm_struct *dst_mm, + void *page_kaddr; + int ret; + struct page *page; ++ pgoff_t offset, max_off; ++ struct inode *inode; + + if (!*pagep) { + ret = -ENOMEM; +@@ -49,7 +51,7 @@ static int mcopy_atomic_pte(struct mm_struct *dst_mm, + + /* fallback to copy_from_user outside mmap_sem */ + if (unlikely(ret)) { +- ret = -EFAULT; ++ ret = -ENOENT; + *pagep = page; + /* don't free the page */ + goto out; +@@ -74,8 +76,17 @@ static int mcopy_atomic_pte(struct mm_struct *dst_mm, + if (dst_vma->vm_flags & VM_WRITE) + _dst_pte = pte_mkwrite(pte_mkdirty(_dst_pte)); + +- ret = -EEXIST; + dst_pte = pte_offset_map_lock(dst_mm, dst_pmd, dst_addr, &ptl); ++ if (dst_vma->vm_file) { ++ /* the shmem MAP_PRIVATE case requires checking the i_size */ ++ inode = dst_vma->vm_file->f_inode; ++ offset = linear_page_index(dst_vma, dst_addr); ++ max_off = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE); ++ ret = -EFAULT; ++ if (unlikely(offset >= max_off)) ++ goto out_release_uncharge_unlock; ++ } ++ ret = -EEXIST; + if (!pte_none(*dst_pte)) + goto out_release_uncharge_unlock; + +@@ -109,11 +120,22 @@ static int mfill_zeropage_pte(struct mm_struct *dst_mm, + pte_t _dst_pte, *dst_pte; + spinlock_t *ptl; + int ret; ++ pgoff_t offset, max_off; ++ struct inode *inode; + + _dst_pte = pte_mkspecial(pfn_pte(my_zero_pfn(dst_addr), + dst_vma->vm_page_prot)); +- ret = -EEXIST; + dst_pte = pte_offset_map_lock(dst_mm, dst_pmd, dst_addr, &ptl); ++ if (dst_vma->vm_file) { ++ /* the shmem MAP_PRIVATE case requires checking the i_size */ ++ inode = dst_vma->vm_file->f_inode; ++ offset = linear_page_index(dst_vma, dst_addr); ++ max_off = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE); ++ ret = -EFAULT; ++ if (unlikely(offset >= max_off)) ++ goto out_unlock; ++ } ++ ret = -EEXIST; + if (!pte_none(*dst_pte)) + goto out_unlock; + set_pte_at(dst_mm, dst_addr, dst_pte, _dst_pte); +@@ -206,8 +228,9 @@ retry: + if (!dst_vma || !is_vm_hugetlb_page(dst_vma)) + goto out_unlock; + /* +- * Only allow __mcopy_atomic_hugetlb on userfaultfd +- * registered ranges. ++ * Check the vma is registered in uffd, this is ++ * required to enforce the VM_MAYWRITE check done at ++ * uffd registration time. + */ + if (!dst_vma->vm_userfaultfd_ctx.ctx) + goto out_unlock; +@@ -275,7 +298,7 @@ retry: + + cond_resched(); + +- if (unlikely(err == -EFAULT)) { ++ if (unlikely(err == -ENOENT)) { + up_read(&dst_mm->mmap_sem); + BUG_ON(!page); + +@@ -381,7 +404,17 @@ static __always_inline ssize_t mfill_atomic_pte(struct mm_struct *dst_mm, + { + ssize_t err; + +- if (vma_is_anonymous(dst_vma)) { ++ /* ++ * The normal page fault path for a shmem will invoke the ++ * fault, fill the hole in the file and COW it right away. The ++ * result generates plain anonymous memory. So when we are ++ * asked to fill an hole in a MAP_PRIVATE shmem mapping, we'll ++ * generate anonymous memory directly without actually filling ++ * the hole. For the MAP_PRIVATE case the robustness check ++ * only happens in the pagetable (to verify it's still none) ++ * and not in the radix tree. ++ */ ++ if (!(dst_vma->vm_flags & VM_SHARED)) { + if (!zeropage) + err = mcopy_atomic_pte(dst_mm, dst_pmd, dst_vma, + dst_addr, src_addr, page); +@@ -440,13 +473,9 @@ retry: + if (!dst_vma) + goto out_unlock; + /* +- * Be strict and only allow __mcopy_atomic on userfaultfd +- * registered ranges to prevent userland errors going +- * unnoticed. As far as the VM consistency is concerned, it +- * would be perfectly safe to remove this check, but there's +- * no useful usage for __mcopy_atomic ouside of userfaultfd +- * registered ranges. This is after all why these are ioctls +- * belonging to the userfaultfd and not syscalls. ++ * Check the vma is registered in uffd, this is required to ++ * enforce the VM_MAYWRITE check done at uffd registration ++ * time. + */ + if (!dst_vma->vm_userfaultfd_ctx.ctx) + goto out_unlock; +@@ -480,7 +509,8 @@ retry: + * dst_vma. + */ + err = -ENOMEM; +- if (vma_is_anonymous(dst_vma) && unlikely(anon_vma_prepare(dst_vma))) ++ if (!(dst_vma->vm_flags & VM_SHARED) && ++ unlikely(anon_vma_prepare(dst_vma))) + goto out_unlock; + + while (src_addr < src_start + len) { +@@ -521,7 +551,7 @@ retry: + src_addr, &page, zeropage); + cond_resched(); + +- if (unlikely(err == -EFAULT)) { ++ if (unlikely(err == -ENOENT)) { + void *page_kaddr; + + up_read(&dst_mm->mmap_sem); +diff --git a/mm/vmstat.c b/mm/vmstat.c +index 527ae727d547..6389e876c7a7 100644 +--- a/mm/vmstat.c ++++ b/mm/vmstat.c +@@ -1500,6 +1500,10 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat, + if (is_zone_first_populated(pgdat, zone)) { + seq_printf(m, "\n per-node stats"); + for (i = 0; i < NR_VM_NODE_STAT_ITEMS; i++) { ++ /* Skip hidden vmstat items. */ ++ if (*vmstat_text[i + NR_VM_ZONE_STAT_ITEMS + ++ NR_VM_NUMA_STAT_ITEMS] == '\0') ++ continue; + seq_printf(m, "\n %-12s %lu", + vmstat_text[i + NR_VM_ZONE_STAT_ITEMS + + NR_VM_NUMA_STAT_ITEMS], +diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c +index 72eee34092ae..fabc299cb875 100644 +--- a/net/ipv4/ip_tunnel.c ++++ b/net/ipv4/ip_tunnel.c +@@ -261,8 +261,8 @@ static struct net_device *__ip_tunnel_create(struct net *net, + } else { + if (strlen(ops->kind) > (IFNAMSIZ - 3)) + goto failed; +- strlcpy(name, ops->kind, IFNAMSIZ); +- strncat(name, "%d", 2); ++ strcpy(name, ops->kind); ++ strcat(name, "%d"); + } + + ASSERT_RTNL(); +diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c +index be3d9e3183dc..959c9aea3d1a 100644 +--- a/net/tipc/subscr.c ++++ b/net/tipc/subscr.c +@@ -375,7 +375,7 @@ int tipc_topsrv_start(struct net *net) + topsrv->tipc_conn_new = tipc_subscrb_connect_cb; + topsrv->tipc_conn_release = tipc_subscrb_release_cb; + +- strncpy(topsrv->name, name, strlen(name) + 1); ++ strscpy(topsrv->name, name, sizeof(topsrv->name)); + tn->topsrv = topsrv; + atomic_set(&tn->subscription_count, 0); + +diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn +index c6ebf4239e64..8d5357053f86 100644 +--- a/scripts/Makefile.extrawarn ++++ b/scripts/Makefile.extrawarn +@@ -11,6 +11,8 @@ + # are not supported by all versions of the compiler + # ========================================================================== + ++KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned) ++ + ifeq ("$(origin W)", "command line") + export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W) + endif +@@ -26,6 +28,7 @@ warning-1 += -Wold-style-definition + warning-1 += $(call cc-option, -Wmissing-include-dirs) + warning-1 += $(call cc-option, -Wunused-but-set-variable) + warning-1 += $(call cc-option, -Wunused-const-variable) ++warning-1 += $(call cc-option, -Wpacked-not-aligned) + warning-1 += $(call cc-disable-warning, missing-field-initializers) + warning-1 += $(call cc-disable-warning, sign-compare) + +diff --git a/scripts/unifdef.c b/scripts/unifdef.c +index 7493c0ee51cc..db00e3e30a59 100644 +--- a/scripts/unifdef.c ++++ b/scripts/unifdef.c +@@ -395,7 +395,7 @@ usage(void) + * When we have processed a group that starts off with a known-false + * #if/#elif sequence (which has therefore been deleted) followed by a + * #elif that we don't understand and therefore must keep, we edit the +- * latter into a #if to keep the nesting correct. We use strncpy() to ++ * latter into a #if to keep the nesting correct. We use memcpy() to + * overwrite the 4 byte token "elif" with "if " without a '\0' byte. + * + * When we find a true #elif in a group, the following block will +@@ -450,7 +450,7 @@ static void Idrop (void) { Fdrop(); ignoreon(); } + static void Itrue (void) { Ftrue(); ignoreon(); } + static void Ifalse(void) { Ffalse(); ignoreon(); } + /* modify this line */ +-static void Mpass (void) { strncpy(keyword, "if ", 4); Pelif(); } ++static void Mpass (void) { memcpy(keyword, "if ", 4); Pelif(); } + static void Mtrue (void) { keywordedit("else"); state(IS_TRUE_MIDDLE); } + static void Melif (void) { keywordedit("endif"); state(IS_FALSE_TRAILER); } + static void Melse (void) { keywordedit("endif"); state(IS_FALSE_ELSE); } +diff --git a/sound/pci/trident/trident.c b/sound/pci/trident/trident.c +index cedf13b64803..2f18b1cdc2cd 100644 +--- a/sound/pci/trident/trident.c ++++ b/sound/pci/trident/trident.c +@@ -123,7 +123,7 @@ static int snd_trident_probe(struct pci_dev *pci, + } else { + strcpy(card->shortname, "Trident "); + } +- strcat(card->shortname, card->driver); ++ strcat(card->shortname, str); + sprintf(card->longname, "%s PCI Audio at 0x%lx, irq %d", + card->shortname, trident->port, trident->irq); + +diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c +index 697872d8308e..8b7abbd69116 100644 +--- a/sound/x86/intel_hdmi_audio.c ++++ b/sound/x86/intel_hdmi_audio.c +@@ -1839,7 +1839,7 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev) + /* setup private data which can be retrieved when required */ + pcm->private_data = ctx; + pcm->info_flags = 0; +- strncpy(pcm->name, card->shortname, strlen(card->shortname)); ++ strlcpy(pcm->name, card->shortname, strlen(card->shortname)); + /* setup the ops for playabck */ + snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &had_pcm_ops); +