linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ubifs: possible missed le64_to_cpu() in journal
@ 2019-10-16 10:08 Ben Dooks (Codethink)
  2019-10-16 10:44 ` Richard Weinberger
  0 siblings, 1 reply; 2+ messages in thread
From: Ben Dooks (Codethink) @ 2019-10-16 10:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Artem Bityutskiy, Richard Weinberger, Adrian Hunter,
	linux-kernel, Ben Dooks (Codethink),
	linux-mtd

In the ubifs_jnl_write_inode() functon, it calls ubifs_iget()
with xent->inum. The xent->inum is __le64, but the ubifs_iget()
takes native cpu endian.

I think that this should be changed to passing le64_to_cpu(xent->inum)
to fix the following sparse warning:

fs/ubifs/journal.c:902:58: warning: incorrect type in argument 2 (different base types)
fs/ubifs/journal.c:902:58:    expected unsigned long inum
fs/ubifs/journal.c:902:58:    got restricted __le64 [usertype] inum

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
Cc: Richard Weinberger <richard@nod.at>
Cc: Artem Bityutskiy <dedekind1@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: linux-mtd@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 fs/ubifs/journal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
index d6136f7c1cfc..388fe8f5dc51 100644
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -899,7 +899,7 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode)
 			fname_name(&nm) = xent->name;
 			fname_len(&nm) = le16_to_cpu(xent->nlen);
 
-			xino = ubifs_iget(c->vfs_sb, xent->inum);
+			xino = ubifs_iget(c->vfs_sb, le64_to_cpu(xent->inum));
 			if (IS_ERR(xino)) {
 				err = PTR_ERR(xino);
 				ubifs_err(c, "dead directory entry '%s', error %d",
-- 
2.23.0


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ubifs: possible missed le64_to_cpu() in journal
  2019-10-16 10:08 [PATCH] ubifs: possible missed le64_to_cpu() in journal Ben Dooks (Codethink)
@ 2019-10-16 10:44 ` Richard Weinberger
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Weinberger @ 2019-10-16 10:44 UTC (permalink / raw)
  To: Ben Dooks (Codethink)
  Cc: linux-kernel, linux-kernel, linux-mtd, Adrian Hunter, Artem Bityutskiy

----- Ursprüngliche Mail -----
> Von: "Ben Dooks (Codethink)" <ben.dooks@codethink.co.uk>
> An: linux-kernel@lists.codethink.co.uk
> CC: "Ben Dooks (Codethink)" <ben.dooks@codethink.co.uk>, "richard" <richard@nod.at>, "Artem Bityutskiy"
> <dedekind1@gmail.com>, "Adrian Hunter" <adrian.hunter@intel.com>, "linux-mtd" <linux-mtd@lists.infradead.org>,
> "linux-kernel" <linux-kernel@vger.kernel.org>
> Gesendet: Mittwoch, 16. Oktober 2019 12:08:03
> Betreff: [PATCH] ubifs: possible missed le64_to_cpu() in journal

> In the ubifs_jnl_write_inode() functon, it calls ubifs_iget()
> with xent->inum. The xent->inum is __le64, but the ubifs_iget()
> takes native cpu endian.
> 
> I think that this should be changed to passing le64_to_cpu(xent->inum)
> to fix the following sparse warning:
> 
> fs/ubifs/journal.c:902:58: warning: incorrect type in argument 2 (different base
> types)
> fs/ubifs/journal.c:902:58:    expected unsigned long inum
> fs/ubifs/journal.c:902:58:    got restricted __le64 [usertype] inum
> 
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
> Cc: Richard Weinberger <richard@nod.at>
> Cc: Artem Bityutskiy <dedekind1@gmail.com>
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Cc: linux-mtd@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> ---
> fs/ubifs/journal.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
> index d6136f7c1cfc..388fe8f5dc51 100644
> --- a/fs/ubifs/journal.c
> +++ b/fs/ubifs/journal.c
> @@ -899,7 +899,7 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct
> inode *inode)
> 			fname_name(&nm) = xent->name;
> 			fname_len(&nm) = le16_to_cpu(xent->nlen);
> 
> -			xino = ubifs_iget(c->vfs_sb, xent->inum);
> +			xino = ubifs_iget(c->vfs_sb, le64_to_cpu(xent->inum));

Good catch!

Thanks,
//richard

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-10-16 10:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-16 10:08 [PATCH] ubifs: possible missed le64_to_cpu() in journal Ben Dooks (Codethink)
2019-10-16 10:44 ` Richard Weinberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).