From patchwork Tue Dec 6 20:07:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 30492 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3027123wrr; Tue, 6 Dec 2022 12:09:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf6PdCgcWObAplKSFQ2+lmmsIWamgxi70pCypDZWUgClpdm363zolx8Xd4xd0HOQJZaS03CI X-Received: by 2002:a63:e646:0:b0:470:15cd:d428 with SMTP id p6-20020a63e646000000b0047015cdd428mr81721357pgj.213.1670357379683; Tue, 06 Dec 2022 12:09:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670357379; cv=none; d=google.com; s=arc-20160816; b=O/Nlo5aA9k78tD/0IJ7O/gbwL1us4E/2cv5NZAHizlyyXB9dOU5rwhzDi7eLaRwFkm tyX0XUtb6cUBzEx7m9vkjP9skigwmYiIVkM/HV1OviTpP/s2OPMg5mrGkCeRsJVyMvq0 WbQfpoYMSu0QugSS9X/H48ABmat7iZccAA1R6FR0A4flroJNFEH8coK9fRi1pv9xZDL+ ZWfdpJ61IXuEqwbKWz49lrCYe2f6QT2Kg2LxX/7OftOz3vS56RiSnbayXsk7naThqF70 9IOH9aO0c87vtN2W1UAzsp//ak/af0wjh2B2DK4As1YQKPp09cUf5KZCzr6koCkrnhUj JSuQ== 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=mvTkfYS/F5bhxjZrXTlkPXrK+rtGefsDiAak505Ve5I=; b=ZnWCe8wk+uvcMIVlZKfI+demAmtaFgL7Wq/emyJs/q0Nx/1WNQ/k00yucQx6Ijb7DF m3lZ5e1uKcAzmejYgXNso2fo5hzqzSpZ3D703Dn9GtFrt5GwRwcYmxL2DJ1WhqUq3PmY gx3ApCa44hkLu3mZSOW/5IgwGv/e0KeiX9i+PCwEbAxzrwsKZmCZ111dZxdu3I1LIy1w 9BFvA5guPUYNT6sf1qs2L7C5hdXy5CQ/La2RsCgzj2btTjfmSuXXwQR/va8rPCJ4MkMQ oukin7M3SCyxwiOlMrxhlJuULY/H6lVleiIz5DDBC4EiV3vAZg7C23kPhX76ab/h2wHB epxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=opmIFnOx; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j193-20020a638bca000000b00477bf2ebf14si18316119pge.266.2022.12.06.12.09.25; Tue, 06 Dec 2022 12:09:39 -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=@walle.cc header.s=mail2022082101 header.b=opmIFnOx; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229875AbiLFUIc (ORCPT + 99 others); Tue, 6 Dec 2022 15:08:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229718AbiLFUHz (ORCPT ); Tue, 6 Dec 2022 15:07:55 -0500 Received: from mail.3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB66C13DEE; Tue, 6 Dec 2022 12:07:52 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 63FB43B39; Tue, 6 Dec 2022 21:07:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1670357270; 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=mvTkfYS/F5bhxjZrXTlkPXrK+rtGefsDiAak505Ve5I=; b=opmIFnOxHWQg0pmLwLLkrxg6RJTvYGzaJg6JawH8Qi4UGjW5MBsazUYQrHZW/DXBTnn2tq kAPYGcC6FhZA/GYC3fT6VL2tg9SkTyQUXn/FvX95xIzu48RfERGNithitZ5pp6rHYnZ1XO dKF/RGFhhjXQpREAv18gyflhb60KHzTe7t4BHMAxK+mLxNdbn2ZRnt26GDqwf1sDpFtLsM srt8hj2Nkhpz1iUxL3TL42Tqbkc80+eMrCA5o2H+smHMnJbqoXgdshfa4CRdatudLUz6+o IllbFKKUaK3GIj9NbN3MdzDzmU8zmOjQsXEzH4DzumDHh4MAFZ4d/qbTh7axQA== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , Sascha Hauer Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle , Dan Carpenter Subject: [PATCH v5 09/21] nvmem: core: fix cell removal on error Date: Tue, 6 Dec 2022 21:07:28 +0100 Message-Id: <20221206200740.3567551-10-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221206200740.3567551-1-michael@walle.cc> References: <20221206200740.3567551-1-michael@walle.cc> MIME-Version: 1.0 X-Spam: Yes X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1751496659727709080?= X-GMAIL-MSGID: =?utf-8?q?1751496659727709080?= nvmem_add_cells() could return an error after some cells are already added to the provider. In this case, the added cells are not removed. Remove any registered cells if nvmem_add_cells() fails. Signed-off-by: Michael Walle --- changes since v4: - new patch drivers/nvmem/core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 7c76e0e0072e..70c3d0a20d0d 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -851,7 +851,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) if (config->cells) { rval = nvmem_add_cells(nvmem, config->cells, config->ncells); if (rval) - goto err_teardown_compat; + goto err_remove_cells; } rval = nvmem_add_cells_from_table(nvmem); @@ -868,7 +868,6 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) err_remove_cells: nvmem_device_remove_all_cells(nvmem); -err_teardown_compat: if (config->compat) nvmem_sysfs_remove_compat(nvmem, config); err_device_del: