Skip to content

Commit 05c8de4

Browse files
XiaoNi87hailan94
authored andcommitted
md: fix return value of mddev_trylock
A return value of 0 is treaded as successful lock acquisition. In fact, a return value of 1 means getting the lock successfully. Link: https://lore.kernel.org/linux-raid/20260127073951.17248-1-xni@redhat.com Fixes: 9e59d60 ("md: call del_gendisk in control path") Reported-by: Bart Van Assche <bvanassche@acm.org> Closes: https://lore.kernel.org/linux-raid/20250611073108.25463-1-xni@redhat.com/T/#mfa369ef5faa4aa58e13e6d9fdb88aecd862b8f2f Signed-off-by: Xiao Ni <xni@redhat.com> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Li Nan <linan122@huawei.com> Signed-off-by: Yu Kuai <yukuai@fnnas.com>
1 parent 6abc7d5 commit 05c8de4

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/md/md.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,8 +735,8 @@ static inline int mddev_trylock(struct mddev *mddev)
735735
int ret;
736736

737737
ret = mutex_trylock(&mddev->reconfig_mutex);
738-
if (!ret && test_bit(MD_DELETED, &mddev->flags)) {
739-
ret = -ENODEV;
738+
if (ret && test_bit(MD_DELETED, &mddev->flags)) {
739+
ret = 0;
740740
mutex_unlock(&mddev->reconfig_mutex);
741741
}
742742
return ret;

0 commit comments

Comments
 (0)