Re: [PATCH v9 06/13] exfat: add exfat entry operations

From: Christoph Hellwig
Date: Wed Jan 08 2020 - 13:00:44 EST


> +int exfat_ent_get(struct super_block *sb, unsigned int loc,
> + unsigned int *content)
> +{
> + struct exfat_sb_info *sbi = EXFAT_SB(sb);
> + int err;
> +
> + if (!is_valid_cluster(sbi, loc)) {
> + exfat_fs_error(sb, "invalid access to FAT (entry 0x%08x)",
> + loc);
> + return -EIO;
> + }
> +
> + err = __exfat_ent_get(sb, loc, content);
> + if (err) {
> + exfat_fs_error(sb,
> + "failed to access to FAT (entry 0x%08x, err:%d)",
> + loc, err);
> + return err;
> + }
> +
> + if (!is_reserved_cluster(*content) &&
> + !is_valid_cluster(sbi, *content)) {
> + exfat_fs_error(sb,
> + "invalid access to FAT (entry 0x%08x) bogus content (0x%08x)",
> + loc, *content);
> + return -EIO;
> + }
> +
> + if (*content == EXFAT_FREE_CLUSTER) {
> + exfat_fs_error(sb,
> + "invalid access to FAT free cluster (entry 0x%08x)",
> + loc);
> + return -EIO;
> + }
> +
> + if (*content == EXFAT_BAD_CLUSTER) {
> + exfat_fs_error(sb,
> + "invalid access to FAT bad cluster (entry 0x%08x)",
> + loc);
> + return -EIO;
> + }
> + return 0;

Maybe these explicit checks should move up, and then is_reserved_cluster
can be replaced with an explicit check just for EXFAT_EOF_CLUSTER?

Otherwise looks good:

Reviewed-by: Christoph Hellwig <hch@xxxxxx>