From patchwork Mon Dec 28 12:44:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 352665 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp9778032jai; Mon, 28 Dec 2020 06:14:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJyT9J6djo/mnjC84fcjoeiXcbG4DGIonABFAhW7B0d44iXOjDANxKA/8Q7DCUZ/oYNbu1W1 X-Received: by 2002:a17:906:c83b:: with SMTP id dd27mr42501023ejb.356.1609164740163; Mon, 28 Dec 2020 06:12:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609164740; cv=none; d=google.com; s=arc-20160816; b=s+3DWlsAEuzp8ICy04R31ytYOpy/zNZI5k/gdJVN0Mi3M5/J+JSFpsEzWGx7K+u/zz rQMchddB/LkZDB3DOnLVJ/BmqoDBrK2EmEjtmldDKThrD6uz75qcL/ZR7Vw48nWIwu31 EwCsjFlJVHpTkelAS+8iibBaf58UXSLS1rJNcWDTmIB3CXpJCM6pIa22LwMiRnmm3knV zW0IAlF8rE7yUAV91sm+6LLqBNrivYX2IdJVDa38Qb1/CgPddZ52O8tfTKpUHAkpnLgD NP1ZUoatj15QUtRP3BVfDNK1R7greL0A9rij67ge33kuUhqRjPTb+oe3NcvrV0AzURdq QDKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=87JyqhJ8RvJ+CV6c/TYCeUMqpsDcqg0oX0coD1JpVFo=; b=bg3xlIF+i4V6DdwFe763DUR/Iwe4csPi9qvLD4moZHWWb0VJ2Ob7kuWhkselQnq5vz Ql+KO8FVO0h0bnpm3k8uC2wMxyxMxo+dAwp+THy3n8r4Hwtvw1soOV4jfnzFVw6T9As2 QMOmtY1aNJ34da0o/ux3HF+aEqS+HJ9WE+FiEROVpIY74OzyRyuB1fG0ewx9wdJcP+YL j7DbQqFNQ6hyhJJV0haCSFieZqOoEViS0ZZAOr5FtCce3MTyTG2bz+jzfFgme+mJ3cxH gP+0abFyi3j04sip8nWNPnCfI0w7q45sC6EreLy0wcruxaPMigoUXSyoiQHmfa29JkCS Ymmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Xq6/wAvC"; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k17si18222178ejc.181.2020.12.28.06.12.19; Mon, 28 Dec 2020 06:12:20 -0800 (PST) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Xq6/wAvC"; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439704AbgL1OLk (ORCPT + 14 others); Mon, 28 Dec 2020 09:11:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:46202 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439679AbgL1OLj (ORCPT ); Mon, 28 Dec 2020 09:11:39 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id AD214206D8; Mon, 28 Dec 2020 14:10:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609164659; bh=TXmHWA5i4ADZoYAD6YP/2ICw8bmzH/5PlNx/ghfPBEc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xq6/wAvCaFhAcUB5vyguemU+0rQfEGnfphipWQu/8Fg7V1kP48NESvMF9gSDaNgaJ cPM0WYbq8442HzHf1wURekUoNMiWvzhcSDuD9AgDZLmyPZg4UwGw/DyHYrv7t2pbVZ 14GH1qMoVSnEOo0pFK/qjzv02bLRKwOm1npbJXlg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Cristian Marussi , Sudeep Holla , Jassi Brar , Sasha Levin Subject: [PATCH 5.10 253/717] mailbox: arm_mhu_db: Fix mhu_db_shutdown by replacing kfree with devm_kfree Date: Mon, 28 Dec 2020 13:44:11 +0100 Message-Id: <20201228125033.106476023@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Sudeep Holla [ Upstream commit 9905f728b0bda737fe2c2afd7c24f3365a45cc7b ] The mhu_db_channel info is allocated per channel using devm_kzalloc from mhu_db_mbox_xlate which gets called from mbox_request_channel. However we are releasing the allocated mhu_db_channel info using plain kfree from mhu_db_shutdown which is called from mbox_free_channel. This leads to random crashes when the channel is freed like below one: Unable to handle kernel paging request at virtual address 0080000400000008 [0080000400000008] address between user and kernel address ranges Internal error: Oops: 96000044 [#1] PREEMPT SMP Modules linked in: scmi_module(-) CPU: 1 PID: 2212 Comm: rmmod Not tainted 5.10.0-rc5 #31 Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform, BIOS EDK II Nov 19 2020 pstate: 20000085 (nzCv daIf -PAN -UAO -TCO BTYPE=--) pc : release_nodes+0x74/0x230 lr : devres_release_all+0x40/0x68 Call trace: release_nodes+0x74/0x230 devres_release_all+0x40/0x68 device_release_driver_internal+0x12c/0x1f8 driver_detach+0x58/0xe8 bus_remove_driver+0x64/0xe0 driver_unregister+0x38/0x68 platform_driver_unregister+0x1c/0x28 scmi_driver_exit+0x38/0x44 [scmi_module] __arm64_sys_delete_module+0x188/0x260 el0_svc_common.constprop.0+0x80/0x1a8 do_el0_svc+0x2c/0x98 el0_sync_handler+0x160/0x168 el0_sync+0x174/0x180 Code: 1400000d eb07009f 54000460 f9400486 (f90004a6) ---[ end trace c55ffd306c140233 ]--- Fix it by replacing kfree with devm_kfree as required. Fixes: 7002ca237b21 ("mailbox: arm_mhu: Add ARM MHU doorbell driver") Reported-by: Cristian Marussi Signed-off-by: Sudeep Holla Tested-by: Cristian Marussi Reviewed-by: Cristian Marussi Signed-off-by: Jassi Brar Signed-off-by: Sasha Levin --- drivers/mailbox/arm_mhu_db.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.27.0 diff --git a/drivers/mailbox/arm_mhu_db.c b/drivers/mailbox/arm_mhu_db.c index 275efe4cca0c2..8eb66c4ecf5bf 100644 --- a/drivers/mailbox/arm_mhu_db.c +++ b/drivers/mailbox/arm_mhu_db.c @@ -180,7 +180,7 @@ static void mhu_db_shutdown(struct mbox_chan *chan) /* Reset channel */ mhu_db_mbox_clear_irq(chan); - kfree(chan->con_priv); + devm_kfree(mbox->dev, chan->con_priv); chan->con_priv = NULL; }