Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7151489ybi; Mon, 8 Jul 2019 15:41:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqwR1XOb41GMQckQznRuvnVIViMDIsunxcqiBjYuVmGH+UvmP35+Sm2Yc/YKG2tmQUIZzGqY X-Received: by 2002:a17:902:4283:: with SMTP id h3mr27112904pld.15.1562625662799; Mon, 08 Jul 2019 15:41:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562625662; cv=none; d=google.com; s=arc-20160816; b=bxLWerKlBGYDKq40qeQt83ZHO0j9PkIs4/HyLlHwWaX/YYZV+/4FiXXAFsfWo3sEL1 J+yAw0yDR7HkiqcBDcgJwmya4qzzKom0sJ/jBTJna8/YbvCKl5CybK4PrMNvxm0JdnVT aEr0o7Y75u/8h4R8EmTvuz6dyMLZb1pTxnlJF0oxuroDMGu6h1dbqD4XOKmvlNvqlxKy LZNB3jiCcVTXxThFBjB+uu/djUas7MuKBu66QrUWlT67FLcz1Id3B6atvMOGyuJwRxJV 13bsvrq9pbsvy7iNoPWdU21Jp79TtMrq4WO4hBLnxstgDnhtW2/b3zmDsPM/JXhgTsZ1 0CqA== 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=0w5RKr92PuTf5KNXXJ0pGoT22Kb9QFEsFw9VVtBULcE=; b=gKC2lAAovdIlqnjNou79FwB7zx1JUgmUS9fWikTlIa4//K+3VMjImubaxuge5GxK5h Z3KbaC4FZcFDhAR3uIxCmJwBUs+VbR7iaoMe2me0liCgy+rQK4ZU4sk+Dx+zBpcw2RoI NNuaacNgtdjnIGTNQhZzFwAJJT3YTlkIMI60wng+V6c4Roljzf7wmSnrbq7FlMg2vS8G f4cjfMAfpyfbwpNJF8r0vVS1tyy5suM09jzWYj24Uz3wB4T6XEPe4XMPABFXSxMAfKb1 2Q7kDRL3EjW4GLOxFJzTLLGtDFw4aZh+vaJR2c4haZFXg78pRJThZLgui5gJ3QJvyw+d Qszg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TEiaGyBT; 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 y19si12899762pll.326.2019.07.08.15.40.48; Mon, 08 Jul 2019 15:41:02 -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=@kernel.org header.s=default header.b=TEiaGyBT; 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 S2390869AbfGHPfB (ORCPT + 99 others); Mon, 8 Jul 2019 11:35:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:37172 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390618AbfGHPes (ORCPT ); Mon, 8 Jul 2019 11:34:48 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 5F18B204EC; Mon, 8 Jul 2019 15:34:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562600086; bh=jOGAo5Kf6rRcDT4LicwRH4ehDO0TFEjE18kYIJhuJN0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TEiaGyBTDWF1Z4qLtzxywUmmetxWC1q5nZscYRmlGutiN1zoYjXk8JopjaDonPnoF V5slMUdo/NwfNwfxRoG56KimSfrd9PRKCK8Irco/NNnJnsOVyybB4tYFjfD4AMgKJ8 NEHhkiZqTdIg1DNNmqmPf5q+rq9Z9QiI/SSNFbpA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vadim Pasternak , Andy Shevchenko , Sasha Levin Subject: [PATCH 5.1 47/96] platform/mellanox: mlxreg-hotplug: Add devm_free_irq call to remove flow Date: Mon, 8 Jul 2019 17:13:19 +0200 Message-Id: <20190708150529.065200329@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708150526.234572443@linuxfoundation.org> References: <20190708150526.234572443@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit 8c2eb7b6468ad4aa5600aed01aa0715f921a3f8b ] Add devm_free_irq() call to mlxreg-hotplug remove() for clean release of devices irq resource. Fix debugobjects warning triggered by rmmod It prevents of use-after-free memory, related to mlxreg_hotplug_work_handler. Issue has been reported as debugobjects warning triggered by 'rmmod mlxtreg-hotplug' flow, while running kernel with CONFIG_DEBUG_OBJECTS* options. [ 2489.623551] ODEBUG: free active (active state 0) object type: work_struct hint: mlxreg_hotplug_work_handler+0x0/0x7f0 [mlxreg_hotplug] [ 2489.637097] WARNING: CPU: 5 PID: 3924 at lib/debugobjects.c:328 debug_print_object+0xfe/0x180 [ 2489.637165] RIP: 0010:debug_print_object+0xfe/0x180 ? [ 2489.637214] Call Trace: [ 2489.637225] __debug_check_no_obj_freed+0x25e/0x320 [ 2489.637231] kfree+0x82/0x110 [ 2489.637238] release_nodes+0x33c/0x4e0 [ 2489.637242] ? devres_remove_group+0x1b0/0x1b0 [ 2489.637247] device_release_driver_internal+0x146/0x270 [ 2489.637251] driver_detach+0x73/0xe0 [ 2489.637254] bus_remove_driver+0xa1/0x170 [ 2489.637261] __x64_sys_delete_module+0x29e/0x320 [ 2489.637265] ? __ia32_sys_delete_module+0x320/0x320 [ 2489.637268] ? blkcg_exit_queue+0x20/0x20 [ 2489.637273] ? task_work_run+0x7d/0x100 [ 2489.637278] ? exit_to_usermode_loop+0x5b/0xf0 [ 2489.637281] do_syscall_64+0x73/0x160 [ 2489.637287] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 2489.637290] RIP: 0033:0x7f95c3596fd7 The difference in release flow with and with no devm_free_irq is listed below: bus: 'platform': remove driver mlxreg-hotplug mlxreg_hotplug_remove(start) -> devm_free_irq (with new code) mlxreg_hotplug_remove (end) release_nodes (start) mlxreg-hotplug: DEVRES REL devm_hwmon_release (8 bytes) device: 'hwmon3': device_unregister PM: Removing info for No Bus:hwmon3 mlxreg-hotplug: DEVRES REL devm_kzalloc_release (88 bytes) mlxreg-hotplug: DEVRES REL devm_kzalloc_release (6 bytes) mlxreg-hotplug: DEVRES REL devm_kzalloc_release (5 bytes) mlxreg-hotplug: DEVRES REL devm_kzalloc_release (5 bytes) mlxreg-hotplug: DEVRES REL devm_kzalloc_release (5 bytes) mlxreg-hotplug: DEVRES REL devm_kzalloc_release (5 bytes) mlxreg-hotplug: DEVRES REL devm_kzalloc_release (5 bytes) mlxreg-hotplug: DEVRES REL devm_kzalloc_release (5 bytes) mlxreg-hotplug: DEVRES REL devm_kzalloc_release (5 bytes) mlxreg-hotplug: DEVRES REL devm_kzalloc_release (5 bytes) mlxreg-hotplug: DEVRES REL devm_kzalloc_release (5 bytes) mlxreg-hotplug: DEVRES REL devm_kzalloc_release (5 bytes) mlxreg-hotplug: DEVRES REL devm_irq_release (16 bytes) (no new code) mlxreg-hotplug: DEVRES REL devm_kzalloc_release (1376 bytes) ------------[ cut here ]------------ (no new code): ODEBUG: free active (active state 0) object type: work_struct hint: mlxreg_hotplug_work_handler release_nodes(end) driver: 'mlxreg-hotplug': driver_release Fixes: 1f976f6978bf ("platform/x86: Move Mellanox platform hotplug driver to platform/mellanox") Signed-off-by: Vadim Pasternak Signed-off-by: Andy Shevchenko Signed-off-by: Sasha Levin --- drivers/platform/mellanox/mlxreg-hotplug.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/platform/mellanox/mlxreg-hotplug.c b/drivers/platform/mellanox/mlxreg-hotplug.c index 687ce6817d0d..f85a1b9d129b 100644 --- a/drivers/platform/mellanox/mlxreg-hotplug.c +++ b/drivers/platform/mellanox/mlxreg-hotplug.c @@ -694,6 +694,7 @@ static int mlxreg_hotplug_remove(struct platform_device *pdev) /* Clean interrupts setup. */ mlxreg_hotplug_unset_irq(priv); + devm_free_irq(&pdev->dev, priv->irq, priv); return 0; } -- 2.20.1