Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1415627rdg; Sat, 14 Oct 2023 00:58:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH3oOZxlhl8I/epgxsZcI6WSMcLpA3dtSLkOHtJjsO3s35ro0Mha3LtnL8AaOGXSrbd4npt X-Received: by 2002:a05:6a20:7d9c:b0:129:3bb4:77f1 with SMTP id v28-20020a056a207d9c00b001293bb477f1mr31357230pzj.0.1697270305611; Sat, 14 Oct 2023 00:58:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697270305; cv=none; d=google.com; s=arc-20160816; b=rhTcSWduWhrBQag5g3vkysqXxNHuAMu2EWH20+lRMS8K3BGDGZVIwGx18vBK+TRBB/ tda5xaiF6JW61EhwCD0iNS6RVOl+8ahuvHRyM6oWX+3AgXIm4BsGQtKikEwQr/OtgjRJ xV3jnXRlFSD/qZc5Kx5YauFuo78b7W5IdCTZoyVmeEhVue5egHFC8koj/VOZB08NgaLP 8FT0YUz8PR8+hlAwwX9z9SdfmOQ11Wk9ir5wsJdt6i3NEC6GDCWwN7SpufL+WsIv5jgb jjgE2AG0DDCy9WG1wlXsgUNgf5KHP8idOhd4OKRzqGpODzpSDoZpXxgDtLaPHVr40bjn XNxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=C3JZBj8UNE1RTHFSrGe4HMHkrU5m6j5rUcUwl/TMX+o=; fh=Sl/fxGwZSYkQNujMwXLe3d7uo/wprUIKE23qbZGBQ/Y=; b=meu8Hu92BJUDhdtVEBv4ZXHTrRC2KanmcIXMzfVuanEyWm1XxEO3QP0eXglh7zKjSA PgXRBOuGdsxbR7FuBUgvf+WY1Y21Ieuu1gpyCJVUmGiNJDtSBibymmRW8m4MLuZ1sZmD BK5ATkOLj66SwU+Cuj2J8B/hqylU/psASCyc8PL2DBfYf8SJ99IvnaIMlBgGfVoPoLoy I3J4AqYpOKKICL1dXhcFJkzt0LNKa6eqrujElgNgbz4zTEswZoBdctb0VNaZx2k7rrIE yENoOzhs2hyWpapxHmdzy7JWoGYkCNVmv86XYKNmzfPmpOWx+bn/fBB5FCrDPZppa6R+ kh7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QlMlXx8H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id k3-20020a170902c40300b001bbc138af04si7044042plk.158.2023.10.14.00.58.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Oct 2023 00:58:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QlMlXx8H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 1137582CEFE3; Sat, 14 Oct 2023 00:58:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232876AbjJNH6D (ORCPT + 99 others); Sat, 14 Oct 2023 03:58:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232838AbjJNH6C (ORCPT ); Sat, 14 Oct 2023 03:58:02 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2B8EA9; Sat, 14 Oct 2023 00:57:59 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2c503dbe50dso21867221fa.1; Sat, 14 Oct 2023 00:57:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697270278; x=1697875078; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=C3JZBj8UNE1RTHFSrGe4HMHkrU5m6j5rUcUwl/TMX+o=; b=QlMlXx8H4zON5JiYEUp/FsEZH4xm4ZLD9akxFAE/hSULXC+QzapSC8M9PxTpVeEx0m 6XgwGZ5IJNFBcY+fts1ZFSK084PR8jsq3Ol3w9VD5Efb3UxrXSbfrthLiN8sN0KMeaDF aDLWK85xdkWpLPcDqDOZCjpvwF61FCKGrF33qxrLpQEQXKQRiu4mtyASizU5v78Hyxza ZxrlHgWoU0mv/WcK3UZu9HPpMOmMs18xWAai2QvdrK7elKYNV9zQHuiuAadR6WbAwrGv w4jrx0drzDX8rLbGlx389/4cCshJtX/W3i4vLarb34iATZOJKnhth678Na/NX3Pg6hyt ejRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697270278; x=1697875078; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=C3JZBj8UNE1RTHFSrGe4HMHkrU5m6j5rUcUwl/TMX+o=; b=DknY5Zm1Vpj9OdDKypuXT8PEQbAJE/b/rfcSKUPk9pOK43ZIQAihJFk9MgQOcI8NlY RI73wDkMDZrWEgwQn/t0LWUP90vAA8FLtpPae+tXpI+fdUtuH1nC2Vu44B5DnbK2YX+2 ukxmz9zSdfUOJ112SKkGyKnRs5awv9OyJXlpBbuMrnLX78BGWryobwLZfosx6dhw/Zm3 e9XeVlfGVH4m/FFUQGOjFm3CFauvH/Tb9AfuJMsabsctUzNbt1tcxLJRvTQfMnXpY7ZY 49k7vML3/l1MdTSvwcAu0VSYuf/8DyEkJ9Px8dSijFws38BKVrCe8Jz0mZlYTU/20/J4 T+Tw== X-Gm-Message-State: AOJu0Yxf51QTt5e0hDgOl19BVd5BDZB7tya8WjrEuX+fdmTnCZw1v+Nf 92alOT4YFklhirLqrSltw2E= X-Received: by 2002:a2e:a9a2:0:b0:2c5:32b:28ea with SMTP id x34-20020a2ea9a2000000b002c5032b28eamr4145909ljq.32.1697270277851; Sat, 14 Oct 2023 00:57:57 -0700 (PDT) Received: from ?IPV6:2a02:8389:41cf:e200:57e7:d911:5fee:d153? (2a02-8389-41cf-e200-57e7-d911-5fee-d153.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:57e7:d911:5fee:d153]) by smtp.gmail.com with ESMTPSA id e24-20020a05600c4b9800b00405442edc69sm1289370wmp.14.2023.10.14.00.57.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 14 Oct 2023 00:57:57 -0700 (PDT) Message-ID: <973e87e1-13a5-40d2-9917-ed1984fb9edd@gmail.com> Date: Sat, 14 Oct 2023 09:57:55 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] Input: bcm5974 - check endpoint type before starting traffic To: Dmitry Torokhov Cc: John Horan , Henrik Rydberg , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+348331f63b034f89b622@syzkaller.appspotmail.com References: <20231007-topic-bcm5974_bulk-v2-1-021131c83efb@gmail.com> Content-Language: en-US From: Javier Carrasco In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Sat, 14 Oct 2023 00:58:23 -0700 (PDT) Hi Dmitry, On 14.10.23 05:03, Dmitry Torokhov wrote: > Hi Javier, > > On Thu, Oct 12, 2023 at 06:51:49PM +0200, Javier Carrasco wrote: >> >> +static bool bcm5974_ep_is_int_in(struct usb_host_interface *iface, int addr) >> +{ >> + struct usb_endpoint_descriptor *endpoint; >> + int i; >> + >> + for (i = 0; i < iface->desc.bNumEndpoints; i++) { >> + endpoint = &iface->endpoint[i].desc; >> + if (endpoint->bEndpointAddress == addr) { >> + if (usb_endpoint_is_int_in(endpoint)) >> + return true; >> + } >> + } >> + return false; >> +} > > This essentially reimplements usb_find_endpoint() in a sense, so can we > instead do: > > ep = usb_find_endpoint(iface, addr); > if (!ep || !usb_endpoint_is_int_in(ep)) { > dev_err(...); > return ...; > } > Thanks for your feedback. usb_find_endpoint is a static function from the usb core and in principle is not available here, but your code snippet seems to reinterpret usb_check_int_endpoints() for a single address. I would suggest using usb_check_int_endpoints and pass both addresses at the same time (if both exist, of course). > > Also it looks like the handling of button endpoint is interleaved with > the trackpad endpoint, I wonder if it would not be better if we have a > separate "if (cfg->tp_type == TYPE1)" where we would do the check, > allocate URB, and did all the rest of set up for button transfers. Using usb_check_int_endpoints would solve this immediately. > > Thanks. > Thanks and best regards, Javier Carrasco