From patchwork Fri Mar 30 11:44:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arvind Yadav X-Patchwork-Id: 10317621 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 D692560383 for ; Fri, 30 Mar 2018 11:44:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C5CDB2A515 for ; Fri, 30 Mar 2018 11:44:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B794D2A518; Fri, 30 Mar 2018 11:44:28 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, 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 758E52A515 for ; Fri, 30 Mar 2018 11:44:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752168AbeC3LoS (ORCPT ); Fri, 30 Mar 2018 07:44:18 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:42028 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751941AbeC3LoQ (ORCPT ); Fri, 30 Mar 2018 07:44:16 -0400 Received: by mail-pf0-f193.google.com with SMTP id a16so5290284pfn.9; Fri, 30 Mar 2018 04:44:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=UtDzOnohsLh194D7AL25+1lbrNIY22RcCGWAulXCkLg=; b=Ix9Ix7eC7/uz54UFxELKcP+MF1WfdaEH+W3i23v7gscZM9hG6sgYRZOrcYbOVHh/V1 ign1BFjN7B2SiuwlGiFms75cFLTXutxEjTkPamuFtbb6jI5Pbd1lSdWER1R2oAe1Tev/ 4LzUErr9dsUNgoVEuJmoOMXC4ZeB0BOFOrlLuoHHgXLoEJ17tPYVv4Xolh+Ndkbr4Dtp y0uut6GNN2X0Nj8utYov0ppU/l8XH39tBbMIyZSoumAOcnEbtX24PcrV9hwRigSwAKyd uvw0dN7GZ7FSXur2K8bbxvAajDTDcEfjnrG3JORi8bq8W8w2grEq0a2PWl9nsUYAyCIA Ks7Q== 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=UtDzOnohsLh194D7AL25+1lbrNIY22RcCGWAulXCkLg=; b=a2ea2Af2tDx6c6bCfSW7mPwlePVj5V1Ze5VkVZKl10Y4+q2KAD/khT76HmJCoPTYZJ h07wcruoeI+wwUY7qvR1n2coMBr5U1ZXuuN9Jp05cqIrZ/RSnHJtaFUOGpunPJm618ac W6fjxq3ND5lBCWqbz3pHE4xKE8NCo84znRAYQRr69JwLeLJ1VC9HCBqhrNDgsXnCmvQT wPDUmkGxOEoesB1g76oiAnMc2v6qeLznPx/raPxu6AlV4somvcevfKdxQrJM8+88I+7q wcdJgUAYLBKwbGzSJyikMbyaOMPiOb4cT83nsYhsb1QZv63FOaFv62fdgoUJq5/2wn41 GOJQ== X-Gm-Message-State: AElRT7GXfZXU/AI6LImKaTXTldM8OJZLV9JgPH4jQh04vV1Ul6z3Il/C v8x99COwqfyqGc6s4TxxbiZKrA== X-Google-Smtp-Source: AIpwx4/v9LGLpD0//+qet0wmaIKQMm95aIpCib5D3MTOcGRQM+qZTURc7mVti9d9wF9oX9Fy80D9WQ== X-Received: by 10.98.247.19 with SMTP id h19mr9502283pfi.239.1522410255626; Fri, 30 Mar 2018 04:44:15 -0700 (PDT) Received: from localhost.localdomain ([106.51.29.61]) by smtp.gmail.com with ESMTPSA id r11sm20168370pfg.0.2018.03.30.04.44.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 30 Mar 2018 04:44:14 -0700 (PDT) From: Arvind Yadav To: myungjoo.ham@samsung.com, kyungmin.park@samsung.com, cw00.choi@samsung.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH] PM / devfreq: use put_device() instead of kfree() Date: Fri, 30 Mar 2018 17:14:03 +0530 Message-Id: X-Mailer: git-send-email 2.7.4 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 Never directly free @dev after calling device_register() or device_unregister(), even if device_register() returned an error. Always use put_device() to give up the reference initialized. Signed-off-by: Arvind Yadav --- drivers/devfreq/devfreq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index fe2af6a..a225b94 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -625,7 +625,8 @@ struct devfreq *devfreq_add_device(struct device *dev, err = device_register(&devfreq->dev); if (err) { mutex_unlock(&devfreq->lock); - goto err_dev; + put_device(&devfreq->dev); + goto err_out; } devfreq->trans_table = devm_kzalloc(&devfreq->dev, @@ -671,6 +672,7 @@ struct devfreq *devfreq_add_device(struct device *dev, mutex_unlock(&devfreq_list_lock); device_unregister(&devfreq->dev); + devfreq = NULL; err_dev: if (devfreq) kfree(devfreq);