Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1059245pxy; Sun, 1 Aug 2021 11:02:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxo2mzJSHB0HeH1VS3Xn3PI91fOAoBk6tOO1a6/FvVFfB3BAvMn6y+teRPEZq8Px5PkEZ2V X-Received: by 2002:a6b:c812:: with SMTP id y18mr4544631iof.3.1627840929559; Sun, 01 Aug 2021 11:02:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627840929; cv=none; d=google.com; s=arc-20160816; b=DdhRt1r/yY9wPnfedpXSQgnq1LhoroXggax5ffFaNAt6eURqoW/3GGjoziaAMIqjnq RlhW/HPBTnD8PwbZ/xYN3a543UduBqAIyyS2NbA5B+FUvFIBfSByxUFErTnOrfYu98Qe YCQpCgmMgGdr2AXMEnuVAxuALEW0tpf4GGDYNOhvX5oP+c0rUDS6T9osfigK7F4NrsEl s1YXQHPqFfmT8Hxycz4MYwYJDbTQUAW3kBkuxf08Mrja+xwsjXJieMr26tzfmFbzdg6U ZUukTR90wJJwlPlcVduJvAdgWkTYzuLFZYAqkGK7RiGm1S0iOCInh785nL6UjMDPV2xT Yawg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=Y4JFS+o8Vh0jV+A2dEQCVC/+FoVxKkOZ+dTGJOCdB0U=; b=Zu1bRgfK7Z6jjjZouX/iYEbyvaNdcCTcFrS4ektoMXNT7tIDAzn2J8Cm4JUIN0YsKD 9HQbwto63fnEmpQj4LsS+598vAxqA8lK5Gf2A5i8jhFGJjFE/bkpQ9kKRsITRwLDJPb+ ajJYcK74Vb2K4QRobOV5A0LB66B+5vfZ7raNrkA5cW3+x4wxLA+seG02L7lIo3ZCZHhP EgNbTslSyK0qeQMSLHTjTVbKQyfP5Hb+PkO6CrgYmH458I1FLrNdRF3EmZK2I7hvWk9i n2pS+ZzdX+puWXDtkKlHLhVUPnwu0Av17HHUPUTW6p7TFB3nsdPUYMC3ExgW5pmU0NyC pxDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w5si10226959ilu.14.2021.08.01.11.01.55; Sun, 01 Aug 2021 11:02:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230130AbhHASBQ convert rfc822-to-8bit (ORCPT + 99 others); Sun, 1 Aug 2021 14:01:16 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:38047 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229851AbhHASBQ (ORCPT ); Sun, 1 Aug 2021 14:01:16 -0400 Received: from smtpclient.apple (p5b3d23f8.dip0.t-ipconnect.de [91.61.35.248]) by mail.holtmann.org (Postfix) with ESMTPSA id B636ECECDF; Sun, 1 Aug 2021 20:01:06 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.100.0.2.22\)) Subject: Re: [PATCH v2] bluetooth: bcm203x: update the reference count of udev From: Marcel Holtmann In-Reply-To: <20210731154102.GA908767@pc> Date: Sun, 1 Aug 2021 20:01:06 +0200 Cc: Johan Hedberg , Luiz Augusto von Dentz , Greg Kroah-Hartman , BlueZ , open list , Alan Stern , Oliver Neukum Content-Transfer-Encoding: 8BIT Message-Id: <9B2209B6-D371-432B-A3F5-F1CD7C7967A3@holtmann.org> References: <20210731154102.GA908767@pc> To: Salah Triki X-Mailer: Apple Mail (2.3654.100.0.2.22) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Salah, > Use usb_get_dev() to increment the reference count of the usb device > structure in order to avoid releasing the structure while it is still in > use. And use usb_put_dev() to decrement the reference count and thus, > when it will be equal to 0 the structure will be released. > > Signed-off-by: Salah Triki > --- > Change since v1: > Modification of the description > > drivers/bluetooth/bcm203x.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c > index e667933c3d70..547d35425d70 100644 > --- a/drivers/bluetooth/bcm203x.c > +++ b/drivers/bluetooth/bcm203x.c > @@ -166,7 +166,7 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id > if (!data) > return -ENOMEM; > > - data->udev = udev; > + data->udev = usb_get_dev(udev); > data->state = BCM203X_LOAD_MINIDRV; > > data->urb = usb_alloc_urb(0, GFP_KERNEL); > @@ -244,6 +244,8 @@ static void bcm203x_disconnect(struct usb_interface *intf) > > usb_set_intfdata(intf, NULL); > > + usb_put_dev(data->udev); > + > usb_free_urb(data->urb); > kfree(data->fw_data); > kfree(data->buffer); I do not understand this. If this is something broken, then it is broken in btusb.c as well and that driver is heavily used by all sorts of devices. So we should have seen bug reports about this. Regards Marcel