linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] btrfs: drop extent map range more efficiently
@ 2023-02-27 12:31 Dan Carpenter
  2023-02-27 21:59 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2023-02-27 12:31 UTC (permalink / raw)
  To: fdmanana; +Cc: linux-btrfs

Hello Filipe Manana,

The patch db21370bffbc: "btrfs: drop extent map range more
efficiently" from Sep 19, 2022, leads to the following Smatch static
checker warning:

	fs/btrfs/extent_map.c:767 btrfs_drop_extent_map_range()
	passing uninitialized variable 'flags'

fs/btrfs/extent_map.c
    740         while (em) {
    741                 /* extent_map_end() returns exclusive value (last byte + 1). */
    742                 const u64 em_end = extent_map_end(em);
    743                 struct extent_map *next_em = NULL;
    744                 u64 gen;
    745                 unsigned long flags;
                        ^^^^^^^^^^^^^^^^^^^

    746                 bool modified;
    747                 bool compressed;
    748 
    749                 if (em_end < end) {
    750                         next_em = next_extent_map(em);
    751                         if (next_em) {
    752                                 if (next_em->start < end)
    753                                         refcount_inc(&next_em->refs);
    754                                 else
    755                                         next_em = NULL;
    756                         }
    757                 }
    758 
    759                 if (skip_pinned && test_bit(EXTENT_FLAG_PINNED, &em->flags)) {
    760                         start = em_end;
    761                         if (end != (u64)-1)
    762                                 len = start + len - em_end;
    763                         goto next;
    764                 }
    765 
    766                 clear_bit(EXTENT_FLAG_PINNED, &em->flags);
--> 767                 clear_bit(EXTENT_FLAG_LOGGING, &flags);
                                                       ^^^^^^
flags is uninitialized at this point.  This clear_bit() is a no-op.

    768                 modified = !list_empty(&em->list);
    769 
    770                 /*
    771                  * The extent map does not cross our target range, so no need to
    772                  * split it, we can remove it directly.
    773                  */
    774                 if (em->start >= start && em_end <= end)
    775                         goto remove_em;
    776 
    777                 flags = em->flags;
    778                 gen = em->generation;
    779                 compressed = test_bit(EXTENT_FLAG_COMPRESSED, &em->flags);

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-27 22:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-27 12:31 [bug report] btrfs: drop extent map range more efficiently Dan Carpenter
2023-02-27 21:59 ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).