Skip to contentSkip to conversation

fs/xfs/xfs_buf.c:2066:11-12: WARNING kmalloc is used to allocate this memory at line 2029 (fwd)

PATCH New Julia Lawall 1 participant 1 message Dec 8, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 105/205 fs/xfs/xfs_buf.c:2066:11-12: WARNING kmalloc is used to allocate this memory at line 2029 (fwd)

Hello,

There seems to be no reason not to use kfree in this code (line 2066).

julia

---------- Forwarded message ----------
Date: Fri, 8 Dec 2023 13:38:35 +0800
From: kernel test robot <[email protected]>
To: [email protected]
Cc: [email protected], Julia Lawall <[email protected]>
Subject: [djwong-xfs:xfile-page-caching 105/205] fs/xfs/xfs_buf.c:2066:11-12:
WARNING kmalloc is used to allocate this memory at line 2029

BCC: [email protected]
CC: [email protected]
TO: "Darrick J. Wong" <[email protected]>

Hi Darrick,

FYI, the error/warning was bisected to this commit, please ignore it if it's irrelevant.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git xfile-page-caching
head:   ae5732f1c245c24e63c885992c35f723f36f79ff
commit: 20739d9063f5efc04853e453a68816a0e1cad461 [105/205] xfs: make GFP_ usage consistent when allocating buftargs

:::::: branch date: 27 hours ago
:::::: commit date: 27 hours ago
config: x86_64-randconfig-102-20231208 (https://download.01.org/0day-ci/archive/20231208/[email protected]/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07)
reproduce: (https://download.01.org/0day-ci/archive/20231208/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags

| Reported-by: kernel test robot <[email protected]>
| Reported-by: Julia Lawall <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

cocci warnings: (new ones prefixed by >>)

Quoted 1 line
Quoted 1 line

fs/xfs/xfs_buf.c:2066:11-12: WARNING kmalloc is used to allocate this memory at line 2029

vim +2066 fs/xfs/xfs_buf.c

^1da177e4c3f41 fs/xfs/linux-2.6/xfs_buf.c Linus Torvalds  2005-04-16  2021
3e4ce1b43d1268 fs/xfs/xfs_buf.c           Darrick J. Wong 2023-03-06  2022  static struct xfs_buftarg *
3e4ce1b43d1268 fs/xfs/xfs_buf.c           Darrick J. Wong 2023-03-06  2023  xfs_alloc_buftarg_common(
ebad861b5702c3 fs/xfs/linux-2.6/xfs_buf.c Dave Chinner    2010-09-22  2024  	struct xfs_mount	*mp,
3e4ce1b43d1268 fs/xfs/xfs_buf.c           Darrick J. Wong 2023-03-06  2025  	const char		*descr)
^1da177e4c3f41 fs/xfs/linux-2.6/xfs_buf.c Linus Torvalds  2005-04-16  2026  {
3e4ce1b43d1268 fs/xfs/xfs_buf.c           Darrick J. Wong 2023-03-06  2027  	struct xfs_buftarg	*btp;
^1da177e4c3f41 fs/xfs/linux-2.6/xfs_buf.c Linus Torvalds  2005-04-16  2028
20739d9063f5ef fs/xfs/xfs_buf.c           Darrick J. Wong 2023-03-10 @2029  	btp = kzalloc(sizeof(*btp), GFP_NOFS);
3e4ce1b43d1268 fs/xfs/xfs_buf.c           Darrick J. Wong 2023-03-06  2030  	if (!btp)
3e4ce1b43d1268 fs/xfs/xfs_buf.c           Darrick J. Wong 2023-03-06  2031  		return NULL;
^1da177e4c3f41 fs/xfs/linux-2.6/xfs_buf.c Linus Torvalds  2005-04-16  2032
ebad861b5702c3 fs/xfs/linux-2.6/xfs_buf.c Dave Chinner    2010-09-22  2033  	btp->bt_mount = mp;
0e6e847ffe3743 fs/xfs/linux-2.6/xfs_buf.c Dave Chinner    2011-03-26  2034
f9bccfcc3b59b9 fs/xfs/xfs_buf.c           Brian Foster    2020-05-06  2035  	/*
f9bccfcc3b59b9 fs/xfs/xfs_buf.c           Brian Foster    2020-05-06  2036  	 * Buffer IO error rate limiting. Limit it to no more than 10 messages
f9bccfcc3b59b9 fs/xfs/xfs_buf.c           Brian Foster    2020-05-06  2037  	 * per 30 seconds so as to not spam logs too much on repeated errors.
f9bccfcc3b59b9 fs/xfs/xfs_buf.c           Brian Foster    2020-05-06  2038  	 */
f9bccfcc3b59b9 fs/xfs/xfs_buf.c           Brian Foster    2020-05-06  2039  	ratelimit_state_init(&btp->bt_ioerror_rl, 30 * HZ,
f9bccfcc3b59b9 fs/xfs/xfs_buf.c           Brian Foster    2020-05-06  2040  			     DEFAULT_RATELIMIT_BURST);
f9bccfcc3b59b9 fs/xfs/xfs_buf.c           Brian Foster    2020-05-06  2041
5ca302c8e502ca fs/xfs/xfs_buf.c           Glauber Costa   2013-08-28  2042  	if (list_lru_init(&btp->bt_lru))
d210a9874b8f61 fs/xfs/xfs_buf.c           Michal Hocko    2017-11-23  2043  		goto error_free;
5ca302c8e502ca fs/xfs/xfs_buf.c           Glauber Costa   2013-08-28  2044
20739d9063f5ef fs/xfs/xfs_buf.c           Darrick J. Wong 2023-03-10  2045  	if (percpu_counter_init(&btp->bt_io_count, 0, GFP_NOFS))
d210a9874b8f61 fs/xfs/xfs_buf.c           Michal Hocko    2017-11-23  2046  		goto error_lru;
9c7504aa72b6e2 fs/xfs/xfs_buf.c           Brian Foster    2016-07-20  2047
3e4ce1b43d1268 fs/xfs/xfs_buf.c           Darrick J. Wong 2023-03-06  2048  	btp->bt_shrinker = shrinker_alloc(SHRINKER_NUMA_AWARE, "xfs-%s:%s",
3e4ce1b43d1268 fs/xfs/xfs_buf.c           Darrick J. Wong 2023-03-06  2049  			descr, mp->m_super->s_id);
17e7a00e60c8ff fs/xfs/xfs_buf.c           Qi Zheng        2023-09-11  2050  	if (!btp->bt_shrinker)
d210a9874b8f61 fs/xfs/xfs_buf.c           Michal Hocko    2017-11-23  2051  		goto error_pcpu;
17e7a00e60c8ff fs/xfs/xfs_buf.c           Qi Zheng        2023-09-11  2052
17e7a00e60c8ff fs/xfs/xfs_buf.c           Qi Zheng        2023-09-11  2053  	btp->bt_shrinker->count_objects = xfs_buftarg_shrink_count;
17e7a00e60c8ff fs/xfs/xfs_buf.c           Qi Zheng        2023-09-11  2054  	btp->bt_shrinker->scan_objects = xfs_buftarg_shrink_scan;
17e7a00e60c8ff fs/xfs/xfs_buf.c           Qi Zheng        2023-09-11  2055  	btp->bt_shrinker->private_data = btp;
17e7a00e60c8ff fs/xfs/xfs_buf.c           Qi Zheng        2023-09-11  2056
17e7a00e60c8ff fs/xfs/xfs_buf.c           Qi Zheng        2023-09-11  2057  	shrinker_register(btp->bt_shrinker);
17e7a00e60c8ff fs/xfs/xfs_buf.c           Qi Zheng        2023-09-11  2058
^1da177e4c3f41 fs/xfs/linux-2.6/xfs_buf.c Linus Torvalds  2005-04-16  2059  	return btp;
^1da177e4c3f41 fs/xfs/linux-2.6/xfs_buf.c Linus Torvalds  2005-04-16  2060
d210a9874b8f61 fs/xfs/xfs_buf.c           Michal Hocko    2017-11-23  2061  error_pcpu:
d210a9874b8f61 fs/xfs/xfs_buf.c           Michal Hocko    2017-11-23  2062  	percpu_counter_destroy(&btp->bt_io_count);
d210a9874b8f61 fs/xfs/xfs_buf.c           Michal Hocko    2017-11-23  2063  error_lru:
d210a9874b8f61 fs/xfs/xfs_buf.c           Michal Hocko    2017-11-23  2064  	list_lru_destroy(&btp->bt_lru);
d210a9874b8f61 fs/xfs/xfs_buf.c           Michal Hocko    2017-11-23  2065  error_free:
20739d9063f5ef fs/xfs/xfs_buf.c           Darrick J. Wong 2023-03-10 @2066  	kvfree(btp);
^1da177e4c3f41 fs/xfs/linux-2.6/xfs_buf.c Linus Torvalds  2005-04-16  2067  	return NULL;
^1da177e4c3f41 fs/xfs/linux-2.6/xfs_buf.c Linus Torvalds  2005-04-16  2068  }

^1da177e4c3f41 fs/xfs/linux-2.6/xfs_buf.c Linus Torvalds 2005-04-16 2069

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki