Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp663697pxv; Thu, 15 Jul 2021 12:51:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyzHtz/y/j0IQN5OgdDxYhzAzu1zvpDRspAKhJuschm86CM3Ub1TKkUInK7Tks8Tn6BjHN X-Received: by 2002:a17:907:76da:: with SMTP id kf26mr7198812ejc.511.1626378664788; Thu, 15 Jul 2021 12:51:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626378664; cv=none; d=google.com; s=arc-20160816; b=EjDQG+eFeGU8J4EFjJ7SGUMouVACCOfj0dIFqBnnnk/P9hkbbcjbN8lqiAK2rrMMEU R89cea6ix+wgg66bNN/uq98ChkIcA91+a6JA8a/wh/AR1nrtb1mqud/iaNXl2GxOi9LU /r0GPMWa9x35VSADALnNzlfhb6jPy6w+KmKu9kQUNMuVjEa+0J+WRYJd/c6eKaQtDcGO 8S1qxdd8uzHEWg6IzhTitMxaxl1fb4uLGGOU5zkie6udvxuhM9WwngBP4dtMTl6HG4to 1okNA1kemCyLbmXOFaQQ9KbW11oAQ0IrFBroDN47JYlFt5oKtcb5PXr5/H8epCDdfNjY 8h3g== 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=+eoFcwz2eStfUdCW4kvMdcpipmPQE2fOUIaEi0nquJk=; b=qP1TvMNpLWmVzmthvcF40jed0W7dpYWp76qjL+xYSwmG7WbCAdJR0oscGauR23kN06 9TFArMRNUF8rDsvvGWyuAFFq8h3xR9jHMPiQPBLGCJ9Vonb3xnusx8R33iKY8FO6L4jj 6cxUDrYPTOIw+f60PeTAEJSjuWnp3Y++OyS0NTN2oikAE9GUglvL+1lnm4941+ATEm6K kS18a4ajwBy1oxtxdYYFT0GhJeSXU37Gl1n3o/yxvIIaAFV4wAhMTajuAVlj4LfcPsOG Jt2WnmrZG2CZNiv1Dygyssou+klFF8p91xIc7+8Sn3U2xPWntU+2mZE2mzeq3CWdzjb8 oWag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QH2mHPyT; 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 y12si8279713edd.423.2021.07.15.12.50.40; Thu, 15 Jul 2021 12:51:04 -0700 (PDT) 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=QH2mHPyT; 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 S1344847AbhGOTtw (ORCPT + 99 others); Thu, 15 Jul 2021 15:49:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:58816 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245005AbhGOTTI (ORCPT ); Thu, 15 Jul 2021 15:19:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D6ADB61285; Thu, 15 Jul 2021 19:13:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626376426; bh=g82bctk938ScfdJINpkIncGH+nIC5VosejmaIJZh80I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QH2mHPyTLx0o3WMHGCyYbcOKdd2UADIPQe94U3cP9VSGEohBaXy1iScIopF8XnEYV KrAc5s3WG8Or4g/GM06jeWWG5siH0IFhWNBstOzA9tHFMOILwkoMnWShR5y4CoIYBg bbucsMTni61EHwPE774dGM/BdjRfBVN4RFX2nBuY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 5.13 251/266] media: gspca/sunplus: fix zero-length control requests Date: Thu, 15 Jul 2021 20:40:06 +0200 Message-Id: <20210715182652.152713411@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@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 b4bb4d425b7b02424afea2dfdcd77b3b4794175e upstream. The direction of the pipe argument must match the request-type direction bit or control requests may fail depending on the host-controller-driver implementation. Control transfers without a data stage are treated as OUT requests by the USB stack and should be using usb_sndctrlpipe(). Failing to do so will now trigger a warning. Fix the single zero-length control request which was using the read-register helper, and update the helper so that zero-length reads fail with an error message instead. Fixes: 6a7eba24e4f0 ("V4L/DVB (8157): gspca: all subdrivers") Cc: stable@vger.kernel.org # 2.6.27 Signed-off-by: Johan Hovold Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/usb/gspca/sunplus.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/media/usb/gspca/sunplus.c +++ b/drivers/media/usb/gspca/sunplus.c @@ -242,6 +242,10 @@ static void reg_r(struct gspca_dev *gspc gspca_err(gspca_dev, "reg_r: buffer overflow\n"); return; } + if (len == 0) { + gspca_err(gspca_dev, "reg_r: zero-length read\n"); + return; + } if (gspca_dev->usb_err < 0) return; ret = usb_control_msg(gspca_dev->dev, @@ -250,7 +254,7 @@ static void reg_r(struct gspca_dev *gspc USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 0, /* value */ index, - len ? gspca_dev->usb_buf : NULL, len, + gspca_dev->usb_buf, len, 500); if (ret < 0) { pr_err("reg_r err %d\n", ret); @@ -727,7 +731,7 @@ static int sd_start(struct gspca_dev *gs case MegaImageVI: reg_w_riv(gspca_dev, 0xf0, 0, 0); spca504B_WaitCmdStatus(gspca_dev); - reg_r(gspca_dev, 0xf0, 4, 0); + reg_w_riv(gspca_dev, 0xf0, 4, 0); spca504B_WaitCmdStatus(gspca_dev); break; default: