• Filipe Manana's avatar
    btrfs: deal with unexpected extent type during reflinking · b2d9f2dc
    Filipe Manana authored
    
    
    Smatch complains about a possible dereference of a pointer that was not
    initialized:
    
        CC [M]  fs/btrfs/reflink.o
        CHECK   fs/btrfs/reflink.c
      fs/btrfs/reflink.c:533 btrfs_clone() error: potentially dereferencing uninitialized 'trans'.
    
    This is because we are not dealing with the case where the type of a file
    extent has an unexpected value (not regular, not prealloc and not inline),
    in which case the transaction handle pointer is not initialized.
    
    Such unexpected type should be impossible, except in case of some memory
    corruption caused either by bad hardware or some software bug causing
    something like a buffer overrun.
    
    So ASSERT that if the extent type is neither regular nor prealloc, then
    it must be inline. Bail out with -EUCLEAN and a warning in case it is
    not. This silences smatch.
    Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    b2d9f2dc
reflink.c 27.7 KB