From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796039618; b=uY89VSrqdQRw5N9ZA904WIeopwAkcPh9dezfenAGK2e1865/xjtB1drhmpuk7FKqgmUO qtEAnaCbumf9FaSjrCab8XN/22XS4zA4rSFhPlcPuVJ6dhC7S7lnK+rUpR7k/tcItp3Xz 2fM0S5MwdXb0ynRnY7/u4ukJdao/2s9SNLWmziOauHwJJSX8EPi07W24kmQVo91qkBjTb jptH1jh6OUAxtgQqf0GXqxz+0mRIV3nC2aCm+jMuisyVncM91R0teWbt49mQClMC243+7 kOSf7soROqslRUbi/bVVAXnaD4oP9DjW+uoySRRZB3EmfHvcWu+W0UJmJ6aZxB7iDsg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796039618; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=PRZ5QtG/mXwgtQWpgD1aap3xYyU/qnPpRxcsAaiB/1s=; b=kG/PZwAbvbrwa8/mh8A3hb77XhCm6q8NDVFcr7VdWy+MUfeYBH6rAw1PrvBt3F5IZpbq sEgZsBOgMmg89r7mQICGdDvETuGg9RzTZVlC/7UmMVkej5mTpbCqciGLOsiWPeKbUVvn1 1a6B5w3JOE7q7FBVz4yRVqwxxYgnsDKQqQiBBOLVGquTDf9/kDuCAf0CIRqnoN6Z9poqv d7G0n5TG86+HnAK4b3prfULlbcv7el5sog1HKAm9wQPkBvcnMtL/E2OixmZHgrimRZzte 5inNcNJ+yXleyZjM7wO55cvDKOR7vcd3HxYqHP/Rc0PRGiZh6micIUUQ/jWEo3poTXg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BzvazWcl; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89E8F606A6AA for ; Mon, 30 Nov 2026 11:53:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BzvazWcl Received: by smtp.kernel.org (Postfix) with ESMTPSA id 269711F00898; Mon, 30 Nov 2026 11:53:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796039618; bh=PRZ5QtG/mXwgtQWpgD1aap3xYyU/qnPpRxcsAaiB/1s=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=BzvazWcl3Z658ai1jlikujzUkMyDRVov7dBRFB8tHYksoRqAbetPGP/bD+nLnuUL4 uvXHLTo1C7YsYgcCvw4Vzm21CYbGTT7UX9yA+yuzlSPTGpNm2I6Cs1ryVUKVZPXbYL fgScmvw8TvCOfEOIHOcERhZWNomXC8nNjuP1EGMRfuL+veD3aHu/D03LCbrrD9IVFg YGLifDC53TH9wt9wpqaUl//Qdq3/ICn6fJinfvDb2k0Ro+y93JYuHyxgvvfXCrsGes ESRiUQPW1ZMBzbG63jXWxiAYEHlw3Kyx1mYbA2Rwy3Cno43EHdnNF3TXd+KRGrjl6s CNZya8GMMc06A== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] usb: gadget: f_uac1: fix return value of string attribute stores Reply-To: sashiko-reviews@lists.linux.dev To: "Lin Tzu Yang" Cc: linux-usb@vger.kernel.org In-Reply-To: <20261130115055.842820-1-rongh7426@gmail.com> References: <20261130115055.842820-1-rongh7426@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 11:53:37 +0000 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list > The configfs store for the f_uac1 string attributes (function_name, > p_it_name, c_it_name and the others) returns the result of scnprintf() > with a size of min(sizeof(opts->name), len). That is at most len - 1, > so every write is reported as short. The writer then writes the rest > again; for the last byte the size is 1, nothing is stored and 0 is > returned, and a writer that retries on a short write never finishes. > Each retry also overwrites the name with what is left, so the name ends > up empty. >=20 > With busybox in a QEMU arm64 guest (dummy_hcd), all of these hang until > they are killed, and the name reads back empty afterwards: >=20 > echo MyAudio > functions/uac1.0/function_name > printf NoNewline > functions/uac1.0/function_name > echo Mic > functions/uac1.0/p_it_name >=20 > This started when snprintf() was replaced by scnprintf(): snprintf() > returned the full length of the string, which is len. >=20 > Do what f_uac2 does since commit 9499327714de ("usb: gadget: f_uac2: fix > return value for UAC2_ATTRIBUTE_STRING store") and commit e60284b63245 > ("usb: gadget: f_uac2: fix non-newline-terminated function name"): > return len, and strip only a trailing newline, so a name written without > one keeps its last character. >=20 > Fixes: c1a371866db9 ("usb: gadget: f_uac1: Replace snprintf() with the sa= fer scnprintf() variant") > Cc: stable@vger.kernel.org > Signed-off-by: Lin Tzu Yang Sashiko has reviewed this patch and found no issues. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130115055.8428= 20-1-rongh7426@gmail.com?part=3D1