Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2268647pxb; Mon, 11 Jan 2021 05:38:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJxvK7UELgJp31pcFykmqvvOkIWUxoUMHmwwhJNEzGF285HrdVqjLcIxAj7JhMccz6avB6Qb X-Received: by 2002:a17:906:720e:: with SMTP id m14mr10555272ejk.161.1610372283547; Mon, 11 Jan 2021 05:38:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610372283; cv=none; d=google.com; s=arc-20160816; b=x6JuWUKaZJvhZwP5Gt2qC4Uzq1wAjDwi4Qm/VP3T+F7e0YnG01clyClFs5XaEy3ZWX SklaF8/stvKI2t06EbnvszagkwvIjtQf1WQWku0L07ji4FObKioO4j3KJ3NSEvpm756A LeUN1ftAHlcW6xQ9qDvoEM2yfv8S/dV6u2CPFfMntH5o6w4X+7G10oLkYih/5ePMHkBL kkO7FmxPFt8zOHN1gh1Z4ZYjy7ULPu49UBLjCxj1oy+woXoiVq8c75BcvGVrdPaaB2YQ ZZdbzRUpPgvwkhszRzy99p0e0VuZruC+Y4FXnR2voJIrS2WoHdKKGFDN9zOueBLuHjMs OV6Q== 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=u4+QVN80wL588qdh6L7NgUUmqvYeVvTpfneSUqtF5Xs=; b=HWOC5pMrRkXbwkiL/IpuMk7ijiVJR02MFSHRTBxr0MzgW/oLN/SYRtF8tSjoz9dum7 8bjPaFFYDAFIhG+Ib/k56g4tI1sWAy0TSJFhuBOeiYJKCysc+1F3ZSt23wE6QxrnMmj5 zpMg9oGcuQ09T9v3JNIYWicZKyhJ4pZhtZmG47b3H0VwA99KIHkXIAsRkk9szE8sAaUR Y+NWggMsY0lbMYB5Dzt0XEqwKuRBti++00B+jLT/PWEg30/FQEd5UqWdQX2Pl/qa/u0o Yqb42SNS+fUZr3v2dHLdnw01kU4k502FiG+zTZU6HnsV9v3u9WcKveOK5aFhtoL66nIw d7nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fdAWiAue; 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 j16si6269621ejc.358.2021.01.11.05.37.38; Mon, 11 Jan 2021 05:38:03 -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=fdAWiAue; 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 S1732048AbhAKNOI (ORCPT + 99 others); Mon, 11 Jan 2021 08:14:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:60704 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731919AbhAKNNq (ORCPT ); Mon, 11 Jan 2021 08:13:46 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id B0F4522ADF; Mon, 11 Jan 2021 13:13:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370786; bh=34WK/JO9EGofM1VPONr95EJPWXbjCgz42fnwczCGMRg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fdAWiAueRBEMNKI8fovynODE3MwCVBwr69nALd0uZryny1zpKF3cie0aIUyz4TbfY ckOmBHD5RV007ecBuwms8ZVmH28gIbFlm9Hf46RIRzYm4bCauYLNbAVVovbLSuniAL aV/EOL6tuPbxhH8OiRdYAZ6X6Nmhx/jMNRcCoHIU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold Subject: [PATCH 5.4 65/92] USB: usblp: fix DMA to stack Date: Mon, 11 Jan 2021 14:02:09 +0100 Message-Id: <20210111130042.283198036@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130039.165470698@linuxfoundation.org> References: <20210111130039.165470698@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 @@ -274,8 +274,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