From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7052FCA9EB9 for ; Sat, 26 Oct 2019 13:23:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 47C932070B for ; Sat, 26 Oct 2019 13:23:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572096234; bh=zmCS8vj7AGjE7ByQs4OVVrBF7UKrVF1K9L42I/Wq2Z4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=KlZSXm2FafAT9WB7HkRVJqI4nb80K7i3bkhLTqkpSp14gaLMvjNii6qi3Gb5BmcoB Ae0TdrgwrHxi2o1FcNeoSdut6ZK+RsDRCD3u0ofFRThiUiPRUbX1RWFBSiQNTRlRdp +sIxdLC7Kdh1ILqBBryUSFk8iGVGxFqVA2MlJMpY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729925AbfJZNXh (ORCPT ); Sat, 26 Oct 2019 09:23:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:45420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729905AbfJZNXh (ORCPT ); Sat, 26 Oct 2019 09:23:37 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4F46A20867; Sat, 26 Oct 2019 13:23:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572096216; bh=zmCS8vj7AGjE7ByQs4OVVrBF7UKrVF1K9L42I/Wq2Z4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VPt5kzmsEtejwi55xnE2Ia4VYe+Zlvpmw8VPn7WbfFS+F4lxZFshj+mcUNczhpLAj si9fL3MmFTvqV3uFAikV2SOOxuo+dWDPH1hXarZWVIOf0g0L6IWDyTg9X1viLDoVcG 6xsf68Aa+oiIuQ10lPU2wTnFmOGAHswEIzrBkFiU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Oliver Neukum , "David S . Miller" , Sasha Levin , linux-usb@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.4 15/17] usb: hso: obey DMA rules in tiocmget Date: Sat, 26 Oct 2019 09:22:59 -0400 Message-Id: <20191026132302.4622-15-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191026132302.4622-1-sashal@kernel.org> References: <20191026132302.4622-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Oliver Neukum [ Upstream commit af0de1303c4e8f44fadd7b4c593f09f22324b04f ] The serial state information must not be embedded into another data structure, as this interferes with cache handling for DMA on architectures without cache coherence.. That would result in data corruption on some architectures Allocating it separately. v2: fix syntax error Signed-off-by: Oliver Neukum Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/usb/hso.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index cbbff16d438f5..faa9089aebcc2 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c @@ -210,7 +210,7 @@ struct hso_tiocmget { int intr_completed; struct usb_endpoint_descriptor *endp; struct urb *urb; - struct hso_serial_state_notification serial_state_notification; + struct hso_serial_state_notification *serial_state_notification; u16 prev_UART_state_bitmap; struct uart_icount icount; }; @@ -1455,7 +1455,7 @@ static int tiocmget_submit_urb(struct hso_serial *serial, usb_rcvintpipe(usb, tiocmget->endp-> bEndpointAddress & 0x7F), - &tiocmget->serial_state_notification, + tiocmget->serial_state_notification, sizeof(struct hso_serial_state_notification), tiocmget_intr_callback, serial, tiocmget->endp->bInterval); @@ -1502,7 +1502,7 @@ static void tiocmget_intr_callback(struct urb *urb) /* wIndex should be the USB interface number of the port to which the * notification applies, which should always be the Modem port. */ - serial_state_notification = &tiocmget->serial_state_notification; + serial_state_notification = tiocmget->serial_state_notification; if (serial_state_notification->bmRequestType != BM_REQUEST_TYPE || serial_state_notification->bNotification != B_NOTIFICATION || le16_to_cpu(serial_state_notification->wValue) != W_VALUE || @@ -2595,6 +2595,8 @@ static void hso_free_tiomget(struct hso_serial *serial) usb_free_urb(tiocmget->urb); tiocmget->urb = NULL; serial->tiocmget = NULL; + kfree(tiocmget->serial_state_notification); + tiocmget->serial_state_notification = NULL; kfree(tiocmget); } } @@ -2645,10 +2647,13 @@ static struct hso_device *hso_create_bulk_serial_device( num_urbs = 2; serial->tiocmget = kzalloc(sizeof(struct hso_tiocmget), GFP_KERNEL); + serial->tiocmget->serial_state_notification + = kzalloc(sizeof(struct hso_serial_state_notification), + GFP_KERNEL); /* it isn't going to break our heart if serial->tiocmget * allocation fails don't bother checking this. */ - if (serial->tiocmget) { + if (serial->tiocmget && serial->tiocmget->serial_state_notification) { tiocmget = serial->tiocmget; tiocmget->endp = hso_get_ep(interface, USB_ENDPOINT_XFER_INT, -- 2.20.1