Re: [PATCH] int340X/processor_thermal_device: Fix proc_thermal_rapl_remove()

From: Zhang Rui
Date: Tue Jul 23 2019 - 03:32:57 EST


On ä, 2019-07-23 at 09:30 +0200, Rafael J. Wysocki wrote:
> On Mon, Jul 22, 2019 at 12:23 PM Rafael J. Wysocki <rjw@xxxxxxxxxxxxx
> > wrote:
> >
> >
> > From: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
> >
> > Passing 0 to cpuhp_remove_state() triggers the BUG_ON() in
> > __cpuhp_remove_state_cpuslocked() and the argument passed to
> > powercap_unregister_control_type() is expected to be a valid
> > pointer, so avoid calling these functions with incorrect
> > arguments from proc_thermal_rapl_remove().
> >
> > Fixes: 555c45fe0d04 ("int340X/processor_thermal_device: add support
> > for MMIO RAPL")
> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
Acked-by: Zhang Rui <rui.zhang@xxxxxxxxx>

> Any comments?
>
> If not, I'll queue this up along with the other RAPL-related fix
> (https://patchwork.kernel.org/patch/11050999/).
>
> >
> > ---
> > Âdrivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> > |ÂÂÂÂ4 ++++
> > Â1 file changed, 4 insertions(+)
> >
> > Index: linux-
> > pm/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> > ===================================================================
> > --- linux-
> > pm.orig/drivers/thermal/intel/int340x_thermal/processor_thermal_dev
> > ice.c
> > +++ linux-
> > pm/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> > @@ -487,6 +487,7 @@ static int proc_thermal_rapl_add(struct
> > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂrapl_mmio_cpu_online,
> > rapl_mmio_cpu_down_prep);
> > ÂÂÂÂÂÂÂÂif (ret < 0) {
> > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂpowercap_unregister_control_type(rapl_mmio_priv.con
> > trol_type);
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂrapl_mmio_priv.control_type = NULL;
> > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂreturn ret;
> > ÂÂÂÂÂÂÂÂ}
> > ÂÂÂÂÂÂÂÂrapl_mmio_priv.pcap_rapl_online = ret;
> > @@ -496,6 +497,9 @@ static int proc_thermal_rapl_add(struct
> >
> > Âstatic void proc_thermal_rapl_remove(void)
> > Â{
> > +ÂÂÂÂÂÂÂif (IS_ERR_OR_NULL(rapl_mmio_priv.control_type))
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂreturn;
> > +
> > ÂÂÂÂÂÂÂÂcpuhp_remove_state(rapl_mmio_priv.pcap_rapl_online);
> > ÂÂÂÂÂÂÂÂpowercap_unregister_control_type(rapl_mmio_priv.control_typ
> > e);
> > Â}
> >
> >
> >