Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3523793pxf; Mon, 15 Mar 2021 11:27:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5zeuQggsp9yr6X+0OoiEy741SXC3oWY1re6ph7EG/FSm7+XBuXru1+aNPDeeXZqVcs/67 X-Received: by 2002:a05:6402:13ce:: with SMTP id a14mr31600489edx.365.1615832871967; Mon, 15 Mar 2021 11:27:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832871; cv=none; d=google.com; s=arc-20160816; b=mluySmMldrfNsFWW3TjEUJFjbBxFSxxIk0FY87HWqiKWPhzuicoeMfeYaNJC3L5ahI HbYfpqJMZ5URCuYbRVOJZU1jwtgJfhtNxeX/EwQu7tUOoGS57gdloBB6u8LppNsuhPUD Pqgx9Sy9pCoh0062WLe0s9CXUkVuJmC9+9VxVKu+BzXL8d/NjMKNyS37chf/zbMxzOj4 7GpqmZiEOAdj28gRO2d3xN6k2+NTvvN7VJbcGT5qC1+dO0LsXSUVP0IIhVsWvxFcMw6X Sa7kL0X56I2+oTcRvIr0QaGfnv4/2a/V4EEcEP8P9NVtoX4A8RZahRGsktOpGfCyLSIq lhUA== 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=h8eI8AAzA88ZUynN1SaeZavZkxjozeJJbjBYbfKSQ3ohQh3927K4IKcAf4LnOdlFTQ hEYE2K3K7SyQMDJnMKNO9ExvFV7DEUrk9xwC9j9WHiK7SV2l+jllvW2T5KZ1RijMnKVx pzXrGf/LQ7Lf91nVi84KpfAYIkA1av5t9/wUaKVNKjEFZH3DobtQ/4tDdF18ZItVRRUk QX4hi+h1FV7YbwKEAFWVxjovpnaQMIh4BtUz9twNh+EgKBbrW5TWcNz/z8da6/S3t7k7 BzFgmj0QTv7pJ2wGQQ2ZoOfxbAyBxTpgtSoewRqAidkL4BkK1fHFOHh7+lCMLKMtBpFh pl9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=guQInOrk; 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 y3si11699206eds.265.2021.03.15.11.27.23; Mon, 15 Mar 2021 11:27:51 -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=guQInOrk; 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 S233080AbhCOO2T (ORCPT + 99 others); Mon, 15 Mar 2021 10:28:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:37500 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232263AbhCOOAh (ORCPT ); Mon, 15 Mar 2021 10:00:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4F8C164EF3; Mon, 15 Mar 2021 14:00:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816823; bh=uEJo1uYAUKC2yFLQgXzIXbHI3oV4iq54+jSSHrfHZM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=guQInOrkxRzpT6znpllHv1o+m3Rrj4y5wwA5qqy/8qnu4yAdBW/zGbMxWda0qunI5 fYSeFE0mW2wmBAblPVgDasYQbYVm8rnNzaJSH3CJKzDb6gQEDNweHeK0XaQNlPQ+2G lLNBiJTFXkRaib1goue1bv0Qw27pxdtJIx2/9JLY= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ian Abbott Subject: [PATCH 5.4 134/168] staging: comedi: addi_apci_1032: Fix endian problem for COS sample Date: Mon, 15 Mar 2021 14:56:06 +0100 Message-Id: <20210315135554.747947375@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135550.333963635@linuxfoundation.org> References: <20210315135550.333963635@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 */