Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3462543pxp; Tue, 8 Mar 2022 15:06:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJxEQJ0j5YaBqhFZ0+e56Ldg2a39gVS389C3/tGvaLHo7Qdl15VPmbFWE7Kz5YGfNMgFzy/4 X-Received: by 2002:a05:6a00:1d1f:b0:4f7:4605:8f44 with SMTP id a31-20020a056a001d1f00b004f746058f44mr1579283pfx.58.1646780818835; Tue, 08 Mar 2022 15:06:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646780818; cv=none; d=google.com; s=arc-20160816; b=DM9PUSDK+v7tzeWtgKVA1Psdm1f1Dnj1Nn4Uy9JFoq0ek3FEqmdn/+rS1W+5vdwCa9 Op/9jMDDQWrW8cLtj05SzYgtYq8itB2x8Qg/ZkDjgOl/Zs3vDqPPZh/cdmep4l3Vilo5 y6MyXB3rCfGdgBDuoESI9hc8fLKaVhW0Nnn14+fXz2dI8+anJg5ywMvFQEzozkGjn1c6 E0gkzhazmE3nL7xikbSohV4vBIQF07NsyMV7hweOXwmE5f0ZCh3d+g+iNPAqfioR999a WFaJmLWz9Ay54IojBjuUI8yICdPPoRHR+tB4laswmSZLFUm69QR7Pj3hSFiEF3qosh8o z+Yw== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=K+9YbZ3uM6Q6zgv/k/bMfdKp+7HUTNYyg/a5cYiOx0I=; b=zmWeH/zh7gr06wSuSURwx4kfEkA6zLhXHjivWBbv+Bq9PGqBgP+54MPqT+hDdADPXK HghpoPRsPqDk1alQy8Z+Ot1GvYvtKSe4/z14va8Wk7hMOaeXb6LUev2FYTOH+GjuIWU8 Sw3cZsuskyH3tBdrjXZMahWys2RMnj5T+vXsL+fjv6DN07hCeIXWdNjfnbfk4u+eFxNb +I/CSUaZMBM5qpf06taSm9lAHzD8me/uXFT7xA2Lqn1QhGkQ7jUR4LEDbbDujglo+H4W 1+sJj6zo+iQOuknDyPCN8lxKWUYg4Rei35kwRgj1kZ5qkYSnIfAnB1PPNkEGUGuTpiGN DPFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CQnyZ6uK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id h8-20020a17090a2ec800b001bedf1f3526si289675pjs.146.2022.03.08.15.06.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 15:06:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CQnyZ6uK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6019364BEC; Tue, 8 Mar 2022 15:05:48 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244100AbiCGQUv (ORCPT + 99 others); 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 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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