s390/vmur: remove unnecessary BUG statement
authorPeter Oberparleiter <oberpar@linux.ibm.com>
Wed, 28 Sep 2022 13:34:33 +0000 (15:34 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Mon, 10 Oct 2022 08:15:10 +0000 (10:15 +0200)
An existing BUG statement in vmur's interrupt handler triggers if:

  1. An online vmur device is removed (e.g. due to driver unload, manual
     unbind or channel-report words indicating hypervisor-side device
     removal)
  2. Device deactivation fails due to firmware/hypervisor error, leaving
     subchannel enabled for interrupts + drvdata=NULL
  3. Interrupt occurs

This situation is highly unlikely and not a clear indication of a
general system error that would warrant stopping the full Linux system.
Also it can be prevented completely by clearing the interrupt handler
when unsetting a vmur device's drvdata.

Replace the BUG statement in vmur's interrupt handler by clearing the
interrupt handler callback during device removal. Also move the initial
setting of the interrupt handler callback under lock for consistency
reasons.

Reviewed-by: Sven Schnelle <svens@linux.ibm.com>
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
drivers/s390/char/vmur.c

index 68f49e2e964c0d9877d3e1410cee6c1d689afe06..471f07ca5066c3d07c8eac25c5e898bfb916e70b 100644 (file)
@@ -293,7 +293,6 @@ static void ur_int_handler(struct ccw_device *cdev, unsigned long intparm,
                return;
        }
        urd = dev_get_drvdata(&cdev->dev);
-       BUG_ON(!urd);
        /* On special conditions irb is an error pointer */
        if (IS_ERR(irb))
                urd->io_request_rc = PTR_ERR(irb);
@@ -809,7 +808,6 @@ static int ur_probe(struct ccw_device *cdev)
                rc = -ENOMEM;
                goto fail_urdev_put;
        }
-       cdev->handler = ur_int_handler;
 
        /* validate virtual unit record device */
        urd->class = get_urd_class(urd);
@@ -823,6 +821,7 @@ static int ur_probe(struct ccw_device *cdev)
        }
        spin_lock_irq(get_ccwdev_lock(cdev));
        dev_set_drvdata(&cdev->dev, urd);
+       cdev->handler = ur_int_handler;
        spin_unlock_irq(get_ccwdev_lock(cdev));
 
        mutex_unlock(&vmur_mutex);
@@ -963,6 +962,7 @@ static void ur_remove(struct ccw_device *cdev)
        spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
        urdev_put(dev_get_drvdata(&cdev->dev));
        dev_set_drvdata(&cdev->dev, NULL);
+       cdev->handler = NULL;
        spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
 
        mutex_unlock(&vmur_mutex);