diff --git a/driver/device-mapper/dm-target.c b/driver/device-mapper/dm-target.c index 55e851f68..b2a083b7e 100644 --- a/driver/device-mapper/dm-target.c +++ b/driver/device-mapper/dm-target.c @@ -25,8 +25,6 @@ #include "dm.h" -#include - static struct target *_targets; static spinlock_t _lock = SPIN_LOCK_UNLOCKED; @@ -45,6 +43,7 @@ struct target *dm_get_target(const char *name) spin_lock(&_lock); t = __get_target(name); spin_unlock(&_lock); + return t; } @@ -153,9 +152,9 @@ int linear_ctr(offset_t low, offset_t high, struct mapped_device *md, lc->dev = MKDEV((int) major, (int) minor); lc->offset = (int) start - (int) low; - if (!dm_add_device(md, lc->dev)) { + if ((r = dm_add_device(md, lc->dev))) { kfree(lc); - return 0; + return r; } *result = lc; diff --git a/driver/device-mapper/dm.c b/driver/device-mapper/dm.c index a9d6375e8..fb1fc9e4f 100644 --- a/driver/device-mapper/dm.c +++ b/driver/device-mapper/dm.c @@ -232,7 +232,7 @@ static int blk_close(struct inode *inode, struct file *file) wl; md = _devs[minor]; - if (!md || md->use_count <= 1) { + if (!md || md->use_count < 1) { WARN("reference count in mapped_device incorrect"); wu; return -ENXIO;