vfio: ccw: remove unnecessary NULL checks of a pointer
authorDong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
Wed, 12 Apr 2017 09:08:15 +0000 (11:08 +0200)
committerCornelia Huck <cornelia.huck@de.ibm.com>
Wed, 12 Apr 2017 10:33:36 +0000 (12:33 +0200)
Remove several unnecessary checks for the @private pointer, since it
can never be NULL in these places.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
Message-Id: <20170412090816.79108-2-bjsdjshi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
drivers/s390/cio/vfio_ccw_fsm.c
drivers/s390/cio/vfio_ccw_ops.c

index 55b6cc55758eece2641e48f37dbb645dd0ac5dc5..80a0559cd7ce2b6525628a48b2f735a1a29e79aa 100644 (file)
@@ -161,12 +161,8 @@ err_out:
 static void fsm_irq(struct vfio_ccw_private *private,
                    enum vfio_ccw_event event)
 {
-       struct irb *irb;
+       struct irb *irb = this_cpu_ptr(&cio_irb);
 
-       if (!private)
-               return;
-
-       irb = this_cpu_ptr(&cio_irb);
        memcpy(&private->irb, irb, sizeof(*irb));
 
        queue_work(vfio_ccw_work_q, &private->io_work);
index b2e6154040344a323a412dca46caede26abd2023..55d0c87e73c3c58161b0238f5143ae4d896923e7 100644 (file)
@@ -19,9 +19,6 @@ static int vfio_ccw_mdev_reset(struct mdev_device *mdev)
        int ret;
 
        private = dev_get_drvdata(mdev_parent_dev(mdev));
-       if (!private)
-               return -ENODEV;
-
        sch = private->sch;
        /*
         * TODO:
@@ -49,9 +46,6 @@ static int vfio_ccw_mdev_notifier(struct notifier_block *nb,
        struct vfio_ccw_private *private =
                container_of(nb, struct vfio_ccw_private, nb);
 
-       if (!private)
-               return NOTIFY_STOP;
-
        /*
         * Vendor drivers MUST unpin pages in response to an
         * invalidation.
@@ -134,9 +128,6 @@ static int vfio_ccw_mdev_remove(struct mdev_device *mdev)
                dev_get_drvdata(mdev_parent_dev(mdev));
        int ret;
 
-       if (!private)
-               goto out;
-
        if ((private->state == VFIO_CCW_STATE_NOT_OPER) ||
            (private->state == VFIO_CCW_STATE_STANDBY))
                goto out;
@@ -187,9 +178,6 @@ static ssize_t vfio_ccw_mdev_read(struct mdev_device *mdev,
                return -EINVAL;
 
        private = dev_get_drvdata(mdev_parent_dev(mdev));
-       if (!private)
-               return -ENODEV;
-
        region = &private->io_region;
        if (copy_to_user(buf, (void *)region + *ppos, count))
                return -EFAULT;
@@ -209,8 +197,6 @@ static ssize_t vfio_ccw_mdev_write(struct mdev_device *mdev,
                return -EINVAL;
 
        private = dev_get_drvdata(mdev_parent_dev(mdev));
-       if (!private)
-               return -ENODEV;
        if (private->state != VFIO_CCW_STATE_IDLE)
                return -EACCES;
 
@@ -274,9 +260,6 @@ static int vfio_ccw_mdev_set_irqs(struct mdev_device *mdev,
                return -EINVAL;
 
        private = dev_get_drvdata(mdev_parent_dev(mdev));
-       if (!private)
-               return -ENODEV;
-
        ctx = &private->io_trigger;
 
        switch (flags & VFIO_IRQ_SET_DATA_TYPE_MASK) {