2024-06-03 11:10:15

by carrion bent

[permalink] [raw]
Subject: [PATCH] ext4:fix macro definition error of EXT4_DIRENT_HASH and EXT4_DIRENT_MINOR_HASH

the macro parameter "entry" of EXT4_DIRENT_HASH and
EXT4_DIRENT_MINOR_HASH was not used, but rather the
variable de was directly used, which may be a local
variable inside a function that calls the macros

Signed-off-by: carrion bent <[email protected]>
---
fs/ext4/ext4.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 983dad8..04bdd27 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2338,9 +2338,9 @@ struct ext4_dir_entry_2 {
((struct ext4_dir_entry_hash *) \
(((void *)(entry)) + \
((8 + (entry)->name_len + EXT4_DIR_ROUND) & ~EXT4_DIR_ROUND)))
-#define EXT4_DIRENT_HASH(entry) le32_to_cpu(EXT4_DIRENT_HASHES(de)->hash)
+#define EXT4_DIRENT_HASH(entry) le32_to_cpu(EXT4_DIRENT_HASHES(entry)->hash)
#define EXT4_DIRENT_MINOR_HASH(entry) \
- le32_to_cpu(EXT4_DIRENT_HASHES(de)->minor_hash)
+ le32_to_cpu(EXT4_DIRENT_HASHES(entry)->minor_hash)

static inline bool ext4_hash_in_dirent(const struct inode *inode)
{
--
2.7.4



2024-06-04 17:32:20

by Eric Biggers

[permalink] [raw]
Subject: Re: [PATCH] ext4:fix macro definition error of EXT4_DIRENT_HASH and EXT4_DIRENT_MINOR_HASH

On Mon, Jun 03, 2024 at 06:57:19PM +0800, carrion bent wrote:
> the macro parameter "entry" of EXT4_DIRENT_HASH and
> EXT4_DIRENT_MINOR_HASH was not used, but rather the
> variable de was directly used, which may be a local
> variable inside a function that calls the macros
>
> Signed-off-by: carrion bent <[email protected]>
> ---
> fs/ext4/ext4.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 983dad8..04bdd27 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -2338,9 +2338,9 @@ struct ext4_dir_entry_2 {
> ((struct ext4_dir_entry_hash *) \
> (((void *)(entry)) + \
> ((8 + (entry)->name_len + EXT4_DIR_ROUND) & ~EXT4_DIR_ROUND)))
> -#define EXT4_DIRENT_HASH(entry) le32_to_cpu(EXT4_DIRENT_HASHES(de)->hash)
> +#define EXT4_DIRENT_HASH(entry) le32_to_cpu(EXT4_DIRENT_HASHES(entry)->hash)
> #define EXT4_DIRENT_MINOR_HASH(entry) \
> - le32_to_cpu(EXT4_DIRENT_HASHES(de)->minor_hash)
> + le32_to_cpu(EXT4_DIRENT_HASHES(entry)->minor_hash)
>
> static inline bool ext4_hash_in_dirent(const struct inode *inode)
> {

Thanks! Can you call out explicitly in the commit message that (fortunately)
all callers pass in 'de', so this bug didn't have an effect? Also, in the
commit title, there needs to be a space after "ext4:". Otherwise this patch
looks good to me.

- Eric

2024-06-06 05:44:05

by carrion bent

[permalink] [raw]
Subject: [PATCH v2] ext4: fix macro definition error of EXT4_DIRENT_HASH and EXT4_DIRENT_MINOR_HASH

the macro parameter 'entry' of EXT4_DIRENT_HASH and
EXT4_DIRENT_MINOR_HASH was not used, but rather the
variable 'de' was directly used, which may be a local
variable inside a function that calls the macros.
Fortunately, all callers have passed in 'de' so far,
so this bug didn't have an effect.

Signed-off-by: carrion bent <[email protected]>
---
fs/ext4/ext4.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 983dad8..04bdd27 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2338,9 +2338,9 @@ struct ext4_dir_entry_2 {
((struct ext4_dir_entry_hash *) \
(((void *)(entry)) + \
((8 + (entry)->name_len + EXT4_DIR_ROUND) & ~EXT4_DIR_ROUND)))
-#define EXT4_DIRENT_HASH(entry) le32_to_cpu(EXT4_DIRENT_HASHES(de)->hash)
+#define EXT4_DIRENT_HASH(entry) le32_to_cpu(EXT4_DIRENT_HASHES(entry)->hash)
#define EXT4_DIRENT_MINOR_HASH(entry) \
- le32_to_cpu(EXT4_DIRENT_HASHES(de)->minor_hash)
+ le32_to_cpu(EXT4_DIRENT_HASHES(entry)->minor_hash)

static inline bool ext4_hash_in_dirent(const struct inode *inode)
{
--
2.7.4