Merge remote-tracking branch 'lsk/v3.10/topic/of' into linux-linaro-lsk
[firefly-linux-kernel-4.4.55.git] / block / genhd.c
index e670148c3773a2d0b3486c09dca6fabc44198377..ea49f8631c229dabb47865a2d1eddba8e8f3b94e 100644 (file)
@@ -1070,9 +1070,16 @@ int disk_expand_part_tbl(struct gendisk *disk, int partno)
        struct disk_part_tbl *old_ptbl = disk->part_tbl;
        struct disk_part_tbl *new_ptbl;
        int len = old_ptbl ? old_ptbl->len : 0;
-       int target = partno + 1;
+       int i, target;
        size_t size;
-       int i;
+
+       /*
+        * check for int overflow, since we can get here from blkpg_ioctl()
+        * with a user passed 'partno'.
+        */
+       target = partno + 1;
+       if (target < 0)
+               return -EINVAL;
 
        /* disk_max_parts() is zero during initialization, ignore if so */
        if (disk_max_parts(disk) && target > disk_max_parts(disk))
@@ -1491,9 +1498,11 @@ static void __disk_unblock_events(struct gendisk *disk, bool check_now)
        intv = disk_events_poll_jiffies(disk);
        set_timer_slack(&ev->dwork.timer, intv / 4);
        if (check_now)
-               queue_delayed_work(system_freezable_wq, &ev->dwork, 0);
+               queue_delayed_work(system_freezable_power_efficient_wq,
+                               &ev->dwork, 0);
        else if (intv)
-               queue_delayed_work(system_freezable_wq, &ev->dwork, intv);
+               queue_delayed_work(system_freezable_power_efficient_wq,
+                               &ev->dwork, intv);
 out_unlock:
        spin_unlock_irqrestore(&ev->lock, flags);
 }
@@ -1536,7 +1545,8 @@ void disk_flush_events(struct gendisk *disk, unsigned int mask)
        spin_lock_irq(&ev->lock);
        ev->clearing |= mask;
        if (!ev->block)
-               mod_delayed_work(system_freezable_wq, &ev->dwork, 0);
+               mod_delayed_work(system_freezable_power_efficient_wq,
+                               &ev->dwork, 0);
        spin_unlock_irq(&ev->lock);
 }
 
@@ -1629,7 +1639,8 @@ static void disk_check_events(struct disk_events *ev,
 
        intv = disk_events_poll_jiffies(disk);
        if (!ev->block && intv)
-               queue_delayed_work(system_freezable_wq, &ev->dwork, intv);
+               queue_delayed_work(system_freezable_power_efficient_wq,
+                               &ev->dwork, intv);
 
        spin_unlock_irq(&ev->lock);