From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16AE4155C87; Tue, 13 Oct 2026 12:21:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791894103; cv=none; b=ConTbUHJI8k/bFs2WAdpeYPJ45mEqWd+54LGmcxX2Rw07pmQ2hhexCNX7wG0Eehkt4A32H/mkKGzo1ddKN1KohFUBhMd8hcOKw9UFgqW3ZwoVJh5B1qVJIqcM+RpCeXmC3qXY4PWhuHIiPtCLMryLQKEy8UhYet1DZMtNb/CY6o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791894103; c=relaxed/simple; bh=xP4wUK8A0+9f743kmqY9PdrdqDOB4lQuQ3l6Nf5NYrs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XpjK5hgWH27xfQkU6SksOAYTjkXF6RjAwfThMeFNO1ZrQiWRp9oTMranRjd9f9qxuap3IEtIPNTQZeDXi2p+wns4NFTL7lNF1IpAWRMy8YxcFFc1y76EjsbU/7LRs8AQl/L1D++Szw61YUyO4I42YvbWxRwtdl+A12Dy+9sGh5E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=rVke4CaQ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="rVke4CaQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71E5C1F000FF; Tue, 13 Oct 2026 12:21:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791894101; bh=yr70JgUKRzqH8SBhMq3tYgimsiPBwTiAaPHWpTPZ3ls=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=rVke4CaQuKPQ4NTE0gGd94pSGBaHliee650adALlsfvjWsox6umfi2QsImtuQu+0w heXYby/+sq0n6UyTJg/EaCiqE77v2O+er5NBu8GywcBumZVaBIEXjEqGFEjvCTSJLk L/UrLEMv7SGr9RcuJC+68nLGINy84cn0bWyR5VCI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Haoxiang Li , Bastien Nocera , Jiri Kosina , Sasha Levin Subject: [PATCH 6.18 448/621] HID: logitech-hidpp: Fix FF device cleanup on init failure Date: Tue, 13 Oct 2026 13:37:23 +0200 Message-ID: <20261013112931.463213751@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261013112920.855194808@linuxfoundation.org> References: <20261013112920.855194808@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Haoxiang Li [ Upstream commit dd5be4d9ce2dfc4d4a4527ef7d31d21a78e3cdac ] hidpp_ff_init() creates the input force-feedback device with input_ff_create(), then allocates the HID++ FF private data, effect ID array, and workqueue. If any of those allocations fail after input_ff_create() succeeds, the function returns an error without destroying the FF device. Add an unwind path that frees the private allocations made by hidpp_ff_init() and calls input_ff_destroy() for failures after input_ff_create() succeeds. Fixes: ff21a635dd1a ("HID: logitech-hidpp: Force feedback support for the Logitech G920") Signed-off-by: Haoxiang Li Reviewed-by: Bastien Nocera Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/hid-logitech-hidpp.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 94ffda22ef41d..a2bb7d8b15b69 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -2854,18 +2854,19 @@ static int hidpp_ff_init(struct hidpp_device *hidpp, * ownership to FF core */ data = kmemdup(data, sizeof(*data), GFP_KERNEL); - if (!data) - return -ENOMEM; + if (!data) { + error = -ENOMEM; + goto err_destroy_ff; + } data->effect_ids = kcalloc(num_slots, sizeof(int), GFP_KERNEL); if (!data->effect_ids) { - kfree(data); - return -ENOMEM; + error = -ENOMEM; + goto err_free_data; } data->wq = create_singlethread_workqueue("hidpp-ff-sendqueue"); if (!data->wq) { - kfree(data->effect_ids); - kfree(data); - return -ENOMEM; + error = -ENOMEM; + goto err_free_effect_ids; } data->hidpp = hidpp; @@ -2895,6 +2896,14 @@ static int hidpp_ff_init(struct hidpp_device *hidpp, version); return 0; + +err_free_effect_ids: + kfree(data->effect_ids); +err_free_data: + kfree(data); +err_destroy_ff: + input_ff_destroy(dev); + return error; } /* ************************************************************************** */ -- 2.53.0