From patchwork Fri Apr 1 07:23:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haowen Bai X-Patchwork-Id: 1612070 X-Patchwork-Delegate: richard@nod.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=XoAAQOYj; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KVBWh5BGjz9sGC for ; Fri, 1 Apr 2022 18:24:48 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=BMsxhLZohTmBMTwt53nIOB3k68W4qmkB3mCskTyRG7M=; b=XoAAQOYjSE6cG6 XYzOUFOCs3s8/ZNirZDpWZTlYP9crvQCzsqqLUuQrYeJlEm911ot0crRWdbFed8C9LNJdrVoa+Top sL6tnXn29zu2tip+q8f0U51liOJfuht3pXV73YlPMn7qLBmSyvmVcMg6O9q4joYIzIOsHhmDYLYc5 tE156EweMpEghXZ/AGEUPn45B7H5E1mWF7y7iuiYleNUHUf/dZd1UZB5FpzdZ91D8FZF8gPllEBMP dOiZMRYhoO/Jr482V5sZf5rD2BQ+1IrOKQ2AQkdq1mGjCWvXD2tQkrtuNGSNRoI3jslBYwLi9u+C9 60I7V3fiTRTApqyRC4YQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1naBdQ-004mhf-Th; Fri, 01 Apr 2022 07:23:52 +0000 Received: from edge05.meizu.com ([157.122.146.251] helo=mail.meizu.com) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1naBdN-004meV-AZ for linux-mtd@lists.infradead.org; Fri, 01 Apr 2022 07:23:51 +0000 Received: from IT-EXMB-1-125.meizu.com (172.16.1.125) by mz-mail12.meizu.com (172.16.1.108) with Microsoft SMTP Server (TLS) id 14.3.487.0; Fri, 1 Apr 2022 15:23:34 +0800 Received: from meizu.meizu.com (172.16.137.70) by IT-EXMB-1-125.meizu.com (172.16.1.125) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.14; Fri, 1 Apr 2022 15:23:32 +0800 From: Haowen Bai To: David Woodhouse , Richard Weinberger CC: Haowen Bai , , Subject: [PATCH] fs/jffs2: Fix potential NULL dereference in jffs2_add_frag_to_fragtree() Date: Fri, 1 Apr 2022 15:23:30 +0800 Message-ID: <1648797810-27042-1-git-send-email-baihaowen@meizu.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [172.16.137.70] X-ClientProxiedBy: IT-EXMB-1-124.meizu.com (172.16.1.124) To IT-EXMB-1-125.meizu.com (172.16.1.125) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220401_002349_582595_69DFF224 X-CRM114-Status: UNSURE ( 9.83 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 1.4 (+) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: this could be null, so we need to checking null before dereference Signed-off-by: Haowen Bai --- fs/jffs2/nodelist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c index b86c78d178c6..ed3b3b25bfab 100644 --- a/fs/jffs2/nodelist.c +++ b/fs/jffs2/nodelist.c @@ -246, 7 +246, 7 @@ static int jffs2_add_frag_to_frag [...] Content analysis details: (1.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org this could be null, so we need to checking null before dereference Signed-off-by: Haowen Bai --- fs/jffs2/nodelist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c index b86c78d178c6..ed3b3b25bfab 100644 --- a/fs/jffs2/nodelist.c +++ b/fs/jffs2/nodelist.c @@ -246,7 +246,7 @@ static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *r return no_overlapping_node(c, root, newfrag, this, lastend); } - if (this->node) + if (this && this->node) dbg_fragtree2("dealing with frag %u-%u, phys %#08x(%d).\n", this->ofs, this->ofs + this->size, ref_offset(this->node->raw), ref_flags(this->node->raw));