]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
btrfs: use kmalloc_array() for open-coded arithmetic in kmalloc()
authorMiquel Sabaté Solà <mssola@mssola.com>
Fri, 19 Sep 2025 14:58:15 +0000 (16:58 +0200)
committerDavid Sterba <dsterba@suse.com>
Tue, 23 Sep 2025 06:49:25 +0000 (08:49 +0200)
commitf08d7147da5fb5ab4c26199dcbebb614283c99bb
tree21378b67cdaf7c93364c825530727a54ca6d9dc7
parent98077f7f2180fa996710452564ebe71adc66af59
btrfs: use kmalloc_array() for open-coded arithmetic in kmalloc()

As pointed out in the documentation, calling 'kmalloc' with open-coded
arithmetic can lead to unfortunate overflows and this particular way of
using it has been deprecated. Instead, it's preferred to use
'kmalloc_array' in cases where it might apply so an overflow check is
performed.

Note this is an API cleanup and is not fixing any overflows because in
all cases the multipliers are bounded small numbers derived from number
of items in leaves/nodes.

Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/delayed-inode.c
fs/btrfs/tree-log.c