From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36319C433EF for ; Thu, 17 Feb 2022 15:25:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232830AbiBQPZV (ORCPT ); Thu, 17 Feb 2022 10:25:21 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:56660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236472AbiBQPZU (ORCPT ); Thu, 17 Feb 2022 10:25:20 -0500 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 5AB982B101C for ; Thu, 17 Feb 2022 07:25:03 -0800 (PST) Received: (qmail 821319 invoked by uid 1000); 17 Feb 2022 10:25:02 -0500 Date: Thu, 17 Feb 2022 10:25:02 -0500 From: Alan Stern To: Dan Carpenter , Greg KH Cc: Dongliang Mu , Salah Triki , benjamin.tissoires@redhat.com, jikos@kernel.org, linux-input@vger.kernel.org, linux-usb@vger.kernel.org, noralf@tronnes.org, syzkaller-bugs , tzimmermann@suse.de Subject: Re: [PATCH] HID: elo: Fix refcount leak in elo_probe() Message-ID: References: <000000000000d31cac05d7c4da7e@google.com> <20220217080459.GB2407@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220217080459.GB2407@kadam> Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org On Thu, Feb 17, 2022 at 11:04:59AM +0300, Dan Carpenter wrote: > Salah sent a bunch of these. The reasoning was explained in this email. > > https://www.spinics.net/lists/kernel/msg4026672.html > > When he resent the patch, Greg said that taking the reference wasn't > needed so the patch wasn't applied. (Also it had the same reference > leak so that's a second reason it wasn't applied). Indeed, the kerneldoc for usb_get_intf() does say that each reference held by a driver must be refcounted. And there's nothing wrong with doing that, _provided_ you do it correctly. But if you know the extra refcount will never be needed (because the reference will be dropped before the usb_interface in question is removed), fiddling with the reference count is unnecessary. I guess whether or not to do it could be considered a matter of taste. On the other hand, it wouldn't hurt to update the kerneldoc for usb_get_intf() (and usb_get_dev() also). We could point out that if a driver does not access the usb_interface structure after its disconnect routine returns, incrementing the refcount isn't mandatory. Greg, any opinion on this? Alan Stern