diff options
author | Russell King <rmk+kernel@armlinux.org.uk> | 2019-12-09 11:09:04 +0000 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2020-01-20 20:12:40 -0500 |
commit | f93793fd73a629f4c86b0d91fd84fe175705aff9 (patch) | |
tree | b4187bc69a3b276b928a379197f75d0961b8e015 /fs/adfs | |
parent | f6f14a0d71b0773a1d4147d1a3c33d537cd213ab (diff) | |
download | linux-f93793fd73a629f4c86b0d91fd84fe175705aff9.tar.bz2 |
fs/adfs: map: fix map scanning
When scanning the map for a fragment id, we need to keep track of the
free space links, so we don't inadvertently believe that the freespace
link is a valid fragment id.
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/adfs')
-rw-r--r-- | fs/adfs/map.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/adfs/map.c b/fs/adfs/map.c index 82e1bf101fe6..a81de80c45c1 100644 --- a/fs/adfs/map.c +++ b/fs/adfs/map.c @@ -72,9 +72,12 @@ static int lookup_zone(const struct adfs_discmap *dm, const unsigned int idlen, const u32 idmask = (1 << idlen) - 1; unsigned char *map = dm->dm_bh->b_data; unsigned int start = dm->dm_startbit; - unsigned int fragend; + unsigned int freelink, fragend; u32 frag; + frag = GET_FRAG_ID(map, 8, idmask & 0x7fff); + freelink = frag ? 8 + frag : 0; + do { frag = GET_FRAG_ID(map, start, idmask); @@ -82,7 +85,9 @@ static int lookup_zone(const struct adfs_discmap *dm, const unsigned int idlen, if (fragend >= endbit) goto error; - if (frag == frag_id) { + if (start == freelink) { + freelink += frag & 0x7fff; + } else if (frag == frag_id) { unsigned int length = fragend + 1 - start; if (*offset < length) |