Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1066820rwe; Thu, 25 Aug 2022 14:55:23 -0700 (PDT) X-Google-Smtp-Source: AA6agR5mNpUq3fl+CEqm8roiKsserR1P4uz8PuZSTlvCgRhcdiTOAn/wPcAklitegwSWSrjvSjTs X-Received: by 2002:a05:6402:4515:b0:443:7833:3d7b with SMTP id ez21-20020a056402451500b0044378333d7bmr4553767edb.151.1661464523133; Thu, 25 Aug 2022 14:55:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661464523; cv=none; d=google.com; s=arc-20160816; b=RCavlFvKTPSMvZRD785zkxFEhJpMs7aEejldRUC/w7CjrHowhXK7cKSbgQCgL6cFQS R8eAj8TRzNmZmVQ6yyvjnVObyRLhJiIy+4RkWtxVJfUEiezqPt18v+nMirHoM8lhcgdW gzV/xJksYx/S6BOdutT+o0UP7eFyanwP27Wnph0mgnnqUvH6C4EoLVXnv8sW9rgXV/5r f8u8RfBes2uK4IL534oNc0JSHwUXuIODKPHyUJxkGZutzJHJV3Sb+KMwUNE8zDXItOew gp9pXWgCRqqRiqA+pVinoWtpkam72fnOdaIS1hTdMnhFjB6AQQhu+W/9lgO/yveKSGFY OsMQ== 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=NgLen7ZHBqbaEWUEF25Dd4sUxZqmNPV1jG0lui9seU8=; b=pfNQ7y4pRSST0J9/1fkhvtMld0NH8j1xJ3BbKk7rOqvHh1WrAoAgfkFQCUxTumz1Ff yATaGcdV1HsGb/mC+JXyYp3EGvAqbya8TiLa419giwvP0P6EYJbrpHOMghCCI6wMaIaQ tAFOnC2+4e/cpVyWENtT5FORV3Wa7CI2jZysEtDA9H0kUVAwJJ5Bmd8I3tgkteHwNuD5 8/uYJKpmv5vvM1L/+6pihAG8C07k9QLXVQQP/T2EUl1W9ZZGB/Hyq/x/nhJeNGS5KgIK 07go6xJW34OvxlbatzWRdrea5XHpD1kyzvE3e73GvJftg+b4pjyvJbx8bXpZWr9pd6Pa 3HDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=VcqoGrhL; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id di21-20020a170906731500b0073d7884a3c8si213691ejc.594.2022.08.25.14.54.14; Thu, 25 Aug 2022 14:55:23 -0700 (PDT) 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=VcqoGrhL; 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 S243919AbiHYVp5 (ORCPT + 99 others); Thu, 25 Aug 2022 17:45:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244033AbiHYVoy (ORCPT ); Thu, 25 Aug 2022 17:44:54 -0400 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AD3A240BC; Thu, 25 Aug 2022 14:44:50 -0700 (PDT) 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 133A87F31; Thu, 25 Aug 2022 23:44:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1661463878; 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=NgLen7ZHBqbaEWUEF25Dd4sUxZqmNPV1jG0lui9seU8=; b=VcqoGrhLt0c3LRfQ2ZcqfMCdqELmHOQRt7EuuHArdq4lvVDTdutbAkdsWIhVK4ynt3vvBk lTqjBwxDVQ/b+HCJJSXLe8mG4KD7ZbbwsLQ5E6+wiiQLgx3YvhoCL5hOeRBU+7209QsH2J 2YXZ0DKqzbs7e4ZBerGP+WbfzNoNr0dmVXwwMataxbjLXqphHM9Z9pLnGIFkvihuz7VAyy RxiARaM+V0u0pRJpT24ioa3X0Buu193+e3+Rm4HtplXGSsM+dP+0ENXFb+sXbCcTUyR3N/ yn8Y6/fZUzcuJmF4IVkw9TcltcuRM41CDe73f2odmeNwqcuXfTav49Ptd06nZQ== From: Michael Walle To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Srinivas Kandagatla , Shawn Guo , Li Yang , =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Frank Rowand Cc: linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Ahmad Fatoum , Michael Walle Subject: [PATCH v1 04/14] nvmem: core: drop the removal of the cells in nvmem_add_cells() Date: Thu, 25 Aug 2022 23:44:13 +0200 Message-Id: <20220825214423.903672-5-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220825214423.903672-1-michael@walle.cc> References: <20220825214423.903672-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 If nvmem_add_cells() fails, the whole nvmem_register() will fail and the cells will then be removed anyway. This is a prepartion to introduce a nvmem_add_one_cell() which can then be used by nvmem_add_cells(). This is then the same to what nvmem_add_cells_from_table() and nvmem_add_cells_from_of() do. Signed-off-by: Michael Walle --- drivers/nvmem/core.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index ab055e4fc409..be38e62fd190 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -515,7 +515,7 @@ static int nvmem_add_cells(struct nvmem_device *nvmem, int ncells) { struct nvmem_cell_entry **cells; - int i, rval; + int i, rval = 0; cells = kcalloc(ncells, sizeof(*cells), GFP_KERNEL); if (!cells) @@ -525,28 +525,22 @@ static int nvmem_add_cells(struct nvmem_device *nvmem, cells[i] = kzalloc(sizeof(**cells), GFP_KERNEL); if (!cells[i]) { rval = -ENOMEM; - goto err; + goto out; } rval = nvmem_cell_info_to_nvmem_cell_entry(nvmem, &info[i], cells[i]); if (rval) { kfree(cells[i]); - goto err; + goto out; } nvmem_cell_entry_add(cells[i]); } +out: /* remove tmp array */ kfree(cells); - return 0; -err: - while (i--) - nvmem_cell_entry_drop(cells[i]); - - kfree(cells); - return rval; } -- 2.30.2