Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp575130pxj; Thu, 20 May 2021 16:40:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3vVnn+L802kGR2qHu90DKwT9icPvlXGwO2o+dAYjq32q+HQPT8C0KKMTHIgj0KwYGi4Y5 X-Received: by 2002:a05:6e02:13ec:: with SMTP id w12mr8500431ilj.285.1621554057739; Thu, 20 May 2021 16:40:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621554057; cv=none; d=google.com; s=arc-20160816; b=gPG3oVSLLTL+egEDHcQJaGhru1aMRaNuYuBy007o2z6WOnRI+GajjzFbaBxmeY+ptM fRM/MwpFnrxAgoQvYH6s6CahTllBPNy3n9W0yBEoImMsUR8uOgXKn1h4CplV2uZT5YFD 4jGkzTKpMR8V2sU4GSFVMGNYC0zJypCEWtqdGg8C30yH+MQI3esgCrbqxnjF6NX1QWBE 478h301LXLWBRA61PvDw4uQ+qKj3qrYwnrZQwMBcW4dDx1BfDk8rm1wdk0UpfredSLuF 8h+QamesTkQcCsa9Rg0Pr2YeRkyjToo3ZVlNmAio1T+6I1oq8njFZ6pPr8vUV6OSS+v4 dF1Q== 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=BNFcj/lPL5sE2HDxRBa/VPICRRnWhTFSV61QwjypkvQ=; b=W+5tSZk+y5pe5IAMZubhWLIPvG1VlTs7F0t1amvvvkHKejueiY1P9ZrSZalBcXTKeD 2HeWlo7OYrmnH/Zm1xvtW/YtaZZHjPq8lqRz3puTe+TAsxOnObRwPT3SdDtqcsPJLAnh StS37Ng7C+xopf0frc19NeDWXamXLQ+jF2EM0iAmd9p4cK3l5AbMb93OXqwzCcD1375P F5xmu67yBStqAXR5WKoxysf2rbjLZHPvBjfoWNdU5pJEgWsAgHGC5RYUhRXybNsGElHQ 9xqzARyjbKTmkVxYqCHpeqQBMYTHfK1bY4o7W2TV6sUJUgpr3mZDjk+iB5CRFe8mtzlC 5+Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=giKVwIHp; 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 t19si3374800iog.66.2021.05.20.16.40.44; Thu, 20 May 2021 16:40:57 -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=giKVwIHp; 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 S241711AbhETLcl (ORCPT + 99 others); Thu, 20 May 2021 07:32:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:56154 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239719AbhETLL1 (ORCPT ); Thu, 20 May 2021 07:11:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8022361942; Thu, 20 May 2021 10:07:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505252; bh=uiYM2F+7VWWT1FmjtdmltqoL6ZZCeOhLp755MzLJqmM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=giKVwIHpywSQJa1ZPtupsIuqbCLb2pQ5ux3OEIgfYVIMeyUU6xpaF9LWYq5rpB8wA uIgSdhA8LDkVEdYBZ+GwEzfgdGjnj8FR8KyQuB86Kup0NogY+O0CKg/zZjmNkid3Fh 1dVy5CU328Te1+fHpcn0PQw5aNnBlX0hss3sepNU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dean Anderson Subject: [PATCH 4.4 051/190] usb: gadget/function/f_fs string table fix for multiple languages Date: Thu, 20 May 2021 11:21:55 +0200 Message-Id: <20210520092103.865287189@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092102.149300807@linuxfoundation.org> References: <20210520092102.149300807@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 @@ -2341,6 +2341,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; @@ -2376,7 +2377,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;