Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2821720pxb; Mon, 11 Jan 2021 22:18:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwohwP4SHQ68Ix8yvteM5IxNufeK52faEh3+wJ2MLSzd4J9W+lkNSbs9xh/t4kW5NiZnrI/ X-Received: by 2002:a17:906:3ac3:: with SMTP id z3mr2058871ejd.449.1610432297167; Mon, 11 Jan 2021 22:18:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610432297; cv=none; d=google.com; s=arc-20160816; b=Gu9ebwAEwIcDBvF0iNT1C5fa0qq7ukfNU/5nsTnIaQvmK2JuV2m/2CtbZTd9wnHyNR hPUNeKzRMKE7AwSa8BxxLD/mmz6ff+NoWwkO6QX7PPI/OEBd1haeWSdMgQiy4VV4zfrC cT1+wpwg8CkwztxJSpOmfyWacG0egeMao5+SqTzNl7xEpapiO8K3u2WvqfPHtIdkKYs0 nk5qQ8xJLk8fr1aigSHOApDd3YV+E1ptE/qD0ha/MfU/FgnbI4iRN5x6iEHQg00DAZBh anvljL7nmJyG+LiWmf6vBS86b/LfUt7z2lQnm+mV8LLfjBjH9hhwmGw8pQvrEubWQf71 yI2g== 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=DmzRGoc3f83uLzPRmUlc7zDXEzJww3R2X7tjhA0oraA=; b=Xe4/fXfHpA7X480xncDSFYwW162SJpUJ9okdfTMKX42uCC/1FI95Q9CAF5747vgXw5 dYjf1uYcmXcZjXIXeTVAgeye0LSny6DwNKG4QlDnJvl6cnIS+Ap0BWH/y40GN15GheXg BEQHYwwgVR54iiHvr9loL9mkvjiOBwhnoXxbDPQsNfJJAza/PY16WN9Goqklzv2BkoH2 fodJ04HEwMSI8jBMmtYMlscAQ1XT5LMU4B8j1ED4FRPE5PhjTHQHAquDsErKEu+RAtO1 NDrIV2vV9C2Wd3/Z1di4ikFY5ePJ4IY7o6J2x9wbDIyOadiUJ4lTG6bhXzRPivu7TNn4 B8Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IQ9Q0fhj; 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 ak17si816904ejc.288.2021.01.11.22.17.53; Mon, 11 Jan 2021 22:18:17 -0800 (PST) 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=IQ9Q0fhj; 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 S2387509AbhAKNwI (ORCPT + 99 others); Mon, 11 Jan 2021 08:52:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:56364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730699AbhAKNJG (ORCPT ); Mon, 11 Jan 2021 08:09:06 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D0F1122ADF; Mon, 11 Jan 2021 13:08:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370505; bh=TOJcZvjnJZQGS+cQbsthieBdACSYNWvv/ibbBiaOXuY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IQ9Q0fhj5GIy6Gk7xbgk0Zj8stxmzHes+r3QQWwysOdyMZ8IsiuwxEpNmVbuCWqEC mX/SWsRJXrt2EarxuhtQjHWbuZwc0hogIh9E6KhFwaDCF7Ghr0z/hxs7802Ne8RAdN KIeZ7hvTh39tyofPLzx+NkYraIH4sjIix56himo4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold Subject: [PATCH 4.19 51/77] USB: serial: iuu_phoenix: fix DMA from stack Date: Mon, 11 Jan 2021 14:02:00 +0100 Message-Id: <20210111130038.874137327@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130036.414620026@linuxfoundation.org> References: <20210111130036.414620026@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: Johan Hovold commit 54d0a3ab80f49f19ee916def62fe067596833403 upstream. Stack-allocated buffers cannot be used for DMA (on all architectures) so allocate the flush command buffer using kmalloc(). Fixes: 60a8fc017103 ("USB: add iuu_phoenix driver") Cc: stable # 2.6.25 Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/iuu_phoenix.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c @@ -536,23 +536,29 @@ static int iuu_uart_flush(struct usb_ser struct device *dev = &port->dev; int i; int status; - u8 rxcmd = IUU_UART_RX; + u8 *rxcmd; struct iuu_private *priv = usb_get_serial_port_data(port); if (iuu_led(port, 0xF000, 0, 0, 0xFF) < 0) return -EIO; + rxcmd = kmalloc(1, GFP_KERNEL); + if (!rxcmd) + return -ENOMEM; + + rxcmd[0] = IUU_UART_RX; + for (i = 0; i < 2; i++) { - status = bulk_immediate(port, &rxcmd, 1); + status = bulk_immediate(port, rxcmd, 1); if (status != IUU_OPERATION_OK) { dev_dbg(dev, "%s - uart_flush_write error\n", __func__); - return status; + goto out_free; } status = read_immediate(port, &priv->len, 1); if (status != IUU_OPERATION_OK) { dev_dbg(dev, "%s - uart_flush_read error\n", __func__); - return status; + goto out_free; } if (priv->len > 0) { @@ -560,12 +566,16 @@ static int iuu_uart_flush(struct usb_ser status = read_immediate(port, priv->buf, priv->len); if (status != IUU_OPERATION_OK) { dev_dbg(dev, "%s - uart_flush_read error\n", __func__); - return status; + goto out_free; } } } dev_dbg(dev, "%s - uart_flush_read OK!\n", __func__); iuu_led(port, 0, 0xF000, 0, 0xFF); + +out_free: + kfree(rxcmd); + return status; }