From nobody Fri Apr 3 07:42:22 2026 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E761234889A for ; Thu, 19 Feb 2026 15:43:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771515827; cv=none; b=C2DL4Z7RLQJ3OK3ZaygcNXAuIxGm4DfWALlf/bmadKYF9oG0w86bTkPaZDxnhsSad1Uv4SRVmTdjNiFmi13dU6jiL0ycdr1IKl7zlpunhcFxyPr/BCi/Qt35gHmVt+MbzczDcq3Fb+fJ0Uogf9VdkqppKlSroo+x8GQhJJjjcTQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771515827; c=relaxed/simple; bh=nzPlGBZWCF9yeYjLabCnMDGzP0Cy9kD50BaatJTqHwM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=H4GzEbcLSntwaL/2fiS9olFCf6SFDxjK4PC7lNV+QcHVtpjxCGYksFFg/gcimA/VsY1H7dkwoeqOJMTj/CCfou3Mixr4fmdjRNfoKukKoNoQpuFx6JZTFDSUAJxOpPui4ZxZd8ZXdSGUpyZ1ZfqgoCrc6P0HNSfCIkMz7g7+tEk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--gnoack.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=f5Z7ktjq; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--gnoack.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="f5Z7ktjq" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-4836e35292cso10726075e9.1 for ; Thu, 19 Feb 2026 07:43:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1771515824; x=1772120624; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=gQkcQ412VYYjl5d+2hc4YyIXE6A0slRRsKwOiMGJ4lA=; b=f5Z7ktjqnbXA5BdkuRlF3mTxc5Cqp/HRktFqeCP17tyvgev7LlTTTyfNGJl0xqV9vE uZonCM97VmC+ut5wLbLKTp1kGeUOExY8Q1Ro8YWFKhXxsL9lrEiSBAs+cEU3d7zj9pRB ws7YME/KVK+UeoKro1aeuULP5BZb5ey6vqq0mmJqYsthS1oocdSv3OvngeICTpbDqmIv NsUgK1iTCpLW5vqY33OVcDaidBy+4LwHIb2B/uQlJpRUA9AI92DXYJNvkF8gy06+pS1t eRxyMDJgRvNe5JbcV8FSaFQu/nGUxpfT6dOO8TtEein1HidACU0ONqk11th2kOrI5jux mlsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771515824; x=1772120624; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=gQkcQ412VYYjl5d+2hc4YyIXE6A0slRRsKwOiMGJ4lA=; b=VdqRW9ntrpk6I0yBRVm3+MeGz3+H3s9UzxrkXDtVwfhuEYP+sq6s7yA2gPdBbm1wak cL+AUUD5R3TCU6/fPuxSASBXGgl8V20Z2p9tjm1B4SPdVM9Bj3l2H/j4Aj8j7XfuBocG mA9uW14e6yoaGVEzi8EeOnhR3AXej6AxKPWzF1oWN85dtu01wT8Gy5cfJydqp94GM/Mm pCXw4O6/aMzyVuHbmbibZkzFxxR185ut709oby4DMuL5S9FaWV+GV5BeavCzNtwp30lH UnhdGj5QfbuYzQH3UlwZUqHqaQbLaYfPaa9ZtrMo5I36/DUXX0EEgbgArLFaGduMd95S ONOQ== X-Forwarded-Encrypted: i=1; AJvYcCUtw74x1W9tlV4gK6AB4AuJTEUrtQn2MVZGx365tQkLF+jUyOfxP6Uz+iCjWRiEzoLxOtwTooqmDfAY5Ks=@vger.kernel.org X-Gm-Message-State: AOJu0YyhPTMEe4q2jsycNd5maEqJDnAUkgnpK9Zr0iBFa54nDo0elSAd jGzIMusYBILLLo5cyNYRWYTfzWCtMa1MRViG2vbzYiW/xDNPIIJ/vsY2gAnGrn3O9dUIl48l989 2S86uNw== X-Received: from wmjq15.prod.google.com ([2002:a7b:ce8f:0:b0:480:4a03:7b63]) (user=gnoack job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:4f44:b0:480:4b59:932e with SMTP id 5b1f17b1804b1-48373a0a0c2mr344104445e9.11.1771515824251; Thu, 19 Feb 2026 07:43:44 -0800 (PST) Date: Thu, 19 Feb 2026 16:43:35 +0100 In-Reply-To: <20260219154338.786625-1-gnoack@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260219154338.786625-1-gnoack@google.com> X-Mailer: git-send-email 2.53.0.371.g1d285c8824-goog Message-ID: <20260219154338.786625-2-gnoack@google.com> Subject: [PATCH v2 1/4] HID: Document memory allocation properties of report_fixup() From: "=?UTF-8?q?G=C3=BCnther=20Noack?=" To: Jiri Kosina , Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, "=?UTF-8?q?G=C3=BCnther=20Noack?=" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The memory pointer returned by the report_fixup() hook does not get freed by the caller. Instead, report_fixup() must return (in return value and *rsize) a memory buffer with at least the same lifetime as the input buffer (defined by rdesc and original *rsize). This is usually achieved using one of the following techniques: * Returning a pointer and size to a sub-portion of the input buffer * Returning a pointer to a static buffer * Allocating a buffer with a devm_*() function, which will automatically get freed when the device is removed. Signed-off-by: G=C3=BCnther Noack --- include/linux/hid.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/hid.h b/include/linux/hid.h index dce862cafbbd..2990b9f94cb5 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -836,6 +836,12 @@ struct hid_usage_id { * raw_event and event should return negative on error, any other value wi= ll * pass the event on to .event() typically return 0 for success. * + * report_fixup must return a report descriptor pointer whose lifetime is = at + * least that of the input rdesc. This is usually done by mutating the in= put + * rdesc and returning it or a sub-portion of it. In case a new buffer is + * allocated and returned, the implementation of report_fixup is responsib= le for + * freeing it later. + * * input_mapping shall return a negative value to completely ignore this u= sage * (e.g. doubled or invalid usage), zero to continue with parsing of this * usage by generic code (no special handling needed) or positive to skip --=20 2.53.0.371.g1d285c8824-goog