[bug report] fsdax: decouple zeroing from the iomap buffered I/O code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Christoph Hellwig,

The patch c6f40468657d: "fsdax: decouple zeroing from the iomap
buffered I/O code" from Nov 29, 2021, leads to the following Smatch
static checker warning:

	fs/iomap/buffered-io.c:904 iomap_zero_iter()
	warn: unsigned 'bytes' is never less than zero.

fs/iomap/buffered-io.c
    879 static loff_t iomap_zero_iter(struct iomap_iter *iter, bool *did_zero)
    880 {
    881         const struct iomap *srcmap = iomap_iter_srcmap(iter);
    882         loff_t pos = iter->pos;
    883         loff_t length = iomap_length(iter);
    884         loff_t written = 0;
    885 
    886         /* already zeroed?  we're done. */
    887         if (srcmap->type == IOMAP_HOLE || srcmap->type == IOMAP_UNWRITTEN)
    888                 return length;
    889 
    890         do {
    891                 unsigned offset = offset_in_page(pos);
    892                 size_t bytes = min_t(u64, PAGE_SIZE - offset, length);
    893                 struct page *page;
    894                 int status;
    895 
    896                 status = iomap_write_begin(iter, pos, bytes, &page);
    897                 if (status)
    898                         return status;
    899 
    900                 zero_user(page, offset, bytes);
    901                 mark_page_accessed(page);
    902 
    903                 bytes = iomap_write_end(iter, pos, bytes, bytes, page);
--> 904                 if (bytes < 0)

bytes is unsigned and iomap_write_end() doesn't return negatives.

    905                         return bytes;
    906 
    907                 pos += bytes;
    908                 length -= bytes;
    909                 written += bytes;
    910                 if (did_zero)
    911                         *did_zero = true;
    912         } while (length > 0);
    913 
    914         return written;
    915 }

regards,
dan carpenter



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux