From 457d1b54cfd1ea8bb72d50e79c46ebe81ab2180b Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Wed, 15 Nov 2017 17:30:45 -0600 Subject: [PATCH] scoutfs: fix scoutfs_item_create() item leak We'll leak the new item if we don't have lock coverage. Move the check around to fix this. Signed-off-by: Mark Fasheh --- kmod/src/item.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kmod/src/item.c b/kmod/src/item.c index c680e99a..840030ee 100644 --- a/kmod/src/item.c +++ b/kmod/src/item.c @@ -1082,13 +1082,13 @@ int scoutfs_item_create(struct super_block *sb, struct scoutfs_key_buf *key, if (invalid_key_val(key, val)) return -EINVAL; + if (WARN_ON_ONCE(!lock_coverage(lock, key, DLM_LOCK_EX))) + return -EINVAL; + item = alloc_item(sb, key, val); if (!item) return -ENOMEM; - if (WARN_ON_ONCE(!lock_coverage(lock, key, DLM_LOCK_EX))) - return -EINVAL; - do { spin_lock_irqsave(&cac->lock, flags);