[linux-next:master 11978/13093] fs/ntfs/iomap.c:150 ntfs_read_iomap_begin_resident() warn: inconsistent returns '&base_ni->mrec_lock'.

kernel test robot <[email protected]>
Newsgroups dev.linux.lists.oe-kbuild
Message-ID <[email protected]>
BCC: [email protected]
CC: [email protected]
TO: Hyeontae Lee <[email protected]>
CC: Namjae Jeon <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   1701fda2f58e345c050f4309971bdc07cd6146ba
commit: 9cf6ac617e8e9d95fd71081fe12a77c381520bda [11978/13093] ntfs: serialize resident iomap reads with mrec_lock
:::::: branch date: 5 hours ago
:::::: commit date: 30 hours ago
config: i386-randconfig-141-20260805 (https://download.01.org/0day-ci/archive/20260806/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
smatch: v0.5.0-9187-g5189e3fb

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: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

smatch warnings:
fs/ntfs/iomap.c:150 ntfs_read_iomap_begin_resident() warn: inconsistent returns '&base_ni->mrec_lock'.

vim +150 fs/ntfs/iomap.c

b041ca562526b3 Namjae Jeon  2026-02-13   82  
b041ca562526b3 Namjae Jeon  2026-02-13   83  static int ntfs_read_iomap_begin_resident(struct inode *inode, loff_t offset, loff_t length,
9cf6ac617e8e9d Hyeontae Lee 2026-07-31   84  		unsigned int flags, struct iomap *iomap, bool keep_mrec_lock)
b041ca562526b3 Namjae Jeon  2026-02-13   85  {
b041ca562526b3 Namjae Jeon  2026-02-13   86  	struct ntfs_inode *base_ni, *ni = NTFS_I(inode);
b041ca562526b3 Namjae Jeon  2026-02-13   87  	struct ntfs_attr_search_ctx *ctx;
b041ca562526b3 Namjae Jeon  2026-02-13   88  	loff_t i_size;
b041ca562526b3 Namjae Jeon  2026-02-13   89  	u32 attr_len;
b041ca562526b3 Namjae Jeon  2026-02-13   90  	int err = 0;
b041ca562526b3 Namjae Jeon  2026-02-13   91  	char *kattr;
b041ca562526b3 Namjae Jeon  2026-02-13   92  
b041ca562526b3 Namjae Jeon  2026-02-13   93  	if (NInoAttr(ni))
b041ca562526b3 Namjae Jeon  2026-02-13   94  		base_ni = ni->ext.base_ntfs_ino;
b041ca562526b3 Namjae Jeon  2026-02-13   95  	else
b041ca562526b3 Namjae Jeon  2026-02-13   96  		base_ni = ni;
b041ca562526b3 Namjae Jeon  2026-02-13   97  
9cf6ac617e8e9d Hyeontae Lee 2026-07-31   98  	mutex_lock(&base_ni->mrec_lock);
9cf6ac617e8e9d Hyeontae Lee 2026-07-31   99  
b041ca562526b3 Namjae Jeon  2026-02-13  100  	ctx = ntfs_attr_get_search_ctx(base_ni, NULL);
b041ca562526b3 Namjae Jeon  2026-02-13  101  	if (!ctx) {
b041ca562526b3 Namjae Jeon  2026-02-13  102  		err = -ENOMEM;
b041ca562526b3 Namjae Jeon  2026-02-13  103  		goto out;
b041ca562526b3 Namjae Jeon  2026-02-13  104  	}
b041ca562526b3 Namjae Jeon  2026-02-13  105  
b041ca562526b3 Namjae Jeon  2026-02-13  106  	err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len,
b041ca562526b3 Namjae Jeon  2026-02-13  107  			CASE_SENSITIVE, 0, NULL, 0, ctx);
b041ca562526b3 Namjae Jeon  2026-02-13  108  	if (unlikely(err))
b041ca562526b3 Namjae Jeon  2026-02-13  109  		goto out;
b041ca562526b3 Namjae Jeon  2026-02-13  110  
b041ca562526b3 Namjae Jeon  2026-02-13  111  	attr_len = le32_to_cpu(ctx->attr->data.resident.value_length);
b041ca562526b3 Namjae Jeon  2026-02-13  112  	if (unlikely(attr_len > ni->initialized_size))
b041ca562526b3 Namjae Jeon  2026-02-13  113  		attr_len = ni->initialized_size;
b041ca562526b3 Namjae Jeon  2026-02-13  114  	i_size = i_size_read(inode);
b041ca562526b3 Namjae Jeon  2026-02-13  115  
b041ca562526b3 Namjae Jeon  2026-02-13  116  	if (unlikely(attr_len > i_size)) {
b041ca562526b3 Namjae Jeon  2026-02-13  117  		/* Race with shrinking truncate. */
b041ca562526b3 Namjae Jeon  2026-02-13  118  		attr_len = i_size;
b041ca562526b3 Namjae Jeon  2026-02-13  119  	}
b041ca562526b3 Namjae Jeon  2026-02-13  120  
b041ca562526b3 Namjae Jeon  2026-02-13  121  	if (offset >= attr_len) {
b041ca562526b3 Namjae Jeon  2026-02-13  122  		if (flags & IOMAP_REPORT)
b041ca562526b3 Namjae Jeon  2026-02-13  123  			err = -ENOENT;
b041ca562526b3 Namjae Jeon  2026-02-13  124  		else {
b041ca562526b3 Namjae Jeon  2026-02-13  125  			iomap->type = IOMAP_HOLE;
b041ca562526b3 Namjae Jeon  2026-02-13  126  			iomap->offset = offset;
b041ca562526b3 Namjae Jeon  2026-02-13  127  			iomap->length = length;
b041ca562526b3 Namjae Jeon  2026-02-13  128  		}
b041ca562526b3 Namjae Jeon  2026-02-13  129  		goto out;
b041ca562526b3 Namjae Jeon  2026-02-13  130  	}
b041ca562526b3 Namjae Jeon  2026-02-13  131  
b041ca562526b3 Namjae Jeon  2026-02-13  132  	kattr = (u8 *)ctx->attr + le16_to_cpu(ctx->attr->data.resident.value_offset);
b041ca562526b3 Namjae Jeon  2026-02-13  133  
b041ca562526b3 Namjae Jeon  2026-02-13  134  	iomap->type = IOMAP_INLINE;
5aec1efb11ab2a Namjae Jeon  2026-06-09  135  	iomap->inline_data = kattr;
b041ca562526b3 Namjae Jeon  2026-02-13  136  	iomap->offset = 0;
b041ca562526b3 Namjae Jeon  2026-02-13  137  	iomap->length = attr_len;
b041ca562526b3 Namjae Jeon  2026-02-13  138  
b041ca562526b3 Namjae Jeon  2026-02-13  139  out:
b041ca562526b3 Namjae Jeon  2026-02-13  140  	if (ctx)
b041ca562526b3 Namjae Jeon  2026-02-13  141  		ntfs_attr_put_search_ctx(ctx);
b041ca562526b3 Namjae Jeon  2026-02-13  142  
9cf6ac617e8e9d Hyeontae Lee 2026-07-31  143  	if (!err && keep_mrec_lock && iomap->type == IOMAP_INLINE) {
9cf6ac617e8e9d Hyeontae Lee 2026-07-31  144  		iomap->private = base_ni;
9cf6ac617e8e9d Hyeontae Lee 2026-07-31  145  		return 0;
9cf6ac617e8e9d Hyeontae Lee 2026-07-31  146  	}
9cf6ac617e8e9d Hyeontae Lee 2026-07-31  147  
9cf6ac617e8e9d Hyeontae Lee 2026-07-31  148  	mutex_unlock(&base_ni->mrec_lock);
9cf6ac617e8e9d Hyeontae Lee 2026-07-31  149  
b041ca562526b3 Namjae Jeon  2026-02-13 @150  	return err;
b041ca562526b3 Namjae Jeon  2026-02-13  151  }
b041ca562526b3 Namjae Jeon  2026-02-13  152  

:::::: The code at line 150 was first introduced by commit
:::::: b041ca562526b3c4a71b41b80ba5e520eac636ad ntfs: update iomap and address space operations

:::::: TO: Namjae Jeon <[email protected]>
:::::: CC: Namjae Jeon <[email protected]>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.