Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3522672pxf; Mon, 15 Mar 2021 11:26:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgMxZAsUBtGHwyMbvUcpZoESaLn3jMvLrUTFJc4JwSF9UmRxSYwhyBSGvIIpJZr7x1ABU7 X-Received: by 2002:a17:907:b06:: with SMTP id h6mr24985468ejl.144.1615832786356; Mon, 15 Mar 2021 11:26:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832786; cv=none; d=google.com; s=arc-20160816; b=jUbhfRsIlcMG6/NCv7FwdYae/8tfwIHMy0xxGNihw9mIDElJPVKLkmSTGh4nCD5CwG Wfk+V1Khzg1MijvE+gdM+I4F12ENI/dPrG5mKwNURBEWBwNhbaeZu3s6AWOwTAsQbbAV MSXAQ3nNlFpdsOAXNBIJZ/XM5Z4RF/Qx/gh5atyogcJR+xom/QThIrABlENArSk2Y/2B vIFzIUvRz+w9H3xXQDorvywDajWugoaW7NXygXMydmNs2oaZScI6qw4YooCFv3kBeuRf AWE/oow8F0NetDJwKmYnCBzALkq34WrDbI84mJ0ro0XIGULAdm+YZNHaDSF22vsI6io9 P5og== 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=ghhqmtpz9zxALY85t0Gv5eWRldB2nzWMyz5AAUuSLmg=; b=rMq6rUc0o32vdYt+1uKfDU6dhXxIXd7hBD9/IYNOF9J2EnPlJlllUHv4JUwqRo7c4O BiGoW8jGGzZlNunBvauXhEgEj4+9kEKLeXg3YJ2jnYWOXOLYiuO+/5hGi26JXLVmQXyQ 2oEc38IFTIItQ1MjX95eElqKq7LUYpp8+cAEB6rTATbhFLdIUbycmic3cKX5iEDLrJfA 1qSxFOdBxHPCRCI7bjITCGv4K6LpmZSThLWMG/jXGpbd7qF6OKKsRJQ0q/+YsmbwjXvx +2vXWjeBr0KiL0fEGAmRI1KgJcmkjjycyCk5QtfieaKF1wPPfGEaX3/MAjvV/213kGk1 bPaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mTuwoBOl; 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 u18si7086028edo.335.2021.03.15.11.26.04; Mon, 15 Mar 2021 11:26:26 -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=mTuwoBOl; 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 S239115AbhCOO1r (ORCPT + 99 others); Mon, 15 Mar 2021 10:27:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:35610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233115AbhCOOAn (ORCPT ); Mon, 15 Mar 2021 10:00:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C102764F6E; Mon, 15 Mar 2021 14:00:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816829; bh=uEJo1uYAUKC2yFLQgXzIXbHI3oV4iq54+jSSHrfHZM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mTuwoBOlXvr14+Opu9cv2CkyS10tSklGjIfXAY/8k+ngzTIAhd4LFEhw6oeRs/vnw ZcvMm3bxqtikrHYa4/JGwYsG7pQ0PXcnT/0mb8LmnxsscawhwMrPt0cwwtoHoEmfg2 DNGUwWGZgUWGhWO1sqEmiClV7+Gzol5gdfnzK/NI= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ian Abbott Subject: [PATCH 4.19 096/120] staging: comedi: addi_apci_1032: Fix endian problem for COS sample Date: Mon, 15 Mar 2021 14:57:27 +0100 Message-Id: <20210315135723.115417830@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135720.002213995@linuxfoundation.org> References: <20210315135720.002213995@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 25317f428a78fde71b2bf3f24d05850f08a73a52 upstream. The Change-Of-State (COS) subdevice supports Comedi asynchronous commands to read 16-bit change-of-state values. However, the interrupt handler is calling `comedi_buf_write_samples()` with the address of a 32-bit integer `&s->state`. On bigendian architectures, it will copy 2 bytes from the wrong end of the 32-bit integer. Fix it by transferring the value via a 16-bit integer. Fixes: 6bb45f2b0c86 ("staging: comedi: addi_apci_1032: use comedi_buf_write_samples()") Cc: # 3.19+ Signed-off-by: Ian Abbott Link: https://lore.kernel.org/r/20210223143055.257402-2-abbotti@mev.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1032.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/staging/comedi/drivers/addi_apci_1032.c +++ b/drivers/staging/comedi/drivers/addi_apci_1032.c @@ -260,6 +260,7 @@ static irqreturn_t apci1032_interrupt(in struct apci1032_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; unsigned int ctrl; + unsigned short val; /* check interrupt is from this device */ if ((inl(devpriv->amcc_iobase + AMCC_OP_REG_INTCSR) & @@ -275,7 +276,8 @@ static irqreturn_t apci1032_interrupt(in outl(ctrl & ~APCI1032_CTRL_INT_ENA, dev->iobase + APCI1032_CTRL_REG); s->state = inl(dev->iobase + APCI1032_STATUS_REG) & 0xffff; - comedi_buf_write_samples(s, &s->state, 1); + val = s->state; + comedi_buf_write_samples(s, &val, 1); comedi_handle_events(dev, s); /* enable the interrupt */