Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5673562ybv; Tue, 18 Feb 2020 01:46:22 -0800 (PST) X-Google-Smtp-Source: APXvYqxK5njd6Jw5/r8kwGaRzuX57gvS1gUOlDlnFBTC8rjVHsEn5M26yRCWjKRpPxukSC2xiYdK X-Received: by 2002:a9d:7f98:: with SMTP id t24mr15958138otp.338.1582019182044; Tue, 18 Feb 2020 01:46:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582019182; cv=none; d=google.com; s=arc-20160816; b=q9Mgep90jJX3VXoAgQpe97WxAz7h3x96fyL0oCtrEZwsDyXzKqTV2Xf4DwChd5FxvE qgpHXGCB3wvwOXz2tgTFqmX3WZsvTVoJRSAc9SqobrfJ1I2D3dYzOmf53/3gm/pKUE07 u918mj2dH6jb9kxHKChEcIL+o7/NyyCJL7tSEyg9Dg1SfwNpyRGEKPrPNuAAuuR3On5I bD5FO/XboKBYYhTIfipx+Op8Wq9k84tA5Nb+Z6rm7xnObho34aZV4p1iTxK80nJkLiTa YZGWhBn4VFmXt8DiahiCNFaLMDSrsgW8b5KgXVWm53OskN2NHRXqAhEbMUdEczYEFqYn /MEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=9XVsQps1/vECfqy4vvjUlJkB0Wdi1HRB2ynEm0uGvLU=; b=NeNg/3pYt9Umd8u4cScDTdCfXbMBwQIBEW/3UtqNn/n/8zWDH2oST8y21QA2azBbLp 342FRe6uD03PQkQYskJ4FDvoxIhVf0XNjhLjw9nBFHZaiFszmwbtQWcyxW1LXd+HRgW6 1J0KP+IX4qtplP7RTGzO2FfAARX54xN/UC1mP4cS9eFNf5u/e+4GCP/kDCzvga+WwMO5 caqCdS8NoaLoHnowfTxwtjZEV5rlG4I95xt0pdPxM2LddvN1WBN9lEtf1Ba4DsNL0QBR eSrL+o2RLMSMmoOqXJAR7mtc84N90MBZ+ntm10/QSfIzXeiwPWIjQFHT30CGO+JaTsoF /S/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=wCt6Xy7h; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 107si1508745oth.14.2020.02.18.01.46.08; Tue, 18 Feb 2020 01:46:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=wCt6Xy7h; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726548AbgBRJpE (ORCPT + 99 others); Tue, 18 Feb 2020 04:45:04 -0500 Received: from mail-qk1-f193.google.com ([209.85.222.193]:37547 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726383AbgBRJpE (ORCPT ); Tue, 18 Feb 2020 04:45:04 -0500 Received: by mail-qk1-f193.google.com with SMTP id c188so18876581qkg.4 for ; Tue, 18 Feb 2020 01:45:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=9XVsQps1/vECfqy4vvjUlJkB0Wdi1HRB2ynEm0uGvLU=; b=wCt6Xy7h7SLxMTWAHkvasgiQNxbFwovHBFNKQFIKvB2x+m3gdr49sdpintVS6KM6Tz spDJfjHnmeq1y0mZ2osVbQUwL/iipt7Xbb6Q9g8e70iWgEewAnTkOTtxBbL/AngrNVBp 2fkDuTN+f7hCMQswtvGn4/rpUU5M3LzfNPwuLAPTyevugM8tc61RL3Xlvhwb0GVWkwhu CaEpiGguPy3Sfc9/PzMLxYHikY8U4t3lxf8dV2vCNHKOmty1orsnat70eEdafafMWTCa z6p/+kyK+5VD9EwEwWUG6KAdugsep1U9qM6SMEvAoRZoff4Y3vWqBkuziQ+QmXpk++XL taRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=9XVsQps1/vECfqy4vvjUlJkB0Wdi1HRB2ynEm0uGvLU=; b=LhIY7P+eQ0YnUZiqrJfzdS+U9/bOLEDfN5b7s4i9pOuZIPeL/ZILayM80mn01ZsGsS +3uWv4jPlzOXaaIdXASYAZWAGOVR5PH+hsbNZ6tN1HZeazLeDP3kz7wFcXADvpU8Alx1 v1VcHwe9sYyZCd9pNpdN0Dt0fFVcMO9WfdUNvjzgwMGT0obhzWm3+/v3kY4QD8x99qbF Cu4OfNZdhkX9BsQFen7g7w5uWKm2ZSoW0RsFoYwvZD9uVXeLHn7tCsViSZdnvXfFwWzH 3DeW9+9LzQridH6XncjBl0QwGg5wVShij0J14xMr9JjX+dFTQgMXyNB+BHdJJctHNE1b WNNQ== X-Gm-Message-State: APjAAAXjk19nmoZsFZMG8dcUmcpw2HMXbROabz6CNGYjd4Nmkmk+U9Zl EomRWHWMeAAXfQQOOvHpyxGoXjTxjref+SPiC8bOvg== X-Received: by 2002:a37:8343:: with SMTP id f64mr17248561qkd.21.1582019102971; Tue, 18 Feb 2020 01:45:02 -0800 (PST) MIME-Version: 1.0 References: <20200217195435.9309-1-brgl@bgdev.pl> <20200217195435.9309-3-brgl@bgdev.pl> In-Reply-To: From: Bartosz Golaszewski Date: Tue, 18 Feb 2020 10:44:52 +0100 Message-ID: Subject: Re: [PATCH 2/6] nvmem: fix memory leak in error path To: Srinivas Kandagatla Cc: Bartosz Golaszewski , Linus Walleij , Khouloud Touil , linux-gpio , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org wt., 18 lut 2020 o 10:42 Srinivas Kandagatla napisa=C5=82(a): > > > > On 17/02/2020 19:54, Bartosz Golaszewski wrote: > > From: Bartosz Golaszewski > > > > We need to remove the ida mapping when returning from nvmem_register() > > with an error. > > > > Signed-off-by: Bartosz Golaszewski > Was too quick in my last reply.. > > > --- > > drivers/nvmem/core.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c > > index ef326f243f36..b0be03d5f240 100644 > > --- a/drivers/nvmem/core.c > > +++ b/drivers/nvmem/core.c > > @@ -353,7 +353,7 @@ struct nvmem_device *nvmem_register(const struct nv= mem_config *config) > > nvmem->wp_gpio =3D gpiod_get_optional(config->dev, "wp", > > GPIOD_OUT_HIGH); > > if (IS_ERR(nvmem->wp_gpio)) > > - return ERR_CAST(nvmem->wp_gpio); > > + goto err_ida_remove; > > Looks like this is adding nvmem leak here. > May be something like this should help: > > > if (IS_ERR(nvmem->wp_gpio)) { > rval =3D ERR_CAST(nvmem->wp_gpio); > ida_simple_remove(&nvmem_ida, nvmem->id); > kfree(nvmem); > return rval; > > } > Srinivas, I just sent a v2 of this series that addresses it as well. Please don't apply v1 yet. Bartosz