From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.7 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796299938; b=2VLHJCkQhlqATAC5vm6xSm/Yq84/fgoOMZRymVt0ucRyvycwJ0wJW3gqkXfNSYjzyS0s B+lkU3SQBA47HtmWK9rK8t2q6z/ga9engjSzHtRy2d0PM513qnUStmB7GehkrIkdyqKZH qTrklowZdxuKIqe7gc+zBh+og2F5V1zesip7KCBQiGKoBKZM1lcPGAIwFBpaJ3YdrujNh rohH1L1TD+92NeCRl4yhqa97SdzAu/qiXSKdZP0dvQM2oEonsPI01EWFGM77XHkUY6H65 0da7367ItXja36BDcZnHtpt84Gx1SfMTOG9EWwc9dM6gVa5AK79wLrC0nTa+BybW9WQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796299938; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To:Organization; bh=Yz64wNd9211T22zSgzRqMxZtZyML1NnfAcQc1d8J6w8=; b=D7LQfYVgKDjMGdWXULCTBfe2+u3GgIAX5/qxBZALe3vwn6YyQ+hhnC1zFyANdJ9BgtDb 5vk/Lgxsvlx59yJR78PIBHxCuENlrdwqkj+TjyNKAlP+VhinyM8Q5LsRXVzD8uxuNYYKr OLYKZJpT/UNwNh0X+7iZCuJFWjOyU9fqKsFWWZZgnDFzQtX0mJjFNhFzPuWdf7fjfRDpm LH+7/1zf1tGnrVcw01W7JOYpPHG3L/3NM4AhQcBhEwsC5CwWZZQkMNRZXpKV9m/12doOp bpc76GNfDBLSejP6gFcNtBzxicUEd+YiVk9FZRQNf4vOuVshj9MLevHLgsLf6+4ZO1Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=QSPPlaAi; arc=none smtp.remote-ip=192.198.163.7 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B3258606A6BA; Thu, 3 Dec 2026 12:12:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B3258606A6BA Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=QSPPlaAi DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796299938; x=1827835938; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=Yz64wNd9211T22zSgzRqMxZtZyML1NnfAcQc1d8J6w8=; b=QSPPlaAiMLyrfSdEyiRSlj63hfmicYAFrj8A0rwHBAkDwq5MALqcDS7w +4wBKEFTWjo8LjhG4ppxNZC0+KfJT/lQCHyWHOoDN3lug7ZTlYizQAW/v VcDvgF483obF9hvHW590ANFaV0GZMJ9E8eKu2np6ieaZIngB+G9yp0wjn kTpQO6iVl8rvF1Y4pWDiTjezaszSB2hesK5rXE3yrGShKPpxH3GipOWtE QyXfumsnP0Dv4I4xGuuiImv0J0uc1irQnNC2+pIO73xLwSjD4pp4qTqqq AeY6T32Fv8zFjJ3R+atrghh452Rpj7mt4yxhxPJShIU+/bam/qShhyQJQ Q==; X-CSE-ConnectionGUID: d0BboAv9Q8SfAWXMu0zuvA== X-CSE-MsgGUID: votc8uVxT06X//rrgAksPQ== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5107306" X-IronPort-AV: E=Sophos;i="6.27,248,1787036400"; d="scan'208";a="5107306" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 04:12:02 -0800 X-CSE-ConnectionGUID: XOxfBP6nTsGfzdesPwHR4w== X-CSE-MsgGUID: 8gHB8TI6TSGVkNR5MHMuGQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,248,1787036400"; d="scan'208";a="14189812" Received: from inaky-mobl1.amr.corp.intel.com (HELO localhost) ([10.245.244.115]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 04:11:59 -0800 Date: Thu, 3 Dec 2026 14:11:56 +0200 From: Andy Shevchenko To: Dmitry Torokhov Cc: Linus Walleij , Bartosz Golaszewski , Benson Leung , Guenter Roeck , Stephen Boyd , patches@opensource.cirrus.com, linux-gpio@vger.kernel.org, chrome-platform@lists.linux.dev, stable@vger.kernel.org Subject: Re: [PATCH 6/6] gpio: cros-ec: Fix firmware node reference count underflow Message-ID: References: <20261202-gpio-arizona-fwnode-fix-v1-0-3899179bf9d1@gmail.com> <20261202-gpio-arizona-fwnode-fix-v1-6-3899179bf9d1@gmail.com> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261202-gpio-arizona-fwnode-fix-v1-6-3899179bf9d1@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo On Wed, Dec 02, 2026 at 10:45:51PM -0800, Dmitry Torokhov wrote: > cros_ec_gpio_probe() attaches the underlying EC protocol device's > firmware node to the child platform device using device_set_node() > without taking a reference. On teardown, platform_device_release() drops > a firmware node reference and removes any attached software node, > underflowing the protocol device's reference count and prematurely > tearing down an attached software node. > > Take a reference with fwnode_handle_get() when attaching the protocol > device's firmware node if the platform device does not already have one, > and register cros_ec_gpio_put_fwnode() via devm_add_action_or_reset() > before devm_gpiochip_add_data() to clear the platform device's node and > drop the reference. Because devres runs in LIFO order, the GPIO chip and > acpi_gpiochip_remove() on the parent device finish before the node is > cleared, and device_del() unbinds the driver before > device_platform_notify_remove() and platform_device_release(). > > This preserves ACPI companion attachment for acpi_gpiochip_add(), which > inspects the parent device while cros-ec-dev does not propagate it, > while gpio_chip.fwnode is also assigned explicitly. ... > + ret = devm_add_action_or_reset(dev, cros_ec_gpio_put_fwnode, > + dev); Don't hesitate in such a case to use longer line. ret = devm_add_action_or_reset(dev, cros_ec_gpio_put_fwnode, dev); is only 2 characters longer than 80. It's allowed in order to improve readability. > + if (ret) > + return ret; -- With Best Regards, Andy Shevchenko