Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp261878rdb; Thu, 22 Feb 2024 03:00:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU1onL/0q79miFkQb9wKMTo9KSX9q7nH85FmXUWX10aIys4hOHIEPxu5nPo3o3p+SXmDcK2/uKsygKgTasK0wf3OMPSaWTVoWRfBP6BGg== X-Google-Smtp-Source: AGHT+IG+WYiBbi4tZODQuPMuiBkxUCv/wdACjHtmL0rNoSfDZlxdOJOqpVo/yPhnCHhiFVZ7YwgY X-Received: by 2002:a9d:6d85:0:b0:6e4:755e:617c with SMTP id x5-20020a9d6d85000000b006e4755e617cmr978815otp.31.1708599620860; Thu, 22 Feb 2024 03:00:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708599620; cv=pass; d=google.com; s=arc-20160816; b=CLM1CzRmj1yqmAA0ufNvIogY5nl9MgwOYHALi/G1S9bzv6xvpPMNNd0rz8p+FhTasZ wdINgTl5AQ8jz2yxReGiTteeZAqqaSiaWJhh2y8TZjhYz+Tfr6I3JSVpMZ0KeD3yfhts WIL6eALkxnqcjCad7TSylch1NHHSEhXbsm/onjbE/BE52MG7JucA6NE+HIqcqx+VGFSY ada54TNg8D/FfVlrhi9dUjOYjK/Yf45q20RxOT4k/lUj8vjVNWjm4IycYdoVBQ6tHq4S NPU3BOfg9RzaSLPL9lmkCecA6w+cS0j68/ldVxOhsrrUvOVU+7bdxZg03aMyaE0UuOkX +2eg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=If0nc9cpG0C+2T1xh8+4TleRWChMsk96hA+uEtXVAuA=; fh=8M3ALQqE+IwhrS11EDKLkLfc0TNhxve9wWU6P6UAGMc=; b=Qibd3nIEq1ZCj3NMFVTW9nzaGT0fSxWIlG/Koc94cwNkfJ1kE2+kiJTfgu/YDedNKH Tl67X+1yjkGNFha6pis7XlYvXnI6HfBPue5C5pX3Xz9vcF1UxcCgtKonCmr7NLogsvHf yGRTn1XWYIIS0mvE5xjpnlAfECoGhMSrm6w+txIK9yqQWCh+/InskU9Qeymy+Gwf0PPl 9OGHHjOarUhU8+ND7+jHSzbKjDrhodj28v9XY2BQ7Sg4bUpYVOFqnEdZxmWfxOsREhYR nMiz1LJxBtUX6Wh4+bA9tJZhkjmnV1/BvNamr4geieVr5bF+5xs9WrpKZ9OMytFsuK0D jNGw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-76365-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76365-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id m6-20020a633f06000000b005dc5576e634si10176502pga.896.2024.02.22.03.00.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:00:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76365-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-76365-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76365-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 2F383B271C5 for ; Thu, 22 Feb 2024 10:55:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 51B44405CF; Thu, 22 Feb 2024 10:52:58 +0000 (UTC) Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C1023FB2D; Thu, 22 Feb 2024 10:52:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708599177; cv=none; b=OH9KFvLv4BmCRxUITy4POXjvAxCX+GtxcUWGP3KYj4/Z3fyCHK0M0tpzw9pFFUDmO/V4P/3YYD7dMKDatMsMn8FCORo5dw78JRULd9FZ3uMHSNFfR31Zd9S/s92lRbtSwE83Exa1thauhL7ZfjgEDsmYgceERPheY9zGzHIlKaI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708599177; c=relaxed/simple; bh=mvKZwxbf/e4KF9+fRM4X3wplM/O7yu2E+CvOcToAuEw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=pjY8XoXslJNGliA1EZ1M8zljGMwmqEjnl6uZ12SItx09JS3vYpa10ryS7cE+Mnmgy8tK6Hp1Y968arRmBiUJVmaeWjUAQ1ya+lEOOiwDq0tf7dPQqrkCllQKr6dhFAnTG2Pl/xm0T46WZbjNFmWmrQ0WGkjpXLMFYtcxbKTkd1k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.167.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-3bc21303a35so2863221b6e.0; Thu, 22 Feb 2024 02:52:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708599175; x=1709203975; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=If0nc9cpG0C+2T1xh8+4TleRWChMsk96hA+uEtXVAuA=; b=Jbbu7rhAtgszkFooPYgpfNAdfIghiCS4janxYyP49nhz0/2VeJJVvK9N/J5mgHNTed 4ZqSsWPCxDRBZhd0g6dFiCJjbsR4tn7TdxvRW2vnUXi4V8ncGUERezfoXHEC/NLeoY9O nJzizbWCKp5l3m1u84VHxskA8JaREd49kNORdVepn8YSY954guqx6DRXp8E4aMJk6pXK zumHqhbKHnafY17bgsGOuqKqeeEezOtiDYInAkx55erBNDEb6TtRz2Em6V6sdM466vFG KS6wBNnNwWhbiZmWR4lrge41fWATuAPR5hAW+3xDCGi3OHcgCVEOJjqluHvzKUUCN0it 3MuQ== X-Forwarded-Encrypted: i=1; AJvYcCVSKZGzMYxcL4JabY61WIdrkzCONnATvtAji62AYzSEsS9ze6NfeIqnPU30rxTUPPwCUK7vX5vu9JftgiOJTnJS9YHFmxYmskE8tNzOSSJN+GKB4wGsGSvLm3auq27pAagK1wdLFkCK5ty6geraLq7mAAK2UZ/o8dc+5CwUEunvbwa8 X-Gm-Message-State: AOJu0Yyzul8XDiLKMKy2p1OXMGct44HsQFjpSr4fA8IZ9f2NeWKWOihe ozXn4eIvSPnyjLI80Fb6WoC1o+2+tQqgHDdd1sxidMZXcCdRg7tvxa+HNG5gxck6lB4otZN8lJ/ l63gMqUDLxO7lbhoGTsxyr54XStA= X-Received: by 2002:a4a:a886:0:b0:5a0:396d:2489 with SMTP id q6-20020a4aa886000000b005a0396d2489mr20650oom.1.1708599175400; Thu, 22 Feb 2024 02:52:55 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <4551531.LvFx2qVVIh@kreacher> <2262393.iZASKD2KPV@kreacher> In-Reply-To: From: "Rafael J. Wysocki" Date: Thu, 22 Feb 2024 11:52:44 +0100 Message-ID: Subject: Re: [PATCH v2 4/6] thermal: core: Store zone ops in struct thermal_zone_device To: Daniel Lezcano Cc: "Rafael J. Wysocki" , Linux PM , LKML , Linux ACPI , Lukasz Luba , Zhang Rui , Srinivas Pandruvada , Stanislaw Gruszka , AngeloGioacchino Del Regno , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Feb 22, 2024 at 11:47=E2=80=AFAM Daniel Lezcano wrote: > > On 14/02/2024 13:45, Rafael J. Wysocki wrote: > > From: Rafael J. Wysocki > > > > The current code requires thermal zone creators to pass pointers to > > writable ops structures to thermal_zone_device_register_with_trips() > > which needs to modify the target struct thermal_zone_device_ops object > > if the "critical" operation in it is NULL. > > > > Moreover, the callers of thermal_zone_device_register_with_trips() are > > required to hold on to the struct thermal_zone_device_ops object passed > > to it until the given thermal zone is unregistered. > > > > Both of these requirements are quite inconvenient, so modify struct > > thermal_zone_device to contain struct thermal_zone_device_ops as field = and > > make thermal_zone_device_register_with_trips() copy the contents of the > > struct thermal_zone_device_ops passed to it via a pointer (which can be > > const now) to that field. > > > > Also adjust the code using thermal zone ops accordingly and modify > > thermal_of_zone_register() to use a local ops variable during > > thermal zone registration so ops do not need to be freed in > > thermal_of_zone_unregister() any more. > > [ ... ] > > > static void thermal_of_zone_unregister(struct thermal_zone_device *tz= ) > > { > > struct thermal_trip *trips =3D tz->trips; > > - struct thermal_zone_device_ops *ops =3D tz->ops; > > > > thermal_zone_device_disable(tz); > > thermal_zone_device_unregister(tz); > > kfree(trips); > > Not related to the current patch but with patch 1/6. Freeing the trip > points here will lead to a double free given it is already freed from > thermal_zone_device_unregister() after the changes introduces in patch > 1, right ? No, patch [1/6] doesn't free the caller-supplied ops, just copies them into the local instance. Attempting to free a static ops would not be a good idea, for example. BTW, thanks for all of the reviews, but this series is not applicable without the one at https://lore.kernel.org/linux-pm/6017196.lOV4Wx5bFT@kreacher/