lkml.org 
[lkml]   [2020]   [Jan]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v9 06/13] exfat: add exfat entry operations
> +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@lst.de>

\
 
 \ /
  Last update: 2020-01-08 19:01    [W:0.189 / U:51.664 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site