Skip to content

Commit 07641b5

Browse files
zhangyueliu-song-6
authored andcommitted
md: fix double free of mddev->private in autorun_array()
In driver/md/md.c, if the function autorun_array() is called, the problem of double free may occur. In function autorun_array(), when the function do_md_run() returns an error, the function do_md_stop() will be called. The function do_md_run() called function md_run(), but in function md_run(), the pointer mddev->private may be freed. The function do_md_stop() called the function __md_stop(), but in function __md_stop(), the pointer mddev->private also will be freed without judging null. At this time, the pointer mddev->private will be double free, so it needs to be judged null or not. Signed-off-by: zhangyue <[email protected]> Signed-off-by: Song Liu <[email protected]>
1 parent 55df1ce commit 07641b5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/md/md.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6271,7 +6271,8 @@ static void __md_stop(struct mddev *mddev)
62716271
spin_lock(&mddev->lock);
62726272
mddev->pers = NULL;
62736273
spin_unlock(&mddev->lock);
6274-
pers->free(mddev, mddev->private);
6274+
if (mddev->private)
6275+
pers->free(mddev, mddev->private);
62756276
mddev->private = NULL;
62766277
if (pers->sync_request && mddev->to_remove == NULL)
62776278
mddev->to_remove = &md_redundancy_group;

0 commit comments

Comments
 (0)