From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1F59A33DEE0; Wed, 15 Apr 2026 09:38:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776245940; cv=none; b=FdUhQwydHU43a6yBwT3znBj60qfjgBSY0t+JhHH1LbiAiY+oSvJ6ppmMMiouDX6ENavVc+Kmzai3ATpT/Fc9uxSG7MIp7xrz5v+Ws+biDBv0dI6bNs13dQ/cc+TYQLSXvCMx2+L7+lLsAQiWm6qe8ZAKXAWlBXsEORswVudbem0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776245940; c=relaxed/simple; bh=p6yeoEak9mTQ0fS2V2dwoa/+Qm8bsXAjoO+/AGCnjjI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZlCT7XgGHmDKEDatv39PoWpvDPbBKjUs+vs/npxVbcC4o6ysMRsmb+fOhoqSZxTLtZcKNGus/ZBcP7rvHV8LqdHNuA9ReUD22CttZodjqsdo7uu3ct0vzHWLLaJZFafLRoocMF6LbJ3/o6XlZJgIfCFC7lXmK1djbkPVpi2vIfQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dBPGuqzo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dBPGuqzo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6BF6C2BCB4; Wed, 15 Apr 2026 09:38:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776245939; bh=p6yeoEak9mTQ0fS2V2dwoa/+Qm8bsXAjoO+/AGCnjjI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=dBPGuqzoZILl4elrDnNwHp9HSSQsutVZz0Vda6OWv+iDfA5AHhu5/T0rJcomEQkq3 BaKbRZNGZ4Hw0S+PL/qGqUDDu2PK5QgQqhyNwJdkF4T2U0LrEm9g7lH2kA2hBVzh+N 0IlmDnaFEyo2JQq6Y2Llyhlvx8cQQXGPAHNEHPt7UgdB6L53coJHHM3zvHyh79BFqL pTuJ0hu9XDA8RiO+TYc0+yMvUNx2TvYdY9vaQhwfqIGOaaozoJUEOQH3RgF1HbyVyN Y2W/crdWu+6D9iKyf93ZiXYNbZF+NMBHXwsZnbMlWtHTK3sZjhYORTZFl8OtEplD2u QX7exOE1QtUGA== From: Benjamin Tissoires Date: Wed, 15 Apr 2026 11:38:16 +0200 Subject: [PATCH 3/4] HID: multitouch: use __free(kfree) to clean up temporary buffers Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260415-wip-fix-core-v1-3-ed3c4c823175@kernel.org> References: <20260415-wip-fix-core-v1-0-ed3c4c823175@kernel.org> In-Reply-To: <20260415-wip-fix-core-v1-0-ed3c4c823175@kernel.org> To: Jiri Kosina , =?utf-8?q?Filipe_La=C3=ADns?= , Bastien Nocera , Ping Cheng , Jason Gerecke , Viresh Kumar , Johan Hovold , Alex Elder , Greg Kroah-Hartman , Lee Jones Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev, linux-usb@vger.kernel.org, Benjamin Tissoires X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776245925; l=2586; i=bentiss@kernel.org; s=20230215; h=from:subject:message-id; bh=p6yeoEak9mTQ0fS2V2dwoa/+Qm8bsXAjoO+/AGCnjjI=; b=KMH3GbFxII3+hzO3Hz3encOrIQFgbhWDvs+kw66TxlTgHyrZh1waHtZLjmukoAAsYQgG9I6dl /JP4Xoau4/XDE7sV1Hyem8tISOeA9IKZaWQbHgxlCIM+Kn9Joq3c+mv X-Developer-Key: i=bentiss@kernel.org; a=ed25519; pk=7D1DyAVh6ajCkuUTudt/chMuXWIJHlv2qCsRkIizvFw= This simplifies error handling and protects against memory leaks. Signed-off-by: Benjamin Tissoires --- drivers/hid/hid-multitouch.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index eeab0b6e32cc..b19463e545d6 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -507,7 +507,6 @@ static void mt_get_feature(struct hid_device *hdev, struct hid_report *report) { int ret; u32 size = hid_report_len(report); - u8 *buf; /* * Do not fetch the feature report if the device has been explicitly @@ -516,7 +515,7 @@ static void mt_get_feature(struct hid_device *hdev, struct hid_report *report) if (hdev->quirks & HID_QUIRK_NO_INIT_REPORTS) return; - buf = hid_alloc_report_buf(report, GFP_KERNEL); + u8 *buf __free(kfree) = hid_alloc_report_buf(report, GFP_KERNEL); if (!buf) return; @@ -529,7 +528,7 @@ static void mt_get_feature(struct hid_device *hdev, struct hid_report *report) /* The report ID in the request and the response should match */ if (report->id != buf[0]) { hid_err(hdev, "Returned feature report did not match the request\n"); - goto free; + return; } ret = hid_report_raw_event(hdev, HID_FEATURE_REPORT, buf, @@ -537,9 +536,6 @@ static void mt_get_feature(struct hid_device *hdev, struct hid_report *report) if (ret) dev_warn(&hdev->dev, "failed to report feature\n"); } - -free: - kfree(buf); } static void mt_feature_mapping(struct hid_device *hdev, @@ -1658,7 +1654,6 @@ static bool mt_need_to_apply_feature(struct hid_device *hdev, struct mt_class *cls = &td->mtclass; struct hid_report *report = field->report; unsigned int index = usage->usage_index; - char *buf; u32 report_len; int max; @@ -1673,17 +1668,18 @@ static bool mt_need_to_apply_feature(struct hid_device *hdev, return false; if (cls->quirks & MT_QUIRK_FORCE_GET_FEATURE) { - report_len = hid_report_len(report); - buf = hid_alloc_report_buf(report, GFP_KERNEL); + char *buf __free(kfree) = hid_alloc_report_buf(report, GFP_KERNEL); + if (!buf) { hid_err(hdev, "failed to allocate buffer for report\n"); return false; } + + report_len = hid_report_len(report); hid_hw_raw_request(hdev, report->id, buf, report_len, HID_FEATURE_REPORT, HID_REQ_GET_REPORT); - kfree(buf); } field->value[index] = td->inputmode_value; -- 2.53.0