From: Roel Kluin Date: Wed, 4 Mar 2009 20:01:41 +0000 (-0800) Subject: [JFFS2] jffs2_acl_count() tests < 0 on unsigned X-Git-Tag: firefly_0821_release~14718^2~42 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=fc371a25eab8816d49c2d322d91b48a11e206018;p=firefly-linux-kernel-4.4.55.git [JFFS2] jffs2_acl_count() tests < 0 on unsigned size_t s is unsigned and cannot be less than 0. Signed-off-by: Roel Kluin Signed-off-by: Andrew Morton Signed-off-by: David Woodhouse --- diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c index d98713777a1b..6e63e8b41066 100644 --- a/fs/jffs2/acl.c +++ b/fs/jffs2/acl.c @@ -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;