Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp449930ybv; Wed, 19 Feb 2020 02:55:30 -0800 (PST) X-Google-Smtp-Source: APXvYqytbZ4cdAz2mndiE0V6VUlwC0tLx5kt/rHPerZp9Reey09fXTgcCPdb+X4JOyPv/Cmmei2E X-Received: by 2002:aca:4f4c:: with SMTP id d73mr4287819oib.107.1582109730747; Wed, 19 Feb 2020 02:55:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582109730; cv=none; d=google.com; s=arc-20160816; b=tosT1gERvtpTUdTJ3X5ixafEU1bitciNhYtPFmz4n2Dvdw09+r51BYU66abMNzdDcz V0DYhyTLVbqiTcU6obfKhHX+sIfIfQ7UPCvQLz8jufuCT5nYVBO45wjqZjpnhYDJBqkK k6M5Is3WLciqu9qpv8cxwwAiKy+mtpHUWOUcQxxmVdsJA/yXFO9p3YCn8XLYa00x5BcA tSQantmfN8WUHNGASDn4ggXCy0l4Fkiatp56a5Sm9nIpcvwzJP4Lt1itsbc52aPrNtE2 w9Eyy4yZrDPLN70MsprL8d+SEX61uxgS9r3TsEAnOugYSRpf8djia9JYJ7EdxN4jwU7K 5JPA== 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=BC5JBxhf1L5HFeMhJ5aFhi6TWfttWOnbJEt9bKPTIJY=; b=VIeQSq+jFo/ZUVRXJPiCJQFAzpwJcY+YW5sGEjkaRZHgOpfebG8Ioru/67GzcSjRyR t+Hzfnb9YJuMhEgk3KMpp3bfXXVYUBx7vG7SAcwzFT9eBBB4g21oWa7ynbiIxLAWRcME YKRNnqILvE8Hb8mun0rASTX/Zma7JGXuf+UI405njnNs4U82lLKi+MOkJGmU+QaQJjsr AcPX0OMMJfO9ZzUgAIuWpt2efg4h26a0d3KQ8Wd39YeNxxccsIyAimKTfl7xYRkyeLyO 67TVnqre4g8lFFHigC2H8xqp81+PsvE0k/9ipCfO1JmaaOFySi1Q6hXOwY6gTrzF1HKE tIWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=JNvMBzc+; 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 f28si955898otc.110.2020.02.19.02.55.18; Wed, 19 Feb 2020 02:55:30 -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=JNvMBzc+; 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 S1727184AbgBSKyH (ORCPT + 99 others); Wed, 19 Feb 2020 05:54:07 -0500 Received: from mail-qk1-f193.google.com ([209.85.222.193]:34955 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726469AbgBSKyF (ORCPT ); Wed, 19 Feb 2020 05:54:05 -0500 Received: by mail-qk1-f193.google.com with SMTP id v2so22587219qkj.2 for ; Wed, 19 Feb 2020 02:54:05 -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=BC5JBxhf1L5HFeMhJ5aFhi6TWfttWOnbJEt9bKPTIJY=; b=JNvMBzc+vlyBrHXzEGZKInLBhZLIMe9ePS7Kl50HX5bTTg61NpbrkQ38au/HO6YalS 4GUQv7RD4JbU/BGvQHaTm7AgZqFjoUkAcXKWgcOgbFmw3A72UKk+v5FURaJ+teqQvRxh qHCfnNj2MhUZE18oWRHKBWNQ5CC9Qtk5nsyzcVJ7Q7ohvx1lx2u58kpoq6SlE39hIfYf IlFMvgyDLu+oRLuwKdWFSsx0EkdAfwH8cuA00gdMVwmfg/5WricxnpOSX4kA2g3qzQxc KgS8KijqLWcfSw4kiBo5g9xt8p9m4mpzoFhA5uoqUb27Lec530Q83Vpepwws8qn984+h c4Tg== 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=BC5JBxhf1L5HFeMhJ5aFhi6TWfttWOnbJEt9bKPTIJY=; b=IGwqXCAKCx2981n6+C8sniL5YwFFgdRKCTR7fDpQw6XwuzEHTMHpD932npjmB9+ENg ee1bsac7T7LW8R5RnrCEbrXQ8gvI1UKofdorbqeV+nwoEpkfj+csXK2GwJ1phvPQdtFO nBWxwS3K4/Zpa3bmDgyGgKBN1uRpCBjjFp5up6Jhdh9IiZaJwKDh+60W9xHUfmCaclv+ yZOBIfIkzPzms+MyBceuOUCwJIoQfvb9UVogdiEs4w+S41NHy2HHIZfUN6Vz9HH6wwe3 kuZSuygICAsseil4dyUlZOKqk1kt/gHOwVpszgCNGh60hjrcf1xqEx/579/1RfEeQmxM bEVg== X-Gm-Message-State: APjAAAWaI0GnAvWw2vYfAJO8F9Bz1vZ8ME5R/jQ3imrQxRY4NqUAAyIJ Z5iQWicBj2/6ZNJ3nj2ujSN4flgGt4JWrXAT0pKKyw== X-Received: by 2002:a37:a488:: with SMTP id n130mr22380303qke.120.1582109644632; Wed, 19 Feb 2020 02:54:04 -0800 (PST) MIME-Version: 1.0 References: <20200219092218.18143-1-brgl@bgdev.pl> <20200219092218.18143-2-brgl@bgdev.pl> In-Reply-To: From: Bartosz Golaszewski Date: Wed, 19 Feb 2020 11:53:53 +0100 Message-ID: Subject: Re: [PATCH v3 1/7] nvmem: fix memory leak in error path To: Srinivas Kandagatla Cc: Bartosz Golaszewski , Linus Walleij , Khouloud Touil , Geert Uytterhoeven , 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 =C5=9Br., 19 lut 2020 o 11:52 Srinivas Kandagatla napisa=C5=82(a): > > > > On 19/02/2020 09:22, Bartosz Golaszewski wrote: > > From: Bartosz Golaszewski > > > > We need to free the ida mapping and nvmem struct if the write-protect > > GPIO lookup fails. > > > > Fixes: 2a127da461a9 ("nvmem: add support for the write-protect pin") > > Signed-off-by: Bartosz Golaszewski > > --- > > drivers/nvmem/core.c | 7 +++++-- > > 1 file changed, 5 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c > > index ef326f243f36..89974e40d250 100644 > > --- a/drivers/nvmem/core.c > > +++ b/drivers/nvmem/core.c > > @@ -352,8 +352,11 @@ struct nvmem_device *nvmem_register(const struct n= vmem_config *config) > > else > > 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); > > + if (IS_ERR(nvmem->wp_gpio)) { > > + ida_simple_remove(&nvmem_ida, nvmem->id); > > + kfree(nvmem); > > + return ERR_PTR(rval); > > Why are you returning rval here? > This points return value of ida_simple_get and not the actual error code > from wp_gpio. > Duh! Thanks for catching this. Bart