From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=68.232.154.123 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796024309; b=0bF24o1m8Rpwe1tF6EF+41+tQRmnmLazLJf3GZC2ckT8utszuKxzX8trOk+OU5BYcgHV Q+awuQaUPMlQ5WZUakzkNuSKFcKlOJV7AIpIUrQSpC4+WTsbeWshbJ37VDT1zi6w8x8pt bLr0dHL0AkAHqVT08XS3KFhJBkABAD52NzltNSbTLdSz8csJgi0yFjwSggJWRuVdt8DcW BZRmVenkHLp8YF3yZMtoCLfbrg0UIPqI7Ll/PzZUqbbQOBa21Xx33+OEKVWx01uy0Uklu pn+d20Sd11J/9PmP5vVYnib6+DXtbi0sNOaXc4zIDE2WvD0PGnMYywSfj9xl1IFC6nA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796024309; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-Amp-Result:Received:Received:Received:From:To:CC: Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type; bh=d0nVKt187Fk3nxPa644tOys2T8lIkAsFnQ4+JWVEh9Y=; b=WkpopW5qwGJy9ayiM5bvulGcDzE1jyrfSAqbwsSgtnKX0lCeZNiQIBAQ7huj4cU66tTi azOPVd/SMb0DvzNwFasufRPMhfaXWHboodOhdBUHahvOajyJDdoI0D1lUEtCiX8SXwbew apLgWzexdEwuOCc/ypUknDwuwniCO3wajDiQtPkfplsZplxdTX+22p/flXKz8jZXAWJsY nIPfLEWqzLK/RWXu8MtY0rjt5lDOns7PeLfh/oUGeANjn1jTisXTlKkkZ2cZ8zOwaLlHB OejYHyU79Xjx9n2p1N1YhbdJb9s18EOO4iITBMrgvuwWKhgvaF3pCxzBkrl616p+PBQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=HP+9fwRz; arc=none smtp.remote-ip=68.232.154.123 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8588606A320; Mon, 30 Nov 2026 07:38:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E8588606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=HP+9fwRz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1796024309; x=1827560309; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PVE1brV9ww7cD9+aKZdAnQlGzR+tyLt70zrQ1z23I7c=; b=HP+9fwRzKqV1NtcR/kqp6vQT+0uCYrTdTjfF63760S7KwUbIM0aX6DsB 1IIiChWwDmPoGqNHerVKdKEeXzaL8+y1WMI8qb+/e1A/v1jvC3RH67cbg rDxWa1e0xDTYeZp/V+Nqxk2THd+P+ZGbYAJDIJap8q+h1tTV/cooWegYk eaVwHoxaZlDHRg/j+ZCDP8kldWS3mNG6LDrSGdPL4kAslC4GL5VdCu4ez dReooUUW3XOf52JEsEv3JSwLrBzfMUfTxLa8lcPRr9J4exLMMOWQZFuQJ wMhR0SgR4RWHfLdqBMjK0gbr5izEaH9Ne3zZQGHna5OxveO2YzJOqlLyU A==; X-CSE-ConnectionGUID: olVmLwrCTYW9k7D8rLZIqg== X-CSE-MsgGUID: O3p3q0BaTSSMrHNYbkZAvQ== X-IronPort-AV: E=Sophos;i="6.27,242,1787036400"; d="scan'208";a="234244524" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 00:38:28 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.87.152) by chn-vm-ex4.mchp-main.com (10.10.87.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.2562.57; Mon, 30 Nov 2026 00:38:27 -0700 Received: from che-ll-i67131.microchip.com (10.10.85.11) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Mon, 30 Nov 2026 00:38:15 -0700 From: Manikandan Muralidharan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH v11 3/8] nvmem: core: take a reference on dev.of_node in nvmem_register() Date: Mon, 30 Nov 2026 13:07:26 +0530 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain nvmem_register() stores config->of_node (or config->dev->of_node) into nvmem->dev.of_node without taking its own reference. Callers that get the node via of_get_compatible_child() etc. and drop their reference right after registering leave nvmem->dev.of_node backed by no reference at all. Take an of_node_get() when assigning nvmem->dev.of_node and release it in nvmem_release(). Existing callers that hold their own get/put pair around the registration call need no changes, since get/put on a device_node is per-holder and independent of core now also holding one. Fixes: 1333a6779501 ("nvmem: core: allow specifying of_node") Reviewed-by: Miquel Raynal Reviewed-by: Michael Walle Suggested-by: Michael Walle Signed-off-by: Manikandan Muralidharan --- drivers/nvmem/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index d976c0d6603b..a755cc4318dc 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -570,6 +570,7 @@ static void nvmem_release(struct device *dev) nvmem_device_remove_all_cells(nvmem); ida_free(&nvmem_ida, nvmem->id); cleanup_srcu_struct(&nvmem->srcu); + of_node_put(nvmem->dev.of_node); kfree(nvmem); } @@ -972,9 +973,9 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) nvmem->keepout = config->keepout; nvmem->nkeepout = config->nkeepout; if (config->of_node) - nvmem->dev.of_node = config->of_node; + nvmem->dev.of_node = of_node_get(config->of_node); else - nvmem->dev.of_node = config->dev->of_node; + nvmem->dev.of_node = of_node_get(config->dev->of_node); switch (config->id) { case NVMEM_DEVID_NONE: -- 2.43.0