Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp713315pxv; Thu, 15 Jul 2021 14:12:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3/Lbb+XA/QHizhZcK5qEe8Hzefaw7wAb6eoheYN0IYBexMkBbDmb3pFCZ7tsT25OKFkg5 X-Received: by 2002:aa7:cb0e:: with SMTP id s14mr9834869edt.141.1626383537524; Thu, 15 Jul 2021 14:12:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626383537; cv=none; d=google.com; s=arc-20160816; b=z6J5A/GJv+VQMemBqpYwd1XJzaBPSi4JZmv1oyfpLOs0dFimqNULogUtBnyup63nTA qutKZ4OrA6Ly0gUXQmh0kTS9dQo6S8C0FS6XgOk32bGNVKiHEThQGzGYZdFe5uEpUHfd 77cPnvaHC4QRloTeZ9h07Kg+dNUNTgeYDn41o17IvS8/1tvzBtSt+2JpUmhHBwfF7lWK XPTiNVwOUK615huCGp2wqB5lCX6654BYsQL0410KrZAGs9z/7C7cJ3dIAnWzvnpb+JuT +sviO9DixjtG2mvx0nducVAOz3KA1LR+Kj0eq44/Pg8UwnB+t0wy4TYIQpJUbWs7FRBX vHYQ== 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=KM5iMkGBmgxr93qdcDhXF0XfpEK/GwbUPBnWlMSxssBxRsbyV/yqOs6XKMeEIFXBze baxeqowFa7OU6NYDBAxClfHxAtehwIZrvy0pjmb53XysCTJf4UkgIVaTlpYXEMoWNMgE dSy1XY5FENWGApYN24tZ8BcTF+lHgMlvCUz/DVtKWok4kaJCKiM7HqSutPXrNmLUIGbX LDnRnFAls5zR5/ckYmpzkZSwlX1fcpGpjd9/SLrgwfQzlFcME12HEazzCcGUqvaferp2 1PsHSfjJh8t2NYDKTgskb+8gNCDAog/2DTlOxvzXzUV/5sFdEz0fo2d49ySd8I9t3xnn i63Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DN5M44R+; 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 q5si7763951eji.717.2021.07.15.14.11.54; Thu, 15 Jul 2021 14:12:17 -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=DN5M44R+; 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 S244051AbhGOTXC (ORCPT + 99 others); Thu, 15 Jul 2021 15:23:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:46122 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240025AbhGOTGm (ORCPT ); Thu, 15 Jul 2021 15:06:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 30524613F3; Thu, 15 Jul 2021 19:02:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375766; bh=g82bctk938ScfdJINpkIncGH+nIC5VosejmaIJZh80I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DN5M44R+Uz7LwkqgGl+vcLgnWYMhO6yL4x9heDjB1aNvkJzLvz2j2aW3jNYrQoJ3j JRPO64TF7UDLMPNnr+0lCIHIjWXcVTO9l95wY6HZne5X6hb2DmK8OhvaSPy5Vk8SKS b9Y42v8tnV47lcuvezPrTcXv7TWRrsnenwP7jh1s= 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.12 227/242] media: gspca/sunplus: fix zero-length control requests Date: Thu, 15 Jul 2021 20:39:49 +0200 Message-Id: <20210715182632.874200480@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182551.731989182@linuxfoundation.org> References: <20210715182551.731989182@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: