From c5ef76bf27337406d48990acbfdaa869fd30f47b Mon Sep 17 00:00:00 2001 From: Alasdair G Kergon Date: Tue, 12 Dec 2017 12:57:25 +0000 Subject: [PATCH] device: Internal error if writing 0 bytes to dev. --- lib/device/dev-io.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/device/dev-io.c b/lib/device/dev-io.c index a9a9aac05..dc9ad13f2 100644 --- a/lib/device/dev-io.c +++ b/lib/device/dev-io.c @@ -804,6 +804,11 @@ int dev_write(struct device *dev, uint64_t offset, size_t len, dev_io_reason_t r if (!_dev_is_valid(dev)) return 0; + if (!len) { + log_error(INTERNAL_ERROR "Attempted to write 0 bytes to %s at " FMTu64, dev_name(dev), offset); + return 0; + } + where.dev = dev; where.start = offset; where.size = len;