Received: by 10.213.65.68 with SMTP id h4csp240843imn; Fri, 30 Mar 2018 04:45:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/Pw4IwlBq0gVJbKGRs6SeFJpn19W2C1Hmzhs2iRrXDAvENVQZ0NugzaWr0uBpKdHC4KuAD X-Received: by 2002:a17:902:6bc1:: with SMTP id m1-v6mr12727932plt.111.1522410348787; Fri, 30 Mar 2018 04:45:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522410348; cv=none; d=google.com; s=arc-20160816; b=wLqsmSo6aH17QbSwRXQ1ZDxyQar3PGYyPqy6Wfl9/8P7W7KLYFBLwK/0EJnASagwLQ ptU5IfcSnytfzGXoBTn8OkqQseRJv0iUgT5+Gc2Qrz8s2etIUNtNo8aciJVMJhK6tSY1 GR8XKSg4pBSBYkXSXYaGAoYS0tXjHGHJV6ZvHSWrdcyTmSMKaMftnYn35ygBVjYVu0qL SieVJLnuYGIOikexO8t6x+bCaTfZNbS2Zfw0xhscCRJudHDzV6VJGTFJUlOhAz0ulNJi cTP3epHoA218TwmoF5wOSNZ1JABmjgG3vfOr9ThQm6S/Ey3wDT0dVfJIT4IIP7xtRK1B 8OgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=UtDzOnohsLh194D7AL25+1lbrNIY22RcCGWAulXCkLg=; b=u2Hp3hQ1WeDi68YXkVPi4P/VGQ5TDltbYNd5w0r2VCXaO7B6a1GcFKLN5gI+6jvVw6 HlECBdUORKLBEINwKEr9QWA+9cNHobus5VftyoekzjA9Wwuedw5+sUVzh+7vC06TUl5J UIvoX0Ul5BidQrrEamko3weoHzplVTZjv6+2VcBTaSUIHvfj+3m7W6JGMzmqyPz5rt+u Ypd5NihG2iriJXd0fg4BvCFGFLy/3w/NheymCl2jctVKpa8FzLuBp3iuwWPdtpLU0JDY nW9KuvhP2HWyChVnhhP79KTzMEBhctkjaVUX61HXpmcM/pPlkFpbNtRCEpFLXlbbp0J5 JktA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ix9Ix7eC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c12-v6si843704plo.216.2018.03.30.04.45.34; Fri, 30 Mar 2018 04:45:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ix9Ix7eC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752195AbeC3LoT (ORCPT + 99 others); Fri, 30 Mar 2018 07:44:19 -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-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.7.4