From patchwork Tue Apr 24 22:35:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 10361163 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1F34F602D6 for ; Tue, 24 Apr 2018 22:37:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0769628E37 for ; Tue, 24 Apr 2018 22:37:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F061328E3A; Tue, 24 Apr 2018 22:37:32 +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,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 8E0AE28E37 for ; Tue, 24 Apr 2018 22:37:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751537AbeDXWhH (ORCPT ); Tue, 24 Apr 2018 18:37:07 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:40845 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751150AbeDXWf0 (ORCPT ); Tue, 24 Apr 2018 18:35:26 -0400 Received: by mail-pf0-f194.google.com with SMTP id f189so4349183pfa.7 for ; Tue, 24 Apr 2018 15:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ymXyPh0uVSbIWiHrga/nZV/9JPCTRUyA32ovWL0SySg=; b=Ikh2lJJ6epAjmZ6X6xBYTQC6KEuxODuRzHATZEslUwjsyHHhZtc0kFq0L8DWD21KxQ o1nAb2Fsn02OdpHBztxyhMfmbxGGXunl+GTpAEuvNZG88qPpa2E5MhU+V68Eg+Dhvs38 eemh2WRdobjp8iWnZ3xIX5nWeW6QKYdgBXHD0= 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:in-reply-to :references; bh=ymXyPh0uVSbIWiHrga/nZV/9JPCTRUyA32ovWL0SySg=; b=rDZjmFGCrtWFA+YpYZvzK6ybO0TyqxRIj5KPEaAsVWqrmNLSPjbgnJJPdVIueKYU5Y Ztp9rvZrSQE9ODWS885g7pJDzwMqNmyozMCLbQD3wfu/PcsMSBnxNz0R6caeCsHiQPOA mse8fLqiGVmahs1Dooz0YnysKsUFudbPv+B2EOec7gB6Ys/W+KlAZ+nt4t6d1EFqR013 Bp87Ih3e6+lU0B5QO7CLFJf19xmypaz3kWTRiX9hyaUWsBWDwj1N44JMgbOAcaGh3sG4 /EEKR99BymEfIB8cA+MW5HzGe+zO3rsq9rKC43tba7HYrR1LOpru4++fAJanA3pw7fJt YT1g== X-Gm-Message-State: ALQs6tAE1xOW/+Ss3PokfzlFxOU7rXYmpybg0/+dHuiWwhYUV58kJP6F w3d+oNKwxNj1sTBQBwojLd9MESmvS7c= X-Google-Smtp-Source: AIpwx4+ol/d3CV9MyLBpSxk3Ib/kIgfU+U4Zsm5KODyxZqI/bJv/7k74GBi1unkYjIS3RSy0wm37xg== X-Received: by 10.98.156.7 with SMTP id f7mr25575948pfe.104.1524609325846; Tue, 24 Apr 2018 15:35:25 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id w26sm35856621pfi.17.2018.04.24.15.35.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 15:35:25 -0700 (PDT) From: Bjorn Andersson To: MyungJoo Ham , Kyungmin Park , Chanwoo Choi Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/6] PM / devfreq: Free devfreq upon set_freq_table error Date: Tue, 24 Apr 2018 15:35:16 -0700 Message-Id: <20180424223521.28193-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180424223521.28193-1-bjorn.andersson@linaro.org> References: <20180424223521.28193-1-bjorn.andersson@linaro.org> 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 When set_freq_table() fails we must still free the previously allocated devfreq context, so jump to the correct label for this. Also when this happens devfreq will always be non-NULL, so drop the unnecessary conditional. Also destroy the devfreq mutex as we're cleaning up the devfreq object. Signed-off-by: Bjorn Andersson --- drivers/devfreq/devfreq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 2067cd229ce3..30a672397ff0 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -597,7 +597,7 @@ struct devfreq *devfreq_add_device(struct device *dev, mutex_unlock(&devfreq->lock); err = set_freq_table(devfreq); if (err < 0) - goto err_out; + goto err_dev; mutex_lock(&devfreq->lock); } @@ -669,8 +669,8 @@ struct devfreq *devfreq_add_device(struct device *dev, device_unregister(&devfreq->dev); err_dev: - if (devfreq) - kfree(devfreq); + mutex_destroy(&devfreq->lock); + kfree(devfreq); err_out: return ERR_PTR(err); }