Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4467553ybz; Tue, 28 Apr 2020 11:47:41 -0700 (PDT) X-Google-Smtp-Source: APiQypIyTdBrJTExKXQKwjyISWdiYMb1mZkZxBuNFWqu5csRlZNlmarwYiBhJ+eyEOPx56bRPiJn X-Received: by 2002:aa7:d3cb:: with SMTP id o11mr23044081edr.194.1588099661476; Tue, 28 Apr 2020 11:47:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588099661; cv=none; d=google.com; s=arc-20160816; b=oXk6yv/8H9hYs5e89c3ju0Uu+jLsQsC1yIY6JgZSyV1ZSNCh7sZNyliZ/HLZLpk+oa cupLSs16rHTIPGfAMqEn03pfPaaC2C94DvrH0kzZnfJXF6G2rRDFXKRe52qLtwey3Ox/ OzxOl+5clj6ng7h1c9BuJZw973N4FaOGKVRI40qIKc43IEQ/zZapipW/U2sR4KX25a2w 47+kCe6C4sCa9c1MfHqipuPScy0XkKBkbcoz8m/tUkH71TYh60eHpo1+K71bItWxOCJj XTUEGc+TvTgjA8uCYC3+ybq26GKhc3u60WvMj6jSTvV1PdU5b9tXyGFzXykMXJPyrkSg 19/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6J26ni/Q1YZKS6q6UFUvTNXp5bIWYngvicmWoUkgFo4=; b=p6aZj36ViJwuz9Vl1WJALI0vWtMxJBYgKdGlZpMptY/A4EKHG5Z+bEjvb51Rpsr2L0 W1WASjQh4E/p1UjFl3PGBkPMGnDCbEUB2J564Wh9j5SpmUB8xm2KinaFRLCxdHLa6QTA tQdqWBVmU8EMZ/CHMdlwCxt26CAsGdweTzlTJblPgUfcH7d7SpQUG25mmMY3Z+5V9cV7 lyodK5nqC6AtLdxhpJSL00dH2x0dLCLQxAxQQkGmqWskF2T+RZn8GFcfYU6mrtlYsKRf ZFg70kEM3RwTzJvuby1Oh+bE6kPX6NFwgnCMzQ92sV/xhJWwwClAOZv59Io6pRzKSimE TmKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yI6zbfDC; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w25si2019140edq.368.2020.04.28.11.47.18; Tue, 28 Apr 2020 11:47:41 -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=@kernel.org header.s=default header.b=yI6zbfDC; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731331AbgD1SoB (ORCPT + 99 others); Tue, 28 Apr 2020 14:44:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:36798 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731318AbgD1Sn6 (ORCPT ); Tue, 28 Apr 2020 14:43:58 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 12E7720575; Tue, 28 Apr 2020 18:43:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588099437; bh=TPBgyzcxmy5rNzkqWq4w+WSW2526okjlRBilxUqOVSg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yI6zbfDCPAtwCrZQ1B4geE9yr6ybz+lp9Wbr/iTIaq8po0+prD07SHtXUvBG1s7X5 AMYqVCIJ/lx6MY5JG3Zbjh3gVEu3G9OlUtK/qXlLZr3cXsiwHatsbszmPmaDkHXAJv jCa/b1ri9NHmAEsl8P9sWKNy8lz+SzLMJVeH3qcA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Udipto Goswami , Sriharsha Allenki , Manu Gautam Subject: [PATCH 5.4 151/168] usb: f_fs: Clear OS Extended descriptor counts to zero in ffs_data_reset() Date: Tue, 28 Apr 2020 20:25:25 +0200 Message-Id: <20200428182250.559496617@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200428182231.704304409@linuxfoundation.org> References: <20200428182231.704304409@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Udipto Goswami commit 1c2e54fbf1da5e5445a0ab132c862b02ccd8d230 upstream. For userspace functions using OS Descriptors, if a function also supplies Extended Property descriptors currently the counts and lengths stored in the ms_os_descs_ext_prop_{count,name_len,data_len} variables are not getting reset to 0 during an unbind or when the epfiles are closed. If the same function is re-bound and the descriptors are re-written, this results in those count/length variables to monotonically increase causing the VLA allocation in _ffs_func_bind() to grow larger and larger at each bind/unbind cycle and eventually fail to allocate. Fix this by clearing the ms_os_descs_ext_prop count & lengths to 0 in ffs_data_reset(). Fixes: f0175ab51993 ("usb: gadget: f_fs: OS descriptors support") Cc: stable@vger.kernel.org Signed-off-by: Udipto Goswami Signed-off-by: Sriharsha Allenki Reviewed-by: Manu Gautam Link: https://lore.kernel.org/r/20200402044521.9312-1-sallenki@codeaurora.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/f_fs.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -1828,6 +1828,10 @@ static void ffs_data_reset(struct ffs_da ffs->state = FFS_READ_DESCRIPTORS; ffs->setup_state = FFS_NO_SETUP; ffs->flags = 0; + + ffs->ms_os_descs_ext_prop_count = 0; + ffs->ms_os_descs_ext_prop_name_len = 0; + ffs->ms_os_descs_ext_prop_data_len = 0; }