ANDROID: video: adf: Avoid directly referencing user pointers
[firefly-linux-kernel-4.4.55.git] / drivers / md / dm-mpath.c
index aaa6caa46a9f2dbceaf3d9c1aac92037b3b731b2..5b2ef966012b585874ca0bc796d1ff47309c8313 100644 (file)
@@ -1220,10 +1220,10 @@ static void activate_path(struct work_struct *work)
 {
        struct pgpath *pgpath =
                container_of(work, struct pgpath, activate_path.work);
+       struct request_queue *q = bdev_get_queue(pgpath->path.dev->bdev);
 
-       if (pgpath->is_active)
-               scsi_dh_activate(bdev_get_queue(pgpath->path.dev->bdev),
-                                pg_init_done, pgpath);
+       if (pgpath->is_active && !blk_queue_dying(q))
+               scsi_dh_activate(q, pg_init_done, pgpath);
        else
                pg_init_done(pgpath, SCSI_DH_DEV_OFFLINED);
 }
@@ -1537,32 +1537,34 @@ static int multipath_prepare_ioctl(struct dm_target *ti,
                struct block_device **bdev, fmode_t *mode)
 {
        struct multipath *m = ti->private;
-       struct pgpath *pgpath;
        unsigned long flags;
        int r;
 
-       r = 0;
-
        spin_lock_irqsave(&m->lock, flags);
 
        if (!m->current_pgpath)
                __choose_pgpath(m, 0);
 
-       pgpath = m->current_pgpath;
-
-       if (pgpath) {
-               *bdev = pgpath->path.dev->bdev;
-               *mode = pgpath->path.dev->mode;
+       if (m->current_pgpath) {
+               if (!m->queue_io) {
+                       *bdev = m->current_pgpath->path.dev->bdev;
+                       *mode = m->current_pgpath->path.dev->mode;
+                       r = 0;
+               } else {
+                       /* pg_init has not started or completed */
+                       r = -ENOTCONN;
+               }
+       } else {
+               /* No path is available */
+               if (m->queue_if_no_path)
+                       r = -ENOTCONN;
+               else
+                       r = -EIO;
        }
 
-       if ((pgpath && m->queue_io) || (!pgpath && m->queue_if_no_path))
-               r = -ENOTCONN;
-       else if (!*bdev)
-               r = -EIO;
-
        spin_unlock_irqrestore(&m->lock, flags);
 
-       if (r == -ENOTCONN && !fatal_signal_pending(current)) {
+       if (r == -ENOTCONN) {
                spin_lock_irqsave(&m->lock, flags);
                if (!m->current_pg) {
                        /* Path status changed, redo selection */