From patchwork Sat Feb 16 16:31:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 10816303 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4892013BF for ; Sat, 16 Feb 2019 16:31:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3592B2C3EF for ; Sat, 16 Feb 2019 16:31:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 255CC2C40C; Sat, 16 Feb 2019 16:31:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD17D2C3EF for ; Sat, 16 Feb 2019 16:31:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730984AbfBPQb4 (ORCPT ); Sat, 16 Feb 2019 11:31:56 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:45620 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726057AbfBPQb4 (ORCPT ); Sat, 16 Feb 2019 11:31:56 -0500 Received: by mail-pg1-f196.google.com with SMTP id y4so6262447pgc.12; Sat, 16 Feb 2019 08:31:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=LO3QrEf9owC5ZOEMrXxiFtSgd/NWCotfP8eeokdC2i8=; b=PaHX6me/h9dvQWxmJNZs39smveT2uy2UddFwRbuTcGq/9ARB9PsJt0pSJ10sloH9SE /8+G0FtEAB/xfzk9RJ9XiDegqWST7Gjhly2pAY2GkR0KpMfo56rf9OOq/YKV53KLQ4lU hmp+5KVM29VeOS5/j+etuOjOf0N1C/tHQt9/c2SAYZT9vWpv8uAf2OiWcw/RHQScAlNu +jVA5cRmFGRdWvc928IxlO1XIkUg2V5RVSEX/VW9/QlTlX1Zmz9pfW3p8FuGaSf4MprX PkF3tTwGBukjOGontQiOiW9nYqRS4gtj2ju94V593DGUYUE6TBMk8LJNYw33ffKIFdlF ouJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=LO3QrEf9owC5ZOEMrXxiFtSgd/NWCotfP8eeokdC2i8=; b=j4LZm1dZUe98P89m0U7eLbvqO7rRzK7Z0mVRg2bwiyjZjhJEFJEgVwKX1A7obt2N9G l2h/V6zi7IUZmce9yquyw21srIVCnS0UhziSYZhTirkCqVPlu6jX9tin0OQ70JNW6Cp7 bd4tLxlfCnUDoBe8qUbHYhGIb0nV/QwIxxvYuWTYK+kwtzxQ+5A4n4YG6vk38/64y7Z0 QyK1Q6B64tBYpXNPifbtoteaG8J1nB1Ahb0DHHMvrLWTNUrJ2KvuDT2ZVVfRswwWM7Bk NJuhsyhCVVq65TvkAJiGIS5Ly2qKwPizFVwyRXe7ob5SuLSfkUOQo1AXEUUvEN0peC93 ECrQ== X-Gm-Message-State: AHQUAubU6ErALypjQDJKvFWIvezG/jDD5Phe+Mu82+ngyLNja4QjPA4r XW+FkdElTBOmmFmrOud1wRY= X-Google-Smtp-Source: AHgI3IZA8RrwU96a2b4ROhL2T4Xuw9ulV3+X8XQn3r4wK1JP1Szg2+fr5WaoBClngjdv4YK0LszfJg== X-Received: by 2002:a63:f10c:: with SMTP id f12mr14667460pgi.374.1550334715958; Sat, 16 Feb 2019 08:31:55 -0800 (PST) Received: from localhost (68.168.130.77.16clouds.com. [68.168.130.77]) by smtp.gmail.com with ESMTPSA id l22sm14763633pfj.179.2019.02.16.08.31.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 16 Feb 2019 08:31:55 -0800 (PST) From: Yangtao Li To: sudeep.holla@arm.com, rjw@rjwysocki.net, viresh.kumar@linaro.org Cc: linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Yangtao Li Subject: [PATCH] cpufreq: scmi: fix use-after-free in scmi_cpufreq_exit() Date: Sat, 16 Feb 2019 11:31:48 -0500 Message-Id: <20190216163148.12375-1-tiny.windzz@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This issue was detected with the help of Coccinelle. So change the order of function calls to fix it. Fixes: 1690d8bb91e37 (cpufreq: scpi/scmi: Fix freeing of dynamic OPPs) Signed-off-by: Yangtao Li Acked-by: Viresh Kumar Acked-by: Sudeep Holla --- drivers/cpufreq/scmi-cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c index 242c3370544e..9ed46d188cb5 100644 --- a/drivers/cpufreq/scmi-cpufreq.c +++ b/drivers/cpufreq/scmi-cpufreq.c @@ -187,8 +187,8 @@ static int scmi_cpufreq_exit(struct cpufreq_policy *policy) cpufreq_cooling_unregister(priv->cdev); dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table); - kfree(priv); dev_pm_opp_remove_all_dynamic(priv->cpu_dev); + kfree(priv); return 0; }