Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DE14C64ED6 for ; Wed, 1 Mar 2023 15:23:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230341AbjCAPXB (ORCPT ); Wed, 1 Mar 2023 10:23:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230306AbjCAPWt (ORCPT ); Wed, 1 Mar 2023 10:22:49 -0500 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCC3C410A4; Wed, 1 Mar 2023 07:22:47 -0800 (PST) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 6BDA560010; Wed, 1 Mar 2023 15:22:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1677684166; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1dh6uGZ61Q7do467wqoDaMh6uB2u9srGrh1AVvKSU6M=; b=VtSYrdBhwFAsMBULAFTYUYpOylcY4XED6Sw6J05beW6Q6pl0XGnYueudCn2JsgvgwiD7Bn J2vlIaTBeDzoBn73VzLTlszWkGkXD9XmvFTTj4cvyNOEmt769lODpdud+WqANq2iOt5Pkm kSZnQozL5PPeKmmUFm52qGZcR0M7cfXxSgwjY65axGIRxyZZziuL7dfjJ0DjJjxyGw/HHB OjGHqCGZPaloeHK5zTxGUBN5eZHFQDmZzJaPSadRdxcdTU8V9YppexKBcwNRQKLPRYtf+5 qyiCIR6wemROamDlR68biNhH2W3OsTU0hvxpbOetLMib/ZKxsGpWkPlBj//OwQ== From: Miquel Raynal To: Srinivas Kandagatla , Cc: Greg Kroah-Hartman , Michael Walle , devicetree@vger.kernel.org, Rob Herring , Frank Rowand , Robert Marko , Luka Perkov , Thomas Petazzoni , rafal@milecki.pl, Miquel Raynal Subject: [PATCH 4/8] nvmem: core: Fix error path ordering Date: Wed, 1 Mar 2023 16:22:35 +0100 Message-Id: <20230301152239.531194-5-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230301152239.531194-1-miquel.raynal@bootlin.com> References: <20230301152239.531194-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The layout is being retrieved before the addition of nvmem cells and after the creation of the sysfs entries. Soon the layout operation will have the possibility to fail, hence adding a new goto label in the error path. Before doing so, we need to fix the operation order in the error path. Signed-off-by: Miquel Raynal --- drivers/nvmem/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 56b4b20a95a9..16044377a41d 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -975,9 +975,9 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) err_remove_cells: nvmem_device_remove_all_cells(nvmem); + nvmem_layout_put(nvmem->layout); if (config->compat) nvmem_sysfs_remove_compat(nvmem, config); - nvmem_layout_put(nvmem->layout); err_put_device: put_device(&nvmem->dev); -- 2.34.1