Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2290534pxb; Mon, 11 Jan 2021 06:10:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJxFXQX15XrSGNXB6rAzD7oyvp8DYo4lfdiKOQcm9IXWSN1vuZTOXpUXAuWFUYeFVGqODEBv X-Received: by 2002:a05:6402:22e1:: with SMTP id dn1mr14673671edb.347.1610374249082; Mon, 11 Jan 2021 06:10:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610374249; cv=none; d=google.com; s=arc-20160816; b=TRnJfH+SD54nvicvlZcj+IN64Ks3uWdrd0sr2wdqzLjgD5VZ9uFV9TUwS9r80jVO92 syVt5LMOD01rqZk1hmTJdfglj2ge9dTtJ5wn6xWG9pGk5lhxKwHgz3N928ec2qnigxfi yRCTkf1OpizYJ9AfEDw+AGYdmA9JCUsXpTcga7yKCb6pdI8VPlpg52UJi4uwKmeh6QHo BwnzTxJ2hPf3rUPMgvu0eWMoCiUwtJ4Aq+rbq3u8fir16lvO3vSEsPjY8qIqpaKmRJFA mG5X9hvCthk+SPulbXTR2HzVR3Zf9Nty4guC/3iXQO/XT5QFlwxf9YPFtUiwYm8BH/15 2UoQ== 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=kJCfcfpOrYJrluM9VRTSy1X87E19lWhYDLwVyElg5mE=; b=KpXjU6/qERlmPDmIK2Vz6CneOiH32fsY2gAC5fXJMgyGAgE+g/Fwg/yNZrtPFpW0/x +MoECi6z0giOgwj2SOtyeoksCh5GjlTyosQppjqFNxX7fGq3WxPqUX04wk0chQ7Xr0lm ZmmURADbB7PlgeFgfMA1J1hH3S32caU/UKW3PHk/ZiKT8ZIJ5UjUrHM8fKFmpxHY8/dT 4v6TqryTKaZCkeZOGGdKTCLz5aVXRNV11cpJLqWkYuIfJXXMRQIvpp7rMZXn11SU1Csa R7MS6gcAp51ZB1OljneSrO/MUh1kuyCji5eGblcddZ7Bw9Hxy8ihx0dAMnVjfT8++1CU Jb8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tBdjD9he; 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 i19si6689055edr.468.2021.01.11.06.10.24; Mon, 11 Jan 2021 06:10:49 -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=tBdjD9he; 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 S1730211AbhAKOHg (ORCPT + 99 others); Mon, 11 Jan 2021 09:07:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:50228 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728061AbhAKNDt (ORCPT ); Mon, 11 Jan 2021 08:03:49 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 223A822C97; Mon, 11 Jan 2021 13:03:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370212; bh=nPFU1VAzWAXKGEkRxxRdPV06oAzjqICHGaasdavhejA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tBdjD9he4/skO8t6TUeeBkgFLVHJzEHY9wP4t6L7mhCQPj66vAij0suOUewED03yc iWKR+jowRoEya5gHsWWIHvciD1jG8fFMTtD0kvuX/uRxgEPpANsBw1svxNzOq/+9Wo 2UXaG83IbTolY6mtMLu4rUoOWvsvqck2M5fae7JU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold Subject: [PATCH 4.9 27/45] USB: serial: iuu_phoenix: fix DMA from stack Date: Mon, 11 Jan 2021 14:01:05 +0100 Message-Id: <20210111130034.953166163@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130033.676306636@linuxfoundation.org> References: <20210111130033.676306636@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 @@ -553,23 +553,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) { @@ -577,12 +583,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; }