From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4040C2C028C for ; Thu, 29 Jan 2026 08:56:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769677002; cv=none; b=B8OpP/uqobYdM7t4Ve8rgUrCRs4FGAjRs7Wb22REw6jK/MTExhsebc6kEZwI+CdzaDCOg2V71kLvAPp5b023Lhkj9Xt5vwCCjex6tCj5zRHztpL89F2z6hSVXlv7EBDhg3wS4OtlZD1B4j5E0ovFTtHPsyzQ44sWDEBQGH4dCEk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769677002; c=relaxed/simple; bh=Jc+itJLFI7nZrOGiVGvgpQwW4Pcfy6oWEaHovGrRsyI=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EXomC8mir7jp5x/FTqONeFDjXvX1Mk9YTn1Bwkwxf+dAJ5Ef2UE0V8et0tAuASTUGJjJYDWkQekKd7iqoAUOafdsfqhrVoit6vdeHnA4IcGuXTjrzbibHp908z7Ik9akp2key6WL2UIg7bsRt/I9h1MNdJf8SOyw1ePGY4Sh3H0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TEnUrwcg; arc=none smtp.client-ip=209.85.167.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TEnUrwcg" Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-59b6f04cae6so676791e87.2 for ; Thu, 29 Jan 2026 00:56:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769676999; x=1770281799; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=KG9xWqkx9/gF4du2pqNNAT1bO7cWgGHdinzUlqAxblE=; b=TEnUrwcgzvqUEfeMUFi8oGZgANM0sLjjtuudMaMHNkHgNpzOy5YpPoxQBlv39UVSkX UVjEZohWgzfZc2C3I5oZcQXAaSnKEo3MGSxImtNh/WGDtYz7CZtMyvjHqPRturs3doOo U7nrbpQfGhRfKeeJXxhRL3kW/zONl47O0PHS4UvPk6NEJKgua6g3ZzHHrAanZ/GO+kv0 hf0bOEMS593C8RDwcHniT5Hn+pZ6H3kmLxw8+nj7kT/YOONV9BKuotwE5YrRxplTO4U0 S1wQXRUlk8epcsQ1SuPwJ1O2RqnKZrgkDY/U809s+3tQnTB7YAg7DR8TVJ86ne4/usNd HwNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769676999; x=1770281799; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=KG9xWqkx9/gF4du2pqNNAT1bO7cWgGHdinzUlqAxblE=; b=r61TKJilqXQEvP6us83VX5jDkt3MZDSvNpcnoBqiX4jEY5i3JDLZBBXqjgk8/xuyau voNF66TqnOkx5ck/G0WEnE6NIIX3BEB5ajFRlWXvhi5dmoyp5OgDrW2zm0jUH21Xcsg6 /RI82BNXYp8i9dMgh9WRCp+ZPgDXUnLAVEiyfzrpofrs9nZqYwgd41ElVFc37wUoX7C3 iWJQsnMy8uD+7CG4JO4hLJRsjndSnoJJpAEJm6cIWLva62AFmikgZzcvy+HiKwlZgoch t+THDm4MOzlMJCXmy06Lj4icIkW84NDa853x1iYZ1MjPQe/O2LtiiAz6mOdh+PHDIR2H 8tdw== X-Forwarded-Encrypted: i=1; AJvYcCUi611vdiQ0NAWPRDDNrO9c6G91hIDnio8rC4hR+Yd7gu29q/6ZN1fymhLZC6huCYvBYvUwHFQjpz8g9Lw=@vger.kernel.org X-Gm-Message-State: AOJu0YwYS5hamJKNKwB7fePss/7MkkgNqOq8vAZBwrpSoF9MbRQyAJxw Zl6LCA0viWwNm3Fxjpq6MvDfglXkyii4NglVT/tM0cwRg8Os8FBbTRuf X-Gm-Gg: AZuq6aKMm+GqEx/Qx3vpPFZ5wqVOC0pyUJP4EUwYiIDxEnD8mp9EUWcQy965MRAy2U2 5lU7NwNuANlpWUrKcbWQ2bp0SxC64VdULvTFg/WJR7crQ+6LQ873UvWjzgIK6BZxImm6fvZUVCf mO5zpdFcXapltY21OaO2/Ea6xlVdzTO0AfEGV4+1Zcdrpuw80EZNVR6I9wNLnyYUJmXgHtFlGyo Bqu6bZzSWKLU23BAIrFwt7Bhv0IMUfok0YoKREEHkh1RX8DEYIltRYoV/Gi6bn/+WCISh01Th6j bbranu0xqxigUxf5Loy9aF9I9cWSEukandr3FAa4AV2fNMEQ0l+NG81XXswZtMV9XzwfBPjJ8GF 5aYAqq4iVQuU2SITXfOrUyuL8pjX1HAddGTWTZj/zSbKexAAEv6koeG2WU4v7i+JWKK4Y/TIIkB hJ+fSnNUJDIA7Laf5OQ8IWWBA= X-Received: by 2002:a05:6512:159b:b0:59d:d342:88af with SMTP id 2adb3069b0e04-59e04017dc1mr3548716e87.16.1769676999124; Thu, 29 Jan 2026 00:56:39 -0800 (PST) Received: from foxbook (bgw148.neoplus.adsl.tpnet.pl. [83.28.86.148]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-38625fcd5bfsm7575811fa.47.2026.01.29.00.56.38 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 29 Jan 2026 00:56:38 -0800 (PST) Date: Thu, 29 Jan 2026 09:56:34 +0100 From: Michal Pecio To: Zilin Guan Cc: mathias.nyman@intel.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, jianhao.xu@seu.edu.cn, stable@vger.kernel.org Subject: Re: [PATCH v3] usb: xhci: Fix memory leak in xhci_disable_slot() Message-ID: <20260129095634.0775dc40.michal.pecio@gmail.com> In-Reply-To: <20260109045410.1532614-1-zilin@seu.edu.cn> References: <20260109045410.1532614-1-zilin@seu.edu.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 9 Jan 2026 04:54:10 +0000, Zilin Guan wrote: > xhci_alloc_command() allocates a command structure and, when the > second argument is true, also allocates a completion structure. > Currently, the error handling path in xhci_disable_slot() only frees > the command structure using kfree(), causing the completion structure > to leak. > > Use xhci_free_command() instead of kfree(). xhci_free_command() > correctly frees both the command structure and the associated > completion structure. Since the command structure is allocated with > zero-initialization, command->in_ctx is NULL and will not be > erroneously freed by xhci_free_command(). > > This bug was found using an experimental static analysis tool we are > developing. The tool is based on the LLVM framework and is > specifically designed to detect memory management issues. It is > currently under active development and not yet publicly available, > but we plan to open-source it after our research is published. > > The bug was originally detected on v6.13-rc1 using our static analysis > tool, and we have verified that the issue persists in the latest > mainline kernel. > > We performed build testing on x86_64 with allyesconfig using > GCC=11.4.0. Since triggering these error paths in xhci_disable_slot() > requires specific hardware conditions or abnormal state, we were > unable to construct a test case to reliably trigger these specific > error paths at runtime. > > Fixes: 7faac1953ed1 ("xhci: avoid race between disable slot command > and host runtime suspend") CC: stable@vger.kernel.org > Signed-off-by: Zilin Guan This looks like correct fix to an actual bug, but it seems that it has been missed? I see it neither in usb-next nor usb-linus or mainline. The leak is still there, even if arguably a small and rare one. Regards, Michal