Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1976500pxm; Thu, 24 Feb 2022 13:24:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrKeIBuihEjzHuvZd4oaX9qxxQxA2AKky0UhGfbphdmR6hsvwumMpMy7P6gNdunPiTGXtu X-Received: by 2002:a62:7617:0:b0:4e1:5f3b:2643 with SMTP id r23-20020a627617000000b004e15f3b2643mr4593026pfc.13.1645737882146; Thu, 24 Feb 2022 13:24:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645737882; cv=none; d=google.com; s=arc-20160816; b=O7QVpPvG9u+sQt2xspXnoiEQyQZD27kF5gjLTyOpfjVeowpylX5H1dVTQTHARTILV+ GIOsG56TMk25XsSnZqiSChIYq7xQnPP1GGx1FMba6cWV37NAL79paJPNuqSPWh5OWWpv G8hxsQAsTG3E/d+EzbP/UtNFYj4YumKPMxpZyT1apL+bXmBlA2zioLRfca3dncVwCbBU g4oiEuGA+YVtsCNDve3vyd3VmqcSli0KAKrHOWiYSpk7dq9gHBfoPk+A+tLS0KfWFFbP fxRiNwtNY6xnCVZkjWNp8bFp6ll7ENW+EQ4QgNs+1XtXRVtnwmz35ubUe8JD42Sm1eIH cKjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=IUBHyJhD/KgAkIiV2RaqQW67XtJAXXd9nyxXUgBYd+8=; b=q6Oe8Wgwch8+M3EW6vu25V4xFlBQmVLuqvKsKqHqr9r4BJ/URgY3EF6ALSEq1PRJYA /F0HXuhSr0VwUAAzK1mK1c+iwSDLJJ5yUyTRXo6aySl1N8X9ViIFclmJt7OVNGA6pQTe YniLfbxMMpv3yE6Il4J+zqe1exlgRxO9okmN5MGRjzmUR+xky8jNydVb714WAg661e51 Vo8X2UHs3Sm1y44gSIISX2jbq+R2mwzYFlProeBh8pvIzNTPW6VCCprMeGBtJB/XI8JV w7wZEMcXT8UBFSb2vte4LmjduS0fkLeDA5JBlPvCWB3mprgqu4lID5tQ0lGkbzuQqFcD 2ZRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hi24-20020a17090b30d800b001bcabb608c4si387178pjb.109.2022.02.24.13.24.26; Thu, 24 Feb 2022 13:24:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233538AbiBXTRW (ORCPT + 99 others); Thu, 24 Feb 2022 14:17:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233500AbiBXTRM (ORCPT ); Thu, 24 Feb 2022 14:17:12 -0500 Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0569465A5; Thu, 24 Feb 2022 11:16:41 -0800 (PST) Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-2d646fffcc2so9150657b3.4; Thu, 24 Feb 2022 11:16:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IUBHyJhD/KgAkIiV2RaqQW67XtJAXXd9nyxXUgBYd+8=; b=xmCxb8EJfK76+POmTfYM9mbNTC6pWjh/VVrtDD+BfLpp6NagHDrdRO6fYHSwOWtvO/ RQc+JXnIG/DvKyKu6xobmfyE90zRFaVTiMlQvh5YUiZ+Z9ywSkSYapY63Z7EQiHgh8LC umUNRohsJLoIHpZqCYVPX1cf6tSCcfSojB5XY2ciWtEE7W9qaUBkOIbtE/u16WyAaMtc aG2tPkeUmh4rWj8QEQvhytZSUg2b55zsL16sRrUwvWcHgZUFTEjUimlNZFUXRwUSlU74 +vs5lXxx5aRwF7IaINgTf2UJgVn91Fy8ovYMx/v3NwXAR4kFZXt6AnJqiPoNrhnzZkoF ZaDw== X-Gm-Message-State: AOAM533uuuDCkYXCk4Vs5pBW5YXLtJZNkihEzH6liBKtanDZmujWYkTA 39puREbC93yuYXiAfbZWyB6KbqlEMcMhKsMM1bv2JnAD X-Received: by 2002:a81:b65f:0:b0:2d6:d29c:63fd with SMTP id h31-20020a81b65f000000b002d6d29c63fdmr4053544ywk.196.1645730201257; Thu, 24 Feb 2022 11:16:41 -0800 (PST) MIME-Version: 1.0 References: <20220223002024.55026-1-chuansheng.liu@intel.com> In-Reply-To: <20220223002024.55026-1-chuansheng.liu@intel.com> From: "Rafael J. Wysocki" Date: Thu, 24 Feb 2022 20:16:30 +0100 Message-ID: Subject: Re: [PATCH] thermal: int340x: fix memory leak in int3400_notify() To: Chuansheng Liu , Srinivas Pandruvada Cc: Linux Kernel Mailing List , Linux PM , "Rafael J. Wysocki" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 23, 2022 at 1:33 AM Chuansheng Liu wrote: > > It is easy to hit the below memory leaks in my TigerLake platform: > > -- > unreferenced object 0xffff927c8b91dbc0 (size 32): > comm "kworker/0:2", pid 112, jiffies 4294893323 (age 83.604s) > hex dump (first 32 bytes): > 4e 41 4d 45 3d 49 4e 54 33 34 30 30 20 54 68 65 NAME=INT3400 The > 72 6d 61 6c 00 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b a5 rmal.kkkkkkkkkk. > backtrace: > [] __kmalloc_track_caller+0x2fe/0x4a0 > [] kvasprintf+0x65/0xd0 > [] kasprintf+0x4e/0x70 > [] int3400_notify+0x82/0x120 [int3400_thermal] > [] acpi_ev_notify_dispatch+0x54/0x71 > [] acpi_os_execute_deferred+0x17/0x30 > [] process_one_work+0x21a/0x3f0 > [] worker_thread+0x4a/0x3b0 > [] kthread+0xfd/0x130 > [] ret_from_fork+0x1f/0x30 > --- > > Fix it by calling kfree() accordingly. > > Fixes: 38e44da59130 ("thermal: int3400_thermal: process "thermal table > changed" event") > > Cc: linux-pm@vger.kernel.org > Cc: stable@vger.kernel.org > Cc: rafael@kernel.org > Cc: srinivas.pandruvada@linux.intel.com > Signed-off-by: Chuansheng Liu Applied as a fix for 5.17-rc, thanks! Srinivas, any concerns? > --- > drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c > index 72acb1f61849..4f478812cb51 100644 > --- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c > +++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c > @@ -404,6 +404,10 @@ static void int3400_notify(acpi_handle handle, > thermal_prop[3] = kasprintf(GFP_KERNEL, "EVENT=%d", therm_event); > thermal_prop[4] = NULL; > kobject_uevent_env(&priv->thermal->device.kobj, KOBJ_CHANGE, thermal_prop); > + kfree(thermal_prop[0]); > + kfree(thermal_prop[1]); > + kfree(thermal_prop[2]); > + kfree(thermal_prop[3]); > } > > static int int3400_thermal_get_temp(struct thermal_zone_device *thermal, > -- > 2.25.0.rc2 >