[JFFS2] jffs2_acl_count() tests < 0 on unsigned
authorRoel Kluin <roel.kluin@gmail.com>
Wed, 4 Mar 2009 20:01:41 +0000 (12:01 -0800)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Fri, 20 Mar 2009 13:18:50 +0000 (13:18 +0000)
size_t s is unsigned and cannot be less than 0.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
fs/jffs2/acl.c

index d98713777a1b62f2aa12f659dd872616d2dbeb4a..6e63e8b41066d9b41ad5f782ded428608cf69994 100644 (file)
@@ -38,12 +38,12 @@ static int jffs2_acl_count(size_t size)
        size_t s;
 
        size -= sizeof(struct jffs2_acl_header);
-       s = size - 4 * sizeof(struct jffs2_acl_entry_short);
-       if (s < 0) {
+       if (size < 4 * sizeof(struct jffs2_acl_entry_short)) {
                if (size % sizeof(struct jffs2_acl_entry_short))
                        return -1;
                return size / sizeof(struct jffs2_acl_entry_short);
        } else {
+               s = size - 4 * sizeof(struct jffs2_acl_entry_short);
                if (s % sizeof(struct jffs2_acl_entry))
                        return -1;
                return s / sizeof(struct jffs2_acl_entry) + 4;