Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1126347rwb; Fri, 18 Nov 2022 13:11:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf7+nFpAhXgBWnhMOGOJfg+rZ4LfUDDpTnOPc+UFLEhyJzm+SO8bzQBQ40LbIHOgh+l10Dp2 X-Received: by 2002:aa7:d8ca:0:b0:463:4dd8:d6ea with SMTP id k10-20020aa7d8ca000000b004634dd8d6eamr7840083eds.426.1668805899084; Fri, 18 Nov 2022 13:11:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668805899; cv=none; d=google.com; s=arc-20160816; b=1I12GxKB8UxOai3wCvz3ObBGxr5iS2kPlth7FmIjj4aBok6ll20PBi5PxnsD7cW8Gn 7L+ByQwiFz+eDEh3tkGMBi9CyjTYh8CErqwiflJSDwSxei25+aDZBDwJx1V8iHwj2xWb J7bZ9qQ9fdn0WHIpRx4DEJiherdEXaq7WxbB7R/Lguiyp00+N44/z55zVp5Y15CHLauu cdNFRAs5EfH0bodRFfdn3IQiNDhvO6Hyr2X4QzXv5PSHGle40v9KNDPqwOe+CAI6E3ZT Ts1oc5OsV7dWiXxgQhTkdhoKRXLpj8tXXv2+A5MAact+qWQtrmkYu0GH4xPlAS8A8bK/ cmRQ== 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; bh=2iMp9VlpLiaatHp56uljv0cfOP7uZssf5dn2roT+yEM=; b=lsIj8g/P/fp0tupmQgID82gmJLezbzjyrnFj3Hq5OJy957jWb+irhxnzYQQovqFYUk cKhZaxVbGskZfXCBHz/uuSvgYGhMtg+BJabjqtQQ6/Fx/vaPPmSParN7FsWHdn4MxUmA Y+Yu8BsAZp2jOiJo4wNU1mG4y4cVw5vdOp5jz5ztZboZq6W+Iz/T9hrx/xeaVyve1BJM wtuye6GcoN4VFYKANfY6Bpm3gGUfUvpZA7VPrJtryuBkLG3we/dwJxEDKCrVAukyCzW+ ElDAScez7GTgrcsgCR7WMAW6Cp4hubDZM0IpxVetOo0nL30Pl1tgZHveaoL4YR4IVrTf QQjw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ht10-20020a170907608a00b0078d148daf4bsi3939654ejc.409.2022.11.18.13.11.15; Fri, 18 Nov 2022 13:11:39 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230035AbiKRVH3 (ORCPT + 90 others); Fri, 18 Nov 2022 16:07:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbiKRVH0 (ORCPT ); Fri, 18 Nov 2022 16:07:26 -0500 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id A443798272 for ; Fri, 18 Nov 2022 13:07:25 -0800 (PST) Received: (qmail 50645 invoked by uid 1000); 18 Nov 2022 16:07:24 -0500 Date: Fri, 18 Nov 2022 16:07:24 -0500 From: Alan Stern To: John Keeping Cc: Lee Jones , Greg KH , balbi@kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: Re: [PATCH 1/1] usb: gadget: f_hid: Conduct proper refcounting on shared f_hidg pointer Message-ID: References: <20221117120813.1257583-1-lee@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_PASS,SPF_PASS autolearn=no 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 Fri, Nov 18, 2022 at 04:37:32PM +0000, John Keeping wrote: > I don't think it's at all simple to fix this - I posted a series > addressing the lifetime issues here a few years ago but didn't chase it > up and there was no feedback: > > https://lore.kernel.org/linux-usb/20191028114228.3679219-1-john@metanate.com/ > > That includes a patch to remove the embedded struct cdev and manage its > lifetime separately, which I think is needed as there are two different > struct device objects here and we cannot tie their lifetimes together. I still don't have a clear picture of what the real problem is. Lee's original patch description just said "external references are presently not tracked", with no details about what those external references are. Why not add just proper cdev_get() and cdev_put() calls to whatever code handles those external references, so that they _are_ tracked? What are the two different struct device objects? Why do their lifetimes need to be tied together? If you do need to tie their lifetimes somehow, why not simply make one of them (the one which is logically allowed to be shorter-lived) hold a reference to the other? Alan Stern