From: Hou Tao <houtao1@huawei.com>
To: <linux-mtd@lists.infradead.org>, <dwmw2@infradead.org>
Cc: <linux-kernel@vger.kernel.org>, <richard.weinberger@gmail.com>,
<boris.brezillon@bootlin.com>
Subject: [PATCH] jffs2: fix invocations of dbg_xattr() for dead jffs2_xattr_ref
Date: Sat, 20 Oct 2018 19:07:53 +0800 [thread overview]
Message-ID: <20181020110753.98407-1-houtao1@huawei.com> (raw)
When jffs2_xattr_ref is dead, xref->ic or xref->xd will be invalid
because these fields will be reused as xref->ino or xref->xid,
so access xref->ic->ino or xref->xd->xid will lead to Oops.
Fix the problem by checking whether or not it is a dead xref.
Signed-off-by: Hou Tao <houtao1@huawei.com>
---
fs/jffs2/xattr.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c
index 3d40fe02b003..0c4c7891556d 100644
--- a/fs/jffs2/xattr.c
+++ b/fs/jffs2/xattr.c
@@ -550,7 +550,8 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref)
ref->xseqno = xseqno;
jffs2_add_physical_node_ref(c, phys_ofs | REF_PRISTINE, PAD(sizeof(rr)), (void *)ref);
- dbg_xattr("success on saving xref (ino=%u, xid=%u)\n", ref->ic->ino, ref->xd->xid);
+ dbg_xattr("success on saving xref (ino=%u, xid=%u)\n",
+ je32_to_cpu(rr.ino), je32_to_cpu(rr.xid));
return 0;
}
@@ -1329,7 +1330,11 @@ int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_
rc = save_xattr_ref(c, ref);
if (!rc)
dbg_xattr("xref (ino=%u, xid=%u) GC'ed from %#08x to %08x\n",
- ref->ic->ino, ref->xd->xid, old_ofs, ref_offset(ref->node));
+ is_xattr_ref_dead(ref) ?
+ ref->ino : ref->ic->ino,
+ is_xattr_ref_dead(ref) ?
+ ref->xid : ref->xd->xid,
+ old_ofs, ref_offset(ref->node));
out:
if (!rc)
jffs2_mark_node_obsolete(c, raw);
--
2.16.2.dirty
next reply other threads:[~2018-10-20 11:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-20 11:07 Hou Tao [this message]
2018-12-09 6:34 ` Hou Tao
2018-12-09 6:52 ` Boris Brezillon
2018-12-13 21:53 ` Richard Weinberger
2018-12-15 13:17 ` Hou Tao
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=20181020110753.98407-1-houtao1@huawei.com \
--to=houtao1@huawei.com \
--cc=boris.brezillon@bootlin.com \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard.weinberger@gmail.com \
/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
all inboxes | Powered by JetHome®