From nobody Mon Feb 9 01:45:48 2026 Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E676F9E8 for ; Thu, 15 Jan 2026 06:42:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768459378; cv=none; b=uaoMpQsl4t2s3XUekIVaPqNIqNc5A1qUr3tCMsGWnGZwHgH8aMBMCncfV2vA3n29Cwm0Zx6gEOiMIlssg8Pn4p+ptzj8ZcbAGN+75azycU4KOYeNzYV7u0Q67cUbnB95JyxFhiaXHLcd6u96OKktRn3wDvYigbtl3XmYog/I5tk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768459378; c=relaxed/simple; bh=vg2mdYZSeXe26ZUxOXIZrPgng6u6wYNbztQz5AudaJw=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=KNjl5n9oUkyMJRDTV4/MQSuM2FaW1zfnaDNSkKdjntocqPZ30so+G3eMTxdd2TOkvEMOF3vjYz4QTrn+WJY0ETIILc0BoLKSKGX++aA4ZNjaavVr0k3ZH0r6Y1uSSYIfIVXyIQCXmSvXbocFJfV00rWOpQ0bla29OU5rpyOgSZs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZtrHEJV2; arc=none smtp.client-ip=209.85.215.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZtrHEJV2" Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-bbf2c3eccc9so659325a12.0 for ; Wed, 14 Jan 2026 22:42:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768459376; x=1769064176; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/wB2J4eqmiCVBCDzAbOLRwInf4lXmX4zLdtF2BG6TU4=; b=ZtrHEJV2OFDJDOBD3g2T09+TzHheyls6k8jxVJm4nYHHeXIU+xEIbYHi+qKSWsP2S+ Non5Pb4H37106SVKs/g1nsR5I7Hkt0A4Ak+ZoBVJUsxKWl/3CazPbBH6lQryOn1gzEBl 3v+0dMnvFU630MUaAsYO/UyQqeHSS44L31F1Du6mkjHUgr4VpnMcTuJJlFx+s658M7/w D32xRfouBs9Ygddteiyo5/fD9IHI4w0cdWsQ+IqZjV/dKNzB/fppOquJiOOX2CjcE6Ob wWjXxuXmLABGwfbn+9iLcF1n+G8YsseAyejl0H35WbVrmAeNfQYGxQXt+cRg0wuLqRbZ SkMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768459376; x=1769064176; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/wB2J4eqmiCVBCDzAbOLRwInf4lXmX4zLdtF2BG6TU4=; b=UuCUbBEOqcK7EPrjwp1u0Gom0N1fo7e65IznNGjes4SPp5PWxeB3iWcbsbqQ7IJf5k nCuXy5AxkCBc1OWDzyAJEYRQnuXW2Rcb3PEiBNssXD0cKh18hzkCeWtZrb9p6rSYhd1q gHDhjueswAWU1XbP4pYpRIhhWMls0kdU3UA5miM7gJKSUKUAFgPuSPCauDcPPWWjRPqy +NugQeAcKZdOLIP0U259INUL4XpBLMQtzAv6KgWqcMCcsMaz6PJObHnX1IAaxo84Gdzl DKJfJkMRDo/bUt4qXIdCka0PzPVCrwMkoeWyOtWCTx0zum2Fx2ioe+oHsHtG1Xn8RZTF N+Nw== X-Gm-Message-State: AOJu0Yw6ayKebsSNFnFu3box8FtzOrBnsZZAhpwtd7Rw/Rmk3bUxHwpz iONsMj85H5Tm0B8q0ABTvi3Nk7ndl8WRYdbrKsqCSqpG0l+nNI9JZ62t X-Gm-Gg: AY/fxX4YBtXlbHdmu2BVeM84nwpYD1X2TpIAPTn+XYpmMjm7nqXRVWlSZyBXdkOxLsf o2nvrBF2Fu8Rq20XnTIwC4LHUeI87wqbi7qhJPDTIzL8MFa47A7bDvj+p8UGBBSYcSCj9KLLNzm oCqXc4BhuEp7JzUeBKFhpDYHljr587koHsTe/53lEu/MgSc094n40GJpNEXuVzkyBtludBlMYri rRFK5fpsy4VuJCe/Cf3y5NeDaFYdPIZeOloEkDw9g4rk5ZLGiRrOwgDygmfxEM9zelBT1J3y33g Df6gwAFKfXzfXR3qnagnWHiT9W1xY45+RFnoONdg/hBi6nWS63ugHnvDjM9ma+Cu/UF5o7jIdHm PzEsNVPFjEVJcNdMGApvYLpV1rLK2Un1mIN5LCFlbCRZ0BnBy4XzrF9ceXXiII+s51kLl1QLaM+ qaPz8Jc0GWHxHJBeLLLwGBS9ZPR4Pw0Nx2OhlUPSJRQweq/45czviXBhUcKeH6ObKrQ8elfpYmG EpqVlxwO7B5ldp58Q== X-Received: by 2002:a17:90b:2247:b0:343:87b3:6fbb with SMTP id 98e67ed59e1d1-35267819273mr1975293a91.8.1768459376408; Wed, 14 Jan 2026 22:42:56 -0800 (PST) Received: from c8971f1abf06.vpc.local (ec2-13-211-200-41.ap-southeast-2.compute.amazonaws.com. [13.211.200.41]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35107c162f4sm1578229a91.7.2026.01.14.22.42.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jan 2026 22:42:56 -0800 (PST) From: Weigang He To: Santosh Shilimkar , Krzysztof Kozlowski Cc: linux-kernel@vger.kernel.org, Weigang He Subject: [PATCH] memory: emif: fix device tree node reference leak Date: Thu, 15 Jan 2026 06:42:37 +0000 Message-Id: <20260115064237.492714-1-geoffreyhe2@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The EMIF driver acquires a device tree node reference via of_parse_phandle() but never releases it with of_node_put(), causing a reference count leak. This affects: 1. Error paths in of_get_memory_device_details() - if allocation or validation fails after of_parse_phandle() succeeds, the reference is leaked 2. Normal driver removal - emif_remove() never releases the reference stored in emif->np_ddr Fix by adding an err_put_node label to properly release the node reference on error paths, and adding of_node_put() in emif_remove() to release the reference during normal driver unload. Fixes: e6b42eb6a66c ("memory: emif: add device tree support to emif driver") Signed-off-by: Weigang He --- drivers/memory/emif.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/memory/emif.c b/drivers/memory/emif.c index 2fadad0666b1f..e4f7547efbff4 100644 --- a/drivers/memory/emif.c +++ b/drivers/memory/emif.c @@ -922,7 +922,7 @@ static struct emif_data *of_get_memory_device_details( if (!emif || !pd || !dev_info) { dev_err(dev, "%s: Out of memory!!\n", __func__); - goto error; + goto err_put_node; } =20 emif->plat_data =3D pd; @@ -946,7 +946,7 @@ static struct emif_data *of_get_memory_device_details( pd->device_info->io_width, pd->phy_type, pd->ip_rev, emif->dev)) { dev_err(dev, "%s: invalid device data!!\n", __func__); - goto error; + goto err_put_node; } /* * For EMIF instances other than EMIF1 see if the devices connected @@ -970,6 +970,8 @@ static struct emif_data *of_get_memory_device_details( emif->plat_data->min_tck =3D of_get_min_tck(np_ddr, emif->dev); goto out; =20 +err_put_node: + of_node_put(np_ddr); error: return NULL; out: @@ -1139,6 +1141,7 @@ static void emif_remove(struct platform_device *pdev) { struct emif_data *emif =3D platform_get_drvdata(pdev); =20 + of_node_put(emif->np_ddr); emif_debugfs_exit(emif); } =20 --=20 2.34.1