From e3fe7a006d0ba5b8985eae6860411787f518e2bd Mon Sep 17 00:00:00 2001 From: Michel Machado Date: Fri, 13 Nov 2015 14:40:43 -0500 Subject: [PATCH] f3probe: fix allocation error of safe device probe_device_max_blocks() was returning an int that once multiplied by block_size was out range. This patch just enforces probe_device_max_blocks() to return an uint64_t, and does the needed adjustments in the code. --- libdevs.c | 2 +- libdevs.h | 2 +- libprobe.c | 2 +- libprobe.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libdevs.c b/libdevs.c index f10aa34..a38ed07 100644 --- a/libdevs.c +++ b/libdevs.c @@ -1209,7 +1209,7 @@ static const char *sdev_get_filename(struct device *dev) return dev_get_filename(dev_sdev(dev)->shadow_dev); } -struct device *create_safe_device(struct device *dev, int max_blocks, +struct device *create_safe_device(struct device *dev, uint64_t max_blocks, int min_memory) { struct safe_device *sdev; diff --git a/libdevs.h b/libdevs.h index 849cea3..5239edd 100644 --- a/libdevs.h +++ b/libdevs.h @@ -100,7 +100,7 @@ void perf_device_sample(struct device *dev, */ struct device *pdev_detach_and_free(struct device *dev); -struct device *create_safe_device(struct device *dev, int max_blocks, +struct device *create_safe_device(struct device *dev, uint64_t max_blocks, int min_memory); #endif /* HEADER_LIBDEVS_H */ diff --git a/libprobe.c b/libprobe.c index b3260ae..ff2affa 100644 --- a/libprobe.c +++ b/libprobe.c @@ -666,7 +666,7 @@ static int find_wrap(struct device *dev, return false; } -int probe_device_max_blocks(struct device *dev) +uint64_t probe_device_max_blocks(struct device *dev) { const int block_order = dev_get_block_order(dev); uint64_t num_blocks = dev_get_size_byte(dev) >> block_order; diff --git a/libprobe.h b/libprobe.h index 1f7835e..014afda 100644 --- a/libprobe.h +++ b/libprobe.h @@ -5,7 +5,7 @@ #include "libdevs.h" -int probe_device_max_blocks(struct device *dev); +uint64_t probe_device_max_blocks(struct device *dev); int probe_device(struct device *dev, uint64_t *preal_size_byte, uint64_t *pannounced_size_byte, int *pwrap,