From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C1EF9C5479D for ; Thu, 5 Jan 2023 18:59:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RLFQn45lNmf774toyzGAjt0quxiNUjtmOijQeovMHsg=; b=NXMIiQQnrHaC+q bf+VfIw2Ci+I6Lt6jR69X6dYS6VQ7knPWG8efmEyBI1axXaIYFaRXo5HgKaCGI2TtEZJGGJ6Tmj4u wCGe6dQnJkjgzOytpr1o/TP/jC86TxGivCSoLgYJDZG4I3RC+gGK6EjDwtmg5ks2q4/THpwH6BSmh 3Aixrg1nxo/G1FcsyIxQx1lBTTdwziiX63B5wozmGU2Uwiecdp/JfpctSMeCx2xNP2DJQ37DDHa/d ClUoixYl2p36X78wxDP1acldFVBuePT/MblkO9589E2q8mFU/9NqnkAyjiK+O8e8W67AZo4YmEx1a t9lsoIo1DwW+7MJmg1aQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pDVRw-00DuIW-18; Thu, 05 Jan 2023 18:58:48 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pDHnh-002LrQ-BF for linux-arm-kernel@lists.infradead.org; Thu, 05 Jan 2023 04:24:22 +0000 Received: by mail-wm1-x333.google.com with SMTP id k22-20020a05600c1c9600b003d1ee3a6289so443379wms.2 for ; Wed, 04 Jan 2023 20:24:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Hgd9Ot6naxiaI/TtbDtOJPnlzZys03z2yUHXxx+Dnb0=; b=ObY5FTqW2prSFPyKFqlize7AVcm/v6aYJ6P99m4vbqs13efQWqvZ/GKp/fqoJ/KHlJ VbBTglI8x8PsnRt62wzmwMXjqY2Qrw8s6BPFxWhhlDRQRozQRQwmVPNoPPIkP0Lm0qpQ 6bLc7bBkUE7PeK9s7Pvz7Z8IAiy8oJwtEWPmdzuZAyTlGs/wVEmypSoieFSU94nrgIjE vVIEjZMqREs3uqnppbGhcm6s62XXXB4j3Pey/C5MENfRdy5G2323GdsHomaedbXDUv5n PKhVmoVlexkT1hc2SRRUOh07z9PnfW/vTkObYEmR4/ee/PG5O7eeqqAEKq1PcCj+6Bnz L/tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Hgd9Ot6naxiaI/TtbDtOJPnlzZys03z2yUHXxx+Dnb0=; b=hBi3sgWHjdy6FcNZShyHLq66LDBf2UxFx+qWSTkz9ZFH3/R83UkvgM+nVvBQBoe1xN AMg8GIa/+FEcqf3qRPcI0h1PIOHKbhvc0tmBS0pFAazr2bVJzFGTSi5UyPOF20G6jS5N WpFxZNwCsSr72Wub/dEaqyzQIqHRnvfMzThgDQdjaK2jGw3gzSrbNcOLHINAKacGoggl GyW1W/Dj9LaqmyrLUx/fE18m0DU0lgw7roM4aRwW5y2z3F7hbBNDynCUhqSONKslrmsP azL6D8mNXrPSVA8KvTCY5jsCGq4q47eCHh/0xqslwzbf2aqhw2MmMGyT/AMGmkZ9swQV x0dg== X-Gm-Message-State: AFqh2kp0mdCGgoKdmhy3OlbBu6p9cFV+QemePE4Nmo/0DyI5eLrotly6 C5av5GvP0vsU90j91nsxIsc= X-Google-Smtp-Source: AMrXdXuW/TANs9lnwR4p6FhzeCdpUe+QOQS7LpdKe9YXFcokWPsU0TMBtkks5sJXAHa2Y3jlcyUYPQ== X-Received: by 2002:a7b:c3d2:0:b0:3c6:e62e:2e72 with SMTP id t18-20020a7bc3d2000000b003c6e62e2e72mr35892543wmj.13.1672892657443; Wed, 04 Jan 2023 20:24:17 -0800 (PST) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id f19-20020a05600c155300b003d98a7aa12csm958404wmg.16.2023.01.04.20.24.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 20:24:16 -0800 (PST) Date: Thu, 5 Jan 2023 07:23:51 +0300 From: Dan Carpenter To: "Russell King (Oracle)" Cc: Srinivas Kandagatla , Bartosz Golaszewski , Gaosheng Cui , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Maxime Ripard , Hector Martin , lkp@intel.com Subject: Re: [PATCH v3 4/5] nvmem: core: fix cleanup after dev_set_name() Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230104_202421_448430_5371977A X-CRM114-Status: GOOD ( 22.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Jan 03, 2023 at 04:59:32PM +0000, Russell King (Oracle) wrote: > If dev_set_name() fails, we leak nvmem->wp_gpio as the cleanup does not > put this. While a minimal fix for this would be to add the gpiod_put() > call, we can do better if we split device_register(), and use the > tested nvmem_release() cleanup code by initialising the device early, > and putting the device. > > This results in a slightly larger fix, but results in clear code. > > Note: this patch depends on "nvmem: core: initialise nvmem->id early" > and "nvmem: core: remove nvmem_config wp_gpio". > > Fixes: 5544e90c8126 ("nvmem: core: add error handling for dev_set_name") > Signed-off-by: Russell King (Oracle) > --- > drivers/nvmem/core.c | 26 +++++++++++--------------- > 1 file changed, 11 insertions(+), 15 deletions(-) > > diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c > index 843e2f5696e6..19497f555e07 100644 > --- a/drivers/nvmem/core.c > +++ b/drivers/nvmem/core.c > @@ -772,15 +772,17 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) > > nvmem->id = rval; > > + nvmem->dev.type = &nvmem_provider_type; > + nvmem->dev.bus = &nvmem_bus_type; > + nvmem->dev.parent = config->dev; > + > + device_initialize(&nvmem->dev); > + > if (!config->ignore_wp) > nvmem->wp_gpio = gpiod_get_optional(config->dev, "wp", > GPIOD_OUT_HIGH); > - if (IS_ERR(nvmem->wp_gpio)) { > - ida_free(&nvmem_ida, nvmem->id); > - rval = PTR_ERR(nvmem->wp_gpio); > - kfree(nvmem); > - return ERR_PTR(rval); > - } > + if (IS_ERR(nvmem->wp_gpio)) > + goto err_put_device; > Missing error code. It still needs the rval = PTR_ERR(nvmem->wp_gpio); If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot | Reported-by: Dan Carpenter regards, dan carpenter _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel