Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp414108pxj; Thu, 20 May 2021 12:15:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSSD6mD/Y4EGFd46AhUwckDSHSkKaJKQE5SHOzdJFfDl/+/IsSmbgrpIBG6g1FYMQfdc8t X-Received: by 2002:a17:907:7848:: with SMTP id lb8mr6350788ejc.494.1621538135261; Thu, 20 May 2021 12:15:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621538135; cv=none; d=google.com; s=arc-20160816; b=kXV+3F/AzJoKsZZupyDpo+KFCltW/dJuY3p2pECTrTHqjk5t0zi+QlwDZYQwIVDRz0 e6gZyx+ovpAJb8LTTWeSd2ERkPzTocx9mUTWgmUwgh8lsNPmYeIpVRJcOneRVPdxJOAB Il871X0zKlUPtA29XExXZmI9ZEr+f8fFU6z4BprwBzE28hnsv1Hindxn25EjJ2pLFjd4 Zpc8g6qWxdN4gIEH169dJvh+1PijXaDzNFObvfmMC3Zxqp5M4pYw8XIJQTQwli23kyt9 yDmxwPb/pajVfI+lVJmuepm30yqEMyd1CB9mWDOIvFq4LdsORZqpRisdGhtyKWwNYuHO eMTw== 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=GaTFLzPAnmE+BAkVzstIk3rQ1ALP9C/yGXtlwOSaHkM=; b=dYKBOnlPVFSV1ztzwImQwbR+qM/Vw5nNJg75XQuOVMZTN4WAwaMjRyC03kzu0TCuID dkoaAcBd7EKFtNvONnhjmgEda2u9FU9S67/bVPssaX1jgUME8dbgU/DqTALEqytvcgIO Ohh+Xp0Cqz7iKnNvz1sIBA8MbLmRf6VrNp0Lr5VALvL5UceNyWUwiCXB2RBjzgt44eyF LieyH7oazt6FJYY35GibO5B9LMixVbENMgFz1neEJeEFez5UJkz9kD5bLSivdKQFZW12 rJ0hPsMTKIiSj6PuzeoDBF0LXa9Tdd08wKVn8vJkugAB11kYNlnuS8pOQQfOzLh7P3xp aXXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xBuwhq4s; 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 m5si3161404ejo.329.2021.05.20.12.15.10; Thu, 20 May 2021 12:15:35 -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=xBuwhq4s; 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 S237241AbhETKki (ORCPT + 99 others); Thu, 20 May 2021 06:40:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:55678 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236341AbhETKZj (ORCPT ); Thu, 20 May 2021 06:25:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5579E61468; Thu, 20 May 2021 09:49:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504186; bh=6Q5uY934E/VMdQv+u9n4rpHhowCGxfQSyTVolvusDM8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xBuwhq4sPHwP3n2Z1eTE4quD8hjnSxe5gFYVhNet7H2esLxpGxFaeq6AmYPqHJ1Q6 r4jX5gZR0mQEpl1G3m1es1N4mxVGTOUT8w/bUtXqXR+B3g1VY08NW0C+L2LA8hb0WV xV2vz0KGo3WxHF6TI97Bgk9ijqwTCuQqW3qjflis= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dean Anderson Subject: [PATCH 4.14 097/323] usb: gadget/function/f_fs string table fix for multiple languages Date: Thu, 20 May 2021 11:19:49 +0200 Message-Id: <20210520092123.431667281@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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 @@ -2543,6 +2543,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; @@ -2578,7 +2579,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;