]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: remove NULL pointer checks in xfs_mru_cache_insert
authorChristoph Hellwig <hch@lst.de>
Thu, 5 Jun 2025 06:16:28 +0000 (08:16 +0200)
committerCarlos Maiolino <cem@kernel.org>
Mon, 16 Jun 2025 08:05:08 +0000 (10:05 +0200)
Remove the check for a NULL mru or mru->list in xfs_mru_cache_insert
as this API misused lead to a direct NULL pointer dereference on first
use and is not user triggerable.  As a smatch run by Dan points out
with the recent cleanup it would otherwise try to free the object we
just determined to be NULL for this impossible to reach case.

Fixes: 70b95cb86513 ("xfs: free the item in xfs_mru_cache_insert on failure")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hans Holmberg <hans.holmberg@wdc.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/xfs_mru_cache.c

index 08443ceec329de0e358f6130313be4d8e184d8c4..c95401de8397dceac5434588f1fbd12bb55344bc 100644 (file)
@@ -425,10 +425,6 @@ xfs_mru_cache_insert(
 {
        int                     error = -EINVAL;
 
-       ASSERT(mru && mru->lists);
-       if (!mru || !mru->lists)
-               goto out_free;
-
        error = -ENOMEM;
        if (radix_tree_preload(GFP_KERNEL))
                goto out_free;