Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2489930pxj; Mon, 10 May 2021 04:21:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYyluge5ZPEdEHimFrNIDJi7wkpqEfBKp6MCNLkAyJ4LQaeAkMysbkdXFZCDiZQCmA7k0w X-Received: by 2002:a05:6638:3398:: with SMTP id h24mr12753548jav.114.1620645676743; Mon, 10 May 2021 04:21:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620645676; cv=none; d=google.com; s=arc-20160816; b=r4rEzejowBlzGKNSH1PvsbOTymNI+HAuMd6xQSqn8f+Y1eAo2afk4fSjbmOjEONciF 5hZ0yf8UTCUvqMoNFCr7agVvsX8O/sMHRhsT/rJYxgtrNOP3yjHWhHcqQAvzQJnU+oOe x3QM5rI6wpR9stK1Uru9G5nl6a+6ApQwBhuEBsFZypvOJ7fRK51BMww+C3wxZY9c9DsC DC0t4pJJbVxFlm7fKP5mn5FTsJili4tDf9MDr/Gzl4u9tDoHwFXAFTr4mLLDtvN72kiJ 4alhmAFtfQ3kdFFp0/oe3X5VmmsEkwinru65vRBOXat9O9pHujVDkvbiRXdoH73kGxHA V7Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9T1lZyPUX364XimA+5S8B8pe11jcn7UMpD1MjM5I6Ho=; b=qaf6cemdeOATIu2mCkxFrtjFQq/eDJgH9GvqpV+uKw7kt21zC1WMhovNXTmizPKXPb 1ULQozAprjfXeBYXdIVUG4HxvwkKS//Yy6xIqOhTfFlOONCDKVQJLhloITxITgC4BWCI AR4uWmoHSqIHgTHQuQGNAXP5b2RFexuCc4VTDIPXCjwmLNOsh0C7K4cgwZS8E/Z7ocsC Ku5vhkXlzLafLJ+70jahYzOHmEzpi+8p7VPxn0m/gqKpQ44yOyFmJeEG+oYSDQrupDWW XnBP9oBDPEkXPbu2l/AagtjlSGPNmstoadjUUGOUqHOkOZNS69cJQ8MFL2w9lv1EIBMU uiTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MEaSyYic; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o8si15167657ilu.133.2021.05.10.04.21.04; Mon, 10 May 2021 04:21:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MEaSyYic; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238740AbhEJLSm (ORCPT + 99 others); Mon, 10 May 2021 07:18:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:52714 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233848AbhEJKzb (ORCPT ); Mon, 10 May 2021 06:55:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AC35D61C24; Mon, 10 May 2021 10:42:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643357; bh=7BYIszUXuT/A65QEXgor+800HHR3fKGQh2+t2C5FD1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MEaSyYicIdXmV1LntIz87PdT7htQXKamcJqZWXcgYDHNmefgdm9f+j/IvsH6xuZO/ VAbfi1MFD4Dx/c4y5oNTV/AWpF/uzC1/ed/Fxk/ENnPcN2GuQJqOcHNjHeKeyhgSgA TIGjQGJ5Waah4sZstjsmpbzwF6l9yKwNHx/CoeCU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dean Anderson Subject: [PATCH 5.10 283/299] usb: gadget/function/f_fs string table fix for multiple languages Date: Mon, 10 May 2021 12:21:20 +0200 Message-Id: <20210510102014.274462771@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dean Anderson commit 55b74ce7d2ce0b0058f3e08cab185a0afacfe39e upstream. Fixes bug with the handling of more than one language in the string table in f_fs.c. str_count was not reset for subsequent language codes. str_count-- "rolls under" and processes u32 max strings on the processing of the second language entry. The existing bug can be reproduced by adding a second language table to the structure "strings" in tools/usb/ffs-test.c. Signed-off-by: Dean Anderson Link: https://lore.kernel.org/r/20210317224109.21534-1-dean@sensoray.com Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/f_fs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -2639,6 +2639,7 @@ static int __ffs_data_got_strings(struct do { /* lang_count > 0 so we can use do-while */ unsigned needed = needed_count; + u32 str_per_lang = str_count; if (unlikely(len < 3)) goto error_free; @@ -2674,7 +2675,7 @@ static int __ffs_data_got_strings(struct data += length + 1; len -= length + 1; - } while (--str_count); + } while (--str_per_lang); s->id = 0; /* terminator */ s->s = NULL;