When trying to create a file in the full root directory of a FAT32
filesystem a NULL dereference can be observed.
When the root directory of a FAT16 filesystem is full fill_dir_slot() must
return -1 to signal that a new directory entry could not be allocated.
Fixes: cd2d727fff7e ("fs: fat: allocate a new cluster for root directory of fat32")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
flush_dir(itr);
/* allocate a cluster for more entries */
- if (!fat_itr_next(itr))
- if (!itr->dent &&
- (!itr->is_root || itr->fsdata->fatsize == 32) &&
+ if (!fat_itr_next(itr) && !itr->dent)
+ if ((itr->is_root && itr->fsdata->fatsize != 32) ||
new_dir_table(itr))
return -1;
}