Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp334932pxy; Sat, 31 Jul 2021 08:42:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxV1aeBOpxxhgAxPGUv4Iv/ZE6CHogvW8d1+rPasfRFP8QVqUGSxdE/OSXT1JUtaOxZ6Aja X-Received: by 2002:a92:c504:: with SMTP id r4mr732046ilg.131.1627746175359; Sat, 31 Jul 2021 08:42:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627746175; cv=none; d=google.com; s=arc-20160816; b=K5FR9/ietaaeNjU0zc4SlKp+3bPvGVpW+O5q/l7euVCa4Z21sxdxrasQAGjbx6GtlL dmBqL30ae7M1pHpmcGRjFSdjnwJJma3zNJhbPZ3YHTddnl/w5CUyBt5dOlAA+eEXPQ9R YLjWyg2P60I0g1ppQWu76650RK8mBY6m91Nge6vbNHGts9oMt3cgF6YgKsJh8u9n8cUE JUQnnFoz8cZMSrCGz8znGqihYWoqRIMy8GSWwWc0u/H3+NcckOaf+Xf95kUAH9yJet1a 1AWAmDzwIBCczc/4gNKAs1VAL4m0hHa6pD1jkeUu2QzTx6Ix8o5oSzss9ec1GSKxdmqL MwFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=L+dmgbj+bVwO8E/tSf1gwHCr2j9+KZpfrmwTyXXdAvQ=; b=XdDDTQoM6uEimWFPq6breIfP7jiNgoHvPbf7vStnyzw7EoSiaU7kGGE2BlSYLyEVrT d7WEMOr+6hhJ8OxU+6kbbH91FnQTCMsCR4AyyU/EnLZDRndYxRetKztK4fptP+60Nr/s ylxJAD2NR8e2DDGdiFc4Q/mxTpK/h3Zo8bA0M5rLeQtGP+zGa3E+yamLCPtI9F1yFLbq 7xcypLjO9+J7Vmyutx2Dno/rICF+BXb2uYMMd6sTUBVhFvPKjyw1AcMzTq9qqKdQcgiO 8LCXFFEE7ByptORB0xMyVlc6imWXiV10mkbbWyzeU5DdZGfO529hMc+14t7dH9LsTj8U DNeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qUtgfaVv; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q15si6762877jat.18.2021.07.31.08.42.18; Sat, 31 Jul 2021 08:42:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qUtgfaVv; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-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 S229541AbhGaPlP (ORCPT + 99 others); Sat, 31 Jul 2021 11:41:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229711AbhGaPlP (ORCPT ); Sat, 31 Jul 2021 11:41:15 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CD81C0613D3; Sat, 31 Jul 2021 08:41:07 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id a192-20020a1c7fc90000b0290253b32e8796so8873021wmd.0; Sat, 31 Jul 2021 08:41:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=L+dmgbj+bVwO8E/tSf1gwHCr2j9+KZpfrmwTyXXdAvQ=; b=qUtgfaVvIr5FUvC+rLRDT4EGaMTXePTgo6MGL5tJ85WgWy6pJclGaBChTZSga+9ZER /JeYeehywW/7lTd9HwxD1Pl590MhXwVlGdgk4Hw8L316k8Wipbt55hkxYvuK2Kpg4YIc FXY27oHX70ZwKi1/nudOZTUI12l3S6xj0ieENv265Ewp9JNLwKUwJxK5oZcAenGbAE65 rwpERw4u7ewcBL5JALsaTNrX95FLTjafeIbYPH6sG7oxsRA5bVh5QPIEkMQhjESL/mEl HY8LR/Q1pQ7H6ceNxxkZXB+BtAtn6P3au0Mzkohckkm7oGK8jxzdXDAU03yzwiOkgXCT qbHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=L+dmgbj+bVwO8E/tSf1gwHCr2j9+KZpfrmwTyXXdAvQ=; b=LDqSHc946ggtpY1L474FjaxLcIWUu88wQdwrHRwDzrs9HUDM6hGYUeITIxOBkq9ZtY y1qcZreIFgiBAA/vfv9ajwd5DeLLc0ed+WHcAv3fBZEWMVhdqTqDvh700JYHTWFTAfOq LWcA4oAHOFRlhgIIMm5HEnoI7nyas0CIv3u46XqcpFxjPbn4htDREY7VzG3AdQNnotwG mDO0S1Uh+mVDQ0sypoN3T/LuMVrSLFkT8p80MTxC8eXtIgSjgKDDD/3oLnZtMAaw62LD 8b0ZSY7zmmm4PRnwStemsMwcj2GTZGWyQt8Tywg4dMNGffm85YIETLGlaS6Qb1EV0bzM p/dg== X-Gm-Message-State: AOAM531N5MJ6okX6jel4vkQXA9C8R3gTTYIPhVxT2lnpvasLWSbXW983 yiwaknzKscsZ4FrYcMMMaY8= X-Received: by 2002:a7b:c409:: with SMTP id k9mr8502927wmi.117.1627746066210; Sat, 31 Jul 2021 08:41:06 -0700 (PDT) Received: from pc ([196.235.233.206]) by smtp.gmail.com with ESMTPSA id t8sm5730882wmj.5.2021.07.31.08.41.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 Jul 2021 08:41:05 -0700 (PDT) Date: Sat, 31 Jul 2021 16:41:02 +0100 From: Salah Triki To: Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz , gregkh@linuxfoundation.org Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] bluetooth: bcm203x: update the reference count of udev Message-ID: <20210731154102.GA908767@pc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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); -- 2.25.1