Listing 1. Test Bug

// Someone is opening our device
static int gOpen(struct inode *Inode, struct file *fp)
{
    printk("%s: (%d:%d) open(%p, %p)\n",
           GENTEST_MODULE_NAME,
           MAJOR(Inode->i_rdev), MINOR(Inode->i_rdev),
           Inode, fp);

    // Increment our USE count.  This is so no one
    // can remove the module while it's being used.
    MOD_INC_USE_COUNT;

    // Hang when device 4  is opened
    if (MINOR(Inode->i_rdev) == 4) {
       int i;
       printk("Computing pi to the last
              decimal position . . .\n");
       for (;;) i++;
    }

    return 0;
} // gOpen