lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <PH0PR03MB67863963179FBA901E649C7599089@PH0PR03MB6786.namprd03.prod.outlook.com>
Date:   Mon, 7 Mar 2022 16:15:23 +0000
From:   "Sa, Nuno" <Nuno.Sa@...log.com>
To:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        "Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
        "linux-acpi@...r.kernel.org" <linux-acpi@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC:     Daniel Scally <djrscally@...il.com>,
        Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
        Sakari Ailus <sakari.ailus@...ux.intel.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "Rafael J. Wysocki" <rafael@...nel.org>,
        Len Brown <lenb@...nel.org>
Subject: RE: [PATCH v2 1/1] device property: Allow error pointer to be passed
 to fwnode APIs



> -----Original Message-----
> From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> Sent: Friday, March 4, 2022 6:33 PM
> To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>; Rafael J.
> Wysocki <rafael.j.wysocki@...el.com>; linux-acpi@...r.kernel.org;
> linux-kernel@...r.kernel.org
> Cc: Daniel Scally <djrscally@...il.com>; Heikki Krogerus
> <heikki.krogerus@...ux.intel.com>; Sakari Ailus
> <sakari.ailus@...ux.intel.com>; Greg Kroah-Hartman
> <gregkh@...uxfoundation.org>; Rafael J. Wysocki
> <rafael@...nel.org>; Len Brown <lenb@...nel.org>; Sa, Nuno
> <Nuno.Sa@...log.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@...log.com>
> Signed-off-by: Andy Shevchenko
> <andriy.shevchenko@...ux.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@...log.com>  

- Nuno Sá

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ