]> git.sur5r.net Git - u-boot/blobdiff - fs/ext4/ext4_common.c
ARM: rmobile: Represent SF partitioning with mtdparts on Silk
[u-boot] / fs / ext4 / ext4_common.c
index bfebe7e3799be3fa8735a2d8bdbc0dd6376863b2..672fead815d8652fc3bb7767312d54ee4d19e199 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2011 - 2012 Samsung Electronics
  * EXT4 filesystem implementation in Uboot by
@@ -15,8 +16,6 @@
  * Copyright (C) 2003, 2004  Free Software Foundation, Inc.
  *
  * ext4write : Based on generic ext4 protocol.
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -432,6 +431,10 @@ uint16_t ext4fs_checksum_update(uint32_t i)
                crc = ext2fs_crc16(crc, desc, offset);
                offset += sizeof(desc->bg_checksum);    /* skip checksum */
                assert(offset == sizeof(*desc));
+               if (offset < fs->gdsize) {
+                       crc = ext2fs_crc16(crc, (__u8 *)desc + offset,
+                                          fs->gdsize - offset);
+               }
        }
 
        return crc;
@@ -656,6 +659,11 @@ static int search_dir(struct ext2_inode *parent_inode, char *dirname)
 
                offset = 0;
                do {
+                       if (offset & 3) {
+                               printf("Badly aligned ext2_dirent\n");
+                               break;
+                       }
+
                        dir = (struct ext2_dirent *)(block_buffer + offset);
                        direntname = (char*)(dir) + sizeof(struct ext2_dirent);
 
@@ -876,6 +884,11 @@ static int unlink_filename(char *filename, unsigned int blknr)
 
        offset = 0;
        do {
+               if (offset & 3) {
+                       printf("Badly aligned ext2_dirent\n");
+                       break;
+               }
+
                previous_dir = dir;
                dir = (struct ext2_dirent *)(block_buffer + offset);
                direntname = (char *)(dir) + sizeof(struct ext2_dirent);
@@ -2329,11 +2342,12 @@ int ext4fs_mount(unsigned part_length)
 
        /* Make sure this is an ext2 filesystem. */
        if (le16_to_cpu(data->sblock.magic) != EXT2_MAGIC)
-               goto fail;
+               goto fail_noerr;
 
 
        if (le32_to_cpu(data->sblock.revision_level) == 0) {
                fs->inodesz = 128;
+               fs->gdsize = 32;
        } else {
                debug("EXT4 features COMPAT: %08x INCOMPAT: %08x RO_COMPAT: %08x\n",
                      __le32_to_cpu(data->sblock.feature_compatibility),
@@ -2364,6 +2378,7 @@ int ext4fs_mount(unsigned part_length)
        return 1;
 fail:
        printf("Failed to mount ext2 filesystem...\n");
+fail_noerr:
        free(data);
        ext4fs_root = NULL;