Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4484275ybx; Mon, 4 Nov 2019 14:11:36 -0800 (PST) X-Google-Smtp-Source: APXvYqyLqC9EJagajNId21Ppb+w+i7xyGCA7QvUXWSdFelYrrrobf+FYZqF85VGszqe5ZaVxAdDe X-Received: by 2002:a17:906:ecad:: with SMTP id qh13mr4170216ejb.25.1572905496813; Mon, 04 Nov 2019 14:11:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572905496; cv=none; d=google.com; s=arc-20160816; b=Pecu2BT21pLG8ospXIU6Zz3EYyGB3kXcmqy7h9fJR0LrtlQhd8yaDWea8rcT86Se5x QgL/tnGEZrwTh5c0oUNyrsqKX7NMmSxjY30c6sZHNrSKGuSc1jvaOyeJUUHT80Q2gu70 RM2Vt9pepF7A3dqwqK66GKE9IEMYHc6onLm8C1VGWXCuVIEYTLg8XEyYo+aVmbIxq7It xKrQCjywmArNLlAOKXtNygIxmtbEZ7NiXKX1UdDtvszZnMRSdQIfdoEGNkvRzyl3YUwE uYS+w1zqw5Ay+ADR4v6u1kTGegazVQ/bNr+/++KKpmqE6TMmYlSEeg1l/zAeEwSfDmCp DhkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=864plpuLHBsPnw8OCeAYXeP+6OrYPLF3KLh0EfL68sQ=; b=WKnzXUYKyRyZ6tzhtJ1ew0iiVCjDTW4s6cv+WI3tKnXlk/Ta5mzSk0vkFALqM4AACJ EsGcV3rlO0xvs5L27FIH6YrZrwNmDfQ1Goj5Qsnn2Oiyx1bQNolV1PVN90vVhjjj2MLz HBymyz23Q7VZSwdWRAvckt9sG/9Sxz54tGE/KM50OVu2z4G6bhIxjh4wDm+OX1NZr5L9 u8/v52IFxFSd5XiGucpxSKxYEtbWHWRdgee3QkbKZVMGbdbW5xvXl4IZ9pVtQlac0zQW oiHPbm5RoO8nR7ZXc1UX72hmWSC/s6on7Gh+WyP3tuthlXss93BDMFKQZAM+4gza21x7 fmAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KplFXULk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z58si8385140edz.141.2019.11.04.14.11.13; Mon, 04 Nov 2019 14:11:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KplFXULk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390406AbfKDWJY (ORCPT + 99 others); Mon, 4 Nov 2019 17:09:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:42470 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390397AbfKDWJX (ORCPT ); Mon, 4 Nov 2019 17:09:23 -0500 Received: from localhost (6.204-14-84.ripe.coltfrance.com [84.14.204.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 77456214E0; Mon, 4 Nov 2019 22:09:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572905363; bh=HsjLLNLxmIouDxnqA72L8QoEOFGWsul04f9vi88c2XQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KplFXULk2n0JhAAmKZkIs4rbLpF54lwcfuec6WrtuPpDkfqGZTR7T4yV5OlANRlmn V7cck/a43vpfHJkGkISo4AfZWWyrNlB6JLlTn7BQF8udyf5scekDoDPMHMif3E+Je6 KnsT5rqgz+eozTBGlw5O1WpD6GqZ/HBvb6Vk8q84= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Benjamin Tissoires , Andrey Smirnov , Jiri Kosina , Henrik Rydberg , "Pierre-Loup A. Griffais" , Austin Palmer , linux-input@vger.kernel.org Subject: [PATCH 5.3 120/163] HID: logitech-hidpp: do all FF cleanup in hidpp_ff_destroy() Date: Mon, 4 Nov 2019 22:45:10 +0100 Message-Id: <20191104212148.906389283@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104212140.046021995@linuxfoundation.org> References: <20191104212140.046021995@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrey Smirnov commit 08c453f6d073f069cf8e30e03cd3c16262c9b953 upstream. All of the FF-related resources belong to corresponding FF device, so they should be freed as a part of hidpp_ff_destroy() to avoid potential race condidions. Fixes: ff21a635dd1a ("HID: logitech-hidpp: Force feedback support for the Logitech G920") Suggested-by: Benjamin Tissoires Signed-off-by: Andrey Smirnov Cc: Jiri Kosina Cc: Benjamin Tissoires Cc: Henrik Rydberg Cc: Pierre-Loup A. Griffais Cc: Austin Palmer Cc: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org # 5.2+ Signed-off-by: Benjamin Tissoires Signed-off-by: Greg Kroah-Hartman --- drivers/hid/hid-logitech-hidpp.c | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -2078,7 +2078,12 @@ static DEVICE_ATTR(range, S_IRUSR | S_IW static void hidpp_ff_destroy(struct ff_device *ff) { struct hidpp_ff_private_data *data = ff->private; + struct hid_device *hid = data->hidpp->hid_dev; + hid_info(hid, "Unloading HID++ force feedback.\n"); + + device_remove_file(&hid->dev, &dev_attr_range); + destroy_workqueue(data->wq); kfree(data->effect_ids); } @@ -2170,31 +2175,6 @@ static int hidpp_ff_init(struct hidpp_de return 0; } -static int hidpp_ff_deinit(struct hid_device *hid) -{ - struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); - struct input_dev *dev = hidinput->input; - struct hidpp_ff_private_data *data; - - if (!dev) { - hid_err(hid, "Struct input_dev not found!\n"); - return -EINVAL; - } - - hid_info(hid, "Unloading HID++ force feedback.\n"); - data = dev->ff->private; - if (!data) { - hid_err(hid, "Private data not found!\n"); - return -EINVAL; - } - - destroy_workqueue(data->wq); - device_remove_file(&hid->dev, &dev_attr_range); - - return 0; -} - - /* ************************************************************************** */ /* */ /* Device Support */ @@ -3713,9 +3693,6 @@ static void hidpp_remove(struct hid_devi sysfs_remove_group(&hdev->dev.kobj, &ps_attribute_group); - if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) - hidpp_ff_deinit(hdev); - hid_hw_stop(hdev); cancel_work_sync(&hidpp->work); mutex_destroy(&hidpp->send_mutex);