Skip to content

Commit 0e4c42c

Browse files
Tom Rixgregkh
authored andcommitted
cifs: check pointer before freeing
commit 77b6ec0 upstream. clang static analysis reports this problem dfs_cache.c:591:2: warning: Argument to kfree() is a constant address (18446744073709551614), which is not memory allocated by malloc() kfree(vi); ^~~~~~~~~ In dfs_cache_del_vol() the volume info pointer 'vi' being freed is the return of a call to find_vol(). The large constant address is find_vol() returning an error. Add an error check to dfs_cache_del_vol() similar to the one done in dfs_cache_update_vol(). Fixes: 54be1f6 ("cifs: Add DFS cache routines") Signed-off-by: Tom Rix <trix@redhat.com> Reviewed-by: Nathan Chancellor <natechancellor@gmail.com> CC: <stable@vger.kernel.org> # v5.0+ Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2207c3c commit 0e4c42c

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎fs/cifs/dfs_cache.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,8 @@ void dfs_cache_del_vol(const char *fullpath)
13171317
vi = find_vol(fullpath);
13181318
spin_unlock(&vol_list_lock);
13191319

1320-
kref_put(&vi->refcnt, vol_release);
1320+
if (!IS_ERR(vi))
1321+
kref_put(&vi->refcnt, vol_release);
13211322
}
13221323

13231324
/**

0 commit comments

Comments
 (0)