From patchwork Wed Mar 1 15:22:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 62958 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3692580wrd; Wed, 1 Mar 2023 07:25:24 -0800 (PST) X-Google-Smtp-Source: AK7set/P3EKGnGn3yR7dJY6ocM+8kDmE06XGhSX7K7o6/17H166Q3a4OaxgYG53G1Dtb0Z1o5Vqn X-Received: by 2002:a17:906:3b85:b0:8b1:7569:b51a with SMTP id u5-20020a1709063b8500b008b17569b51amr6389610ejf.53.1677684324564; Wed, 01 Mar 2023 07:25:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677684324; cv=none; d=google.com; s=arc-20160816; b=CmqVuKhMAt7l4MOWjAeLUarP+wQmQyZVc/JmgDTPTl7e4BwsR9tHSiA1qGF+3jBEUc h4Dq4wZyqsuxtFR+69Ms3PB4R3J/PdbbSBGBX2pB4UbeImhcJpUQS0KJF3dPCMW1VvOq 0CvcosIpWmMuWrTTwk0FKJ6BuBXZ7yrAHiEVtYfN0ejUOz+xMTSElsmep5Sxn5JsPb3F DLLiGaF15e9LPw1LVcbPjvSdxl0oDPLoA3sJJ2eaiWtO15hkaUSL45MwS7Mcs9wyQWkZ XfWbPhiL5d3fb1YlyA0k2hhs0ANerYrKpmCxKgDmUQUkgqm4gIBGF54PpWrQ+dJlZF+O 2TiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1dh6uGZ61Q7do467wqoDaMh6uB2u9srGrh1AVvKSU6M=; b=ksScAQO8KmzJZfgEpZgZRu0HxIoGHkUdfZPxcxtxImznuMmc10WiYf6m8SBLlbuO/k eMoMr++8g0I6NJ11NpGWm3b7k+QoBc/tJr/wsbbNw2/Y2AaI2Lp4C1AcRQwr8cY7NIqs pGsh00SMbBV+odCODumSXlJq7+/NiUPK4rhBoVXMp+rP9nfrWlXOktWgV0cb06JnJ5c0 Ch3r/qfO02jXELC/RVyDxcWRNPeKWMTsxUBrzf+NTH8ZggtcY9Vsmn0ooF+zRh6rkB0S 3SfQ3h8L56dTuBMr3dEDjvW+VqvfilNXv7o+J05ptB6DNg1NXtRhCz/ovphMX8iWQP+1 Mr2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=VtSYrdBh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id br12-20020a170906d14c00b008d14655248fsi1798643ejb.470.2023.03.01.07.25.01; Wed, 01 Mar 2023 07:25:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=VtSYrdBh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230338AbjCAPW7 (ORCPT + 99 others); Wed, 1 Mar 2023 10:22:59 -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 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759179518310720808?= X-GMAIL-MSGID: =?utf-8?q?1759179518310720808?= 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);