From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oa1-f49.google.com (mail-oa1-f49.google.com [209.85.160.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 B35BD3CCFA8 for ; Mon, 23 Mar 2026 19:29:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774294175; cv=none; b=SwO9hZHxKmiT+v3CMPUmsPGJmnLNdDKB/9VXf7O0rIN2zN9s3EjiBPMCmZkDjmBNV5iz6lfb0xDfigsFKqUA6DvfZNWwgp5gqZeLosGyHrEexxCNLFkBlxkOxww3MAgmXcIZLzIb/ZYnTuWixS2Q5X1ubuAp61OadXUNrvH4ong= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774294175; c=relaxed/simple; bh=xMoxGibXuMUc6L0+HH5osTDZ0vid6ZFv3IzUlbot1eU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=nWEyHaPr6cTNNzUlV+D+4q5L8yLefzn0sABxn7RzUT0d18vHbMZi/SMKazcGnRY31iygXkI9fpLN/z4DzGLKUgkqftfgKAs+3c+CblDpF6udZjN7/SBtt32ny0UN7SfSc+TFUfDuFl2HJ2cq7d+DTWMJgoMSpCSPBxNFWy4ih8Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxfoundation.org; spf=pass smtp.mailfrom=linuxfoundation.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=SkRszr99; arc=none smtp.client-ip=209.85.160.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linuxfoundation.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="SkRszr99" Received: by mail-oa1-f49.google.com with SMTP id 586e51a60fabf-41708f6aa5fso2499022fac.2 for ; Mon, 23 Mar 2026 12:29:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1774294171; x=1774898971; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=jasxQAhbU9CVd/7B3RbQtbVkKGwzkglfllHdmwH1F3s=; b=SkRszr99BqSq2icB32YMzcIlVdwIHSomAnSZ4c8wX8AdP23F5MSOI4qZtQplwh0NGA 7pVAQ0RmrRotIJ5k6isShBWgJmBHCn/Tc8dNCPhmCf/D05umr6gFkE5Z/gXY+QG1gOkj kugH7/jxGuX/jrrOH443zpB/IFBYu5I1TYNr4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774294171; x=1774898971; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jasxQAhbU9CVd/7B3RbQtbVkKGwzkglfllHdmwH1F3s=; b=Bpqo0w8zqEE+f/DPQHqL5QqvoBDp+F9l1lEVCQvP8oQSuQmDcMgsFCsnCfEW5AlSFA oZaI1NnVft1JiII8L+HzH1Y0MQ4Ei8s82oxmb8bEvZGwRYUn8ooidFDV2fXdCHrmI765 vwEUslZ9yWMuNcp1zv0092JZB4Pb0pwEGB9p9rbtsJQM28sJT6z9COxafVvhGT3rWvy+ uPFq2y56VujVQlsYaCLxOcbW/gZfL1dWnpix2dIKpbsva+CjGeFoXmERXXgPMa8T3m86 kdZ9l4fIFtkv3ahAva6OyrcAKET3XGB0iVYSnoBCJhbR8VBhKTfuR5y4WviyDYtefjo1 /D/w== X-Forwarded-Encrypted: i=1; AJvYcCX9RLCn848simQMXNTdQ6x3578UVpOEEpUqvKjTpIJpgVDxri6y+v9I9vsJKupExDaHjhsqPWgfKEq/fJk=@vger.kernel.org X-Gm-Message-State: AOJu0YydF1Qy3cjOeFpoSlRJ1e7PqlBZYxqQeSYY09WHRphonjHLYQ+O xxHtJ0Rfqzp9ldmZmSMn1Ae4tgB1AKAjwYKMRGWPwa4xVSGRws92b1EOmMLC8taI6/w= X-Gm-Gg: ATEYQzyHdI7UyWPvrVCildU1SwChm4DlIJkdvvuoNcgjMFAqn5BSDRMyc/jfhA+ZvSf qxca1ya8abUA1a8vAJt4MPy+z0LM2RAl1yZbDLkXz/h/wwU6nmDFRX0dH6wijApH9Y6CFDq81Rv gWmb9lJOYGQ5iBbTIGMRktl8qKCXQcGVHNXxPy8Mbm+zPaGuRzdQgYCvvHhqMYq5iAstFZcNYXE ATys98GjbtjdmRhgxstPOFFbRPfGbg5MS8ms7S9ggb1zZpT5grbdZ2X62Ijrv99ADVnXWIdaU/L ARoPJWb6Iwc+WtyVU50oI2W6lCMs9DcCmrn3l5h47/h5sEkGiSiWHTQDfwG6cg0dOM2iwkljphb TM2IOfuHsqmfljbFRNy/y7KLXxvy2TCZfulHhA6NThoxmyP/VuprVJfmGEAlR163JNeELwNbjQJ FJsnYPFN+kMXhiHlPc2x5RLXMsAJdGTYIUyWM= X-Received: by 2002:a05:6870:5b90:b0:409:95eb:9618 with SMTP id 586e51a60fabf-41c10f73acfmr7775679fac.17.1774294171127; Mon, 23 Mar 2026 12:29:31 -0700 (PDT) Received: from [192.168.1.14] ([38.175.187.108]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-41c14ddf9d4sm10442421fac.16.2026.03.23.12.29.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 23 Mar 2026 12:29:30 -0700 (PDT) Message-ID: Date: Mon, 23 Mar 2026 13:29:29 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] USB: usbip: drop redundant device reference To: Johan Hovold Cc: Greg Kroah-Hartman , Bastien Nocera , Valentina Manea , Shuah Khan , Hongren Zheng , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Shuah Khan References: <20260305133851.2952-1-johan@kernel.org> <20260305133851.2952-3-johan@kernel.org> <9d727cd2-701e-4c5b-9646-82874f2d0a4a@linuxfoundation.org> <55fcc500-afa5-4ee7-bde8-c5eec6932764@linuxfoundation.org> Content-Language: en-US From: Shuah Khan In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 3/11/26 02:02, Johan Hovold wrote: > On Tue, Mar 10, 2026 at 03:51:41PM -0600, Shuah Khan wrote: >> On 3/10/26 02:35, Johan Hovold wrote: >>> On Mon, Mar 09, 2026 at 02:26:03PM -0600, Shuah Khan wrote: >>>> On 3/5/26 06:38, Johan Hovold wrote: >>>>> Driver core holds a reference to the USB device while it is bound to a >>>>> driver and there is no need to take additional references unless the >>>>> structure is needed after disconnect. >>>> >>>> In this case it is necessary for stub driver to hang on to the reference >>>> to maintain exported device status. >>> >>> But the driver does not hold on to the reference taken at probe after >>> disconnect returns. The stub device itself is even freed at disconnect >>> and cannot be used to release the reference. >>> >>> Which exported device status are you referring to here? >> >> I am referring to the device status that usbip host exports to >> the client side. The interaction between host and client is >> handled from stub rx, tx, and also event handler. >> >> Having the reference to the device helps so the device sticks >> around until the stub driver no longer needs it so we don't see >> use after free type issues. > > But the driver drops the reference that it takes during probe at > disconnect, which makes that reference completely redundant as driver > core guarantees that the device won't go away while a driver is bound. > > So that particular reference doesn't help with anything. I am concerned about stub_rx and stub_tx running to handle any packets that come in after while stub driver is in the middle of disconnect. Currently it has the reference while it handles reset events coming from event handler in usbip_in_eh() and until shutdown_busid(busid_priv) is complete. We can make this change and run it through some tests. thanks, -- Shuah