Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2521749pxj; Mon, 10 May 2021 05:07:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx90EnnD2pAgQSCuUZZ41XdH9ech0JXDpa1L/9Cme5n4y4+NClq5Fuyp6I5FNFsxwvVq5vg X-Received: by 2002:a5d:9694:: with SMTP id m20mr17849191ion.40.1620648325817; Mon, 10 May 2021 05:05:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620648325; cv=none; d=google.com; s=arc-20160816; b=I+9koHdepFzHA+nbasV+KOniwvX1XPqj4CH1AewN/Z/dsz/vCcsA22EajdHXXHxtge 5Fg5KsQbuSCglxI2h/81JOIYJD1M3sQRQmTHcSGcowNqiHD2f/0qv45tdwxiUm8knOIL VM+9PoKrSEkUjrcrYIsmWjEt9amEIEuJqnmbx9YkGKVto3GVWePCJHdJ5fGMg9Nzj8f7 LRKgsAifk/iuiC6F/hRl3495sQMWoq6lhAqfOzbk6AQlMyxYFd6vHInP3n1VDRuM01Uq JwJ/2ZeD19CSq0G+uZ0a8IM+zpLCd740AWnXU7Sop15/m/gT+22aKTPBjCxjOKBnfuOx g30w== 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=chfVkcK9ywPZdOSJsjZgZLIZkblibA38MbjsaPUJpAk=; b=h5ri39WqR+/vclk0EH16hen8OiCtNzs3pyC+PPM1pEutA4xLRMOeCsab+NTNcN3SPC XemSLtXCKfFZGUgGO4mQstSI4lIp9INI/Wfg37vtqYQsbiTcm7l4C0ufihHaLsyPMfGd CRjmiJV0qGy1VlgKMD6xfjJ0PDxaqBYqeW+IV2Rhk6D7NhnxH8KcOs8x1IyWFoMtZcHU SLu49HjvVijD1g9so7A7lLz+1AMJWMVBqDLyCcmZXHupPay/er4d7HEKvUEYKb+mxjb2 ZNBqpKd0Wa59lUdOT4A4pmBnM+wj0XMN6eVmhyK/OMEJqsF6VujcaHfra6Lol28NY7tS OIVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bawCVYpx; 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 j6si2794316ilr.104.2021.05.10.05.05.12; Mon, 10 May 2021 05:05:25 -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=bawCVYpx; 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 S244681AbhEJL7u (ORCPT + 99 others); Mon, 10 May 2021 07:59:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:41148 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235964AbhEJLHG (ORCPT ); Mon, 10 May 2021 07:07:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AEF976162D; Mon, 10 May 2021 10:57:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620644238; bh=BnQ2WjSQ5Q+TNsP6SxVor3xEFQL6n8L3r6/lM4WX5ug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bawCVYpxq7MfriyLO8hLdnle5wYtbtg6n2RbyfrJ65bLBU1uxHbJlakAyZpskpVP6 Uvt1cyzUX6h71R+ugkZIQzeScJ5MUaWZeO4woVZqp7MHAGYG0QryGkzg6NxfJGDP09 8J6hQod5SIDZWSdK8X8A2f3qdblhBHS0tOyOlIOo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dean Anderson Subject: [PATCH 5.11 324/342] usb: gadget/function/f_fs string table fix for multiple languages Date: Mon, 10 May 2021 12:21:54 +0200 Message-Id: <20210510102020.818049337@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102010.096403571@linuxfoundation.org> References: <20210510102010.096403571@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 @@ -2640,6 +2640,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 (len < 3) goto error_free; @@ -2675,7 +2676,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;