diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c index e83b2ec5e49f8..e02343c088c3d 100644 --- a/fs/zonefs/super.c +++ b/fs/zonefs/super.c @@ -610,11 +610,15 @@ static long zonefs_fname_to_fno(const struct qstr *fname) return c - '0'; for (i = 0, rname = name + len - 1; i < len; i++, rname--) { + long digit; + c = *rname; if (!isdigit(c)) return -ENOENT; - fno += (c - '0') * shift; + digit = (c - '0') * shift; shift *= 10; + if (check_add_overflow(fno, digit, &fno)) + return -ENOENT; } return fno;