From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 6CEEB41D63D for ; Thu, 16 Jul 2026 13:06:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784207196; cv=none; b=usmp2CdvEmdD3Y5RGNctKTIRaVHLkb5yGTlHe7ui87wwz8LXXHvEsJ+76G5fOqHiUnegJ7arGml4UQMvbollt0BFuAOPJMBnyXuBwKRkA8/hK/WKUrYSRgeSt25ALHPLoUtpZQkzjc9h10+dVQt5pK7vwThKYGn/YDXuRmZIb+E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784207196; c=relaxed/simple; bh=Xi7+jkfRvixEDvKlKdgn1NOAnmqgxRp4hdWWqNrs+k0=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nXDpNZGKQj92moW/0ERUITdkBaGhQz9gi9Xntv+45tWvwIOPiDPMXGLakHoH3OfiBFinPmnxb2iqFy/4ZimSnj8iktpOvk3O8K2JROTWU4pjBApq/MfIYyux0OEzd2vxpZTcVFwGBivA/IJqUX/0yAdt9yPBUVavOnrncU2PZJM= 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=hY0fT25Y; arc=none smtp.client-ip=209.85.221.50 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="hY0fT25Y" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-475417f010dso3368490f8f.2 for ; Thu, 16 Jul 2026 06:06:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784207194; x=1784811994; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=KEMlLAfIDEgrnJc15jx3TtSOL+Fpd+jn7wn3mxNGSgU=; b=hY0fT25YFXTneyADhMqzDIKXAbIRqRtWFFok0ZFX6kc1bxNugv5Au80eS/45MeeOXw /rmQyxp2qMF6/OQnb1Ex/wLJWyp/kzP6YdtI1worlUERS+9NiUATCYXQ+tAKmJRobk/a sjW/faHxNXS1DJaHa6cHUkPxIquAcS21eBMuSd9v6YtM9105bn8sGPX93KsBwdCNjviP GFf9QK/Ttx+iY7r1FQyvODB9bk93FKmrdUl4YBKbvfOcKTYfikHvlaA9JIX4l186nHxi f5gsIRNhtnVjyjP3MK8H6KH0NP0YGrxuAkHf16j0jYOMHg9CEts1WerI/jofJE/PokqZ gfOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784207194; x=1784811994; h=content-transfer-encoding:content-type: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 :content-type; bh=KEMlLAfIDEgrnJc15jx3TtSOL+Fpd+jn7wn3mxNGSgU=; b=qEt4Ruk0t4uRwcB4gzwhyNOpng8i7hJdVXvNnpnXKAoESU7vYRQvsILu9oFsnwgJrc bc/rf/gsywJhZqhIbF6kBy+0HS6sH9gYgObzkL6uegqunI39xT+cz4PRRKhnI6LVlr4S IuXiZFjzKy8vApR2OJ+X456UUZ/4R3t255T44IkOLFKv4dmX0s+aBR75wJFG7lQq32JD 6t+8ooBhq3o3CmIxjOi2g1gKiZi2+wEB1NijGSe/phtgb+tHO2oMtzNQmLM8pDoR6HQ9 EXd22pLSvpCRp1j4L/0+kbWXoI4uscXmmlDsEh/4M0m0Ne8ZExBLkYPst4acQZ0DalfK 0rqg== X-Gm-Message-State: AOJu0YwvwJrtfjYMQ3+XxSqrH9VWC5NhwqmK3rqb9ao220gHkDbe5fj1 7ZfwPZuvV3rVPNZsMSBBtyG5+WNhxyE/x9TVxyJ34crJeThPamfqAvysJQyklUTe X-Gm-Gg: AfdE7clQNJnZseIIXpHwiHGMqQT32wNzoOoFUXOuTtrghnVqhxjnKwwha5L3B3/Q6Yk yTnw8vmPhn9NQuMiLUmebDZ41/yG6xb8ZlI9Upx7Om+oGcHq29Ew5O8WTOhIjjX3r2oDnbms+S+ D+k5nlqkF7hlaClWRWwdNxY+wi6wjoFastjSqDRxyfpNycED/0Sr0oMf3NbDVSdxQvWq+Rx7Xq9 4fKFhdOuP1HpQxXFFtO//MG5Ih5ZGowUyURf8rz4/8CLu2cuNLmDA9h38rj/t1+D7N03DfXSCYW eG0Dl+joGY2rXOpIGA2uvEwcKCoMMNUOz1lyEP1DjNI+EllMIFgWG9jWqSqIfpZ2F+ptWkPi5dT 5l6G/o80xJEA3eX8elWaspZeoBsPLU1YAIh0UbfAmdf0I2ilfyZg0Oj1HVFpHrj5MNZJ/ZXsLBm pJE6EuZ8+uIlUAU1ZNaHfefTnmHjrnDkFVyJkLiFs= X-Received: by 2002:a05:6000:3107:b0:475:f0f0:9efe with SMTP id ffacd0b85a97d-47f4fcf2282mr8392037f8f.53.1784207193466; Thu, 16 Jul 2026 06:06:33 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f464b7f09sm24735322f8f.26.2026.07.16.06.06.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2026 06:06:33 -0700 (PDT) Date: Thu, 16 Jul 2026 14:06:32 +0100 From: David Laight To: syzbot Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: Forwarded: [PATCH] usb: misc: uss720: fix memory leak by replacing usb_unlink_urb with usb_kill_urb Message-ID: <20260716140632.0a9249fe@pumpkin> In-Reply-To: <6a58c9f2.577457d1.8bd2.0021.GAE@google.com> References: <6a588d44.c96faac9.59e0.0011.GAE@google.com> <6a58c9f2.577457d1.8bd2.0021.GAE@google.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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 Thu, 16 Jul 2026 05:09:22 -0700 syzbot wrote: > For archival purposes, forwarding an incoming command email to > linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. > > *** > > Subject: [PATCH] usb: misc: uss720: fix memory leak by replacing usb_unlink_urb with usb_kill_urb > Author: kartikey406@gmail.com > > #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master > > > kmemleak reported memory leaks in uss720_probe() during device > initialization. The leaks occur because kill_all_async_requests_priv() > was using usb_unlink_urb() which is asynchronous and returns immediately > without waiting for the URB completion callbacks to finish. > > This caused a race condition where kref_put() in the probe_abort path > would run before async_complete() had a chance to call destroy_async(), > leaving the URB, request struct (uss720_async_request), and transfer > buffer (dr) unreferenced and leaked. > > Fix this by replacing usb_unlink_urb() with usb_kill_urb() which blocks > until the completion callback has finished, ensuring destroy_async() > runs and frees all associated memory before kref_put() is called on > priv. > > Since usb_kill_urb() may sleep, it cannot be called while holding a > spinlock. Drop and reacquire the spinlock around each usb_kill_urb() > call. Also switch to list_for_each_entry_safe() to safely handle list > modification during iteration, as destroy_async() calls list_del_init() > on the current entry. > > Reported-by: syzbot+56962eb32ba0136cd330@syzkaller.appspotmail.com > Closes: http://syzkaller.appspot.com/bug?extid=56962eb32ba0136cd330 > Signed-off-by: Deepanshu Kartikey > --- > drivers/usb/misc/uss720.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c > index 1ce48f5832d7..f43fbb28044b 100644 > --- a/drivers/usb/misc/uss720.c > +++ b/drivers/usb/misc/uss720.c > @@ -175,13 +175,15 @@ static struct uss720_async_request *submit_async_request(struct parport_uss720_p > > static unsigned int kill_all_async_requests_priv(struct parport_uss720_private *priv) > { > - struct uss720_async_request *rq; > + struct uss720_async_request *rq, *tmp; > unsigned long flags; > unsigned int ret = 0; > > spin_lock_irqsave(&priv->asynclock, flags); > - list_for_each_entry(rq, &priv->asynclist, asynclist) { > - usb_unlink_urb(rq->urb); > + list_for_each_entry_safe(rq, tmp, &priv->asynclist, asynclist) { > + spin_unlock_irqrestore(&priv->asynclock, flags); > + usb_kill_urb(rq->urb); > + spin_lock_irqsave(&priv->asynclock, flags); I'll take a bet on that not being correct. The _safe() only lets you remove the current item. So if the list can be changed by someone else it doesn't help. Possibly this is tidy up code and the lock just isn't needed? Maybe the head of the list should be removed under the lock? (and the rest of the tidy up done at the same time.) David > ret++; > } > spin_unlock_irqrestore(&priv->asynclock, flags);