Re: [PATCH v2] thermal: Fail object registration if thermal class is not registered

From: Greg KH
Date: Tue Jan 24 2023 - 12:05:09 EST


On Mon, Jan 23, 2023 at 09:44:03PM +0100, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
>
> If thermal_class is not registered with the driver core, there is no way
> to expose the interfaces used by the thermal control framework, so
> prevent thermal zones and cooling devices from being registered in
> that case by returning an error from object registration functions.
>
> For this purpose, use a thermal_class pointer that will be NULL if the
> class is not registered. To avoid wasting memory in that case, allocate
> the thermal class object dynamically and if it fails to register, free
> it and clear the thermal_class pointer to NULL.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
> ---
>
> -> v2: This replaces the series at
> https://lore.kernel.org/linux-pm/5905717.lOV4Wx5bFT@kreacher/

Reviewed-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>