From patchwork Tue Jan 3 15:11:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Abbott X-Patchwork-Id: 38491 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4672531wrt; Tue, 3 Jan 2023 07:17:42 -0800 (PST) X-Google-Smtp-Source: AMrXdXvG+yZoU7b7BuXZcw7fzpSU6I91d/HRkEBUcMgAUQjiFYf/Mptlf+do4qrmXU9v1bIQayls X-Received: by 2002:a17:906:2509:b0:7c0:f2c5:ac3f with SMTP id i9-20020a170906250900b007c0f2c5ac3fmr35783404ejb.58.1672759061809; Tue, 03 Jan 2023 07:17:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672759061; cv=none; d=google.com; s=arc-20160816; b=yalgLLl7e5tWELvoMYrHr7IoqPEChs4oRV+fUj3nYGx7PqAi19yJz90Hrb6cGEalgC CeL0z+Ow6FnQ/qfJ77AFI+YadusXAhW67v9xWhzesyZhnMNSF/kTNEIfvI00V8j3PIiC iuoFSQWEjf6s00tXNbREYq9DiHvWPA01+CVfD5+llAPh3s3cbsodGSwXwiZCycEauc5q x3MLoQd1KHXpH0xD4tPyLRa41E+CRDYpRUi8hlD1rlvVs9mREurARJl/Wa079U70lq46 XEzTh/fQZNj0c8yTY7C3RFDfE305/m4pOT7QY2huYl44tWp/2Yo+t2GrLHxopQYO+wB2 P19A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=2RGCYtNIPYt/4JEYa0fxXcHaYvbYqMli2qF2+Fvz5nw=; b=uYP44wiPRoGUpbh+sh8Vv1c0ZKy4Yg6yeFk9cPWiDvpLrUAZ++7NK3nQG9ZnjKigzS T33sstSLSapKc4ujk/LAw6B1SohQUG0R2tmI/iC2iYk2fWzE4MiS+/s0XtEhJ2iyd/Nd 2e2/yQ+xoOYp8JjGbiK3s3cAaUamLY8RXgxivpGrVXvtB1XcMXI1s/NjCDLlOAilbzT4 gngVGQwjLJyzaQdn06q9mG+CzREjq6XNFCheQNNi1uuqBIJzmg1Q+cenJVyyY//nwIOv pHhE9//g0tqn8oq4mUO6P+RyUWYCwVaisoehT1bdH0R4W2quA7gpm0LX2xcAoo3hGiYx Ae5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=GePjypee; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t18-20020a1709063e5200b007b99436026dsi22389179eji.968.2023.01.03.07.17.18; Tue, 03 Jan 2023 07:17:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=GePjypee; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237756AbjACPQs (ORCPT + 99 others); Tue, 3 Jan 2023 10:16:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237742AbjACPQq (ORCPT ); Tue, 3 Jan 2023 10:16:46 -0500 X-Greylist: delayed 299 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 03 Jan 2023 07:16:46 PST Received: from smtp122.ord1d.emailsrvr.com (smtp122.ord1d.emailsrvr.com [184.106.54.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FA145F83 for ; Tue, 3 Jan 2023 07:16:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1672758705; bh=J0bXZlq59YGPe6q2p0FZH6dSxQvGOs+tJINEcXenNX8=; h=From:To:Subject:Date:From; b=GePjypeetYkTwCJaVWn+Zus7KEu2P8YTZfptAQSU9swQnBgmzZG2Nug+Andk+AtS6 jzeKVjF80FEowraaTWMU8YurI6bcMkxk2Seoa0fznXTCfs037VRkIysrNQZ6JNyCgi Jzo0fhWCABmDpJRm+9Mil8kufH3/uZh0d/ullj0o= X-Auth-ID: abbotti@mev.co.uk Received: by smtp16.relay.ord1d.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 78AF940169; Tue, 3 Jan 2023 10:11:44 -0500 (EST) From: Ian Abbott To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Ian Abbott , H Hartley Sweeten Subject: [PATCH] comedi: check data length for INSN_CONFIG_GET_PWM_OUTPUT Date: Tue, 3 Jan 2023 15:11:27 +0000 Message-Id: <20230103151127.19287-1-abbotti@mev.co.uk> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Classification-ID: 7ae8aec4-1a89-4677-b63d-079e463441cf-1-1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754015006129912497?= X-GMAIL-MSGID: =?utf-8?q?1754015006129912497?= Comedi INSN_CONFIG instructions have different expected instructtion data lengths depending on the type of configuration instruction specified by the first word of data. This is checked by `check_insn_config_length()`. There are a few configuration instructions whose data lengths are not currently checked, usually for rare configuration instructions that are implemented differently by different drivers. For unknown configuration instructions, the function logs a warning and accepts the specified data length. The `INSN_CONFIG_GET_PWM_OUTPUT` configuration instruction length is not currently checked, but all the places it is currently used expect a data length of 3. (These places are `ni_get_pwm_config()` in "ni_mio_common.c", and `pci1760_pwm_insn_config()` in "adv_pci1760.c".) Make this length official by checking it in `check_insn_config_length()`. Signed-off-by: Ian Abbott --- drivers/comedi/comedi_fops.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/comedi/comedi_fops.c b/drivers/comedi/comedi_fops.c index e2114bcf815a..b982903aaa46 100644 --- a/drivers/comedi/comedi_fops.c +++ b/drivers/comedi/comedi_fops.c @@ -1215,6 +1215,7 @@ static int check_insn_config_length(struct comedi_insn *insn, case INSN_CONFIG_GET_CLOCK_SRC: case INSN_CONFIG_SET_OTHER_SRC: case INSN_CONFIG_GET_COUNTER_STATUS: + case INSN_CONFIG_GET_PWM_OUTPUT: case INSN_CONFIG_PWM_SET_H_BRIDGE: case INSN_CONFIG_PWM_GET_H_BRIDGE: case INSN_CONFIG_GET_HARDWARE_BUFFER_SIZE: