Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp1282914rwl; Thu, 10 Aug 2023 08:57:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHK19Icw5+KjXm/l+KJNg2S0SE/2gwp/Urf/ZBZY7iZh0rljDXmoVSYnhQV3gk/AHZ7dhY7 X-Received: by 2002:a05:6a20:96c4:b0:13f:a69c:53af with SMTP id hq4-20020a056a2096c400b0013fa69c53afmr3007265pzc.61.1691683078817; Thu, 10 Aug 2023 08:57:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691683078; cv=none; d=google.com; s=arc-20160816; b=JBDqH2gcZgvzzTuAdv2fyyn5g1uOQGMAbOtPWf5x8yZNtkS4Tx/y28hMULZjOAhY+s V1DJ/cLcJiJcUO2ctjJsW56+hZbIHvSNkztBhsQGGnuR3qCb7NSeqdehyMv1Ju6gBVR/ DhoP0heQlhjWg5kayI7FM24Pyka4jSNdvNUJyD/zFqVz/7H7LCHbA7FW5h1k3B1KjaeT Py6ZbE+GOJELiFDd6FuQQ+o22d6yjPd9SahyBkXH+bjLUDoJEpMrMhIyQXo34Zl57ooS P4/Iai3FI8KKjU9XVIawYpKNFnK+jOH8O40D+PdKKuyN6AQv19UnzEURhjjZGztsFdg+ G0gg== 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=+lJIF2LPjKxw9xGeKKAZpUjStxNbZh8gJtnxH7/OdJ8=; fh=9m2Mz+OQzxvXN44kyyfWCmHAxgHUIm5EhV2n4Z7VrQA=; b=gz6wwFua/Fvr8Bl6Y7abHD/NIRYXwqO5Ql/KWbriNYGXZvtfGrKxIgEtDqwzyxu7qF mhFLCXX3H4YcqATWuo5PEMSrgqM2b6HslUM0Lo99Hp+ZM/TJZ+NabhSM+/Afpb3oUKCx b1lR9RCk9kQTNmUnlV51mUQz3F/2Hw/v0HGnH5Oi+ST6Vs9h+uHOisFSUBqAZv8GFDac K/y/y9jd7IgblZX/Jf4+DQgVdIN/0GlMOk6UkmWth3H2PP5wvGcm2Gwu2WBCu3pm+tlc PCSMjrg3epI7ZVznmkGqIrXASaYXm7VOXkT6qEYHqCMb4hVVLlCwcVlW7KmItsk5kJ7M evTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eG74oiJL; 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 m1-20020a656a01000000b005655bf61e2fsi1204114pgu.27.2023.08.10.08.57.46; Thu, 10 Aug 2023 08:57:58 -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=eG74oiJL; 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 S235415AbjHJPTY (ORCPT + 99 others); Thu, 10 Aug 2023 11:19:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231195AbjHJPTW (ORCPT ); Thu, 10 Aug 2023 11:19:22 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CF2226B5; Thu, 10 Aug 2023 08:19:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691680762; x=1723216762; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=x6k1erl4t9tWXDGkDpu6EtDpKNzUku2CvqW/FmS6BLI=; b=eG74oiJLBWk9HFhPxFIiptg5V4C90mKwAs/+4jG9P35rWEw46Il4JlJ4 6YhNw5xLmNxLMW9HgWQC3K/o/ooFGgZaU8263VjlQZWocnehp8GvvXY6G rr1p7GVvdLJg4ef50zSNV8tSleYUza90b6pnaUjtP0WoeDBio9+KODfBE uoit6wTBELaaO91OcKuRdlXivQ/RMELwZFXYgYNMSwJ0+3cC4mv+tobC2 7jk/0jytpLM4HM+VS6LlsmtLeg7STdyHflgD15/1k6GOqND0bYl78Ff5R QV2fJ0oA7A+Wj6SCdHUgyQzoJg9w9LXW+tevErXlGRmsiu8F5q7nPB3HC Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10798"; a="437775476" X-IronPort-AV: E=Sophos;i="6.01,162,1684825200"; d="scan'208";a="437775476" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Aug 2023 08:19:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10798"; a="906102440" X-IronPort-AV: E=Sophos;i="6.01,162,1684825200"; d="scan'208";a="906102440" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga005.jf.intel.com with ESMTP; 10 Aug 2023 08:19:19 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1qU7RV-006Ysq-2m; Thu, 10 Aug 2023 18:19:17 +0300 Date: Thu, 10 Aug 2023 18:19:17 +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] gpiolib: fix reference leaks when removing GPIO chips still in use Message-ID: References: <20230810100335.9330-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 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 06:17:26PM +0300, Andy Shevchenko wrote: > On Thu, Aug 10, 2023 at 12:03:34PM +0200, Bartosz Golaszewski wrote: > > From: Bartosz Golaszewski ... > > void gpiod_free(struct gpio_desc *desc) > > { > > - if (desc && desc->gdev && gpiod_free_commit(desc)) { > > - module_put(desc->gdev->owner); > > - gpio_device_put(desc->gdev); > > - } else { > > + if (!desc) > > + return; > VALIDATE_DESC_VOID() ? If it is not possible to use, the comment should be added, like we have in gpiod_to_irq(). > > + if (!gpiod_free_commit(desc)) > > WARN_ON(extra_checks); > > - } > > + > > + gpio_device_put(desc->gdev); > > + module_put(desc->gdev->owner); > > } -- With Best Regards, Andy Shevchenko