Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp63939pxj; Thu, 20 May 2021 04:39:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNkCY1kA1ad1abvSLrOEHY4pNSIUiTlbmYYs1ccNsRt69i+ZEA82w18Eq2ELFgIwp/RxvV X-Received: by 2002:a05:6402:3513:: with SMTP id b19mr3071176edd.137.1621510799166; Thu, 20 May 2021 04:39:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621510799; cv=none; d=google.com; s=arc-20160816; b=OXSOZ9WP5D/W6NPukLqkNoCqeRQ6cW+NwLiuoTJafUaFBOIcxg7cUd1D9tJppOI1v5 wlWMT/V6y6wRwQX2lPVcPXT0N9rISXX+YKeD3nG/WUFhjuOjf7N/Z3epoottZnSUPYaA vVLT9WGtvr/avdPIWCEtgnE3A+SANvmdIY9Bdr2IoQKyh7VpG5QssCpGAL65MQtuADmf e4ZCao1VzPyVjjM2rqp8hXzWoQoayZXkOXDsnaMKwETL7fw6zAT9W1R1yl8gQSS4GTwE P8fLcoiBVGgVKwgJldLtDiB+RaZDvQB3OcEiZ8MXx1Hc6FZNtOuH6gpsgXvDYSjGApS7 gGTg== 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=JairZwAcY8MFhl7mCoXcYSCwtvOfJxa/1X75bVkh4+c=; b=GvliEyOb+h4nK9PxF5X4iD0bEStNb2Dhbc46SkuXjXUe3n1vKCwMdyfJkB97CbWyY8 6pPLXoklfEtvZXZEvZnPDNqv/3+5nqeFMuSgeRH4mV8ctm0F8kZKhdT0s+tNo2dfmUuW BpvcD1M6LpVqkGEQzhC4WeYgoAqIGsYptfwVWTGMSVInA9q1j2yCQYwxEnnBC1x0aWrO O/DgtHHXyPD+uka1MmX32kP0hdMwSNss283bNygRra0r3I2zZRx8vPmYwW9S/hKhhX2N qsawDDKX8wXiv1lr3PL3H2ZW5Q7AMrJYJCmtLIG+VvrIS2kB3xFEbtEUPLlt/7BC9Njo lfog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qxrgUAWP; 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 d15si2156331edn.606.2021.05.20.04.39.13; Thu, 20 May 2021 04:39:59 -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=qxrgUAWP; 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 S242409AbhETLfZ (ORCPT + 99 others); Thu, 20 May 2021 07:35:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:37920 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240647AbhETLPG (ORCPT ); Thu, 20 May 2021 07:15:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CECBC6192C; Thu, 20 May 2021 10:08:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505331; bh=ipKLPeu42Bq8fzgLGyaGkLJPTPp01iaR00TYtrxmb4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qxrgUAWP6WeEShaSEj+CLH3Rs/1pBN1wvgf+WYv01NgXiLv+s1jupkxVjRX9ll8zr GLUiwHCbsz1k3WKYkFYlKjcgsDdAqAQPEXUsl5rBKGv4tiYgDEnpN9gL/qbSLcCyMQ 6w3nG5Epkjc9uq/nytW3q/ZwRG43bH9eEoT696kI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fabian Vogt , Sasha Levin Subject: [PATCH 4.4 087/190] fotg210-udc: Dont DMA more than the buffer can take Date: Thu, 20 May 2021 11:22:31 +0200 Message-Id: <20210520092105.072513368@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: Fabian Vogt [ Upstream commit 3e7c2510bdfe89a9ec223dd7acd6bfc8bb1cbeb6 ] Before this, it wrote as much as available into the buffer, even if it didn't fit. Fixes: b84a8dee23fd ("usb: gadget: add Faraday fotg210_udc driver") Signed-off-by: Fabian Vogt Link: https://lore.kernel.org/r/20210324141115.9384-7-fabian@ritter-vogt.de Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/gadget/udc/fotg210-udc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/udc/fotg210-udc.c b/drivers/usb/gadget/udc/fotg210-udc.c index 491b04dd6db7..b2910bc65e51 100644 --- a/drivers/usb/gadget/udc/fotg210-udc.c +++ b/drivers/usb/gadget/udc/fotg210-udc.c @@ -340,8 +340,9 @@ static void fotg210_start_dma(struct fotg210_ep *ep, } else { buffer = req->req.buf + req->req.actual; length = ioread32(ep->fotg210->reg + - FOTG210_FIBCR(ep->epnum - 1)); - length &= FIBCR_BCFX; + FOTG210_FIBCR(ep->epnum - 1)) & FIBCR_BCFX; + if (length > req->req.length - req->req.actual) + length = req->req.length - req->req.actual; } } else { buffer = req->req.buf + req->req.actual; -- 2.30.2