summaryrefslogtreecommitdiffstats
path: root/fs/ntfs/runlist.c
diff options
context:
space:
mode:
authorAnton Altaparmakov <aia21@cantab.net>2006-03-23 14:57:43 +0000
committerAnton Altaparmakov <aia21@cantab.net>2006-03-23 14:57:43 +0000
commit67b1dfe77a2eb2a88b37cd77b8979cbdb7695bd6 (patch)
tree95383ef7826a451dea08d58518219ce30b96880d /fs/ntfs/runlist.c
parentb4d8d1a93c6ea042b29bb66fbb1cf6bc556c18f7 (diff)
downloadop-kernel-dev-67b1dfe77a2eb2a88b37cd77b8979cbdb7695bd6.zip
op-kernel-dev-67b1dfe77a2eb2a88b37cd77b8979cbdb7695bd6.tar.gz
NTFS: Fix an (innocent) off-by-one error in the runlist code.
Signed-off-by: Anton Altaparmakov <aia21@cantab.net>
Diffstat (limited to 'fs/ntfs/runlist.c')
-rw-r--r--fs/ntfs/runlist.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/fs/ntfs/runlist.c b/fs/ntfs/runlist.c
index 061b5ff..eb52b80 100644
--- a/fs/ntfs/runlist.c
+++ b/fs/ntfs/runlist.c
@@ -381,6 +381,7 @@ static inline runlist_element *ntfs_rl_insert(runlist_element *dst,
static inline runlist_element *ntfs_rl_replace(runlist_element *dst,
int dsize, runlist_element *src, int ssize, int loc)
{
+ signed delta;
BOOL left = FALSE; /* Left end of @src needs merging. */
BOOL right = FALSE; /* Right end of @src needs merging. */
int tail; /* Start of tail of @dst. */
@@ -396,11 +397,14 @@ static inline runlist_element *ntfs_rl_replace(runlist_element *dst,
left = ntfs_are_rl_mergeable(dst + loc - 1, src);
/*
* Allocate some space. We will need less if the left, right, or both
- * ends get merged.
+ * ends get merged. The -1 accounts for the run being replaced.
*/
- dst = ntfs_rl_realloc(dst, dsize, dsize + ssize - left - right);
- if (IS_ERR(dst))
- return dst;
+ delta = ssize - 1 - left - right;
+ if (delta > 0) {
+ dst = ntfs_rl_realloc(dst, dsize, dsize + delta);
+ if (IS_ERR(dst))
+ return dst;
+ }
/*
* We are guaranteed to succeed from here so can start modifying the
* original runlists.
OpenPOWER on IntegriCloud