From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 D2BD43FE27 for ; Thu, 22 Feb 2024 10:47:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708598858; cv=none; b=INH8MaSYcJEJ5RwanmtYCHawJHptbQzwGOrFeLbNVDc6dMB9SvyHU2twPIVnh6bQFisS1ckp39+kOUC8GOTBnCyZNH76NG2IDP3FCE4URq9pqDSjbaNFWQuyQrnSnBClSD7HYd/3nogu4xGfTiliA4vl/vBnDH30OscdsIBz/jE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708598858; c=relaxed/simple; bh=3zP/VtA1AgtaTaQw2U6AxyLni4JwLiOiv99igy1cVDw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=JabsGLaHjRNLx3HMA3pgHGQNfOX9gMqaCOLPrGe9NrUcHQri0q7A7nRTK3gK1IN17rCPOm8l8wRIAJmNsesMxx7+PvWf115y8LpQnV1d8YoEpHM8Odlwsx87UL6NWf7d5/mwdTjTYdcXJnphOfqPaQR7qx6FI8Isj/dgjwVm+IE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=tplJAyO8; arc=none smtp.client-ip=209.85.221.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="tplJAyO8" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-33d9d43a1eeso23123f8f.2 for ; Thu, 22 Feb 2024 02:47:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708598855; x=1709203655; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=5aqpcdx+kqPsDksMwy3/1ZpsNRD3e+cH+lqKOGDH4SU=; b=tplJAyO8ImuOx31ipVmS25WlR0yZtap78n7NHrgNzYv5S3HdVHA72P3W2jhEvVUUmz e62zXAIXW9p5yY5kG60AEnjenkHxaTX9fao7uHfOzd9uPaqrWIQaiVuHfK9TBtied5Ju +uSUyCiTpqKFsPwLu0GtqXzPYBmrIVFrCnDUUwRBG/vg+7BG4BVs3FDVhnrACM/hyES4 E7AJxiZg9ZsAEHAL3jeskg+eYqIDOGGAy6Wlwz3FdEiAtahWNy9ueiFpUIvYL0hdJO1W B3UpIUv0X1q5SXXe7a4K/cWP44JvQX60MZQpSJ2lDhY3MCVHub60iVPCSOKR2uaRT5k4 Psag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708598855; x=1709203655; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5aqpcdx+kqPsDksMwy3/1ZpsNRD3e+cH+lqKOGDH4SU=; b=BYsFAfxWkEjJRQCwkPA46G7y7NugPytyl7TYxT0yi2Dj7FvNtmv+0d+iK1AH/fqSXr b2I1qPmSpXPWWZoGJth+DwaRAuUyFyyxQAC7eyeLFBpEMnmOh+W6PJ/XUhY2OZ37d3sI iwkLU5rhkEtqpN5Gwbbxgb8boA11YaackUM+2WQNCEp5uoK57Ziqq3hJ1rFPc+OcEY78 209kWH5VBZp4VriuMI1XSjZ3oEm2a9P9YPZXy9WtTm6JFzZH4TClSmcEIOSjcUb3eN8g JOXvBUW2JTf4HzyjY1e6C4qJtUjYIKEMX33GreQ8wlX8IJuiNC6iQbWPjVKQD+dq3ryc qsPg== X-Forwarded-Encrypted: i=1; AJvYcCXd4cP8uFuptP7oME4HGAEA6uGFNOa/t5SyW9pzeEwth4pHByNzbOJSc0ps4o/ZV3TeHTdazhmrsbjNE0VWC0Nury6S+w4bvmA= X-Gm-Message-State: AOJu0YzKBW+DqxQp4I3T//qQjwcKm66T+eDKUAIj3Ydn+ShF5V4Mjl0b 01Urrbw3frcxRPMx/LEu5vTgZhUK0uTm3lOnfQjb10nDbyqmDn/9S+m4RlE/RBMOBLbcTPtIlA+ 8 X-Google-Smtp-Source: AGHT+IGs1kam3tuErV0BZMvW5Bv5dj9iYPqaMk+UBtUuUvBtTpsPOm3+SsvB5+lg6Z2no0OLjEXKYA== X-Received: by 2002:adf:ec4a:0:b0:33d:82c2:ad8d with SMTP id w10-20020adfec4a000000b0033d82c2ad8dmr2582908wrn.56.1708598855237; Thu, 22 Feb 2024 02:47:35 -0800 (PST) Received: from [192.168.10.46] (146725694.box.freepro.com. [130.180.211.218]) by smtp.googlemail.com with ESMTPSA id bo29-20020a056000069d00b0033d5f5571b4sm11278754wrb.44.2024.02.22.02.47.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Feb 2024 02:47:34 -0800 (PST) Message-ID: Date: Thu, 22 Feb 2024 11:47:34 +0100 Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 4/6] thermal: core: Store zone ops in struct thermal_zone_device Content-Language: en-US To: "Rafael J. Wysocki" , Linux PM Cc: 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 References: <4551531.LvFx2qVVIh@kreacher> <2262393.iZASKD2KPV@kreacher> From: Daniel Lezcano In-Reply-To: <2262393.iZASKD2KPV@kreacher> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 = tz->trips; > - struct thermal_zone_device_ops *ops = 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 ? -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog