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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 533EDC433F5 for ; Mon, 7 Mar 2022 16:19:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235239AbiCGQUv (ORCPT ); Mon, 7 Mar 2022 11:20:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239693AbiCGQUu (ORCPT ); Mon, 7 Mar 2022 11:20:50 -0500 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 309E24D9C4; Mon, 7 Mar 2022 08:19:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646669995; x=1678205995; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=nCdJ9kv9kF9+cM2VoJw0GpTu/gzqvrLvVOduS7j3Scc=; b=CQnyZ6uKeXx+2VdZoFPbzHVP6x4A19dlH6gtmodZooPLgDtxfy9Ef6tQ RrnG9bSiU4XxO88sHs1im9ZaciIN+bebuCbb0M7bOtq0++KfIZaOyDWJB ZIUIE+nmZeWtsjTPX6aRnP4LtBhI1zXMkLrK5OmZdmwL1NMSm7Xmulsz3 PYteMph+DQILcVMwmC7I4hz+aJvhQJC8FrUteYZAz0xOGkBbj+hav0P33 L+DPlCpQ7bWHy1gXcEUA9ufvBMZeVDRsRraZQzsOZCEoUZTB3l13Ag1TJ JivhwQBiVT5fjjweMIbIXfRKwPT11BiZnDYDcEOsxSlycGfEIC5fyr2h0 A==; X-IronPort-AV: E=McAfee;i="6200,9189,10279"; a="241865103" X-IronPort-AV: E=Sophos;i="5.90,162,1643702400"; d="scan'208";a="241865103" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2022 08:18:39 -0800 X-IronPort-AV: E=Sophos;i="5.90,162,1643702400"; d="scan'208";a="711162057" Received: from smile.fi.intel.com ([10.237.72.59]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2022 08:18:36 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.95) (envelope-from ) id 1nRG3T-00CrIo-NM; Mon, 07 Mar 2022 18:17:51 +0200 Date: Mon, 7 Mar 2022 18:17:51 +0200 From: Andy Shevchenko To: "Sa, Nuno" Cc: "Rafael J. Wysocki" , "linux-acpi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J. Wysocki" , Len Brown Subject: Re: [PATCH v2 1/1] device property: Allow error pointer to be passed to fwnode APIs Message-ID: References: <20220304173256.39059-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org On Mon, Mar 07, 2022 at 04:15:23PM +0000, Sa, Nuno wrote: > > From: Andy Shevchenko > > Sent: Friday, March 4, 2022 6:33 PM ... > > Some of the fwnode APIs might return an error pointer instead of > > NULL > > or valid fwnode handle. The result of such API call may be considered > > optional and hence the test for it is usually done in a form of > > > > fwnode = fwnode_find_reference(...); > > if (IS_ERR_OR_NULL(fwnode)) > > ...error handling... > > > > Nevertheless the resulting fwnode may have bumped reference count > > and > > hence caller of the above API is obliged to call fwnode_handle_put(). > > Since fwnode may be not valid either as NULL or error pointer the > > check > > has to be performed there. This approach uglifies the code and adds > > a point of making a mistake, i.e. forgetting about error point case. > > > > To prevent this allow error pointer to be passed to the fwnode APIs. ... > > v2: adjusted the entire fwnode API (Sakari) > > > > Nuno, can you test this with the ltc2983 series, including the > > IS_ERR_OR_NULL() > > fix to it? > > Hi Andy, > > Just tested this patch with the ltc2983 series and now > fwnode_handle_put() does not crash when fwnode is an > error pointer. I think this usecase does not cover all > of the patch so I'm not sure if a tested by tag here is > meaningful... I believe it still makes sense because we understand what you have tested. And at least it has some kind of BAT: - compile testing - testing (some of the) branches > If it is, go ahead: > > Tested-by: Nuno Sá Thank you! I'll send v3 because I want to amend the commit message. -- With Best Regards, Andy Shevchenko