Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp873636rdg; Fri, 11 Aug 2023 02:37:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE6Zz7oOd6QuGxru4d0yDOgsYRQZWo+DG6eYu36Ixn28SoGJkVYHrfTXDyTc1brfq9h1/gi X-Received: by 2002:a05:6358:528d:b0:133:a8e:6feb with SMTP id g13-20020a056358528d00b001330a8e6febmr1768468rwa.12.1691746677908; Fri, 11 Aug 2023 02:37:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691746677; cv=none; d=google.com; s=arc-20160816; b=h7KoyAZN0PW469O1k1IYmIliSwWbM3Lulz32WJth4Zq3OTf+PRbzb4tgPHaf/BMXcp OQOoWH2g3aBLcQxFaR9CsLXxI+ttV0p2tDovZWKjBW9zl5tR7+KYbLr3RDg3E59WMCPm 1f5N72pdf3913vzI75CzYfazhUVNT4uPNPtjv6tm+rvvzheMeXz8DW+aOr2e0/YBFYfZ R57DFzSZfCk2DLUG28cc9fSJ1NtQOWGDiGN/kzRFe4F+wu6+v7YihY42i+p3bXe2guFv IO/xyCwvim08a+s41iRGOJj8fMbLE+JdJm8gkvxG+PQU49r18jjT9U4i91MvHkkohywo Ib5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=1BbjUNiJqH5TguOVnvRu2q787m7KK44MW6CXrZz6MG0=; fh=9m2Mz+OQzxvXN44kyyfWCmHAxgHUIm5EhV2n4Z7VrQA=; b=i1B8Xyqn7Hcq2v3WnSL2FRe/ZrYCwNsPKAyvURiLg25VjCbUqx6roE4h8yPrQcl2LP zN/s6Ofel4cGkn8baJFLv6kzCyA/xsFxTBmP/IaJbzTEzaYIaLh4SpnvoCscOffUz+NB 3hRnaDDWC10sq8gP5PSmfde0JVmu/CeI2v651a/988+DnXGktD/QsZJ9ePlIjfNUTzeh VHGWxEjg1Xb5RPyjKeYn5LG5w4CMJj1B0LNAnNGA9+4YqtF6j9ACKEIfPV/PX2CQJbSN 0Sv/mxKWTNwuknAvhm7t64yYnEg+2ZPDRdsnwLK2FNmpTUzmg/+K97fFmGPjIc12vDdf TdfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JA+6wIeD; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a6-20020a63cd46000000b0056532a14f54si3103951pgj.900.2023.08.11.02.37.45; Fri, 11 Aug 2023 02:37:57 -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=@intel.com header.s=Intel header.b=JA+6wIeD; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234718AbjHKJMc (ORCPT + 99 others); Fri, 11 Aug 2023 05:12:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233523AbjHKJMa (ORCPT ); Fri, 11 Aug 2023 05:12:30 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A11FD2D5B; Fri, 11 Aug 2023 02:12:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691745150; x=1723281150; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=Ex4QtUXpfocvEJRdcIdHuspw5Gn/nTjI+tF9OQh7QV8=; b=JA+6wIeDGRgq0mgf/KC/BBBde2qA+OhakTZvPZByj3GabRqYbQZwA6NZ 7iEq4zBxVNzdSA0SULAJwSnBgMJ7E3g0CrANTDgmR4qY7PoRxbn/px9Zl e666vFZYgDZlMC2jaFnwPA/eNtmJYo6as6yFz7Lup3OZ9vK6wk0kM3D/b uMXDwCE2NQYi/+sN0j12EF36BrVrVqvekS/W+AfhHQp6dQJwVc0jqC0ec 4floQ0ptL8Z4CpZr9wzW69Ll/tmeZUIdpu7W9WHGDzI5RvfFMLlF8F8+A C81M7Tr7fhcBgAGZF/i93YA2N0iQ5FAbRcU3VHx34p5bsFcJq68o7Xuth A==; X-IronPort-AV: E=McAfee;i="6600,9927,10798"; a="369106085" X-IronPort-AV: E=Sophos;i="6.01,165,1684825200"; d="scan'208";a="369106085" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2023 02:12:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10798"; a="802601740" X-IronPort-AV: E=Sophos;i="6.01,165,1684825200"; d="scan'208";a="802601740" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga004.fm.intel.com with ESMTP; 11 Aug 2023 02:12:28 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1qUOC2-007zmN-2p; Fri, 11 Aug 2023 12:12:26 +0300 Date: Fri, 11 Aug 2023 12:12:26 +0300 From: Andy Shevchenko To: Bartosz Golaszewski Cc: Linus Walleij , Kent Gibson , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: Re: [PATCH v2] gpiolib: fix reference leaks when removing GPIO chips still in use Message-ID: References: <20230810184846.22144-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230810184846.22144-1-brgl@bgdev.pl> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,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 On Thu, Aug 10, 2023 at 08:48:46PM +0200, Bartosz Golaszewski wrote: > From: Bartosz Golaszewski > > After we remove a GPIO chip that still has some requested descriptors, > gpiod_free_commit() will fail and we will never put the references to the > GPIO device and the owning module in gpiod_free(). > > Rework this function to: > - not warn on desc == NULL as this is a use-case on which most free > functions silently return > - put the references to desc->gdev and desc->gdev->owner unconditionally > so that the release callback actually gets called when the remaining > references are dropped by external GPIO users ... > + /* > + * We must not use VALIDATE_DESC_VOID() as the underlying gdev->chip > + * may already be NULL but we still want to put the references. > + */ Clear now! ... > + if (!gpiod_free_commit(desc)) > WARN_ON(extra_checks); /* Always call gpiod_free_commit() */ WARN_ON(!gpiod_free_commit(desc) && extra_checks); ? -- With Best Regards, Andy Shevchenko