From patchwork Mon Jul 8 14:25:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Keeping X-Patchwork-Id: 811734 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2127.outbound.protection.outlook.com [40.107.236.127]) (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 A67EE13212E; Mon, 8 Jul 2024 14:26:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.127 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720448777; cv=fail; b=Yje64iQRLrbNs3tMmdjv8JQrD5qji7t1jYj6mPImmRQtC87mNSnwLinjSdDeFXf4J0W0KIzcmUSjYaoIZIyCGbIzODURgRF23C5A/ujGc6lqmJzcVn0UmTtlXQ80lNKyNEz6KiJIcsToK9/YegmSbAIT7KxLe/Ju4++0M6Ks4E8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720448777; c=relaxed/simple; bh=XGRkpcz0Hav5kSoXeGAoe8jCScSZajiAyy9nMi0GL5E=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=tkOzwJiz1kFDKfe1amyM5T4oT0XRVlWrX0Q1PUFmke6KTZKdMW25JAeb44A+J7gRixuL4lgQ/KCe+oRpvZoKtBgL7IUqh6A08c49VUyGvgpV5DsyWEt4BMGqfRIFceI6Is1Jpw4lYNnl+AKdoe9tEI63+DS8jrbS3AEXh0KqoW0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inmusicbrands.com; spf=pass smtp.mailfrom=inmusicbrands.com; dkim=pass (1024-bit key) header.d=inmusicbrands.com header.i=@inmusicbrands.com header.b=J3/tH7Vo; arc=fail smtp.client-ip=40.107.236.127 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inmusicbrands.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inmusicbrands.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inmusicbrands.com header.i=@inmusicbrands.com header.b="J3/tH7Vo" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=awqmPOwAaqfDdjLhCCpP3SsJYWXYWiFCX+9TYLjTwp/7KNgF1zf6hd1yT9BDUXuKMQ9uwmUyhQtCFe0e6fnT4zRHcVPjSbTKA2AeeXpno0cqTooSWbgFIlML/eNvdAZAyvMP4itkM02hoVPCnTuml6fu7C4TLx81DHaG2BIfyBEQxWIdf3ca4iBzwqfDyCwWe2qZLa/YwQillvAdhVVMqiw4EyLjuBKxcAm/ujFquSQcAINwK150rF0qMJ5kh3c4DEBrdGqhxpGiJCp1+i9Q5yyXg4SsK3y8VJYFEc2iIuK9uETPTm8ABLdw6TsX4gjZ+tf+JOJN2tZ6zC/NOmioww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Q7nZhON1bZcbOJ5hw5DYyCyV2KhxkFWn8Yi3XLhNvdM=; b=H8t23KVljqdjHdFmqy3WWd9JVq4v0gRjIf9B6I5R+NrN5D/MbLA+CUxa5k5emFPd8530q9XJIcjBo2ZUe5rQg+whduKNCtRRc6qz/WTOJPi6Wf45ZdJ+SjDoD3xYwEKYP9GNrGRwIoJnyzUxxiIO2LRZfKMHHtRGjSkj6azgn0ly9DH6PaqFqCnrpMo6EWckqEVVztQjZs4ZK+taIZQ5/kW47oOs2zjsK/jAg/vtjXKaXtlG9SSuCNBQA7lImXrzWTQzW+iniNZjKZQO1InW50yzzj1G9MCPRyLNos9S8c3ZxK9V5t93AHrkXzc3BMJs0lwjM/bXC+s7BqstAQmLpg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=inmusicbrands.com; dmarc=pass action=none header.from=inmusicbrands.com; dkim=pass header.d=inmusicbrands.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inmusicbrands.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q7nZhON1bZcbOJ5hw5DYyCyV2KhxkFWn8Yi3XLhNvdM=; b=J3/tH7VoZ85wc6KG01GQQTQy8FwePS7qBqiTzJDVyumJ/b9dkkzBULtxq5zMhzESYkGESMDGLNpgL4t0ftCPkhXVGEomfT9FAuJyvY46qbk6MavgqYKzuwjPhrBggnpfzV2GQxdHJjayrt5e0LOWx7d5xj5S9pEX0NPbjcYK02Q= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=inmusicbrands.com; Received: from MW4PR08MB8282.namprd08.prod.outlook.com (2603:10b6:303:1bd::18) by PH0PR08MB9838.namprd08.prod.outlook.com (2603:10b6:510:336::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35; Mon, 8 Jul 2024 14:26:10 +0000 Received: from MW4PR08MB8282.namprd08.prod.outlook.com ([fe80::55b3:31f1:11c0:4401]) by MW4PR08MB8282.namprd08.prod.outlook.com ([fe80::55b3:31f1:11c0:4401%6]) with mapi id 15.20.7741.031; Mon, 8 Jul 2024 14:26:10 +0000 From: John Keeping To: linux-usb@vger.kernel.org Cc: John Keeping , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: [PATCH] usb: gadget: f_uac2: fix non-newline-terminated function name Date: Mon, 8 Jul 2024 15:25:53 +0100 Message-ID: <20240708142553.3995022-1-jkeeping@inmusicbrands.com> X-Mailer: git-send-email 2.45.2 X-ClientProxiedBy: LO4P265CA0162.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2c7::20) To MW4PR08MB8282.namprd08.prod.outlook.com (2603:10b6:303:1bd::18) Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW4PR08MB8282:EE_|PH0PR08MB9838:EE_ X-MS-Office365-Filtering-Correlation-Id: cef57cbb-0933-4b9c-8b67-08dc9f59e976 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|366016|1800799024|376014|38350700014; X-Microsoft-Antispam-Message-Info: ekt1gokQIGAuq8e5PUhrXNgmLOwRJSMkqdhuGYXZIdLpOlV7pjLwJnjMi9U07o6yHUSUXdX7ERCIRrpyDw+21VYAV/+vUovGICccmiCfzcqPpjLIRr0XItgNvYKFQ5lzaUyxMNYI2DS8nOjO4Bm9E9PUG5epzbGMrrGdEU/z6LF0HqINtYBTT3J9kh4FyL3jMpSfWsklhDQ9n13rtzJMSL+XI5QZ0rDmB4Y10gxmzekOtJk3IkT55dPtRTXX6nYgdjAQazMzy5L7vCFjiujJgnsL96qYjFDiPAuNiBdx8tGmdM21R5XAk5AbkYSpWLh5OeeRIWasbI3E6iGHRoGEBbzJV4mF/Fft+5rn4viCJoBF2XUmidMN/iUepmKbQfMpV8MHO5/vKKSbmUijaGuOFCpLW9QP+c9XdyGMyc0PhoMe3DeRaArqxsFcTsySB8Z3GTlaMjzbsp5z+Zmo3MFLLpcgn43nQ7hx8E4gUZWtegNH9qLcO+RIfowWYSIx+LAhtEnKA23eLkThwrIfa9ZIcM47dsCSOjkdbChyPC4J0635wWSR4hvzsg9lvq0nkZuKrT1DHpfS2GqX5fjqopUL0rXH6NGAKc3eJyDHKCViGYCWH7a8kaznoGgFuQL28tPFnU0lD6jZZ0euPtV2zlof6BYZP+fFkIZfWi3XBZtuokWiNK2ME85LGYvWco4aXP/vMOzy24pk9OI6dAsKtP31wPcjPYgDFI70pi3XBp9+DLkHD4R/wHG6q1aVkE+b8SXa0HCNX46FhPepQOO8co3sJrAB2jkXcCiQ4BaMbV5B5u6B4xGTSphftI5yViVYDM1mXpqWeq/IfOgrSilOonFd+ikmKQS0galeTBqzU3+Jw9tQD76BVGTdVTSStxyoxEIIVrSSIp0xsds47yAe+L9dfMB/jAA/YYerPFYkl5/tl7NbITtIgcOGvCURRrlJP1B/Kf7/awVYCH9H7QBJGydQNzyQSSeuoQUxxmOX2cEUZIPQmPujI5kRJK/A1vGGGzFkS41v2aBNs4qWSRjnfXFcQB/DIfFsFjZIItzkzsmPtHlJfrgAbNsfRjH+VFuJ6tfkx+cnfsF5axYRUSESpTFLLhU48fpbnwNmk+uRToizY/mIhKUv+8M1AqckztfVxdAPVtv2s2JH/dvrG4OXF3fdGaHoPC5m2LpqqsKOBbeoMR1r7opmjKHqsDBZWXMpLXQ44vKs1NGFofl2hk7J/PculEXNJBI3/bejkW1kwgRJd7b0degW+ZsAIIX6CrUIC7JDX9MM0IlR2/usjKAVNMxVBnHUJKwui/H3vwVwYw6XqG60updl2d2Be1PoHqinLvMqP2qADD5JCPS92spuxsjiHqNw6cGeFYP9Kgj/KoxHvN7LQJcWUVUQ3Pza4ol4+K3ly1Tcd1mz7PfesNQ4JTnXsQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MW4PR08MB8282.namprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(366016)(1800799024)(376014)(38350700014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5uHFFrNnQsL+ZFlouNYEspTo2Th72gZmR6GZFeBYQUuZjQyrmMWQjBFLA3CpNXBcPlRGGBqjrTxjV4BB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lrEP4udOU0yPYycY/vZ4TZryWn5xrYGPhhoAZCNyEYuB2TnXbWkxsq1pxtZeS4aVNEVg4ZQ7IID/viz91Oxvx+cfiuTQxwdE2kdN+jGWuvCa8eVIOvncyA8+IjbdZ7ReEn7XYvrvoHWpOTumo/ZOAFDRpyUo+wQ7bbKuuu011jwvG/rW4vpJ67Zuj3LL0tanhf8pJePrwNoPxIhCU/hYgZ0OtV4GxwCVdRtUZsvQJ6vY3qa6NBOezXBzu3s2XeDWcOHvOo6JkbwWXndEIt55RiD7I31uwHEfMsPffTs4sVy/1tWq1XFtXBcwORfumsJW75paPrdr6e2+8L0GEMhhQf0R3aj22zrNkSIxecBr1Y9PHth5Nhu/GxSv2etkQzzzuoaIKTItSlhsvg0GecBNRtNHnYri+/x04aUG9d+FHBuyr66AubdtmbuE6/A9v1i8Rmujar1kZNAA== X-OriginatorOrg: inmusicbrands.com X-MS-Exchange-CrossTenant-Network-Message-Id: cef57cbb-0933-4b9c-8b67-08dc9f59e976 X-MS-Exchange-CrossTenant-AuthSource: MW4PR08MB8282.namprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2024 14:26:10.0736 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 24507e43-fb7c-4b60-ab03-f78fafaf0a65 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: w3qM8SmArwktyT3+O0oIhlqDC0K2hpTONVhm6mYJ7/KVkwRMByZq56+pHnsbElznYJOlzKnANkSTg84GSh+IGSinejGJWOZ83iqwDF/rXSI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR08MB9838 Most writes to configfs handle an optional newline, but do not require it. By using the number of bytes written as the limit for scnprintf() it is guaranteed that the final character in the buffer will be overwritten. This is expected if it is a newline but is undesirable when a string is written "as-is" (as libusbgx does, for example). Update the store function to strip an optional newline, matching the behaviour of usb_string_copy(). Signed-off-by: John Keeping --- drivers/usb/gadget/function/f_uac2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c index f85ffa24a5cd5..2d6d3286ffde2 100644 --- a/drivers/usb/gadget/function/f_uac2.c +++ b/drivers/usb/gadget/function/f_uac2.c @@ -2063,7 +2063,10 @@ static ssize_t f_uac2_opts_##name##_store(struct config_item *item, \ goto end; \ } \ \ - ret = scnprintf(opts->name, min(sizeof(opts->name), len), \ + if (len && page[len - 1] == '\n') \ + len--; \ + \ + ret = scnprintf(opts->name, min(sizeof(opts->name), len + 1), \ "%s", page); \ \ end: \