Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp358755rdb; Thu, 22 Feb 2024 06:07:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVnDly2LfdwQPYAzZi2GbV5AVlA3ypj0myPuW3us4poNRlchtKDQVPiVjGsjcCxBB9mTb8hSAwy/XaK0zXF59WN2peFX/g9No1d64M1qQ== X-Google-Smtp-Source: AGHT+IEoAkcW1mjQ3EbMxCOdKV/Nd4gHzqMXvxJC//t07ARKLsXCO5Vnq2aOjFVVgwBSQ6ok/UKE X-Received: by 2002:a05:622a:647:b0:42d:b703:dc0d with SMTP id a7-20020a05622a064700b0042db703dc0dmr27667495qtb.44.1708610858791; Thu, 22 Feb 2024 06:07:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708610858; cv=pass; d=google.com; s=arc-20160816; b=BjbneeLC9nugv0jSeUfH2XxYIo8JUqm9TV7tEakgRIO79wzFjwhSa71f7JihFQuDrR G3DLIW/nwNvEIMDpZhpOL+YtaVh1Eojh2eN2wRNq0oYZQlgdKzoMLEqFQCWke1V3Xl+j BEFggdtXXUMNZz5DAaAIib4oeZ70RHf0aiiw76uNb0PlvN7EmtXYFLXjua3zjWbJ86RC xceeA++xMCPrAcRvW4odgPWnSKbRV02AsYTvV8iDI1iWkGXfft0cCod0x/p0SIql3Vey jp93IG62YMADakdBbSnQvPXMHj8vLYR1yP3KVZM05X8c5U/B73V+v734w95aFQEfxesX 6b/w== 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=mO2nclL9U8dwMBtj05knQsK6PwiKnaTN1YsWrMMD8vI=; fh=ZpsW01IThpfD9ZtNxdCbBB0/KSu6C4BfP0st9+gMfP8=; b=pGBILxCbD8gGH7P8GTeNTzlvdEQszY//Mw3LEjzZRSHgahu06vbtEThsZtF5wZ7Xzz hs2Wg95K7iLfZ7FVCnaZto2oHKCbZJSz0itnIcHP4LjW4vb4YJqIiy3q5tx/KQivPRI2 k8O43E07ZK3VH8FfRFmTsYJ47I0RvaH6eeu0UhCZ3VNNbfV+2NG8kJsO9Gwb4EimqT8d vJCfdG7FGN4HxxhyZlOKZlbhyWR41VgJtd9N1jf7vsQitmD2ItQlGhtyHuTAsi/dOu2d 7kBNjoPORJs76T3NfMgvCu9Ex39jhPC09vmBgu0DwGQ+L3SuwWWoi+NdOzzbl6L0oHM1 enAw==; 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-76670-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76670-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o20-20020a05620a22d400b00787284f8c93si12530551qki.162.2024.02.22.06.07.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 06:07:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76670-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-76670-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76670-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 481E41C23A6A for ; Thu, 22 Feb 2024 14:07:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D9D651482FD; Thu, 22 Feb 2024 14:05:32 +0000 (UTC) Received: from mail-oo1-f41.google.com (mail-oo1-f41.google.com [209.85.161.41]) (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 C2860145FF6; Thu, 22 Feb 2024 14:05:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708610732; cv=none; b=K2fVCYquFpZ+nUmNrNOyrU57XZMKxzbmV6k7CBYI3LMsIQlS9nd4rMNxqKvec08CmjQxDycNlkeajn/MPNXuTKXcrRj6+4uoKsBygw2NY6pxSrh8+F5usmwSyYF0aWleweBjv2LFuZuGYIbI83o/DJb7WvWH8HRVwvqwUt30pp0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708610732; c=relaxed/simple; bh=x+mYmnKRAmVbqPnh7GeoP7TfYOz5wxcG8FEocgdSbnI=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=NZVY7t7BP5xEo8Yvj1KtOlTwO/PAD59WI7x04HH2lY0fLw+6TtTrOYSrQ1P6swCfBXF8Lw2lMSiBRBC19RxJ4vMsqWsW7Lg8ECee/nKnXSeKbjX8g7BYP1gTMCXCVQ8VLzOs4rrda26N9z7zATM1K4V/f9Y1Vgx0cNs80qNqojo= 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.161.41 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-oo1-f41.google.com with SMTP id 006d021491bc7-59d29103089so274261eaf.0; Thu, 22 Feb 2024 06:05:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708610730; x=1709215530; 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=mO2nclL9U8dwMBtj05knQsK6PwiKnaTN1YsWrMMD8vI=; b=FosOGLrKRqK3dYislDlbGkzRHuOq1fL59UceHoVDcHXSAeLbVdAwUn/L6eW/h6v1EZ jwRcYlTok6x+dWcI004aV6m/g0wCINr59mkHx220bv3P6UEX58Ytx7dR90c+lR+aqckL UEbyWT5EPCZa4BsTSxCNC4EVByM3sYSixVGodUxlAQ0OuOZP7M5hM17m7YCA25PrPE9o x13CVygDZ43Wv7pbCt2+R8eLm9M5pCkqjZ/XyGs9cCIRw8uil7241BZAaiWcLuxuzeZe hI2XG7KeWrBfOd3L07Gg1oGcjgWLLLpfNhXKeepL/pcv5AkbfE4wbGRlCOCWcvTnSdGj z5OQ== X-Forwarded-Encrypted: i=1; AJvYcCWSRV3RPmDsllF2xVeXIu4SzhsOCH4/IxrD+8+spQ44bp/Lwsk6+TIJY5q6bp4THlsBUh7RAr8xXuSvM6k6A/Oh4Q+E40cuPYAeewxk6cItSGl1Z1ZTP2SQqXENNrBsKv0tT6TFCfcVpDXfA4BGUTT5lhc4JvGOisAuH/3UFsbdEnR0 X-Gm-Message-State: AOJu0YzdmpdP1xrrry+STA7G6jj06/Uy550z5E25bqXhXts03cvn4iug 7kr8qqdooF3pqABknD4+2yy1l18DIliSTUlgqGPOVAIRc7B7VKsnUVlO35ukS5+BHZr2mOnxTOn aMo98LVOMIryDh1nPs7inyoHASWzReHbB X-Received: by 2002:a4a:a886:0:b0:5a0:396d:2489 with SMTP id q6-20020a4aa886000000b005a0396d2489mr474588oom.1.1708610729714; Thu, 22 Feb 2024 06:05:29 -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 15:05:18 +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:52=E2=80=AFAM Rafael J. Wysocki wrote: > > 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 objec= t > > > if the "critical" operation in it is NULL. > > > > > > Moreover, the callers of thermal_zone_device_register_with_trips() ar= e > > > required to hold on to the struct thermal_zone_device_ops object pass= ed > > > 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 fiel= d and > > > make thermal_zone_device_register_with_trips() copy the contents of t= he > > > 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/ As it turns out, this really is not a big deal, because the rebase is trivial for everything except for the Intel patches, but for those two I have the v1 versions that apply just fine without the other series and have been reviewed. So I can apply this series before the above one and rebase the latter (I'd rather not send a new version of it though, so it can be reviewed as is). So never mind.