summaryrefslogtreecommitdiffstats
path: root/lib/idr.c
diff options
context:
space:
mode:
authorMatthew Wilcox (Oracle) <willy@infradead.org>2020-04-02 14:26:13 -0400
committerMatthew Wilcox (Oracle) <willy@infradead.org>2020-10-07 09:11:33 -0400
commita219b856a2b993da234108307be772448f22b0ce (patch)
tree8cb2debc55b257f113b95ea170a0ecba77fc87c4 /lib/idr.c
parentdd841a749d1ded8e2e5facc4242ee0b6779fc0cb (diff)
downloadlinux-a219b856a2b993da234108307be772448f22b0ce.tar.gz
linux-a219b856a2b993da234108307be772448f22b0ce.tar.bz2
linux-a219b856a2b993da234108307be772448f22b0ce.zip
ida: Free allocated bitmap in error path
If a bitmap needs to be allocated, and then by the time the thread is scheduled to be run again all the indices which would satisfy the allocation have been allocated then we would leak the allocation. Almost impossible to hit in practice, but a trivial fix. Found by Coverity. Fixes: f32f004cddf8 ("ida: Convert to XArray") Reported-by: coverity-bot <keescook+coverity-bot@chromium.org> Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Diffstat (limited to 'lib/idr.c')
-rw-r--r--lib/idr.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/idr.c b/lib/idr.c
index c2cf2c52bbde..4d2eef0259d2 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -470,6 +470,7 @@ alloc:
goto retry;
nospc:
xas_unlock_irqrestore(&xas, flags);
+ kfree(alloc);
return -ENOSPC;
}
EXPORT_SYMBOL(ida_alloc_range);