Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1334073rdg; Fri, 13 Oct 2023 20:04:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IERnWQ+CDdJyTBb+Jmwi/hqEh0hJqKcodQWdzivKl8KWyE6kYs460Ac4pqKTQo0NVIkEYgo X-Received: by 2002:a05:6358:9226:b0:143:21e8:11f2 with SMTP id d38-20020a056358922600b0014321e811f2mr31026534rwb.11.1697252647432; Fri, 13 Oct 2023 20:04:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697252647; cv=none; d=google.com; s=arc-20160816; b=YImztxUNrZevgUcLJG4BfaTsbO7mBY+XZnqTqeSRvq1dRzubnDNGJb3tCMxB2g1bRD S287sB1fxOGUu4fS/KgF0jA++nJWomi7GSHnau8GKzokXhOIXJP3mwOGUIBDIVLpMeHI SAkcfeYiufQl6AhKTD8CfDcnu1tn6/tEv66OdjL0Q7FHx8l9NB1sIzt/vPEcprHnkfFU Us7Py1/LYe0KP0a97+4N5Hp143CijNnW/H7PSYx8YKNlhcR+kB5Kd+pTpcnhJ+BOA5oz rZeyRx2OVIMqq1pb3DEDS+qgioqBUPCpJPzeMBbdFz+WVoEPQFPUbII13YlYcsGCpoR1 r4xw== 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=rJ41a+RB4Qcm7rS/XEuMa2q8TcH82epeacH0wtL3/8E=; fh=RgEQgvz8hTLlMAQ26M8DtEU0EnPoopxjxxgl1ElTwgE=; b=sAeVvMfB+5tahCz39ShPEXSiPDvK2/6iVdFfQxSnqopSt5aip4blbctFuqnUhVEiyz 4ZApWbKfYFQX1wuAK+W7cYFM/zoHnQxoSynelDEMHBu4f+WXSJnV9yDSTeCasPGOJNHy CW7qTlW8r865PqYsEYkPsxwObjR1x0aLo+Gq9QDA/2ZUlQxSsH9o3HnDqDKHWfZGprPd OxoX3suzMgl1nA6HZlkiotmaSTC0N/WToJYPU4wJPXAjlblCRCqzu15T5nfLeyH2MYRp kvitG/luXzIGI6Yf/XQkYtbntSkSFz2bu+7qAVFprPdFS1fn2PE5ibbwojSwbDxO1JE9 2Tyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=TYlvQymo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id v189-20020a6389c6000000b00564f223ef05si3536540pgd.11.2023.10.13.20.04.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 20:04:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=TYlvQymo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 1DE5280C774B; Fri, 13 Oct 2023 20:04:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232326AbjJNDDs (ORCPT + 99 others); Fri, 13 Oct 2023 23:03:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229958AbjJNDDq (ORCPT ); Fri, 13 Oct 2023 23:03:46 -0400 Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15EBBBF; Fri, 13 Oct 2023 20:03:45 -0700 (PDT) Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-3b2bd27f203so83557b6e.3; Fri, 13 Oct 2023 20:03:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697252624; x=1697857424; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=rJ41a+RB4Qcm7rS/XEuMa2q8TcH82epeacH0wtL3/8E=; b=TYlvQymoO07ENRA7PXMwNyo1tkE6nWTgWc/VVEQThBy3y+ztGIaO+y1gh6bFazSw87 olSRLGoK+GUYZ8awURVf0yyFMqdD3RricuTuNkIGS1ODRswn79JkSjDFExBlfWE5APGR kQocaO9rHMnIk5nJZELhd5AoN9Dct4FfF8OFv2EhYk+O/PBheYevrDtfc6FPkUxaQ7N5 flv6LSFiIpWc8lNQK80Ue7FMLz4oElIdSQj98jQZfU7lsS54Uvk1IrJQN4kspxUMyW9w R2EmlsX41PozjLSTJUasV0sYmZ/ApNqr99AJNGyeMK7M3I4DHfa/cdZrAobsGdRNRWZB xnIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697252624; x=1697857424; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=rJ41a+RB4Qcm7rS/XEuMa2q8TcH82epeacH0wtL3/8E=; b=gUWnaYDrcN9P7OggJZViJkwv2Fx+rWMKWp9cCnO2UAycYYrtte3lcvEKQhh3S0M7rI UmneS4tFkTQDs8qfYazv0GdmWKWpYq+tt0AvNEKaCf893xgOZsMUJ0fUR7JLzhnqNcuA td1MGT3VxbzNwTwUMql7Dxcokcv3mXdvZnKt0OldPeeYPIA59mig58oQnH8jfh7qAfhi SAcJdIDrPfuTl78fkgPgAWHwjjjZ0Tc5zGlDjn6mToV5MbRknFy7aiL+eiCSBp5GfVnR mh10bdGR+m54/66BbWDIZJkVQtUohlpVDG7eKAIcxyf949tmgmrmuDm9AP0kJ2MnuFeO liMg== X-Gm-Message-State: AOJu0YxBZrvwlU0lFBXjHiv6XXAHh4yVWbQbvOxQ7wxtLHYuXfrcvprf rdNBXBg3gecKSXtyEMUGwuQ= X-Received: by 2002:a05:6808:1146:b0:3a4:316c:8eeb with SMTP id u6-20020a056808114600b003a4316c8eebmr44717767oiu.40.1697252624151; Fri, 13 Oct 2023 20:03:44 -0700 (PDT) Received: from google.com ([2620:15c:9d:2:469c:3411:2771:1b7f]) by smtp.gmail.com with ESMTPSA id hg20-20020a17090b301400b002776350b50dsm780310pjb.29.2023.10.13.20.03.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 20:03:43 -0700 (PDT) Date: Fri, 13 Oct 2023 20:03:40 -0700 From: Dmitry Torokhov To: Javier Carrasco Cc: John Horan , Henrik Rydberg , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+348331f63b034f89b622@syzkaller.appspotmail.com Subject: Re: [PATCH v2] Input: bcm5974 - check endpoint type before starting traffic Message-ID: References: <20231007-topic-bcm5974_bulk-v2-1-021131c83efb@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231007-topic-bcm5974_bulk-v2-1-021131c83efb@gmail.com> 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 fry.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 (fry.vger.email [0.0.0.0]); Fri, 13 Oct 2023 20:04:05 -0700 (PDT) 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 ...; } 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. Thanks. -- Dmitry