Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp814553imu; Tue, 11 Dec 2018 08:01:03 -0800 (PST) X-Google-Smtp-Source: AFSGD/U9Pjdvy+njkiov4grJzl0TNLOFneYVVLsr8rsAvyGYbZX7KP/qY12S5uxHbkopUgOn75Nw X-Received: by 2002:a63:2054:: with SMTP id r20mr15002610pgm.328.1544544063075; Tue, 11 Dec 2018 08:01:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544544063; cv=none; d=google.com; s=arc-20160816; b=dlg8REob5k5hspClj5WQKS7UlITOjFEdE6NUmWLnWF1toEt60UToDZvuVKrY6T9UAy lMZxNChPd6bYQU7oLXqdqCxC6NoOMkNSsbPXD9tjgjBMyW9sO8sIjNKtV7yWJpzYvYJZ iPqBh0O9JKWmCDPj/y9uC1QbgKN73nTJtVlc7UZNZWKns5wgTnj8JbZBWdSO3Qep47dz 9slBoH40QSSCWuem0U00bPm2lkx2gsXN8oJ7dt6LX74CvrK5fHSgvVkgbZ7aUzAnRUlJ LJiCXU87QApclLEzoD1U892eJr5P1GZ0WUur7erU9tA68OLBYdUTWN5og/oe48T7Pp0N A06A== 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:dkim-signature; bh=z8/U+HilEumi07kjt3Wi37tBQBOR9i+xjGksdoWJvko=; b=HsviqFK5SM2iV8GqeCMNeP2gv2zjQswa2yL2+FUlCC2caLeRxXNMsOGXj9YlLbYzmy JEy/q9WUF1d2JYpes/NiabP+sOUUSZ9jSlJAB0qEcurVz1fM6kNXtsaht4pgslyjWLxd EuNTiQKTDdNNNYChaVRxlX76vtUWN6oWky8z4Q1eDPBHw7dLL9C2lTINxCNYosXs6Ws8 12ifpyo8V1CB8LDVPRfcHrSj6X7vMLecJPj7x11G++R/FeuVD8PU1RzCJDSmO/ICqTvU 3OflDV6+UAQ2Wc8cUn5V6HsEtW9l0sBBFIBlqVrh5CeFhc1M1f8w+vKYVaoSoXcpGUbC OR8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0zwQ6ion; 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 z5si12144689pgh.469.2018.12.11.08.00.48; Tue, 11 Dec 2018 08:01:03 -0800 (PST) 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=@kernel.org header.s=default header.b=0zwQ6ion; 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 S1730916AbeLKP5x (ORCPT + 99 others); Tue, 11 Dec 2018 10:57:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:46738 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730872AbeLKP5m (ORCPT ); Tue, 11 Dec 2018 10:57:42 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A4A8320855; Tue, 11 Dec 2018 15:57:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544543861; bh=A7rPtlATfV6vf+4gGG0uRb4TvgT+XrZiGBrnw+TdlA4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0zwQ6ionCj61n4wUzUnCY3FH+Tblf4aohcOWE1geHM5JRRaaxnmAnVytuQdhFDwO6 h/D47OR2m1uPIVGw6EwQttIF7Qw1/syxKEsVPAc0va4JLFBPxjoPuOh8eUEusiw+gF VGrmYWbWp+2qjPyML33zbouPBnnTH2/B0QklzMiM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Enric Balletbo i Serra , Guenter Roeck , Dmitry Torokhov , Lee Jones Subject: [PATCH 4.19 075/118] Revert "mfd: cros_ec: Use devm_kzalloc for private data" Date: Tue, 11 Dec 2018 16:41:34 +0100 Message-Id: <20181211151647.284558725@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181211151644.216668863@linuxfoundation.org> References: <20181211151644.216668863@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Enric Balletbo i Serra commit 48a2ca0ee3994df53da230c7079a18a70ec914f9 upstream. This reverts commit 3aa2177e47878f7e7616da8a2050c44f22301b6e. That commit triggered a new WARN when unloading the module (see at the end of the commit message). When a class_dev is embedded in a structure then that class_dev is the thing that controls the lifetime of that structure, for that reason device managed allocations can't be used here. See Documentation/kobject.txt. Revert the above patch, so the struct is allocated using kzalloc and we have a release function for it that frees the allocated memory, otherwise it is broken. ------------[ cut here ]------------ Device 'cros_ec' does not have a release() function, it is broken and must be fixed. WARNING: CPU: 3 PID: 3675 at drivers/base/core.c:895 device_release+0x80/0x90 Modules linked in: btusb btrtl btintel btbcm bluetooth ... CPU: 3 PID: 3675 Comm: rmmod Not tainted 4.20.0-rc4 #76 Hardware name: Google Kevin (DT) pstate: 40000005 (nZcv daif -PAN -UAO) pc : device_release+0x80/0x90 lr : device_release+0x80/0x90 sp : ffff00000c47bc70 x29: ffff00000c47bc70 x28: ffff8000e86b0d40 x27: 0000000000000000 x26: 0000000000000000 x25: 0000000056000000 x24: 0000000000000015 x23: ffff8000f0bbf860 x22: ffff000000d320a0 x21: ffff8000ee93e100 x20: ffff8000ed931428 x19: ffff8000ed931418 x18: 0000000000000020 x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000400 x14: 0000000000000143 x13: 0000000000000000 x12: 0000000000000400 x11: 0000000000000157 x10: 0000000000000960 x9 : ffff00000c47b9b0 x8 : ffff8000e86b1700 x7 : 0000000000000000 x6 : ffff8000f7d520b8 x5 : ffff8000f7d520b8 x4 : 0000000000000000 x3 : ffff8000f7d58e68 x2 : ffff8000e86b0d40 x1 : 37d859939c964800 x0 : 0000000000000000 Call trace: device_release+0x80/0x90 kobject_put+0x74/0xe8 device_unregister+0x20/0x30 ec_device_remove+0x34/0x48 [cros_ec_dev] platform_drv_remove+0x28/0x48 device_release_driver_internal+0x1a8/0x240 driver_detach+0x40/0x80 bus_remove_driver+0x54/0xa8 driver_unregister+0x2c/0x58 platform_driver_unregister+0x10/0x18 cros_ec_dev_exit+0x1c/0x2d8 [cros_ec_dev] __arm64_sys_delete_module+0x16c/0x1f8 el0_svc_common+0x84/0xd8 el0_svc_handler+0x2c/0x80 el0_svc+0x8/0xc ---[ end trace a57c4625f3c60ae8 ]--- Cc: stable@vger.kernel.org Fixes: 3aa2177e4787 ("mfd: cros_ec: Use devm_kzalloc for private data") Signed-off-by: Enric Balletbo i Serra Reviewed-by: Guenter Roeck Reviewed-by: Dmitry Torokhov Signed-off-by: Lee Jones Signed-off-by: Greg Kroah-Hartman --- drivers/mfd/cros_ec_dev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/drivers/mfd/cros_ec_dev.c +++ b/drivers/mfd/cros_ec_dev.c @@ -263,6 +263,11 @@ static const struct file_operations fops #endif }; +static void cros_ec_class_release(struct device *dev) +{ + kfree(to_cros_ec_dev(dev)); +} + static void cros_ec_sensors_register(struct cros_ec_dev *ec) { /* @@ -395,7 +400,7 @@ static int ec_device_probe(struct platfo int retval = -ENOMEM; struct device *dev = &pdev->dev; struct cros_ec_platform *ec_platform = dev_get_platdata(dev); - struct cros_ec_dev *ec = devm_kzalloc(dev, sizeof(*ec), GFP_KERNEL); + struct cros_ec_dev *ec = kzalloc(sizeof(*ec), GFP_KERNEL); if (!ec) return retval; @@ -417,6 +422,7 @@ static int ec_device_probe(struct platfo ec->class_dev.devt = MKDEV(ec_major, pdev->id); ec->class_dev.class = &cros_class; ec->class_dev.parent = dev; + ec->class_dev.release = cros_ec_class_release; retval = dev_set_name(&ec->class_dev, "%s", ec_platform->ec_name); if (retval) {