Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp747314ioo; Thu, 26 May 2022 13:58:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHZ+RGi/oPOdt/QL5H3WTEtp11nYYHq1+vVfqdurrSk+HqPgpxgKiDy9GNVWcIfTDX0lmv X-Received: by 2002:a17:907:3ea9:b0:6fe:b416:fe20 with SMTP id hs41-20020a1709073ea900b006feb416fe20mr28516554ejc.358.1653598707025; Thu, 26 May 2022 13:58:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653598707; cv=none; d=google.com; s=arc-20160816; b=lsE697mWSiTclDAHdnbv5SflGteeE+ZQCJ8/uehKzgYQWuqkx0w+t2aOGcuYJIzAAL +MboDH5oZMhOUIIkHuL6kVmfFi7utQvynxT2uaVo0f72sCZW8HBy0A07zgqHtvpxfnXT /TXO5d+TWSN2nAXm99EFQH75Fce60LKYazKGOXsNd1Yy8uL5M4nmeO8lZagwun8fYwGb b3BSUZ0OxaUCmcJngVPsLisjxJTVrlRpU+PUe7ZK3IfkeBSyTz9Mz9gmY+69EY4k0El5 Sq6bF5LtcJbikVFIgqH/N9/UxoJXkZ+p762WqnkdGDFhh0to407KomzsF7Wuw8KBS3SQ QhUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=83qsgRrIHOn2RSbwDsfrRxuBXw3apvQPm7JZl44Kav4=; b=oPndVb9zF2PPGyRgyXYzfdLt7NNrRLpuZENt/e8C5ZkzsVe6/ES8FMSb0/cruIx8jv X4SwM6f+985Zu8TuSV8gohXldO7udK1AiwEIRuqyGmUD5hlvanJ1omWUwjhxSB19NQHo f1yQaY/+WxaOq4a+51UinNntUgT1e5o92w5K03akOywNCuRSOvXwhOQkq14oOEaI5Zz+ xWoRBU2Mr0gFnozzwrB8xv+N/jPESiuh2MWkvOy+MyuYdVKDwOxbGlCUMiCPTpqz9LOk bCoBbie1ruScYia2rFJZYZ3G0o4bWx4BEdlB7SMop/l1SecYXVp8jUY9gLxWWuypivbA 4k7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=O7j7RgMI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d13-20020a170906344d00b006f375d5e033si515957ejb.631.2022.05.26.13.58.00; Thu, 26 May 2022 13:58:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=O7j7RgMI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240732AbiEZMCm (ORCPT + 99 others); Thu, 26 May 2022 08:02:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235180AbiEZMCl (ORCPT ); Thu, 26 May 2022 08:02:41 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78DCFC8BEC for ; Thu, 26 May 2022 05:02:40 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id h13so1525437pfq.5 for ; Thu, 26 May 2022 05:02:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=83qsgRrIHOn2RSbwDsfrRxuBXw3apvQPm7JZl44Kav4=; b=O7j7RgMIDxEyauRoBqv46L6OxDslw86kOtq4JcWBN0WQWYndBfKPRlXE5MupB3YSP4 puX6G/Qp+y1wStHgi8q0ncU/U7HMbVAk124D/8Bw8/ktk7YdTYnCjSkZIdDrSkratO1+ 5HlZGcz3dFzPq7k0E8MgXw+Lzgl8HUomCOui+xdsmVPYboqB3ldcell8VoDwfjuobYcz YjEcUTCzfB5oAd4+RLI5eMp3PdTDEYbGDp1lXYjkNWDhAkGy3PdgVKm4C6tvjykR+sMX KeOXZaIXvHr+zDolJmz0FVYFfnIPyZNrR30xadjhwIOr8d7u8vC7gy+6qxtBtwKUwKYu /5iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=83qsgRrIHOn2RSbwDsfrRxuBXw3apvQPm7JZl44Kav4=; b=b3kwMQ8PZcaMZGSfHQMPULAkuRVkAcLggJddRozDllBy15VNyyHfmxQBNUvaKcwxIn 0siwvCkayjYO6In/Spj02JXdxwpN/Ysm+aXJxYaCcLWTs4/f3ocBgx4GTXW69nQZ3vVB r+AbV6geAfmTH8vmN35KXvwb6PTTi4603rbfv2hP3qmSs5Zu9h+xx63686C8swC2zX2E B+xlsUtBp9a6MMs8OyM0NZ3/bbabB0vGXQ9drWwHni4zOT3Biv33SSt4grzfMTN3VuMk g/4HHi8e2HqXBp7XJX7h/K2YPPUSRrtpDNrI6DMxFsLPiFrT9pq0/8g6f83YwhrVmng3 NzFQ== X-Gm-Message-State: AOAM531E8IzHfnuMEzrWzQ06N7HzYnW+bH1LL5T6HF9DBsGRn8KumzEZ QUbpAL6gehZMfqZaAxc2tPJyrCv2BzMzTshH1g== X-Received: by 2002:a63:4525:0:b0:3db:8a4d:8a77 with SMTP id s37-20020a634525000000b003db8a4d8a77mr33354669pga.542.1653566559987; Thu, 26 May 2022 05:02:39 -0700 (PDT) MIME-Version: 1.0 References: <20220514114819.2773691-1-zheyuma97@gmail.com> <628BBEEB.9010306@gmail.com> <628CCE44.6020007@gmail.com> In-Reply-To: <628CCE44.6020007@gmail.com> From: Zheyu Ma Date: Thu, 26 May 2022 20:02:28 +0800 Message-ID: Subject: Re: [PATCH v2] char: xillybus: Check endpoint type before allocing To: Eli Billauer Cc: Greg KH , arnd@arndb.de, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 24, 2022 at 8:24 PM Eli Billauer wrote: > > On 23/05/22 20:15, Greg KH wrote: > >> Rather, it works like this: The driver uses the EP 1 IN and OUT endpoints to > >> > query the device for a data structure, which contains information on the > >> > device's communication channels. The driver sets up device files > >> > accordingly, and it also gets informed on which bulk OUT endpoints are > >> > present. > >> > > >> > For what it's worth, I think it's fairly safe to assume that if a device > >> > returns a legal data structure (which passes a CRC test), it's a XillyUSB > >> > device. > >> > > Why? You still need to verify that the requested endpoints match up > > with what the device really has. > > > OK. So to summarize: > > EP 1 IN and EP 1 OUT are always present in XillyUSB devices. > > On top of these, there might be additional bulk OUT endpoints. The > driver resolves which ones in setup_channels(), by scanning a data blob > it has received from the device. This takes place in the for-loop inside > this function. When (out_desc & 0x80) is true for a given @i in the > loop, the device has a bulk OUT endpoint with address i+2 (e.g. if this > condition is met for i==2, the device has a bulk OUT EP 4). > > So it seems like setup_channels() would be the right place to make this > check, since it's called during the device's probe. > > I guess it would likewise make sense to check for EP 1 IN and OUT in > xillyusb_setup_base_eps(). > > Thanks, > Eli Thanks for the detailed explanation, I will try to send a new version of the patch to fix the bug. Thanks, Zheyu Ma