Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2289141pxb; Mon, 11 Jan 2021 06:09:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJyFllWvjZAmgK0HA3fR28gIYLiYPt8UAmtV2CVBKaUoddnPqLfztoFmgYRQemIWmLq2U0pt X-Received: by 2002:a17:907:7255:: with SMTP id ds21mr10143501ejc.258.1610374162228; Mon, 11 Jan 2021 06:09:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610374162; cv=none; d=google.com; s=arc-20160816; b=F4Km7EkeYNGg9iVfcR5s1zXnvLnr3qpX+uFkSb44L16MJjMDYTZ2Y/nGkbfJm5AndK kZ/hZcLCAtziKvG/NmTx6qasUrFUvJAeaAsvYnhwFW8x154zJ9a5ZPzyh+2D0Wg5aJu6 /i6qIosSFv6tW+8JwUtsqvdkvG+IbcfOW0Tned0yibo1bIRhfLHoGywNXFxMZ1imDFzj wZMmrP0+JUO48PAkteLEKiwEVrARkd5mezaBXVC6z+E78uHZp95wAonYayjcyICcA20+ hu+u+Orqot4EZJxVVrkEY1jCaQsrkb1gjoO/+bYsE1LfIY6ZBsmwCZh3J9MIgVM5Xq7Q ApuA== 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=agE6bbRpauyWqfBgaXJxYvJItgD5s6ACHzqgcSpt7Wo=; b=RwvTVgvWwnfLVuXicsgSpOxend3Ht5CWJXktijzfFDqK3oj0rzWrQ2RLUJm9M8+rRt hYutwn/gCItftMq9Y05uTDD9+hskHqAgi5BA4m8WSQaZCc0GqoJqtqFutf9pCOC8WYpR kY/1E/dXpfaWv+OkfZSyPnKPzB8votWJPCdevfsJ3uNGqTYPaBBtho+4nny6XO/eUHmQ qsdI7esdAaXip8WXHs6H6Cxija6h254iQa2aUii1VqE1a1oV222MVdv1svBjg+H9zHPY ejEznPMGskBH3tX8Ri04BnndxVWUUky8cwxiUG2RJA8lx8epQ/FKmxJOEHt88E9UvlRx WKAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hUyS79Fc; 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 t23si6596774edw.381.2021.01.11.06.08.50; Mon, 11 Jan 2021 06:09:22 -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=hUyS79Fc; 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 S2388428AbhAKOG1 (ORCPT + 99 others); Mon, 11 Jan 2021 09:06:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:50166 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728048AbhAKND4 (ORCPT ); Mon, 11 Jan 2021 08:03:56 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id F0EF92250F; Mon, 11 Jan 2021 13:03:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370219; bh=I4sHZ/9+9WaCBncCxa31WvcaN/i3zoWGwQUJX7ocuzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hUyS79FceySKjWilvHan9ePGLV/snnbyOLkKuFsVy3b9a0Jv8wigrVqYx2gVM1PcA w4P7sS8n0VZmNPMidp6aDnHGjwssctaM6lUuikRwdI3TIn63QMd0jzaJnBfoaIamok WZuWp2mA9qlmj1Ol0+hQ+2ckYki6+RBdkKAtZOqo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold Subject: [PATCH 4.9 30/45] USB: usblp: fix DMA to stack Date: Mon, 11 Jan 2021 14:01:08 +0100 Message-Id: <20210111130035.101672460@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 020a1f453449294926ca548d8d5ca970926e8dfd upstream. Stack-allocated buffers cannot be used for DMA (on all architectures). Replace the HP-channel macro with a helper function that allocates a dedicated transfer buffer so that it can continue to be used with arguments from the stack. Note that the buffer is cleared on allocation as usblp_ctrl_msg() returns success also on short transfers (the buffer is only used for debugging). Cc: stable@vger.kernel.org Signed-off-by: Johan Hovold Link: https://lore.kernel.org/r/20210104145302.2087-1-johan@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/class/usblp.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c @@ -289,8 +289,25 @@ static int usblp_ctrl_msg(struct usblp * #define usblp_reset(usblp)\ usblp_ctrl_msg(usblp, USBLP_REQ_RESET, USB_TYPE_CLASS, USB_DIR_OUT, USB_RECIP_OTHER, 0, NULL, 0) -#define usblp_hp_channel_change_request(usblp, channel, buffer) \ - usblp_ctrl_msg(usblp, USBLP_REQ_HP_CHANNEL_CHANGE_REQUEST, USB_TYPE_VENDOR, USB_DIR_IN, USB_RECIP_INTERFACE, channel, buffer, 1) +static int usblp_hp_channel_change_request(struct usblp *usblp, int channel, u8 *new_channel) +{ + u8 *buf; + int ret; + + buf = kzalloc(1, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + ret = usblp_ctrl_msg(usblp, USBLP_REQ_HP_CHANNEL_CHANGE_REQUEST, + USB_TYPE_VENDOR, USB_DIR_IN, USB_RECIP_INTERFACE, + channel, buf, 1); + if (ret == 0) + *new_channel = buf[0]; + + kfree(buf); + + return ret; +} /* * See the description for usblp_select_alts() below for the usage