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 7E9263D9DD4; Thu, 16 Jul 2026 14:30:37 +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=1784212239; cv=none; b=qDJzE7XhZi7Z1BMWGhEp2+rxbcCOqSHu79Zjv5zPu1ANHEqbSb+FlRz9t0S25m+alu11p/A9p6ZUspJ1b/iOa0fv1m3C+2i9teNBl8p9pFSqZINtD9IA5UT6mwfWZ4YeQo7vGcK4UkBe+HrSyEmM40iuRa5SFdav1angPg7jsjw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784212239; c=relaxed/simple; bh=eJ9tVaHI8PS3+XcdKXPjYfnEcepKMrJz2MM40olTglU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OuzU8H9wfzluDw31NJqQ3JHnQ72MoG3HI6zY1GUq6n2Vbkwvuhbqdif7s60RRCZIBPhGkeAQqJL2riS+PmGnm2V+2I119Mrh2hEYyRLdi7yku36m8SKCNFN82iHORFaJ/LG8JZEg5PkrYoFgAB4o/n/ImOKJGv7OevVHCYPcL/c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=lzs/8gd3; 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="lzs/8gd3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C77EE1F00A3D; Thu, 16 Jul 2026 14:30:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784212237; bh=LjHWl8eTQNJH1EVBD3vq+K3fxm6/6TStbAN/W1v8lUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lzs/8gd3qsn6WekL/ibQg5ODO+4V5rC5hahuBX72+rfJTjdv6PNV+lXUFSKPp66P0 Hpb0RrkxpNnkoXZVtr00DVgt5jiLoadEr9DAA4zIZz6iPxUvi0+4ytxmIXnDPtj4pb ok3r2v8HKcoWZQtt7E/x/AEKTDQHYhIVT+Y0IDYg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Fan Wu , Heikki Krogerus Subject: [PATCH 6.12 252/349] usb: typec: ucsi: ccg: Fix use-after-free of ucsi on remove Date: Thu, 16 Jul 2026 15:33:06 +0200 Message-ID: <20260716133038.989159721@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260716133033.287196923@linuxfoundation.org> References: <20260716133033.287196923@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Fan Wu commit 1f0bdc2884b67de337215079bba166df0cdf4ac5 upstream. The threaded IRQ handler ccg_irq_handler() calls ucsi_notify_common(), which on a connector-change event calls ucsi_connector_change() and schedules connector work. In ucsi_ccg_remove(), ucsi_destroy() frees uc->ucsi (kfree) before free_irq() is called, so a handler invocation already in flight may access the freed object after ucsi_destroy(). CPU 0 (remove) | CPU 1 (threaded IRQ) ucsi_destroy(uc->ucsi) | ccg_irq_handler() kfree(ucsi) // FREE | ucsi_notify_common(uc->ucsi) // USE Move free_irq() before ucsi_destroy() in the remove path. It is kept after ucsi_unregister(): ucsi_unregister() cancels connector work whose handler issues GET_CONNECTOR_STATUS through ucsi_send_command_common(), which waits for a completion that is signalled from the IRQ handler, so the IRQ must stay active until that work has been cancelled. The probe error path already orders free_irq() before ucsi_destroy(). This bug was found by static analysis. Fixes: e32fd989ac1c ("usb: typec: ucsi: ccg: Move to the new API") Cc: stable Signed-off-by: Fan Wu Reviewed-by: Heikki Krogerus Link: https://patch.msgid.link/20260616132011.103279-1-fanwu01@zju.edu.cn Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/ucsi/ucsi_ccg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/usb/typec/ucsi/ucsi_ccg.c +++ b/drivers/usb/typec/ucsi/ucsi_ccg.c @@ -1502,8 +1502,8 @@ static void ucsi_ccg_remove(struct i2c_c cancel_work_sync(&uc->work); pm_runtime_disable(uc->dev); ucsi_unregister(uc->ucsi); - ucsi_destroy(uc->ucsi); free_irq(uc->irq, uc); + ucsi_destroy(uc->ucsi); } static const struct of_device_id ucsi_ccg_of_match_table[] = {