summaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-flakey.c
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2023-04-18 21:57:47 +0200
committerMike Snitzer <snitzer@kernel.org>2023-04-19 17:06:36 +0200
commit98dba02d9a93eec11bffbb93c7c51624290702d2 (patch)
tree3f8b851cfc7c7e8fe2d60a422a2e04c67c19df99 /drivers/md/dm-flakey.c
parentdm ioctl: fix nested locking in table_clear() to remove deadlock concern (diff)
downloadlinux-98dba02d9a93eec11bffbb93c7c51624290702d2.tar.xz
linux-98dba02d9a93eec11bffbb93c7c51624290702d2.zip
dm flakey: fix a crash with invalid table line
This command will crash with NULL pointer dereference: dmsetup create flakey --table \ "0 `blockdev --getsize /dev/ram0` flakey /dev/ram0 0 0 1 2 corrupt_bio_byte 512" Fix the crash by checking if arg_name is non-NULL before comparing it. Cc: stable@vger.kernel.org Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Diffstat (limited to 'drivers/md/dm-flakey.c')
-rw-r--r--drivers/md/dm-flakey.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/md/dm-flakey.c b/drivers/md/dm-flakey.c
index ebcfb99b186b..ef07b294e550 100644
--- a/drivers/md/dm-flakey.c
+++ b/drivers/md/dm-flakey.c
@@ -125,9 +125,9 @@ static int parse_features(struct dm_arg_set *as, struct flakey_c *fc,
* Direction r or w?
*/
arg_name = dm_shift_arg(as);
- if (!strcasecmp(arg_name, "w"))
+ if (arg_name && !strcasecmp(arg_name, "w"))
fc->corrupt_bio_rw = WRITE;
- else if (!strcasecmp(arg_name, "r"))
+ else if (arg_name && !strcasecmp(arg_name, "r"))
fc->corrupt_bio_rw = READ;
else {
ti->error = "Invalid corrupt bio direction (r or w)";