Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp590352pxb; Wed, 27 Jan 2021 16:03:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzg7bwCP7Oq7WYYQsuNyZf1lf9Ed5HubOymur9xGXp99EJ1fSpj5665GHhOlvGFsRi19MOs X-Received: by 2002:a50:c8c3:: with SMTP id k3mr11343309edh.302.1611792202549; Wed, 27 Jan 2021 16:03:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611792202; cv=none; d=google.com; s=arc-20160816; b=saWtvvQc9IoKP7yS+yYA87ucMXnyIOrhaxOxIpAsmNqXQm1zb3QrIziSzTYOgofTjE 9szlZxIeArbwXNCpw94E19Tqm41lhBCf+1gtg8M4L1Y1Dj3TZfIf6D3X3YyKMUpmlpnV Q6xZaUCsg+QkhMiQNZmKoPAG+Xdo9wU66cmH5Hyyy9aLPgQX7RMQTIO6GLVntmc43CRs QcH5Q3GAmQ2KIq4qAu7d8kjn78tJwm5VTouU+kXSVsyvea+uDS+N3y+R/1iDnjSLzr+x UrCp4xZcJtRNo7IMcaNeU45aB7HZnUs3W0FVXcW27Y3q3dffllIgaF4JdoAQgdzYy6rn 2+DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5MPSazNg4+ZK7prREFGAGcTQxWERa3eaYu1ypOy+6Sc=; b=uACMKI4sEJPxwnNjN6rwdoFgpgLURuLMj7CEIuFBfjP6nZT0U4h34bTv+WWveHe9bU lFLBwwZCfVnTg6xgMQ6d6OA7M8yp1b71rLYfb9i6gHtCPgN73mtv5nIYQr4/QYCDfNMZ yUgNPkR0QGQB+l7KRUPYTHq17kE+R9baxPtMSiW2+vGWtS6h+bHOVb7A/zcEmWUdu7Ne bhTfHnnsPDc8CnQIrYUmr20+ybfMNRJreKd5sAbK6J6YzP6KPeZDzWVgi5tSIzSo0W1d CfRqd0jCVoxIUymK2nOBIanfiEW+733SXh7Ijjx/MorIa/Lkhd4jFO6J/QqlEfSVexyT kokQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=D7ImwHZt; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y6si1816920edp.379.2021.01.27.16.02.57; Wed, 27 Jan 2021 16:03: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=@kernel.org header.s=k20201202 header.b=D7ImwHZt; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235785AbhA0PGj (ORCPT + 99 others); Wed, 27 Jan 2021 10:06:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:54656 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235179AbhA0PAP (ORCPT ); Wed, 27 Jan 2021 10:00:15 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D5FE42168B; Wed, 27 Jan 2021 14:59:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611759575; bh=JM2jUIXgJm/G0mRyqIdPww2k7oyM3aT7ynnTGBy/5GQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=D7ImwHZtNvYrHEqzVN1Yj5Da81j3XEjjWtSacJTgE9jeCggYRPnLAMwKfSPVNqgW5 OgKANGuuK+EFvNmYmBmoys7jHK/2Ier7ZHypTVwgvxxepOVKlFGgsyYs4e2pJT9oTN TnWtzR07vH1LKmuDT7unROFVfZNLKRc9t/7o7dGf4Dc+ajrFYPU2mYUwwvUR3GmCqA ezOk83NQFInlrrMHwqBvTz3FmQyx7ti0Kswu5oQaZKAb+hedFj9sVKcZMArUJiRAEG oPp2G1Qodd3mPxwYdUNW8MQplqfgJiTjRTzE4saLZvUhf2PjCjpuFqpZJmP4txABTQ myPquQLIqYfIA== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1l4mIL-0001wh-VX; Wed, 27 Jan 2021 15:59:46 +0100 Date: Wed, 27 Jan 2021 15:59:45 +0100 From: Johan Hovold To: Anant Thazhemadam Cc: Greg Kroah-Hartman , Lee Jones , Tom Rix , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 06/12] usb: misc: iowarrior: update to use the usb_control_msg_{send|recv}() API Message-ID: References: <20210126183403.911653-1-anant.thazhemadam@gmail.com> <20210126183403.911653-7-anant.thazhemadam@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210126183403.911653-7-anant.thazhemadam@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 27, 2021 at 12:03:57AM +0530, Anant Thazhemadam wrote: > The newer usb_control_msg_{send|recv}() API are an improvement on the > existing usb_control_msg() as it ensures that a short read/write is treated > as an error, data can be used off the stack, and raw usb pipes need not be > created in the calling functions. > For this reason, instances of usb_control_msg() have been replaced with > usb_control_msg_{recv|send}() appropriately. > > Signed-off-by: Anant Thazhemadam > --- > drivers/usb/misc/iowarrior.c | 34 +++++++++++++++++----------------- > 1 file changed, 17 insertions(+), 17 deletions(-) > > diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c > index efbd317f2f25..9d6a7548e537 100644 > --- a/drivers/usb/misc/iowarrior.c > +++ b/drivers/usb/misc/iowarrior.c > @@ -109,12 +109,12 @@ static int usb_get_report(struct usb_device *dev, > struct usb_host_interface *inter, unsigned char type, > unsigned char id, void *buf, int size) > { > - return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), > - USB_REQ_GET_REPORT, > - USB_DIR_IN | USB_TYPE_CLASS | > - USB_RECIP_INTERFACE, (type << 8) + id, > - inter->desc.bInterfaceNumber, buf, size, > - GET_TIMEOUT*HZ); > + return usb_control_msg_recv(dev, 0, > + USB_REQ_GET_REPORT, > + USB_DIR_IN | USB_TYPE_CLASS | > + USB_RECIP_INTERFACE, (type << 8) + id, > + inter->desc.bInterfaceNumber, buf, size, > + GET_TIMEOUT*HZ, GFP_KERNEL); > } > //#endif > > @@ -123,13 +123,13 @@ static int usb_get_report(struct usb_device *dev, > static int usb_set_report(struct usb_interface *intf, unsigned char type, > unsigned char id, void *buf, int size) > { > - return usb_control_msg(interface_to_usbdev(intf), > - usb_sndctrlpipe(interface_to_usbdev(intf), 0), > - USB_REQ_SET_REPORT, > - USB_TYPE_CLASS | USB_RECIP_INTERFACE, > - (type << 8) + id, > - intf->cur_altsetting->desc.bInterfaceNumber, buf, > - size, HZ); > + return usb_control_msg_send(interface_to_usbdev(intf), > + 0, > + USB_REQ_SET_REPORT, > + USB_TYPE_CLASS | USB_RECIP_INTERFACE, > + (type << 8) + id, > + intf->cur_altsetting->desc.bInterfaceNumber, buf, > + size, HZ, GFP_KERNEL); > } But here the buffers are already DMA-able so that the new helpers only add redundant allocations and memcpy's() for no real gain. I'd just drop this one as well. You could consider adding the missing sanity check to the IOW_READ ioctl, which would currently return zeroed data in case of a short read (so there are no info leaks either way). But perhaps that is done on purpose, so perhaps better to leave that too. Johan