In some environments an attempt to load ltp_tbio.ko module will result in a kernel panic.
It happens, because after the module is loaded (add_disk(tbio_dev.gd) in tbio_init() is executed), one or more ioctl() calls are issued to the newly created block device. However, when ioctl() is called, there is no (yet) file /dev/tbio created. Therefore, in tbio_ioctl(): tbio_dev.bdev = blkdev_get_by_path( DEVICE_NAME, FMODE_READ | FMODE_WRITE, NULL); returns -ENODEV, i.e. tbio_dev.bdev == -ENODEV, and it produces a kernel panic at: blkdev_put(tbio_dev.bdev, FMODE_READ | FMODE_WRITE); We could introduce error checking here like this: if (IS_ERR(tbio_dev.bdev)) return PTR_ERR(tbio_dev.bdev); but I assume it would be better to return the previous logic, before commit 69d3b32681 "device-drivers: tbio: fixes", i.e. where tbio_dev.bdev is assigned in tbio_open(). Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmansk...@oracle.com> --- .../device-drivers/tbio/tbio_kernel/ltp_tbio.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-) diff --git a/testcases/kernel/device-drivers/tbio/tbio_kernel/ltp_tbio.c b/testcases/kernel/device-drivers/tbio/tbio_kernel/ltp_tbio.c index 5198b82..4e38fe7 100644 --- a/testcases/kernel/device-drivers/tbio/tbio_kernel/ltp_tbio.c +++ b/testcases/kernel/device-drivers/tbio/tbio_kernel/ltp_tbio.c @@ -376,14 +376,11 @@ static int tbio_ioctl(struct block_device *blk, fmode_t mode, { int err = 0; - tbio_dev.bdev = blkdev_get_by_path( - DEVICE_NAME, FMODE_READ | FMODE_WRITE, NULL); - switch (cmd) { case LTP_TBIO_DO_IO: prk_info("TEST-CASE: LTP_TBIO_DO_IO:"); err = tbio_io(tbio_dev.bdev, (struct tbio_interface *)arg); - break; + break; case LTP_TBIO_CLONE: prk_info("TEST-CASE: LTP_TBIO_CLONE:"); err = test_bio_clone(); @@ -412,7 +409,6 @@ static int tbio_ioctl(struct block_device *blk, fmode_t mode, } prk_info("TEST-CASE DONE"); - blkdev_put(tbio_dev.bdev, FMODE_READ | FMODE_WRITE); return err; } @@ -475,6 +471,8 @@ static void tbio_request(struct request_queue *q) static int tbio_open(struct block_device *blk, fmode_t mode) { + tbio_dev.bdev = blk; + return 0; } -- 1.7.1 ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list