Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3032739pxb; Mon, 18 Oct 2021 07:00:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLpHUWozYFjtiuQffdPe4fCyXOB26ys+k9i1L+dqE8hx4HucPZAUd47UXm/ht3os9AUbei X-Received: by 2002:a17:906:3c51:: with SMTP id i17mr30777907ejg.86.1634565620531; Mon, 18 Oct 2021 07:00:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634565620; cv=none; d=google.com; s=arc-20160816; b=lLeuZ9RZnsfTXDChXh30sVVfN06Nx3hGDJQFEdLiOt8t9+a6orri+R29RwAquAg+lr xPb4cO6Vc9QtlMzrdCfnfDrYtmUIU9/NXEmG27TZs0rN7RHSJGXdS8fEEQueytjJkLO/ 1+0xNflywVwmRdV9NoeiiIhcbQX7b5IYvQHR/YI95Yrm1zWSyGOjcQ1fX34MQbcP7uf4 u/puAHh7eC4RI1NVXFmb+snZa1+SDAsiBGO7vdcw1FDohFPst9qtedClLuB1jMVH3Fou Op9Oz0Ymodf7aZN7MDYyy0WlwTA3A5UTISR/AdgExY+hPD3/UB2G+t7tgIso/YconX5N OZXQ== 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=MvGg/ZDM9kc37OPcC86KrVT36Y8hswQ0cIgtnISzZLU=; b=TWGTmOt2X8FfzKY28ufhUDGnPXu522tmYCrXnUpB5qj+y4deJ09PoMy/7+ky26OebS /SLad0oTOT12J2tVwT80cxGUuL40KSKGxEYCW7T2U6NKTXXlLwVIIZV3qXpqwQNT5j2q mRrE9SKOq27lRchZwzrgUYxz8nbeTCNXj+ITLVVU292Y+h37yADCgf+/d7NciKnUYa99 xiJsgzf7BOeDHbpJwR99fSMhF6dkMG6jOQQxv8eOcKrJXzjai09rn1yFm8qYpba7Egy0 g5WB70pFUFKuiLLGPeG+wAIvyHlH0OI9AS/9hHa3T89UGicbmV7DqcYB0De5nhukEKOI BebA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=y8ZKHFKX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 e10si29273996edj.183.2021.10.18.06.59.56; Mon, 18 Oct 2021 07:00:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=y8ZKHFKX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S233801AbhJRN7R (ORCPT + 99 others); Mon, 18 Oct 2021 09:59:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:57658 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232894AbhJRN5P (ORCPT ); Mon, 18 Oct 2021 09:57:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2D42961354; Mon, 18 Oct 2021 13:40:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634564446; bh=MsdUmbpXvV4lcIRozA/dovk6qBH59yfUaSmkIk4/WsU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y8ZKHFKXibUHaJC0LDyVtT0BmsC5XtW7zYos5pE0sOgRI9eqIHw719s69gX5oSnCw YkDZmXn/QAjcFtwj5bqf+i6kNpvZmeb4+ROGioTFJEJH0my34gW8E3DJS/zt4muFku BQHBIbinBYUWH3MYdIN+AQPyhdG7v1/hxbcP/2BQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jens Wiklander , Sudeep Holla Subject: [PATCH 5.14 092/151] firmware: arm_ffa: Fix __ffa_devices_unregister Date: Mon, 18 Oct 2021 15:24:31 +0200 Message-Id: <20211018132343.676268357@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132340.682786018@linuxfoundation.org> References: <20211018132340.682786018@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sudeep Holla commit eb7b52e6db7c21400b9b2d539f9343fb6e94bd94 upstream. When arm_ffa firmware driver module is unloaded or removed we call __ffa_devices_unregister on all the devices on the ffa bus. It must unregister all the devices instead it is currently just releasing the devices without unregistering. That is pure wrong as when we try to load the module back again, it will result in the kernel crash something like below. -->8 CPU: 2 PID: 232 Comm: modprobe Not tainted 5.15.0-rc2+ #169 Hardware name: FVP Base RevC (DT) Call trace: dump_backtrace+0x0/0x1cc show_stack+0x18/0x64 dump_stack_lvl+0x64/0x7c dump_stack+0x18/0x38 sysfs_create_dir_ns+0xe4/0x140 kobject_add_internal+0x170/0x358 kobject_add+0x94/0x100 device_add+0x178/0x5f0 device_register+0x20/0x30 ffa_device_register+0x80/0xcc [ffa_module] ffa_setup_partitions+0x7c/0x108 [ffa_module] init_module+0x290/0x2dc [ffa_module] do_one_initcall+0xbc/0x230 do_init_module+0x58/0x304 load_module+0x15e0/0x1f68 __arm64_sys_finit_module+0xb8/0xf4 invoke_syscall+0x44/0x140 el0_svc_common+0xb4/0xf0 do_el0_svc+0x24/0x80 el0_svc+0x20/0x50 el0t_64_sync_handler+0x84/0xe4 el0t_64_sync+0x1a0/0x1a4 kobject_add_internal failed for arm-ffa-8001 with -EEXIST, don't try to register things with the same name in the same directory. ---- Fix the issue by calling device_unregister in __ffa_devices_unregister which will also take care of calling device_release(which is mapped to ffa_release_device) Link: https://lore.kernel.org/r/20210924092859.3057562-2-sudeep.holla@arm.com Fixes: e781858488b9 ("firmware: arm_ffa: Add initial FFA bus support for device enumeration") Tested-by: Jens Wiklander Signed-off-by: Sudeep Holla Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/arm_ffa/bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/firmware/arm_ffa/bus.c +++ b/drivers/firmware/arm_ffa/bus.c @@ -127,7 +127,7 @@ static void ffa_release_device(struct de static int __ffa_devices_unregister(struct device *dev, void *data) { - ffa_release_device(dev); + device_unregister(dev); return 0; }