Skip to content

Commit

Permalink
[PATCH] dm: fix find_device race
Browse files Browse the repository at this point in the history
There is a race between dev_create() and find_device().

If the mdptr has not yet been stored against a device, find_device() needs to
behave as though no device was found.  It already returns NULL, but there is a
dm_put() missing: it must drop the reference dm_get_md() took.

The bug was introduced by dm-fix-mapped-device-ref-counting.patch.

It manifests itself if another dm ioctl attempts to reference a newly-created
device while the device creation ioctl is still running.  The consequence is
that the device cannot be removed until the machine is rebooted.  Certain udev
configurations can lead to this happening.

Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Cc: <dm-devel@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Alasdair G Kergon authored and Linus Torvalds committed Nov 9, 2006
1 parent c06cb8b commit bfc5ecd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drivers/md/dm-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,9 +606,14 @@ static struct hash_cell *__find_device_hash_cell(struct dm_ioctl *param)
return __get_name_cell(param->name);

md = dm_get_md(huge_decode_dev(param->dev));
if (md)
mdptr = dm_get_mdptr(md);
if (!md)
goto out;

mdptr = dm_get_mdptr(md);
if (!mdptr)
dm_put(md);

out:
return mdptr;
}

Expand Down

0 comments on commit bfc5ecd

Please sign in to comment.