Linux loop device driver bug (and fix)

Thomas Horsten (thomas@horsten.com)
Tue, 20 Oct 1998 16:22:58 +0200 (CEST)


Hi, this is my first mail to the list so excuse me if I sound stupid.

I have no idea about how to submit bugfixes so I try here :)

I've written an RC5 encryption driver for the loopback device but I
encountered a bug in the loop.c driver. It calls the "release_transfer"
function whenever a file access to the device is closed, but it should
only call it when the device is unset.

This is quite obviously a bug since the corresponding init function is
only called when the device is configured. If the release function is
called in the file_operations release function my module has no way of
knowing it's use count.

So here's the fix:

***************
*** 611,619 ****
if (lo->lo_refcnt <= 0)
printk(KERN_ERR "lo_release: refcount(%d) <= 0\n",
lo->lo_refcnt);
else {
! if (--lo->lo_refcnt == 0)
! err = loop_release_xfer(lo);
! MOD_DEC_USE_COUNT;
}
return err;
}
--- 611,617 ----
if (lo->lo_refcnt <= 0)
printk(KERN_ERR "lo_release: refcount(%d) <= 0\n",
lo->lo_refcnt);
else {
! MOD_DEC_USE_COUNT;
}
return err;
}

Yours sincerely,

Thomas Horsten
Thomas@Horsten.COM

--
PGP public key available, finger thomas@horsten.com

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/