From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B240937FF50; Sat, 12 Sep 2026 19:31:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789241514; cv=none; b=WNsqkOu2L9NpaIeGur5TQPETu1n02KrlWX3/p5I3KxXet1JGwNXINgSDIFP7VoaiWEfJRqRx3J6+ZxrlXEyBhzzgBjSCvT7kkcIXZmXeo3qyrKsg6qrUvSUVcgTuhks8QCWS5fugOCuxarTBnLNxAPa3/ucS04QwdNH+VGsMbnI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789241514; c=relaxed/simple; bh=KRkTr01JjNswG0082yRDvMRY2TjVX0tcxvhWH/o6udA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N2aJ3WQmg6LhcIKP5qvxq8Tzoe253j0Qz20kfMnw+m0cUh985b6U0rdayobqUtx4v4anN1BYxinw4gbJACysEoCnZ30Ceq8/pss3ziLz9GNX+7z57xmCeSswvfup5TRESMMh+ELDsLiRW1u7Wxp0DKrpQ/20n8xX2bpsocPUlHI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=IsVFhqhr; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="IsVFhqhr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B826D1F000FF; Sat, 12 Sep 2026 19:31:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789241512; bh=l9s4cmttBPMPzAiPUOi03mknUxuAdycqo6NkzBoAuw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IsVFhqhrB341cvvsU04qfS/dqKTS/X74j8+lo3g88gohZmEwMNz6CM1JX1Gmu8ROT oup82IrdAjvHjRBTc7QgxHSaRXzNjikM89tHAEvZpjj1aEHeGzguoQz1wtT/vvU25N E4jSwWKJ/v1cAvGblA0hJjsLS9QDckJCu7+E7HsQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Fan Wu , Jason Gunthorpe Subject: [PATCH 5.10 108/798] RDMA/cxgb4: Cancel reg_work before freeing device on remove Date: Sat, 12 Sep 2026 08:55:36 +0200 Message-ID: <20260912065519.435341824@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065516.948645775@linuxfoundation.org> References: <20260912065516.948645775@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Fan Wu commit a7100601aa1a39f799a566acce10db20eaf4b7f2 upstream. c4iw_uld_state_change() queues reg_work to register the RDMA device. c4iw_remove() can free ctx->dev while this work is pending or running, leaving c4iw_register_device() accessing the freed device. Cancel reg_work before removing the device. The registration work can tear down ctx->dev when registration fails, so do not unregister or deallocate it again in that case. This issue was found by an in-house static analysis tool. Fixes: 1c8f1da5d851 ("iw_cxgb4: Fix possible circular dependency locking warning") Link: https://patch.msgid.link/r/20260806130128.465460-1-fanwu01@zju.edu.cn Cc: stable@vger.kernel.org Assisted-by: Codex:gpt-5.6 Signed-off-by: Fan Wu Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/hw/cxgb4/device.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/infiniband/hw/cxgb4/device.c +++ b/drivers/infiniband/hw/cxgb4/device.c @@ -953,6 +953,12 @@ void c4iw_dealloc(struct uld_ctx *ctx) static void c4iw_remove(struct uld_ctx *ctx) { pr_debug("c4iw_dev %p\n", ctx->dev); + + /* c4iw_register_device() may still be using ctx->dev. */ + cancel_work_sync(&ctx->reg_work); + if (!ctx->dev) + return; + debugfs_remove_recursive(ctx->dev->debugfs_root); c4iw_unregister_device(ctx->dev); c4iw_dealloc(ctx);