Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3312974pxf; Mon, 15 Mar 2021 06:58:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOgga+eiMmC1ML/T64udQ7CmsySzV90okmDfa7ZtXZlV0oloWxFPatcaNVKIB9qpD3wjWT X-Received: by 2002:a17:906:7cc:: with SMTP id m12mr23151613ejc.171.1615816698628; Mon, 15 Mar 2021 06:58:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615816698; cv=none; d=google.com; s=arc-20160816; b=FLEoQyDLcCBnJWMUNn1cquKzKjgv0HaLdBWR/aoI53Sc2tX0TdeSxPEYLW7sP8yIcc BmE/jYUO8h32qOxYEN6R8IQYUuQjyzQ7t6LIopGO5zMzJB44iJMxxBvIr4zSJYGJeOdH ufJhfS5pJ6cKNGZIsHMxdnCk8+oNCDa/5YwIkQl0v51Kg9nL3nZCO0WCikJJKzYJ0h+S Ao7t61WRHsgNxneE0BeCn2Sxi1T/FcJQf6UrE8pFvlhpw1itrY4+9dtOHFArDtO3jyRY D4BzqA6u341pyuEEo4BL06oxu0Hr2rrLUL8/Ghj5K7uMePPQGylgmqRd7dmyyRADt/dl /+Wg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xQ+oY6WzOPvs1LOTJdSA3oogdcpjfVuqjKLsk3kGYew=; b=xk3sKGhKX8VeM1KN+/fH5iRRo/8UhaLETsS0uJCsYHyOJNzkKWS6RF32Lx/ODEW3GD uyGHbiL8L0ZB64EIfDVB9g8KWuMJ920sHfJTv9tZko63pIuirRn66bWLkdYxS/PbxSvT WYHbLUWhIiT9bP7Jbx13/TZUgsT6taeleUYzX1X/PuF6M51P4eufVriPCNGoZk8KRm38 DKRd8lU/H6USPQqiLOjzw/Nu7/bvkieKmHlEGjPQoz0n7weiiY5uLbW3MOx1GnOjDWrc NIfQXGGJC0u+p3uq/82meJOKXvWBohfZOqadpSdl4pt0szqX19hqluaS1xxcba4Riclp Sr6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DNi4x2sT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k12si11314788edq.82.2021.03.15.06.57.55; Mon, 15 Mar 2021 06:58:18 -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=@linuxfoundation.org header.s=korg header.b=DNi4x2sT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231853AbhCON46 (ORCPT + 99 others); Mon, 15 Mar 2021 09:56:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:57276 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231377AbhCONyJ (ORCPT ); Mon, 15 Mar 2021 09:54:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A9E41601FD; Mon, 15 Mar 2021 13:54:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816447; bh=SjQzFgZNl0ceigZk74ClIsEtdipV2riX7BXRcPhYQa4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DNi4x2sTbQd78Qzxjbc2IsppT4PKVXjISEmTLcHd/yEwuGCn/yLApJCpOKk7B+ERg d39l5eWAl4EDXN10VX+eOpTWcDpdSWsISDjPDGl9la4ahKT4nI0wIWZ9KR0pLAlRWp 5YmnBC9Jng2rSa5EkL+DKcNyElfB9A/l6Sk4TU78= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ian Abbott Subject: [PATCH 4.4 50/75] staging: comedi: addi_apci_1500: Fix endian problem for command sample Date: Mon, 15 Mar 2021 14:52:04 +0100 Message-Id: <20210315135209.882783287@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135208.252034256@linuxfoundation.org> References: <20210315135208.252034256@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Ian Abbott commit ac0bbf55ed3be75fde1f8907e91ecd2fd589bde3 upstream. The digital input subdevice supports Comedi asynchronous commands that read interrupt status information. This uses 16-bit Comedi samples (of which only the bottom 8 bits contain status information). However, the interrupt handler is calling `comedi_buf_write_samples()` with the address of a 32-bit variable `unsigned int status`. On a bigendian machine, this will copy 2 bytes from the wrong end of the variable. Fix it by changing the type of the variable to `unsigned short`. Fixes: a8c66b684efa ("staging: comedi: addi_apci_1500: rewrite the subdevice support functions") Cc: #4.0+ Signed-off-by: Ian Abbott Link: https://lore.kernel.org/r/20210223143055.257402-3-abbotti@mev.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1500.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) --- a/drivers/staging/comedi/drivers/addi_apci_1500.c +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c @@ -217,7 +217,7 @@ static irqreturn_t apci1500_interrupt(in struct comedi_device *dev = d; struct apci1500_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; - unsigned int status = 0; + unsigned short status = 0; unsigned int val; val = inl(devpriv->amcc + AMCC_OP_REG_INTCSR); @@ -247,14 +247,14 @@ static irqreturn_t apci1500_interrupt(in * * Mask Meaning * ---------- ------------------------------------------ - * 0x00000001 Event 1 has occurred - * 0x00000010 Event 2 has occurred - * 0x00000100 Counter/timer 1 has run down (not implemented) - * 0x00001000 Counter/timer 2 has run down (not implemented) - * 0x00010000 Counter 3 has run down (not implemented) - * 0x00100000 Watchdog has run down (not implemented) - * 0x01000000 Voltage error - * 0x10000000 Short-circuit error + * 0b00000001 Event 1 has occurred + * 0b00000010 Event 2 has occurred + * 0b00000100 Counter/timer 1 has run down (not implemented) + * 0b00001000 Counter/timer 2 has run down (not implemented) + * 0b00010000 Counter 3 has run down (not implemented) + * 0b00100000 Watchdog has run down (not implemented) + * 0b01000000 Voltage error + * 0b10000000 Short-circuit error */ comedi_buf_write_samples(s, &status, 1); comedi_handle_events(dev, s);