fat/nls: Fix handling of utf8 invalid char
[pandora-kernel.git] / fs / nls / nls_base.c
index 477d37d..b25c218 100644 (file)
@@ -124,10 +124,10 @@ int utf8s_to_utf16s(const u8 *s, int len, wchar_t *pwcs)
        while (*s && len > 0) {
                if (*s & 0x80) {
                        size = utf8_to_utf32(s, len, &u);
-                       if (size < 0) {
-                               /* Ignore character and move on */
-                               size = 1;
-                       } else if (u >= PLANE_SIZE) {
+                       if (size < 0)
+                               return -EINVAL;
+
+                       if (u >= PLANE_SIZE) {
                                u -= PLANE_SIZE;
                                *op++ = (wchar_t) (SURROGATE_PAIR |
                                                ((u >> 10) & SURROGATE_BITS));