| Message ID | 20260416023021.626949-10-sjg@u-boot.org |
|---|---|
| State | New |
| Headers |
Return-Path: <concept-bounces+u-boot-concept=u-boot.org@u-boot.org> X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306659; bh=QZqPUm/wM7iBKhtpityoqZA1PXe83sx2we4XuWu81XU=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=rly4ocIppACwkwx9J6W52QXtls1hPKVAKmkJqQH2u4n6OnBRmSJR/x7bAvCaeYvDV PJrKStEWwjiiC1nyIZ3tbHqrKxTRKyX8+91BzQTai/oRIBJsNWkakxO6/VfqRdJaeJ 8SodYtcWYbMNw5Ixccz4iWFqJ36kjw5/EAdX72Fc= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 32F8C6A4A6 for <u-boot-concept@u-boot.org>; Wed, 15 Apr 2026 20:30:59 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id o8Zu_f36-KPi for <u-boot-concept@u-boot.org>; Wed, 15 Apr 2026 20:30:59 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306659; bh=QZqPUm/wM7iBKhtpityoqZA1PXe83sx2we4XuWu81XU=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=rly4ocIppACwkwx9J6W52QXtls1hPKVAKmkJqQH2u4n6OnBRmSJR/x7bAvCaeYvDV PJrKStEWwjiiC1nyIZ3tbHqrKxTRKyX8+91BzQTai/oRIBJsNWkakxO6/VfqRdJaeJ 8SodYtcWYbMNw5Ixccz4iWFqJ36kjw5/EAdX72Fc= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 21E696A44C for <u-boot-concept@u-boot.org>; Wed, 15 Apr 2026 20:30:59 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306656; bh=ttZqhPBTOs3qMZ0Ml99mx3jiKOKrV2wGGsRmlhFIdlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fw0L4N1t0J7TjmMmc8ql4ZRaEnqjrwuhrKX6jpfYlWqj/rXPd1GXA/kfVCQQQnRvJ V0O5ylVjoN+d4C1CpS8kye3oJ2mZ6MCMiP6hqsvmZXOtirigZXpKry0FBkwGXceJwy X5xLPZGO5ndGU0FyjNBxTV5njkBZ9ED8F5zN23QA= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D46546A4A5; Wed, 15 Apr 2026 20:30:56 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id reOrEUJdxcYT; Wed, 15 Apr 2026 20:30:56 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306655; bh=TV8G1/91LpCr9tTteY1d8pGxZ84v5XJWsZmw6V1+QcE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jASKZAhnP9zsQf9hJP0R6PsCqvlcEaitHjvRayT0j3VaL+Bq84R2zSNl2uE9ppwP9 +Q99jNGM02S7llTdq8i6OmoAP5ZFQOlypUcPzpuVElZ0GX4+xVMzp9GklYYcaBY8pG PWipHgvnLRe1+QJJ8Qoe5MmQX4Fix3hJZodlTeLg= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B0D866A4A0; Wed, 15 Apr 2026 20:30:55 -0600 (MDT) From: Simon Glass <sjg@u-boot.org> To: U-Boot Concept <concept@u-boot.org> Date: Wed, 15 Apr 2026 20:29:34 -0600 Message-ID: <20260416023021.626949-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260416023021.626949-1-sjg@u-boot.org> References: <20260416023021.626949-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: OQJUF3F5PRHTVD44XC3GGH2Y4AQITOZV X-Message-ID-Hash: OQJUF3F5PRHTVD44XC3GGH2Y4AQITOZV X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass <sjg@chromium.org> X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 09/33] usb: Drain finished scan threads after run_threads List-Id: Discussion and patches related to U-Boot Concept <concept.u-boot.org> Archived-At: <https://lists.u-boot.org/archives/list/concept@u-boot.org/message/OQJUF3F5PRHTVD44XC3GGH2Y4AQITOZV/> List-Archive: <https://lists.u-boot.org/archives/list/concept@u-boot.org/> List-Help: <mailto:concept-request@u-boot.org?subject=help> List-Owner: <mailto:concept-owner@u-boot.org> List-Post: <mailto:concept@u-boot.org> List-Subscribe: <mailto:concept-join@u-boot.org> List-Unsubscribe: <mailto:concept-leave@u-boot.org> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit |
| Series |
Fix memory leaks and test pollution in sandbox tests
|
|
Commit Message
Simon Glass
April 16, 2026, 2:29 a.m. UTC
From: Simon Glass <sjg@chromium.org> run_threads() loops until uthread_grp_done() reports that every thread in the group has finished. But uthread_schedule() only frees 'done' threads it walks past on the way to the next runnable one - so when the last thread completes, its uthread struct and 32 KB stack sit in the list until something calls uthread_schedule() again. Nothing does, so each usb_init() leaves one thread behind. Call uthread_schedule() once more after the loop exits to drain the tail. Signed-off-by: Simon Glass <sjg@chromium.org> --- drivers/usb/host/usb-uclass.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index a7ac18a7a83..c2c6b79efde 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -375,6 +375,12 @@ static void run_threads(void) return; while (!uthread_grp_done(grp_id)) uthread_schedule(); + /* + * uthread_schedule() only frees 'done' threads it walks past + * on the way to the next runnable one. Call it again so it + * drains the tail of the list and releases the last thread. + */ + uthread_schedule(); nthr = 0; grp_id = 0; #endif