History log of /external/ltp/testcases/kernel/device-drivers/tbio/tbio_kernel/ltp_tbio.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
49a41ae3b50c87b01fbd6e4e9dbd80d1a2ee18e0 19-Dec-2014 Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com> tbio: fix cmd_len handling

sizeof(rq->cmd) does not return the size of cmd buffer in rq,
it will return the size of the pointer, i.e. 4 - on 32-bit systems,
and 8 - on 64-bit systems. This happens, because cmd is a pointer to
__cmd[BLK_MAX_CDB] in struct request in the kernel (see linux/blkdev.h):

unsigned char __cmd[BLK_MAX_CDB];
unsigned char *cmd;
unsigned short cmd_len;

and is not a static buffer by itself.

Therefore on 32-bit systems 'sizeof(rq->cmd) - inter->cmd_len)' will be
'4 - 6', and this is not what we want.

Corrected this, so now we rely on inter->cmd containing a null-terminated string,
and inter->cmd_len containing the exact number of bytes to store this string.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
Acked-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/testcases/kernel/device-drivers/tbio/tbio_kernel/ltp_tbio.c
8480a1910fb4b08951f68a43a2bf227e010777f3 19-Dec-2014 Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com> ltp_tbio.c: fix a possible kernel panic

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.kholmanskikh@oracle.com>
Acked-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/testcases/kernel/device-drivers/tbio/tbio_kernel/ltp_tbio.c
69d3b326811ba347e75335756ae7c5334deb9f11 22-Oct-2013 Alexey Kodanev <alexey.kodanev@oracle.com> device-drivers: tbio: fixes

Obsolete code updated to the actual kernel BIO API.
User-space program rewritten to use LTP lib.

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
/external/ltp/testcases/kernel/device-drivers/tbio/tbio_kernel/ltp_tbio.c
82a13465123b31108d914fe148646c58e23532be 18-Oct-2013 Alexey Kodanev <alexey.kodanev@oracle.com> device-drivers: tbio: rearrange test files

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
/external/ltp/testcases/kernel/device-drivers/tbio/tbio_kernel/ltp_tbio.c