lkml.org 
[lkml]   [2022]   [Mar]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH v2 1/1] device property: Allow error pointer to be passed to fwnode APIs
Date


> -----Original Message-----
> From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Sent: Friday, March 4, 2022 6:33 PM
> To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>; Rafael J.
> Wysocki <rafael.j.wysocki@intel.com>; linux-acpi@vger.kernel.org;
> linux-kernel@vger.kernel.org
> Cc: Daniel Scally <djrscally@gmail.com>; Heikki Krogerus
> <heikki.krogerus@linux.intel.com>; Sakari Ailus
> <sakari.ailus@linux.intel.com>; Greg Kroah-Hartman
> <gregkh@linuxfoundation.org>; Rafael J. Wysocki
> <rafael@kernel.org>; Len Brown <lenb@kernel.org>; Sa, Nuno
> <Nuno.Sa@analog.com>
> Subject: [PATCH v2 1/1] device property: Allow error pointer to be
> passed to fwnode APIs
>
> [External]
>
> 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.
>
> Fixes: 83b34afb6b79 ("device property: Introduce
> fwnode_find_reference()")
> Reported-by: Nuno Sá <nuno.sa@analog.com>
> Signed-off-by: Andy Shevchenko
> <andriy.shevchenko@linux.intel.com>
> ---
>
> 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... If it is, go ahead:

Tested-by: Nuno Sá <nuno.sa@analog.com>

- Nuno Sá

\
 
 \ /
  Last update: 2022-03-07 17:16    [W:2.271 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site