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 95C4CC54EAA for ; Tue, 24 Jan 2023 17:05:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233001AbjAXRFI (ORCPT ); Tue, 24 Jan 2023 12:05:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234013AbjAXREt (ORCPT ); Tue, 24 Jan 2023 12:04:49 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C479136; Tue, 24 Jan 2023 09:04:23 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CC989612D6; Tue, 24 Jan 2023 17:04:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DECA5C433EF; Tue, 24 Jan 2023 17:04:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1674579859; bh=0J2cfmGfNW3mNChq2vBr6v4VgWVucb97qK0+QdNVmOg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=I36VbeRP1nnnIhTw5hw3CQ9aCT7fXz56OY6ke9XwqQD2853eyM5+ShG5hWIX2uJBT sWgHrZOQnXBjUG/N0ky34rNfwBqq6XH+q9ZcwF13/u5H7hGlgu9oVWTtBU2wvSwXQ/ 78vTCLlrLaRyXK0fvYBQpD2Ye78kSbvi6cTOK+B8= Date: Tue, 24 Jan 2023 18:04:16 +0100 From: Greg KH To: "Rafael J. Wysocki" Cc: Linux PM , Daniel Lezcano , LKML , Srinivas Pandruvada , Zhang Rui Subject: Re: [PATCH v2] thermal: Fail object registration if thermal class is not registered Message-ID: References: <5660360.DvuYhMxLoT@kreacher> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5660360.DvuYhMxLoT@kreacher> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 23, 2023 at 09:44:03PM +0100, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > 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 > --- > > -> v2: This replaces the series at > https://lore.kernel.org/linux-pm/5905717.lOV4Wx5bFT@kreacher/ Reviewed-by: Greg Kroah-Hartman