Skip to content

Commit 98dba02

Browse files
Mikulas PatockaMike Snitzer
authored andcommitted
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: [email protected] Signed-off-by: Mikulas Patocka <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent 3d32aaa commit 98dba02

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/md/dm-flakey.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ static int parse_features(struct dm_arg_set *as, struct flakey_c *fc,
125125
* Direction r or w?
126126
*/
127127
arg_name = dm_shift_arg(as);
128-
if (!strcasecmp(arg_name, "w"))
128+
if (arg_name && !strcasecmp(arg_name, "w"))
129129
fc->corrupt_bio_rw = WRITE;
130-
else if (!strcasecmp(arg_name, "r"))
130+
else if (arg_name && !strcasecmp(arg_name, "r"))
131131
fc->corrupt_bio_rw = READ;
132132
else {
133133
ti->error = "Invalid corrupt bio direction (r or w)";

0 commit comments

Comments
 (0)