Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2511766imm; Mon, 24 Sep 2018 05:43:01 -0700 (PDT) X-Google-Smtp-Source: ACcGV61K0yPYImhuE0hCyYiPC6TUvxKqbJuRQXQrQKGG269CE8NybGmPVMNd4OIcWiQR4uX8aYnW X-Received: by 2002:a17:902:b03:: with SMTP id 3-v6mr10809946plq.156.1537792981086; Mon, 24 Sep 2018 05:43:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537792981; cv=none; d=google.com; s=arc-20160816; b=sIcGURRPy8pmoTT5iMFaRkjkuhdmvG6+gRqeiBIr6XFY/1iErleC6t9bFmfj3NF1wp sopgKm1OUtM7ICt8S6IYsl7FQr4XxZm1A6B7Nya2ZoJMM0aW6gIhzLVgCgwpHLWq+84V NP7JUWgQi0nb4iLLYUUnnY7f6rEW3N24IIoUjJskCUZi2pxoC/bxEcKfV+l+3zm50npN msYSKqy2TeSAqgCwlnvnFWe56n0Nq9ZysGHV4oNj2+i3FV64RDo+R+B59XGmZyjhwTd2 oeIA6J2H7NdmAcXnzXEi+LWLLPjsy1ohpElmYlj3P257Wurl3n+g8LQbCfDe7CT8pSiY 7S4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=uzMTjAAq8DHsA7iAYji3J/v6XUK+O8WXN51hYeq3dgQ=; b=nj4tWA34O9D8+9tycg+mz1vLwRgLRAMV7pdATQ++/eKdlRmVjxYdIidYUozot6m0vt EvbfR0tluH5PA47FYBvnbzGr19FqC0JRU2XTGzxE5lVkhXOooRtsNmF+F55HH3jtblke vfQjQctslVoBXo3hC6FGysSDsIDg3/g6c265YbLiJk5ZdBHFSPoEYzf1Vf4hVs/OX4Wp UQynQTeJqcFlpAkkT5NW+ntE81Qvlj4tBSunqJsij2kHrbqz+JT24ArKlBAkCR6q//Ln 2isaOS6JhTW+OkEKkA8kGyH88GcCxyGy8J/JyKA4kA3QYTniscGKAmLDzH4kZWJKwBxL Xe4Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si13866172plx.140.2018.09.24.05.42.45; Mon, 24 Sep 2018 05:43:01 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388597AbeIXSm0 (ORCPT + 99 others); Mon, 24 Sep 2018 14:42:26 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58978 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733259AbeIXSmZ (ORCPT ); Mon, 24 Sep 2018 14:42:25 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id CA4F3109A; Mon, 24 Sep 2018 12:40:27 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arvind Yadav , Chanwoo Choi , MyungJoo Ham , Sasha Levin Subject: [PATCH 4.18 158/235] PM / devfreq: use put_device() instead of kfree() Date: Mon, 24 Sep 2018 13:52:24 +0200 Message-Id: <20180924113121.029746065@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Arvind Yadav [ Upstream commit 2d803dc8f7a5f622ac47c3b650834ada3a2659b9 ] 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 Reviewed-by: Chanwoo Choi Signed-off-by: MyungJoo Ham Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/devfreq/devfreq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -625,7 +625,8 @@ struct devfreq *devfreq_add_device(struc err = device_register(&devfreq->dev); if (err) { mutex_unlock(&devfreq->lock); - goto err_dev; + put_device(&devfreq->dev); + goto err_out; } devfreq->trans_table = @@ -672,6 +673,7 @@ err_init: mutex_unlock(&devfreq_list_lock); device_unregister(&devfreq->dev); + devfreq = NULL; err_dev: if (devfreq) kfree(devfreq);