mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 3/3] fs: ext4: le32_to_cpu() used on a 16-bit field
Date: Fri, 25 Jul 2014 10:42:04 +0200	[thread overview]
Message-ID: <1406277724-4370-4-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1406277724-4370-1-git-send-email-s.hauer@pengutronix.de>

From U-Boot commit:

| commit 8b415f703f88d1d3b0466830047affbbf7f24913
| Author: Rommel Custodio <sessyargc+uboot@gmail.com>
| Date:   Sun Jul 21 10:53:25 2013 +0200
|
|     ext4fs: le32_to_cpu() used on a 16-bit field
|
|     Fix reading ext4_extent_header struture on BE machines.  Some 16 bit
|     fields where converted to 32 bit fields, due to the byte swap on BE
|     machines the containing value was corrupted. Therefore reading ext4
|     filesystems on BE machines where broken before.
|
|     Signed-off-by: Rommel Custodio <sessyargc+uboot@gmail.com>
|     [sent via git-send-email; rework commit message]
|     Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
|     Reviewed-by: Simon Glass <sjg@chromium.org>
|     Tested-by: Simon Glass <sjg@chromium.org>
|     Tested-by: Lukasz Majewski <l.majewski@samsung.com>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 fs/ext4/ext4_common.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index 1bd9215..ab0e6b5 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -51,7 +51,7 @@ static struct ext4_extent_header *ext4fs_get_extent_block(struct ext2_data *data
 	while (1) {
 		index = (struct ext4_extent_idx *)(ext_block + 1);
 
-		if (le32_to_cpu(ext_block->eh_magic) != EXT4_EXT_MAGIC)
+		if (le16_to_cpu(ext_block->eh_magic) != EXT4_EXT_MAGIC)
 			return 0;
 
 		if (ext_block->eh_depth == 0)
@@ -59,14 +59,14 @@ static struct ext4_extent_header *ext4fs_get_extent_block(struct ext2_data *data
 		i = -1;
 		do {
 			i++;
-			if (i >= le32_to_cpu(ext_block->eh_entries))
+			if (i >= le16_to_cpu(ext_block->eh_entries))
 				break;
 		} while (fileblock >= le32_to_cpu(index[i].ei_block));
 
 		if (--i < 0)
 			return 0;
 
-		block = le32_to_cpu(index[i].ei_leaf_hi);
+		block = le16_to_cpu(index[i].ei_leaf_hi);
 		block = (block << 32) + le32_to_cpu(index[i].ei_leaf_lo);
 
 		ret = ext4fs_devread(fs, block << log2_blksz, 0, blksz, buf);
@@ -187,18 +187,18 @@ long int read_allocated_block(struct ext2fs_node *node, int fileblock)
 
 		do {
 			i++;
-			if (i >= le32_to_cpu(ext_block->eh_entries))
+			if (i >= le16_to_cpu(ext_block->eh_entries))
 				break;
 		} while (fileblock >= le32_to_cpu(extent[i].ee_block));
 
 		if (--i >= 0) {
 			fileblock -= le32_to_cpu(extent[i].ee_block);
-			if (fileblock >= le32_to_cpu(extent[i].ee_len)) {
+			if (fileblock >= le16_to_cpu(extent[i].ee_len)) {
 				free(buf);
 				return 0;
 			}
 
-			start = le32_to_cpu(extent[i].ee_start_hi);
+			start = le16_to_cpu(extent[i].ee_start_hi);
 			start = (start << 32) +
 					le32_to_cpu(extent[i].ee_start_lo);
 			free(buf);
-- 
2.0.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2014-07-25  8:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-25  8:42 [PATCH] ext4 fixes from U-Boot Sascha Hauer
2014-07-25  8:42 ` [PATCH 1/3] fs: ext4: fix "invalid extent block" error Sascha Hauer
2014-07-25  8:42 ` [PATCH 2/3] fs: ext4: use EXT2_BLOCK_SIZE instead of fs->blksz Sascha Hauer
2014-07-25  8:42 ` Sascha Hauer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1406277724-4370-4-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox