diff --git a/Makefile b/Makefile
index 0f3d843f42a7..1207bf6a0e7a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 VERSION = 4
 PATCHLEVEL = 4
-SUBLEVEL = 85
+SUBLEVEL = 86
 EXTRAVERSION =
 NAME = Blurry Fish Butt
 
diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
index 4c46c54a3ad7..6638903f0cb9 100644
--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
@@ -157,9 +157,11 @@ void fpsimd_thread_switch(struct task_struct *next)
 
 void fpsimd_flush_thread(void)
 {
+       preempt_disable();
        memset(&current->thread.fpsimd_state, 0, sizeof(struct fpsimd_state));
        fpsimd_flush_task_state(current);
        set_thread_flag(TIF_FOREIGN_FPSTATE);
+       preempt_enable();
 }
 
 /*
diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index a4b466424a32..7fabf49f2aeb 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -313,8 +313,11 @@ retry:
         * signal first. We do not need to release the mmap_sem because it
         * would already be released in __lock_page_or_retry in mm/filemap.c.
         */
-       if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
+       if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) {
+               if (!user_mode(regs))
+                       goto no_context;
                return 0;
+       }
 
        /*
         * Major/minor page fault accounting is only done on the initial
diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index de25aad07853..9016b4b70375 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -304,13 +304,13 @@ static inline unsigned type in##bwl##_p(int port)         
        \
 static inline void outs##bwl(int port, const void *addr, unsigned long count) \
 {                                                                      \
        asm volatile("rep; outs" #bwl                                   \
-                    : "+S"(addr), "+c"(count) : "d"(port));            \
+                    : "+S"(addr), "+c"(count) : "d"(port) : "memory"); \
 }                                                                      \
                                                                        \
 static inline void ins##bwl(int port, void *addr, unsigned long count) \
 {                                                                      \
        asm volatile("rep; ins" #bwl                                    \
-                    : "+D"(addr), "+c"(count) : "d"(port));            \
+                    : "+D"(addr), "+c"(count) : "d"(port) : "memory"); \
 }
 
 BUILDIO(b, b, char)
diff --git a/drivers/gpu/drm/i915/intel_uncore.c 
b/drivers/gpu/drm/i915/intel_uncore.c
index cc91ae832ffb..6fd7b50c5747 100644
--- a/drivers/gpu/drm/i915/intel_uncore.c
+++ b/drivers/gpu/drm/i915/intel_uncore.c
@@ -635,7 +635,8 @@ hsw_unclaimed_reg_detect(struct drm_i915_private *dev_priv)
                          "enabling oneshot unclaimed register reporting. "
                          "Please use i915.mmio_debug=N for more 
information.\n");
                __raw_i915_write32(dev_priv, FPGA_DBG, FPGA_DBG_RM_NOCLAIM);
-               i915.mmio_debug = mmio_debug_once--;
+               i915.mmio_debug = mmio_debug_once;
+               mmio_debug_once = false;
        }
 }
 
diff --git a/drivers/i2c/busses/i2c-jz4780.c b/drivers/i2c/busses/i2c-jz4780.c
index f325663c27c5..4b58e8aaf5c5 100644
--- a/drivers/i2c/busses/i2c-jz4780.c
+++ b/drivers/i2c/busses/i2c-jz4780.c
@@ -786,10 +786,6 @@ static int jz4780_i2c_probe(struct platform_device *pdev)
 
        jz4780_i2c_writew(i2c, JZ4780_I2C_INTM, 0x0);
 
-       i2c->cmd = 0;
-       memset(i2c->cmd_buf, 0, BUFSIZE);
-       memset(i2c->data_buf, 0, BUFSIZE);
-
        i2c->irq = platform_get_irq(pdev, 0);
        ret = devm_request_irq(&pdev->dev, i2c->irq, jz4780_i2c_irq, 0,
                               dev_name(&pdev->dev), i2c);
diff --git a/drivers/net/wireless/p54/fwio.c b/drivers/net/wireless/p54/fwio.c
index 257a9eadd595..4ac6764f4897 100644
--- a/drivers/net/wireless/p54/fwio.c
+++ b/drivers/net/wireless/p54/fwio.c
@@ -488,7 +488,7 @@ int p54_scan(struct p54_common *priv, u16 mode, u16 dwell)
 
                        entry += sizeof(__le16);
                        chan->pa_points_per_curve = 8;
-                       memset(chan->curve_data, 0, sizeof(*chan->curve_data));
+                       memset(chan->curve_data, 0, sizeof(chan->curve_data));
                        memcpy(chan->curve_data, entry,
                               sizeof(struct p54_pa_curve_data_sample) *
                               min((u8)8, curve_data->points_per_channel));
diff --git a/drivers/scsi/isci/remote_node_context.c 
b/drivers/scsi/isci/remote_node_context.c
index 1910100638a2..00602abec0ea 100644
--- a/drivers/scsi/isci/remote_node_context.c
+++ b/drivers/scsi/isci/remote_node_context.c
@@ -66,6 +66,9 @@ const char *rnc_state_name(enum 
scis_sds_remote_node_context_states state)
 {
        static const char * const strings[] = RNC_STATES;
 
+       if (state >= ARRAY_SIZE(strings))
+               return "UNKNOWN";
+
        return strings[state];
 }
 #undef C
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 0e6aaef9a038..c74f74ab981c 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -1054,7 +1054,10 @@ stop_rr_fcf_flogi:
                                        lpfc_sli4_unreg_all_rpis(vport);
                                }
                        }
-                       lpfc_issue_reg_vfi(vport);
+
+                       /* Do not register VFI if the driver aborted FLOGI */
+                       if (!lpfc_error_lost_link(irsp))
+                               lpfc_issue_reg_vfi(vport);
                        lpfc_nlp_put(ndlp);
                        goto out;
                }
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 6514636431ab..8a9e139e2853 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -153,6 +153,7 @@ typedef struct sg_fd {              /* holds the state of a 
file descriptor */
        struct sg_device *parentdp;     /* owning device */
        wait_queue_head_t read_wait;    /* queue read until command done */
        rwlock_t rq_list_lock;  /* protect access to list in req_arr */
+       struct mutex f_mutex;   /* protect against changes in this fd */
        int timeout;            /* defaults to SG_DEFAULT_TIMEOUT      */
        int timeout_user;       /* defaults to SG_DEFAULT_TIMEOUT_USER */
        Sg_scatter_hold reserve;        /* buffer held for this file descriptor 
*/
@@ -166,6 +167,7 @@ typedef struct sg_fd {              /* holds the state of a 
file descriptor */
        unsigned char next_cmd_len; /* 0: automatic, >0: use on next write() */
        char keep_orphan;       /* 0 -> drop orphan (def), 1 -> keep for read() 
*/
        char mmap_called;       /* 0 -> mmap() never called on this fd */
+       char res_in_use;        /* 1 -> 'reserve' array in use */
        struct kref f_ref;
        struct execute_work ew;
 } Sg_fd;
@@ -209,7 +211,6 @@ static void sg_remove_sfp(struct kref *);
 static Sg_request *sg_get_rq_mark(Sg_fd * sfp, int pack_id);
 static Sg_request *sg_add_request(Sg_fd * sfp);
 static int sg_remove_request(Sg_fd * sfp, Sg_request * srp);
-static int sg_res_in_use(Sg_fd * sfp);
 static Sg_device *sg_get_dev(int dev);
 static void sg_device_destroy(struct kref *kref);
 
@@ -625,6 +626,7 @@ sg_write(struct file *filp, const char __user *buf, size_t 
count, loff_t * ppos)
        }
        buf += SZ_SG_HEADER;
        __get_user(opcode, buf);
+       mutex_lock(&sfp->f_mutex);
        if (sfp->next_cmd_len > 0) {
                cmd_size = sfp->next_cmd_len;
                sfp->next_cmd_len = 0;  /* reset so only this write() effected 
*/
@@ -633,6 +635,7 @@ sg_write(struct file *filp, const char __user *buf, size_t 
count, loff_t * ppos)
                if ((opcode >= 0xc0) && old_hdr.twelve_byte)
                        cmd_size = 12;
        }
+       mutex_unlock(&sfp->f_mutex);
        SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sdp,
                "sg_write:   scsi opcode=0x%02x, cmd_size=%d\n", (int) opcode, 
cmd_size));
 /* Determine buffer size.  */
@@ -732,7 +735,7 @@ sg_new_write(Sg_fd *sfp, struct file *file, const char 
__user *buf,
                        sg_remove_request(sfp, srp);
                        return -EINVAL; /* either MMAP_IO or DIRECT_IO (not 
both) */
                }
-               if (sg_res_in_use(sfp)) {
+               if (sfp->res_in_use) {
                        sg_remove_request(sfp, srp);
                        return -EBUSY;  /* reserve buffer already being used */
                }
@@ -902,7 +905,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned 
long arg)
                        return result;
                if (val) {
                        sfp->low_dma = 1;
-                       if ((0 == sfp->low_dma) && (0 == sg_res_in_use(sfp))) {
+                       if ((0 == sfp->low_dma) && !sfp->res_in_use) {
                                val = (int) sfp->reserve.bufflen;
                                sg_remove_scat(sfp, &sfp->reserve);
                                sg_build_reserve(sfp, val);
@@ -977,12 +980,18 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned 
long arg)
                         return -EINVAL;
                val = min_t(int, val,
                            max_sectors_bytes(sdp->device->request_queue));
+               mutex_lock(&sfp->f_mutex);
                if (val != sfp->reserve.bufflen) {
-                       if (sg_res_in_use(sfp) || sfp->mmap_called)
+                       if (sfp->mmap_called ||
+                           sfp->res_in_use) {
+                               mutex_unlock(&sfp->f_mutex);
                                return -EBUSY;
+                       }
+
                        sg_remove_scat(sfp, &sfp->reserve);
                        sg_build_reserve(sfp, val);
                }
+               mutex_unlock(&sfp->f_mutex);
                return 0;
        case SG_GET_RESERVED_SIZE:
                val = min_t(int, sfp->reserve.bufflen,
@@ -1737,13 +1746,22 @@ sg_start_req(Sg_request *srp, unsigned char *cmd)
                md = &map_data;
 
        if (md) {
-               if (!sg_res_in_use(sfp) && dxfer_len <= rsv_schp->bufflen)
+               mutex_lock(&sfp->f_mutex);
+               if (dxfer_len <= rsv_schp->bufflen &&
+                   !sfp->res_in_use) {
+                       sfp->res_in_use = 1;
                        sg_link_reserve(sfp, srp, dxfer_len);
-               else {
+               } else if ((hp->flags & SG_FLAG_MMAP_IO) && sfp->res_in_use) {
+                       mutex_unlock(&sfp->f_mutex);
+                       return -EBUSY;
+               } else {
                        res = sg_build_indirect(req_schp, sfp, dxfer_len);
-                       if (res)
+                       if (res) {
+                               mutex_unlock(&sfp->f_mutex);
                                return res;
+                       }
                }
+               mutex_unlock(&sfp->f_mutex);
 
                md->pages = req_schp->pages;
                md->page_order = req_schp->page_order;
@@ -2034,6 +2052,8 @@ sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp)
        req_schp->sglist_len = 0;
        sfp->save_scat_len = 0;
        srp->res_used = 0;
+       /* Called without mutex lock to avoid deadlock */
+       sfp->res_in_use = 0;
 }
 
 static Sg_request *
@@ -2145,6 +2165,7 @@ sg_add_sfp(Sg_device * sdp)
        rwlock_init(&sfp->rq_list_lock);
 
        kref_init(&sfp->f_ref);
+       mutex_init(&sfp->f_mutex);
        sfp->timeout = SG_DEFAULT_TIMEOUT;
        sfp->timeout_user = SG_DEFAULT_TIMEOUT_USER;
        sfp->force_packid = SG_DEF_FORCE_PACK_ID;
@@ -2220,20 +2241,6 @@ sg_remove_sfp(struct kref *kref)
        schedule_work(&sfp->ew.work);
 }
 
-static int
-sg_res_in_use(Sg_fd * sfp)
-{
-       const Sg_request *srp;
-       unsigned long iflags;
-
-       read_lock_irqsave(&sfp->rq_list_lock, iflags);
-       for (srp = sfp->headrp; srp; srp = srp->nextrp)
-               if (srp->res_used)
-                       break;
-       read_unlock_irqrestore(&sfp->rq_list_lock, iflags);
-       return srp ? 1 : 0;
-}
-
 #ifdef CONFIG_SCSI_PROC_FS
 static int
 sg_idr_max_id(int id, void *p, void *data)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 9c62a6f9757a..600c67ef8a03 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -108,7 +108,7 @@ const struct btrfs_raid_attr 
btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
        },
 };
 
-const u64 const btrfs_raid_group[BTRFS_NR_RAID_TYPES] = {
+const u64 btrfs_raid_group[BTRFS_NR_RAID_TYPES] = {
        [BTRFS_RAID_RAID10] = BTRFS_BLOCK_GROUP_RAID10,
        [BTRFS_RAID_RAID1]  = BTRFS_BLOCK_GROUP_RAID1,
        [BTRFS_RAID_DUP]    = BTRFS_BLOCK_GROUP_DUP,
diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h
index 782d4e814e21..4bc4b1b13193 100644
--- a/include/linux/lightnvm.h
+++ b/include/linux/lightnvm.h
@@ -310,6 +310,7 @@ static inline struct ppa_addr dev_to_generic_addr(struct 
nvm_dev *dev,
 {
        struct ppa_addr l;
 
+       l.ppa = 0;
        /*
         * (r.ppa << X offset) & X len bitmask. X eq. blk, pg, etc.
         */
diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
index 7080ae1eb6c1..f850e906564b 100644
--- a/kernel/gcov/base.c
+++ b/kernel/gcov/base.c
@@ -98,6 +98,12 @@ void __gcov_merge_icall_topn(gcov_type *counters, unsigned 
int n_counters)
 }
 EXPORT_SYMBOL(__gcov_merge_icall_topn);
 
+void __gcov_exit(void)
+{
+       /* Unused. */
+}
+EXPORT_SYMBOL(__gcov_exit);
+
 /**
  * gcov_enable_events - enable event reporting through gcov_event()
  *
diff --git a/kernel/gcov/gcc_4_7.c b/kernel/gcov/gcc_4_7.c
index e25e92fb44fa..46a18e72bce6 100644
--- a/kernel/gcov/gcc_4_7.c
+++ b/kernel/gcov/gcc_4_7.c
@@ -18,7 +18,9 @@
 #include <linux/vmalloc.h>
 #include "gcov.h"
 
-#if __GNUC__ == 5 && __GNUC_MINOR__ >= 1
+#if (__GNUC__ >= 7)
+#define GCOV_COUNTERS                  9
+#elif (__GNUC__ > 5) || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1)
 #define GCOV_COUNTERS                  10
 #elif __GNUC__ == 4 && __GNUC_MINOR__ >= 9
 #define GCOV_COUNTERS                  9
diff --git a/sound/pci/au88x0/au88x0_core.c b/sound/pci/au88x0/au88x0_core.c
index 74177189063c..d3125c169684 100644
--- a/sound/pci/au88x0/au88x0_core.c
+++ b/sound/pci/au88x0/au88x0_core.c
@@ -2150,8 +2150,7 @@ vortex_adb_allocroute(vortex_t *vortex, int dma, int 
nr_ch, int dir,
                                                           stream->resources, 
en,
                                                           
VORTEX_RESOURCE_SRC)) < 0) {
                                        memset(stream->resources, 0,
-                                              sizeof(unsigned char) *
-                                              VORTEX_RESOURCE_LAST);
+                                              sizeof(stream->resources));
                                        return -EBUSY;
                                }
                                if (stream->type != VORTEX_PCM_A3D) {
@@ -2161,7 +2160,7 @@ vortex_adb_allocroute(vortex_t *vortex, int dma, int 
nr_ch, int dir,
                                                                   
VORTEX_RESOURCE_MIXIN)) < 0) {
                                                memset(stream->resources,
                                                       0,
-                                                      sizeof(unsigned char) * 
VORTEX_RESOURCE_LAST);
+                                                      
sizeof(stream->resources));
                                                return -EBUSY;
                                        }
                                }
@@ -2174,8 +2173,7 @@ vortex_adb_allocroute(vortex_t *vortex, int dma, int 
nr_ch, int dir,
                                                   stream->resources, en,
                                                   VORTEX_RESOURCE_A3D)) < 0) {
                                memset(stream->resources, 0,
-                                      sizeof(unsigned char) *
-                                      VORTEX_RESOURCE_LAST);
+                                      sizeof(stream->resources));
                                dev_err(vortex->card->dev,
                                        "out of A3D sources. Sorry\n");
                                return -EBUSY;
@@ -2289,8 +2287,7 @@ vortex_adb_allocroute(vortex_t *vortex, int dma, int 
nr_ch, int dir,
                                                   VORTEX_RESOURCE_MIXOUT))
                            < 0) {
                                memset(stream->resources, 0,
-                                      sizeof(unsigned char) *
-                                      VORTEX_RESOURCE_LAST);
+                                      sizeof(stream->resources));
                                return -EBUSY;
                        }
                        if ((src[i] =
@@ -2298,8 +2295,7 @@ vortex_adb_allocroute(vortex_t *vortex, int dma, int 
nr_ch, int dir,
                                                   stream->resources, en,
                                                   VORTEX_RESOURCE_SRC)) < 0) {
                                memset(stream->resources, 0,
-                                      sizeof(unsigned char) *
-                                      VORTEX_RESOURCE_LAST);
+                                      sizeof(stream->resources));
                                return -EBUSY;
                        }
                }

Reply via email to