Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4870209pjb; Mon, 27 Jul 2020 07:15:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwE+w80v/YOeoxMkdQnpDV+iQqoS2qKMnqSzvj+gHCJT/8JaB9kqjuz1QSnprWNLPmotMC X-Received: by 2002:a17:906:3a0d:: with SMTP id z13mr20770276eje.109.1595859334207; Mon, 27 Jul 2020 07:15:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595859334; cv=none; d=google.com; s=arc-20160816; b=IMWnp5QsgcTo1L+AShQgjztOq5wJo/YSiJ8H6RPad5YoyQjVxVCTv9P1pJmDFPpRBV D0KI/hxRdgxuUIjH8mdzW6XSJMZy7DJMAxA5o93dB1j0NFjNe15+09ATT06EgK6B+Enc pUkyeiLDdkJzoB+vbcrD3p8M9N6sOLW0I+EGmjmsmm2CDWAHi5M0K3WRC0rFUrBW7ERH I7EE3LYYV4uUtI80DxpKzqa4sVCEXCmDVYZmWOyPK6W6RnH343NPuvCDWyR2Mvra9ugf lObZT7wgDqREk7M0b/mwqETTLbLAulvILzXujkPYTRWVViM6PIzRfHg/S5NB3A92RgY5 w9ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=H1C8t20qBJWtPPJUUV3fDZZzWv9afjXxh4KqYvkbPP8=; b=iARvj819igiF4kqyprFe8dt0QqtHEqoXMeHP0eGmcPJd1WqgyIQUlbqDGaityqGoum IFzGJKrkTA/2fXAh417koZNzKo3rXenXM3CPDHsDw/2wFzbAqCyWngvEKb5E8vqxgsFe +P0lYuCWu+Js1HG2Y1cTWMsMfvZ47bQd2F7FXcrWR7xjG6lZrFsDChlIfC0xB/pLEHyQ uPJzzqlGmvkIxK7x5dBH0HXNoYvv+oGxCfPflPYwDKT1GYwEOp3ykeIm3C8SAynoEalI jxaS0hQc1s4xWILHYbBhX8RDG62GFLcEHcN47X9LU80BYfePvlwd5MFBK2bky7EcRBw1 RgSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ySIvT1fy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n1si5444734ejc.134.2020.07.27.07.15.11; Mon, 27 Jul 2020 07:15:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ySIvT1fy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730219AbgG0OMh (ORCPT + 99 others); Mon, 27 Jul 2020 10:12:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:36972 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730225AbgG0OMf (ORCPT ); Mon, 27 Jul 2020 10:12:35 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D335F20838; Mon, 27 Jul 2020 14:12:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595859155; bh=Tdh9cOVs/2IgNFxLPF4ZL/iqY0zBfjy8MZwS73LcFlo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ySIvT1fyw0UfxKLV5v1Hsxdp3RsWjaInf8UpH03UW34GVudmb5xlyQs3BJEXc6Vbt EDEfHDy8PsExTqfvEBZBt6RcMrIKwsGtJfcFSYsDEPKfyi574OzELzoZlNHhHTLllX Qn0s/tY2KTFc0LcxUZtSWCse4hUfpcU/ZecRrI1M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ian Abbott Subject: [PATCH 4.19 67/86] staging: comedi: ni_6527: fix INSN_CONFIG_DIGITAL_TRIG support Date: Mon, 27 Jul 2020 16:04:41 +0200 Message-Id: <20200727134917.781284555@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727134914.312934924@linuxfoundation.org> References: <20200727134914.312934924@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ian Abbott commit f07804ec77d77f8a9dcf570a24154e17747bc82f upstream. `ni6527_intr_insn_config()` processes `INSN_CONFIG` comedi instructions for the "interrupt" subdevice. When `data[0]` is `INSN_CONFIG_DIGITAL_TRIG` it is configuring the digital trigger. When `data[2]` is `COMEDI_DIGITAL_TRIG_ENABLE_EDGES` it is configuring rising and falling edge detection for the digital trigger, using a base channel number (or shift amount) in `data[3]`, a rising edge bitmask in `data[4]` and falling edge bitmask in `data[5]`. If the base channel number (shift amount) is greater than or equal to the number of channels (24) of the digital input subdevice, there are no changes to the rising and falling edges, so the mask of channels to be changed can be set to 0, otherwise the mask of channels to be changed, and the rising and falling edge bitmasks are shifted by the base channel number before calling `ni6527_set_edge_detection()` to change the appropriate registers. Unfortunately, the code is comparing the base channel (shift amount) to the interrupt subdevice's number of channels (1) instead of the digital input subdevice's number of channels (24). Fix it by comparing to 32 because all shift amounts for an `unsigned int` must be less than that and everything from bit 24 upwards is ignored by `ni6527_set_edge_detection()` anyway. Fixes: 110f9e687c1a8 ("staging: comedi: ni_6527: support INSN_CONFIG_DIGITAL_TRIG") Cc: # 3.17+ Signed-off-by: Ian Abbott Link: https://lore.kernel.org/r/20200717145257.112660-2-abbotti@mev.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_6527.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/staging/comedi/drivers/ni_6527.c +++ b/drivers/staging/comedi/drivers/ni_6527.c @@ -332,7 +332,7 @@ static int ni6527_intr_insn_config(struc case COMEDI_DIGITAL_TRIG_ENABLE_EDGES: /* check shift amount */ shift = data[3]; - if (shift >= s->n_chan) { + if (shift >= 32) { mask = 0; rising = 0; falling = 0;