Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp309865pxj; Thu, 20 May 2021 09:49:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoFQzXQ+gjKkzwL9/J7BEt4pI1Eiy67TI38vHA55mPmDTf4v2inwtpNhx3XF+q2a0Cj0i9 X-Received: by 2002:a17:906:a415:: with SMTP id l21mr5521558ejz.233.1621529358266; Thu, 20 May 2021 09:49:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621529358; cv=none; d=google.com; s=arc-20160816; b=rsaUvMb4xIluAkeGX67TmDkvg1tOwvGK+FKuFWZh3osvETW9b0o0Wm1KF+GvBN2u8u pPZmIusV2hvDEOUtHXddmWxG5yHNrYMZtZcDVH7BFeCXxl5leAzSwTGFWyEb24rjOJsY zJfYG2pcZJpBfKGMmtOwUH+LJKr6YZpk0aAUYnhlgr+A3/1Hf+NbeuxtR2GOG4/IB4ZX PxH0wSCQrDk6H5glP1R7RfbQtQWJ/UsNhv4W7OkFyjNHDpsHbRg3PfW5SxOi2mfuftlt MMXDeQPHB0f1WbB8yM241a1PKOnXzWCscXbYuL/ENrvHUg7lfx6VOEXARtfKUxQ0pryh 4RsQ== 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=eWHyMUr7dtBeu5UkBdaTFJElkf2Q2/1hUKbl0/XUfbk=; b=AE45X9jOcsEg/C0EMPrf8AWPuvGwWjDXA04yIb+o0ditKG1QCbB/nksqJk6lzE7/em rKm/b0GEANU1XYdZwSBCDEJDwOQzxBNyhoquYFDieKQqCPf/E2wdugCfBSbbjbYZ0FD6 yirStH32SJq20k8czCaclzfMKVTfI+TfqpbbOvD82h33H8fmiQGEA57ivECTSZTs4/r0 I3e+uFw+v3xcqGAJUl/iEvDdbH90d7njRKA+ve/nMsW+hBHkqncuUsAJI4OfxMoSFjLO Ag4QC9V2b2R+qt17c2L0bgZUXgT/0pk6DiEDiNrVbPLIzLZGmi2vMFjFJO+Y9Ti3xFOS V4Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="see6obA/"; 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 h15si2918551ejt.69.2021.05.20.09.48.54; Thu, 20 May 2021 09:49:18 -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="see6obA/"; 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 S234048AbhETJuW (ORCPT + 99 others); Thu, 20 May 2021 05:50:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:47072 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234059AbhETJrp (ORCPT ); Thu, 20 May 2021 05:47:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 374E161279; Thu, 20 May 2021 09:34:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503265; bh=0C39oF1Adiz30Kou+5CiRp1eIga+ZyUYVS3iHXzomdY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=see6obA/ig9mywfVgEkqz9seBWQE4Yekm7p4eLNIfHVvr4ddUAFJTDLO+4+qeB4hB Mkan2v4MNi1pdao5TsDZYFz++qCYTmH+qrLljbZ5pHgYGygHKr692/xhcrA72igyZs V+7o1M/wPYP3G98fC1/y9MXG45QOoEIH46M7p9BA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dean Anderson Subject: [PATCH 4.19 109/425] usb: gadget/function/f_fs string table fix for multiple languages Date: Thu, 20 May 2021 11:17:58 +0200 Message-Id: <20210520092135.034026932@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@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 @@ -2553,6 +2553,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; @@ -2588,7 +2589,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;