diff --git a/WHATS_NEW b/WHATS_NEW index 22dc07194..70821da05 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -2,6 +2,7 @@ Version 2.02.74 - ================================== Simplify MD/swap signature detection in pvcreate and allow aborting. Remove assumption that --yes must be used only in --force mode. + Fix file descriptor leak in swap signature detection error path. Version 2.02.73 - 18th August 2010 ================================== diff --git a/lib/device/dev-swap.c b/lib/device/dev-swap.c index 62c2bb503..b8ebcca52 100644 --- a/lib/device/dev-swap.c +++ b/lib/device/dev-swap.c @@ -42,7 +42,7 @@ int dev_is_swap(struct device *dev, uint64_t *signature) { char buf[10]; uint64_t size; - int page; + int page, ret = 0; if (!dev_get_size(dev, &size)) { stack; @@ -66,11 +66,12 @@ int dev_is_swap(struct device *dev, uint64_t *signature) break; if (!dev_read(dev, page - SIGNATURE_SIZE, SIGNATURE_SIZE, buf)) { - stack; - return -1; + ret = -1; + break; } if (_swap_detect_signature(buf)) { *signature = page - SIGNATURE_SIZE; + ret = 1; break; } } @@ -78,10 +79,7 @@ int dev_is_swap(struct device *dev, uint64_t *signature) if (!dev_close(dev)) stack; - if (*signature) - return 1; - - return 0; + return ret; } #endif