From patchwork Tue Oct 18 05:18:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 616032 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2417344pvb; Mon, 17 Oct 2022 22:19:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5TvtHcUAiNJDt/qOjhBtsagyul799+dJvk37Jy2a/o66chQKRaV2+KCKh7WpVHTGLya96E X-Received: by 2002:a17:902:b589:b0:17f:5756:b3f9 with SMTP id a9-20020a170902b58900b0017f5756b3f9mr1488463pls.14.1666070380660; Mon, 17 Oct 2022 22:19:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666070380; cv=none; d=google.com; s=arc-20160816; b=b9hHsFYO7cJD1Gmen+P9pICmpdfV/mmB1drdbtX9eX5JrJLA0IIv4shJ91XdsRPgXM v/tf5IIQqA16/9PrtIoO/nWAwaLzfBBBNh55EjU6fGM9tfKmIXD74LnI/e2UiDuxLy+T Z4WH/SvE9AV/CbYoXP2SEgbjB5McqH8gyNnKZM7jK7CBKejGIx4HYaSXA3LwD7oPsEwn WV58RJUvoNcN5SW8/2iHW0OerPSygA2ZIxrTYmqx+G9T534PpKwVgF0MbY+rdc0OscEo Ks0lk+Yprnd9xdoexR4KZhtli5+lN+vLX8IIx1YFWS4NePagJdecjSVl6u6CEyFiHdma 968g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dkim-signature; bh=MAXUmuMka35q59xJ7GBgl9m7FppdrqK+cIGbWIi99zw=; b=rRqwM9DdnWjyJmUo3Cz+d6S+2YAaxY6H2nW97SokCQkFDmqktfuyO8ndMBqQzMHOp7 msCodfRLemEj+eFSoVph7xNELAb99f0q4dTL45lWg8eYLjhC6Ars4d7AIB86CvtK8gAn caM9doXRLUY4fiQD8hDXRqPnLkzA6Eddx33vfl1geLT/qFLwU2n+67t4I33fVZ9kXGui KTnhZAlhBppwwZ38I/IjMrzR19T5dRj/Iw2cb1uAVmgFBqmNuqpNweT+Ky2QUwdQOEAO Lhl9jByLb1gWl/zjaDDRkmQrKRnwekipfPzzHigle0VmP1usu7jhlLmfJNrha5CKClS3 uoig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=npJrLfCh; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=HPM+bXAo; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:3::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:3::133]) by mx.google.com with ESMTPS id e21-20020a170902e0d500b00180f1f7787dsi12202562pla.176.2022.10.17.22.19.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 22:19:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:3::133 as permitted sender) client-ip=2607:7c80:54:3::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=npJrLfCh; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=HPM+bXAo; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:3::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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=MAXUmuMka35q59xJ7GBgl9m7FppdrqK+cIGbWIi99zw=; b=npJrLfChoeSc6m W8dpu46YxYSHF4G+143ud7N9qgZxI/8j5pxIpwMKSWWejv0J8NMNd0/WjgXyDVVdiRhpsFOAmrNzg vxscoT2KaCuP7dEKWlgau6CSSJ80ayd565KGb8cfvjob3YBfKc1bR1yS0QT1FzVLCzTne6bf0/3CO Q1/BaBqNM2ge/LMp8uQmc5kyegB6RxreGCAM5wReTCbYWiQSUOm+7779TakTUdt1P47w+YmExJRrt EYZLsHMTwo4Ysmv4VWZLMB1k7znA879ycl8hz5x9owtr/0AMb9mihxboYIHYLr3b29IKUaSfnHl5V j/7daLclEJka4CRDfdUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1okezy-002jKF-8L; Tue, 18 Oct 2022 05:18:42 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1okezv-002jJo-QX for linux-mtd@lists.infradead.org; Tue, 18 Oct 2022 05:18:41 +0000 Received: by mail-ej1-x62f.google.com with SMTP id a26so29563161ejc.4 for ; Mon, 17 Oct 2022 22:18:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=j73kGLh0CnJEA8KnzgX0A0r/cABVpro+6vQk9HncJpg=; b=HPM+bXAoy7ZCGnX1ENmyyLnoOj1MsxDh81UXLrwDS6oDXnjQIF0tR9ya+iaMncS7Py Yofod3cbYMmVsroPLZTZafFGdSJa8LYW4YszWMIsoCg1RsItyNAKxSK6+E2al7e9WSr5 cUo+0BkCq/IETi8paiV2XEzNTTx7nH7M3QoPI3KE4J/AF4C5ogYMgzRPGuRYwRDrWMC1 yd9/mou9OQXgcPwrmF9/CKtiBxJo6USDFx4pBzsBfHsgxbk08nKUuAdM0k14q5ZLl7Vg ejhBTU42HrIQVOfSVQ/Weul9Mg0lax4uRy1dnt6TFdfp5LmdtczQ2w90FQYt/RxI5nsn wFXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=j73kGLh0CnJEA8KnzgX0A0r/cABVpro+6vQk9HncJpg=; b=T5X0+Mfp7Byq73rKqJvRdij6dX+iHk9VlQ+qu6CTQ2qUQGrcyfdPFPqsw1RX3DAHWw IosVT1zyEYImNPY+rwQJVO6KDQaojCBQmp4gOr+GRhi+6De6xmfcosD6kG9RSZPRw/Np S7zlzRdyZjH6yu1kkVHluq6mci1GSP0upiuIbZQcGo1lAQfdU1dUm+ksVWezPA5gJ0R+ L9U8NYCatd7Pp/R5cVcwaWLRMNZYku8MMfXvIipPbQAc5pLXwxV5lUKUzrFwX8ouZKBx Z+PvhQ+BiVoUx7BTgh8xEXFSwlBzlwWLgON7kZVRWTOQUQKXxAKDrIgaXB2iptSKebBR y+cA== X-Gm-Message-State: ACrzQf1akmaeTJwlbNGWCVeSYgMerNhckMeIst35t8VRQ+Oi4H7cOj7g UXgMHFQVNQF9gBJAeNMO2bI= X-Received: by 2002:a17:907:94d1:b0:790:65a:3a18 with SMTP id dn17-20020a17090794d100b00790065a3a18mr914228ejc.428.1666070314483; Mon, 17 Oct 2022 22:18:34 -0700 (PDT) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id u8-20020a17090657c800b0078c1e174e11sm6908594ejr.136.2022.10.17.22.18.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 22:18:33 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: Christian Marangi , Han Xu , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, =?utf-8?b?UmFm?= =?utf-8?b?YcWCIE1pxYJlY2tp?= Subject: [PATCH 6.1 FIX] mtd: core: add missing of_node_get() in dynamic partitions code Date: Tue, 18 Oct 2022 07:18:22 +0200 Message-Id: <20221018051822.28685-1-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221017_221839_906053_F83ED57E X-CRM114-Status: GOOD ( 14.95 ) X-Spam-Score: 0.1 (/) X-Spam-Report: =?utf-8?q?Spam_detection_software=2C_running_on_the_system_?= =?utf-8?q?=22bombadil=2Einfradead=2Eorg=22=2C?= =?utf-8?q?_has_NOT_identified_this_incoming_email_as_spam=2E__The_original?= =?utf-8?q?_message_has_been_attached_to_this_so_you_can_view_it_or_label?= =?utf-8?q?_similar_future_email=2E__If_you_have_any_questions=2C_see?= =?utf-8?q?_the_administrator_of_that_system_for_details=2E?= =?utf-8?q?_?= =?utf-8?b?IENvbnRlbnQgcHJldmlldzogIEZyb206IFJhZmHDhcKCIE1pw4XCgmVja2kgVGhp?= =?utf-8?b?cyBmaXhlcyB1bmJhbGFuY2VkIG9mX25vZGVfcHV0KCk6?= =?utf-8?q?_=5B_1=2E078910=5D_6_cmdlinepart_partitions_found_on_MTD_device_gp?= =?utf-8?q?mi-nand_=5B_1=2E085116=5D?= =?utf-8?q?_Creating_6_MTD_partitions_on_=22gpmi-nand=22=3A_=5B_1=2E090181=5D?= =?utf-8?q?_0x000000000000-0x000008000000?= =?utf-8?b?IFsuLi5dIA==?= =?utf-8?q?_?= =?utf-8?q?_Content_analysis_details=3A___=280=2E1_points=2C_5=2E0_required?= =?utf-8?q?=29?= =?utf-8?q?_?= =?utf-8?q?_pts_rule_name______________description?= =?utf-8?q?_----_----------------------_-------------------------------------?= =?utf-8?q?-------------?= =?utf-8?q?_-0=2E0_SPF=5FPASS_______________SPF=3A_sender_matches_SPF_record?= =?utf-8?q?_0=2E0_SPF=5FHELO=5FNONE__________SPF=3A_HELO_does_not_publish_an_?= =?utf-8?q?SPF_Record?= =?utf-8?q?_0=2E0_FREEMAIL=5FFROM__________Sender_email_is_commonly_abused_en?= =?utf-8?q?duser_mail?= =?utf-8?q?_provider?= =?utf-8?q?_=5Bzajec5=5Bat=5Dgmail=2Ecom=5D?= =?utf-8?q?_0=2E2_FREEMAIL=5FENVFROM=5FEND=5FDIGIT_Envelope-from_freemail_use?= =?utf-8?q?rname_ends?= =?utf-8?q?_in_digit?= =?utf-8?q?_=5Bzajec5=5Bat=5Dgmail=2Ecom=5D?= =?utf-8?q?_-0=2E0_RCVD=5FIN=5FDNSWL=5FNONE_____RBL=3A_Sender_listed_at_https?= =?utf-8?q?=3A//www=2Ednswl=2Eorg/=2C?= =?utf-8?q?_no_trust?= =?utf-8?b?IFsyYTAwOjE0NTA6NDg2NDoyMDowOjA6MDo2MmYgbGlzdGVkIGluXQ==?= =?utf-8?b?IFtsaXN0LmRuc3dsLm9yZ10=?= =?utf-8?q?_-0=2E1_DKIM=5FVALID=5FAU__________Message_has_a_valid_DKIM_or_DK_?= =?utf-8?q?signature_from?= =?utf-8?q?_author=27s_domain?= =?utf-8?q?_-0=2E1_DKIM=5FVALID_____________Message_has_at_least_one_valid_DK?= =?utf-8?q?IM_or_DK_signature?= =?utf-8?q?_0=2E1_DKIM=5FSIGNED____________Message_has_a_DKIM_or_DK_signature?= =?utf-8?q?=2C_not_necessarily?= =?utf-8?q?_valid?= =?utf-8?q?_-0=2E1_DKIM=5FVALID=5FEF__________Message_has_a_valid_DKIM_or_DK_?= =?utf-8?q?signature_from?= =?utf-8?q?_envelope-from_domain?= 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+patch=linaro.org@lists.infradead.org From: Rafał Miłecki This fixes unbalanced of_node_put(): [ 1.078910] 6 cmdlinepart partitions found on MTD device gpmi-nand [ 1.085116] Creating 6 MTD partitions on "gpmi-nand": [ 1.090181] 0x000000000000-0x000008000000 : "nandboot" [ 1.096952] 0x000008000000-0x000009000000 : "nandfit" [ 1.103547] 0x000009000000-0x00000b000000 : "nandkernel" [ 1.110317] 0x00000b000000-0x00000c000000 : "nanddtb" [ 1.115525] ------------[ cut here ]------------ [ 1.120141] refcount_t: addition on 0; use-after-free. [ 1.125328] WARNING: CPU: 0 PID: 1 at lib/refcount.c:25 refcount_warn_saturate+0xdc/0x148 [ 1.133528] Modules linked in: [ 1.136589] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.0.0-rc7-next-20220930-04543-g8cf3f7 [ 1.146342] Hardware name: Freescale i.MX8DXL DDR3L EVK (DT) [ 1.151999] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 1.158965] pc : refcount_warn_saturate+0xdc/0x148 [ 1.163760] lr : refcount_warn_saturate+0xdc/0x148 [ 1.168556] sp : ffff800009ddb080 [ 1.171866] x29: ffff800009ddb080 x28: ffff800009ddb35a x27: 0000000000000002 [ 1.179015] x26: ffff8000098b06ad x25: ffffffffffffffff x24: ffff0a00ffffff05 [ 1.186165] x23: ffff00001fdf6470 x22: ffff800009ddb367 x21: 0000000000000000 [ 1.193314] x20: ffff00001fdfebe8 x19: ffff00001fdfec50 x18: ffffffffffffffff [ 1.200464] x17: 0000000000000000 x16: 0000000000000118 x15: 0000000000000004 [ 1.207614] x14: 0000000000000fff x13: ffff800009bca248 x12: 0000000000000003 [ 1.214764] x11: 00000000ffffefff x10: c0000000ffffefff x9 : 4762cb2ccb52de00 [ 1.221914] x8 : 4762cb2ccb52de00 x7 : 205d313431303231 x6 : 312e31202020205b [ 1.229063] x5 : ffff800009d55c1f x4 : 0000000000000001 x3 : 0000000000000000 [ 1.236213] x2 : 0000000000000000 x1 : ffff800009954be6 x0 : 000000000000002a [ 1.243365] Call trace: [ 1.245806] refcount_warn_saturate+0xdc/0x148 [ 1.250253] kobject_get+0x98/0x9c [ 1.253658] of_node_get+0x20/0x34 [ 1.257072] of_fwnode_get+0x3c/0x54 [ 1.260652] fwnode_get_nth_parent+0xd8/0xf4 [ 1.264926] fwnode_full_name_string+0x3c/0xb4 [ 1.269373] device_node_string+0x498/0x5b4 [ 1.273561] pointer+0x41c/0x5d0 [ 1.276793] vsnprintf+0x4d8/0x694 [ 1.280198] vprintk_store+0x164/0x528 [ 1.283951] vprintk_emit+0x98/0x164 [ 1.287530] vprintk_default+0x44/0x6c [ 1.291284] vprintk+0xf0/0x134 [ 1.294428] _printk+0x54/0x7c [ 1.297486] of_node_release+0xe8/0x128 [ 1.301326] kobject_put+0x98/0xfc [ 1.304732] of_node_put+0x1c/0x28 [ 1.308137] add_mtd_device+0x484/0x6d4 [ 1.311977] add_mtd_partitions+0xf0/0x1d0 [ 1.316078] parse_mtd_partitions+0x45c/0x518 [ 1.320439] mtd_device_parse_register+0xb0/0x274 [ 1.325147] gpmi_nand_probe+0x51c/0x650 [ 1.329074] platform_probe+0xa8/0xd0 [ 1.332740] really_probe+0x130/0x334 [ 1.336406] __driver_probe_device+0xb4/0xe0 [ 1.340681] driver_probe_device+0x3c/0x1f8 [ 1.344869] __driver_attach+0xdc/0x1a4 [ 1.348708] bus_for_each_dev+0x80/0xcc [ 1.352548] driver_attach+0x24/0x30 [ 1.356127] bus_add_driver+0x108/0x1f4 [ 1.359967] driver_register+0x78/0x114 [ 1.363807] __platform_driver_register+0x24/0x30 [ 1.368515] gpmi_nand_driver_init+0x1c/0x28 [ 1.372798] do_one_initcall+0xbc/0x238 [ 1.376638] do_initcall_level+0x94/0xb4 [ 1.380565] do_initcalls+0x54/0x94 [ 1.384058] do_basic_setup+0x1c/0x28 [ 1.387724] kernel_init_freeable+0x110/0x188 [ 1.392084] kernel_init+0x20/0x1a0 [ 1.395578] ret_from_fork+0x10/0x20 [ 1.399157] ---[ end trace 0000000000000000 ]--- [ 1.403782] ------------[ cut here ]------------ Reported-by: Han Xu Fixes: ad9b10d1eaada169 ("mtd: core: introduce of support for dynamic partitions") Signed-off-by: Rafał Miłecki Tested-by: Han Xu --- drivers/mtd/mtdcore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 18aa54460d36..0b4ca0aa4132 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -562,7 +562,7 @@ static void mtd_check_of_node(struct mtd_info *mtd) if (!mtd_is_partition(mtd)) return; parent = mtd->parent; - parent_dn = dev_of_node(&parent->dev); + parent_dn = of_node_get(dev_of_node(&parent->dev)); if (!parent_dn) return;