Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp716090imj; Wed, 13 Feb 2019 16:23:16 -0800 (PST) X-Google-Smtp-Source: AHgI3IZCQWlT/PyDU//5ekNRBovU94QlTFXWXDSwAV30BydffKEaFvAHYtkfKamF9/i7pa6jQOwC X-Received: by 2002:a63:ef50:: with SMTP id c16mr925545pgk.3.1550103796326; Wed, 13 Feb 2019 16:23:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550103796; cv=none; d=google.com; s=arc-20160816; b=ZyGEFW5HXSpVqakCbxMEkmy0V+1Xsrd17kcs1cEqth/ngsBgI0PLyLCz0LzUDeGys5 B4gU5VRYfXR6+/ZR4K9N6QOCwWZOCMmqiJhewxU4CNIu98cfbBluUEFZiaujtMCfPWOI QQBvlN7EbUjjnWgjj6g1bIHu1ChkfKzsBFc7YM5GsYtzXJ/6l33mHHFqzMRiObPvaEwt Nam388dtZrI1V/nO7xMON+sm+P7ft3D8ul3oY75YtAcPxFNKW36mHd0k39aXUshgK/ut VOQLNZVWwd64lH7WCfhWVVPCIm+s2LNLmtvgWhV0CtHH9zb7/PVgSOwKweNkyLLMKh9u 0U4A== 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=xtRvew+clIZxKfnTWJWfp7+vRZc6lUuXzHTq6Ibep3Q=; b=hVLS4DPyy5veQ1kqSuswt4wOdzp9/N/k94CK021RAbF7hz8keL7ufmh9Gbxqpff5L5 gkOP5c0m3B4HAVl/q/k+Jfh1RA7ezoRZT32bCM4MQW2acui+StAU53fPqM4b3VtwdqrO 3BGynX/jIZ/QAnB7ft7lU7En+S8SQv+XFrMYCD4jVyXokJo388dx9zBvLfxNxvcQr6I5 ApR+IoKJWePUor8SxLHlDcoSD+Mb8ZTr4z/z2v9mp3ILcnFcQFDjgrUwQ6t6rJ9m1J0p sipFOVs5OXQ5MU8U7Qz4ZSvQfU3OYj0hlVAXLBctqMxIGZoBsCffGNuLFf/IxAER39Jq N0lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=y4nWsfaN; 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 e125si705403pgc.411.2019.02.13.16.23.00; Wed, 13 Feb 2019 16:23:16 -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=y4nWsfaN; 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 S2390287AbfBMSsu (ORCPT + 99 others); Wed, 13 Feb 2019 13:48:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:44548 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730819AbfBMSp4 (ORCPT ); Wed, 13 Feb 2019 13:45:56 -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 E073B20811; Wed, 13 Feb 2019 18:45:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550083555; bh=i9RPEOaBnAnS0wO5pb7AMApP4zMj5RK5u00kKQZDTv8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y4nWsfaNj183e6F6hCseCgHG7Tc+uNAMLJluapjACqa/tO7fi9kCAMws23yk0liBF 4I2RksZKKz4ars2p2hWDopPiqiieD2n52DN/pxEtOViAo+4MHpPttb9dikUu8Qz6uI ds9JTJtoZMrDimVuHp7MTl7HG5IbmseaukQA/6gg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sudeep Holla , Arnd Bergmann Subject: [PATCH 4.20 32/50] firmware: arm_scmi: provide the mandatory device release callback Date: Wed, 13 Feb 2019 19:38:37 +0100 Message-Id: <20190213183658.291475193@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190213183655.747168774@linuxfoundation.org> References: <20190213183655.747168774@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.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sudeep Holla commit 46edb8d1322c1763dd04e179992f8e9996085047 upstream. The device/driver model clearly mandates that bus driver that discover and allocate the device must set the release callback. This callback will be used to free the device after all references have gone away. scmi bus driver is missing the obvious callback which will result in the following warning if the device is unregistered: Device 'scmi_dev.1' does not have a release() function, it is broken and must be fixed. See Documentation/kobject.txt. WARNING at drivers/base/core.c:922 device_release+0x8c/0xa0 Hardware name: ARM LTD Juno Development Platform BIOS EDK II Jan 21 2019 Workqueue: events deferred_probe_work_func pstate: 60000005 (nZCv daif -PAN -UAO) pc : device_release+0x8c/0xa0 lr : device_release+0x8c/0xa0 Call trace: device_release+0x8c/0xa0 kobject_put+0x8c/0x208 device_unregister+0x30/0x78 scmi_device_destroy+0x28/0x50 scmi_probe+0x354/0x5b0 platform_drv_probe+0x58/0xa8 really_probe+0x2c4/0x3e8 driver_probe_device+0x12c/0x148 __device_attach_driver+0xac/0x150 bus_for_each_drv+0x78/0xd8 __device_attach+0xe0/0x168 device_initial_probe+0x24/0x30 bus_probe_device+0xa0/0xa8 deferred_probe_work_func+0x8c/0xe0 process_one_work+0x1f0/0x478 worker_thread+0x22c/0x450 kthread+0x134/0x138 ret_from_fork+0x10/0x1c ---[ end trace 420bdb7f6af50937 ]--- Fix the issue by providing scmi_device_release callback. We have everything required for device release already in scmi_device_destroy, so we just need to move freeing of the device to scmi_device_release. Fixes: 933c504424a2 ("firmware: arm_scmi: add scmi protocol bus to enumerate protocol devices") Signed-off-by: Sudeep Holla Cc: stable@vger.kernel.org # 4.17+ Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/arm_scmi/bus.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/drivers/firmware/arm_scmi/bus.c +++ b/drivers/firmware/arm_scmi/bus.c @@ -119,6 +119,11 @@ void scmi_driver_unregister(struct scmi_ } EXPORT_SYMBOL_GPL(scmi_driver_unregister); +static void scmi_device_release(struct device *dev) +{ + kfree(to_scmi_dev(dev)); +} + struct scmi_device * scmi_device_create(struct device_node *np, struct device *parent, int protocol) { @@ -138,6 +143,7 @@ scmi_device_create(struct device_node *n scmi_dev->dev.parent = parent; scmi_dev->dev.of_node = np; scmi_dev->dev.bus = &scmi_bus_type; + scmi_dev->dev.release = scmi_device_release; dev_set_name(&scmi_dev->dev, "scmi_dev.%d", id); retval = device_register(&scmi_dev->dev); @@ -156,9 +162,8 @@ free_mem: void scmi_device_destroy(struct scmi_device *scmi_dev) { scmi_handle_put(scmi_dev->handle); - device_unregister(&scmi_dev->dev); ida_simple_remove(&scmi_bus_id, scmi_dev->id); - kfree(scmi_dev); + device_unregister(&scmi_dev->dev); } void scmi_set_handle(struct scmi_device *scmi_dev)