lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220703095631.16508-1-ansuelsmth@gmail.com>
Date:   Sun,  3 Jul 2022 11:56:31 +0200
From:   Christian Marangi <ansuelsmth@...il.com>
To:     Miquel Raynal <miquel.raynal@...tlin.com>,
        Richard Weinberger <richard@....at>,
        Vignesh Raghavendra <vigneshr@...com>,
        Christian Marangi <ansuelsmth@...il.com>,
        linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org
Cc:     kernel test robot <oliver.sang@...el.com>, stable@...r.kernel.org
Subject: [PATCH] mtd: core: fix NULL pointer dereference with mtd_check_of_node

Actually check if mtd dev have a parent to fix NULL pointer dereference
kernel panic in mtd_check_of_node.

Reported-by: kernel test robot <oliver.sang@...el.com>
Fixes: ad9b10d1eaad ("mtd: core: introduce of support for dynamic partitions")
Cc: stable@...r.kernel.org
Signed-off-by: Christian Marangi <ansuelsmth@...il.com>
---
 drivers/mtd/mtdcore.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 6fafea80fd98..48a357fcf2ed 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -558,8 +558,12 @@ static void mtd_check_of_node(struct mtd_info *mtd)
 	if (dev_of_node(&mtd->dev))
 		return;
 
-	/* Check if a partitions node exist */
+	/* Make sure we have a parent */
 	parent = mtd->parent;
+	if (!parent)
+		return;
+
+	/* Check if a partitions node exist */
 	parent_dn = dev_of_node(&parent->dev);
 	if (!parent_dn)
 		return;
-- 
2.36.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ