* [bug report] ntfs: update attrib operations
@ 2026-02-27 7:58 Dan Carpenter
2026-02-27 9:46 ` Namjae Jeon
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2026-02-27 7:58 UTC (permalink / raw)
To: Namjae Jeon; +Cc: linux-fsdevel
[ Smatch checking is paused while we raise funding. #SadFace
https://lore.kernel.org/all/aTaiGSbWZ9DJaGo7@stanley.mountain/ -dan ]
Hello Namjae Jeon,
Commit 495e90fa3348 ("ntfs: update attrib operations") from Feb 13,
2026 (linux-next), leads to the following Smatch static checker
warning:
fs/ntfs/attrib.c:5197 ntfs_non_resident_attr_collapse_range()
warn: inconsistent returns '&ni->runlist.lock'.
fs/ntfs/attrib.c
5107 int ntfs_non_resident_attr_collapse_range(struct ntfs_inode *ni, s64 start_vcn, s64 len)
5108 {
5109 struct ntfs_volume *vol = ni->vol;
5110 struct runlist_element *punch_rl, *rl;
5111 struct ntfs_attr_search_ctx *ctx = NULL;
5112 s64 end_vcn;
5113 int dst_cnt;
5114 int ret;
5115 size_t new_rl_cnt;
5116
5117 if (NInoAttr(ni) || ni->type != AT_DATA)
5118 return -EOPNOTSUPP;
5119
5120 end_vcn = ntfs_bytes_to_cluster(vol, ni->allocated_size);
5121 if (start_vcn >= end_vcn)
5122 return -EINVAL;
5123
5124 down_write(&ni->runlist.lock);
5125 ret = ntfs_attr_map_whole_runlist(ni);
5126 if (ret)
5127 return ret;
up_write(&ni->runlist.lock) before returning.
5128
5129 len = min(len, end_vcn - start_vcn);
5130 for (rl = ni->runlist.rl, dst_cnt = 0; rl && rl->length; rl++)
5131 dst_cnt++;
5132 rl = ntfs_rl_find_vcn_nolock(ni->runlist.rl, start_vcn);
5133 if (!rl) {
5134 up_write(&ni->runlist.lock);
5135 return -EIO;
5136 }
5137
5138 rl = ntfs_rl_collapse_range(ni->runlist.rl, dst_cnt + 1,
5139 start_vcn, len, &punch_rl, &new_rl_cnt);
5140 if (IS_ERR(rl)) {
5141 up_write(&ni->runlist.lock);
5142 return PTR_ERR(rl);
5143 }
5144 ni->runlist.rl = rl;
5145 ni->runlist.count = new_rl_cnt;
5146
5147 ni->allocated_size -= ntfs_cluster_to_bytes(vol, len);
5148 if (ni->data_size > ntfs_cluster_to_bytes(vol, start_vcn)) {
5149 if (ni->data_size > ntfs_cluster_to_bytes(vol, (start_vcn + len)))
5150 ni->data_size -= ntfs_cluster_to_bytes(vol, len);
5151 else
5152 ni->data_size = ntfs_cluster_to_bytes(vol, start_vcn);
5153 }
5154 if (ni->initialized_size > ntfs_cluster_to_bytes(vol, start_vcn)) {
5155 if (ni->initialized_size >
5156 ntfs_cluster_to_bytes(vol, start_vcn + len))
5157 ni->initialized_size -= ntfs_cluster_to_bytes(vol, len);
5158 else
5159 ni->initialized_size = ntfs_cluster_to_bytes(vol, start_vcn);
5160 }
5161
5162 if (ni->allocated_size > 0) {
5163 ret = ntfs_attr_update_mapping_pairs(ni, 0);
5164 if (ret) {
5165 up_write(&ni->runlist.lock);
5166 goto out_rl;
5167 }
5168 }
5169 up_write(&ni->runlist.lock);
5170
5171 ctx = ntfs_attr_get_search_ctx(ni, NULL);
5172 if (!ctx) {
5173 ret = -ENOMEM;
5174 goto out_rl;
5175 }
5176
5177 ret = ntfs_attr_lookup(ni->type, ni->name, ni->name_len, CASE_SENSITIVE,
5178 0, NULL, 0, ctx);
5179 if (ret)
5180 goto out_ctx;
5181
5182 ctx->attr->data.non_resident.data_size = cpu_to_le64(ni->data_size);
5183 ctx->attr->data.non_resident.initialized_size = cpu_to_le64(ni->initialized_size);
5184 if (ni->allocated_size == 0)
5185 ntfs_attr_make_resident(ni, ctx);
5186 mark_mft_record_dirty(ctx->ntfs_ino);
5187
5188 ret = ntfs_cluster_free_from_rl(vol, punch_rl);
5189 if (ret)
5190 ntfs_error(vol->sb, "Freeing of clusters failed");
5191 out_ctx:
5192 if (ctx)
5193 ntfs_attr_put_search_ctx(ctx);
5194 out_rl:
5195 kvfree(punch_rl);
5196 mark_mft_record_dirty(ni);
--> 5197 return ret;
5198 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [bug report] ntfs: update attrib operations
2026-02-27 7:58 [bug report] ntfs: update attrib operations Dan Carpenter
@ 2026-02-27 9:46 ` Namjae Jeon
0 siblings, 0 replies; 2+ messages in thread
From: Namjae Jeon @ 2026-02-27 9:46 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-fsdevel
On Fri, Feb 27, 2026 at 4:59 PM Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> [ Smatch checking is paused while we raise funding. #SadFace
> https://lore.kernel.org/all/aTaiGSbWZ9DJaGo7@stanley.mountain/ -dan ]
>
> Hello Namjae Jeon,
Hi Dan,
>
> Commit 495e90fa3348 ("ntfs: update attrib operations") from Feb 13,
> 2026 (linux-next), leads to the following Smatch static checker
> warning:
>
> fs/ntfs/attrib.c:5197 ntfs_non_resident_attr_collapse_range()
> warn: inconsistent returns '&ni->runlist.lock'.
Ethan sent the patch for this and I just applied it.
Thanks for your report!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-02-27 9:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-27 7:58 [bug report] ntfs: update attrib operations Dan Carpenter
2026-02-27 9:46 ` Namjae Jeon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox