Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5693683pxv; Wed, 28 Jul 2021 17:47:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPc1Sn3ebtO0FTL5bfp+fIb45SIu0oeWoZkctEdP2satqL7p09pDhuzPiK05gNTFp4eYrS X-Received: by 2002:a17:906:7e04:: with SMTP id e4mr2019318ejr.225.1627519630594; Wed, 28 Jul 2021 17:47:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627519630; cv=none; d=google.com; s=arc-20160816; b=rlQASALwdrFau5xqSD8STHii4W8W84dSCag1vugghDokIYgPFHxavxJtNkhWdpYfSx JQhdExOME9KM17ag3IHQdyVWcK4YrrolwNUt7u+rTpaQ1BKEreulzo2eZ38ijxntteV8 7IXJ8pUa822uQIUdHcQ8EteGU6puaIDxBT4yG3Pyesio5ucwKdpQElYw1CFbNTUjgOye Vz7NNyXlVRo/hXlGg7zLW8reOOFBt/I50CnGuULPeRDXU9iqCulSPM3l53styU/rFoyo gwL/HHVcaVNDs004NBZqF28PGO1A+sYJ8VyYV1v7Nc/8dr0/UI4SCwz8l16jVJiWvkHB YE3A== 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=v7cnCuDq5ZGSk7DH1MRlBzKJ5po3ZMRHzGSaZzKFHNw=; b=YN/EU1I2YKkdWlKed5PWpwNpOYng8eQRlmO4HMCLgnFlq0B+MN3X+j2AbvEga4oskZ DsL7cW1oNfCY423pnX/PTVEOJWVkfXabzkjwfXAbcRS0NaPiyHRtdiMXnoxm3VunCZm2 QvrfUXcv4OCn8GSWwkQGlNm4hc+2YHK7OCc9EMIEv66o3IPbbxJMkraMTugXh5Sw9xZU rKOEw3zYPo+KCxCWRP9lgmmQT/VOL9TNwj6cMrZQ8ZMVXrn3Lv6Wxgpl0t6ULID26qZV aExxotIw7KoW4EBSSne/vgDIJKKojuwR6Q+1c46F2hY+GgIZ12Vg+gNTTRgxA4TEzf/I UW0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qK4kP9aM; 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; 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 g22si1207358edb.11.2021.07.28.17.46.46; Wed, 28 Jul 2021 17:47:10 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qK4kP9aM; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232985AbhG2Ap0 (ORCPT + 99 others); Wed, 28 Jul 2021 20:45:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232890AbhG2ApZ (ORCPT ); Wed, 28 Jul 2021 20:45:25 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3722AC061757; Wed, 28 Jul 2021 17:45:23 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id q3so4677672wrx.0; Wed, 28 Jul 2021 17:45:23 -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=v7cnCuDq5ZGSk7DH1MRlBzKJ5po3ZMRHzGSaZzKFHNw=; b=qK4kP9aMdzNl3v5ZMFoQSSP9i8SlzpJY6ZT6nDqMJGCUCdHA7gjlqJCPYJh4LdZok9 okA2UjqD44XRE+VV5Gv13WsmFMGetkAaVDBwUWIMat89C0ib38VdjS/H3D2XlqLWIMJG 9IpmdhA2Sj1ZfPSld9UD6sAvcy3BLeimRYOWtBVlV4i49FNKpgYwDfQodQLZNY9mSfdF J6GsDw6S/FRkhHdqrAJSygWvHJ4axzyvSax4b2pjORnBhukksWGNCi83EH+OPhUKlJzb yoQIndGSHH5R36Ue/7Cn9hFeO3AzQ5S1i1pqdPVWQTMNMvL3xQGdaJmzjyKfEjzEeNYC S0ig== 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=v7cnCuDq5ZGSk7DH1MRlBzKJ5po3ZMRHzGSaZzKFHNw=; b=I2CHukvJnPUG0201UsR1xHBWVAF4lvOe9flHY02MhVLYZzEHMA/+1/W//n5v8GySsg Hf/y+byNhwgzN7/Pz65tdOWafzPn4AmPrMG9VmDwNseMhdrLl7ANVV7dqe8pLIIsn+rg aecsSrC0uRRiZLt7d2xHOaCbts7pCUup37hg8wwSrLP35WIORe0xn8LtuokGbvDYLJtA BcgnAiApI4Tv/ECkhXVLHIOdOuuzJQynPpdK3gIPdVqUXF+o1K+ZNyD8NX3bTBTc4R1M xKfm36gitrFrjwUJPyF5pphYxL9Idr5NKm1PI3rx+3MUkxJpUMwdWz6kIZwVk2H4X7/c Ws+Q== X-Gm-Message-State: AOAM532BE/gEze1tH8uFScHxCVB9QgitEe8TRW8rodsp+GkfBAqfWBCO baoSEIT/2AygZyu93WWO4DAiBrvGNNo= X-Received: by 2002:adf:cf07:: with SMTP id o7mr1821855wrj.216.1627519521830; Wed, 28 Jul 2021 17:45:21 -0700 (PDT) Received: from pc ([196.235.233.206]) by smtp.gmail.com with ESMTPSA id q72sm1954094wme.14.2021.07.28.17.45.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jul 2021 17:45:21 -0700 (PDT) Date: Thu, 29 Jul 2021 01:45:12 +0100 From: Salah Triki To: Jiri Kosina , Benjamin Tissoires , gregkh@linuxfoundation.org Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RESEND v2] hid-elo: update the reference count of the usb device structure Message-ID: <20210729004451.GA783805@pc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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/hid/hid-elo.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-elo.c b/drivers/hid/hid-elo.c index 0d22713a3874..383dfda8c12f 100644 --- a/drivers/hid/hid-elo.c +++ b/drivers/hid/hid-elo.c @@ -228,13 +228,15 @@ static int elo_probe(struct hid_device *hdev, const struct hid_device_id *id) { struct elo_priv *priv; int ret; + struct usb_device *udev; priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; INIT_DELAYED_WORK(&priv->work, elo_work); - priv->usbdev = interface_to_usbdev(to_usb_interface(hdev->dev.parent)); + udev = interface_to_usbdev(to_usb_interface(hdev->dev.parent)); + priv->usbdev = usb_get_dev(udev); hid_set_drvdata(hdev, priv); @@ -265,6 +267,8 @@ static void elo_remove(struct hid_device *hdev) { struct elo_priv *priv = hid_get_drvdata(hdev); + usb_put_dev(priv->usbdev); + hid_hw_stop(hdev); cancel_delayed_work_sync(&priv->work); kfree(priv); -- 2.25.1