Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3527434pxf; Mon, 15 Mar 2021 11:32:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoHpXS88NGhQzkUWTkfzuZrv6Xxx9hVdCj4yYq2j4G5pceN/nhMl7qsQOGDnY3w9CEqzun X-Received: by 2002:a50:eb8f:: with SMTP id y15mr31673793edr.115.1615833161382; Mon, 15 Mar 2021 11:32:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833161; cv=none; d=google.com; s=arc-20160816; b=b2q1M4tCwcVAjwDH+786ZtgJBfLNRy17T+ANmYvL/1vvhgV9Uz68s6RtvT5vJbQx7s K1BWBTpYgkHwMbmeq2beOgGjCik6dbeHMcnJrHIN9+ed4RT13cbCyIUb0ZWde8/svEav wDCOkTEVS9pLLyDmN4nIPf9bKNqgCHnftXT6aQrvCXs6zJ4CjsZu62sqiRnwRt52ZpvV 5pwX5657WsmxtDtG5HLL7jEv31N7Fneg/u9VrPpxSYABrI3owB8YwhH6TLuGjYZUPq1X Ffx3Hw9tWwPZw6pEj9cxE2mc+A6bzo2k1ynqrc8nC7As+HRvr31Sc3Fn4/OGmvQEOHuw Whzw== 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=jizshFZoTj1zKzz+hwAzab9kQKBF/YAoVtJUaXbaK4RXLTYNjtWz4X1e59ScpDAqYX iko1Dnn6Y2MUmDaehzKwpavey0xkMBgXersij9oE04501gOMeCC6BZ/EHo1P9gjtBTQk VznitfBdYdGt5xPxPV5Pn12KwK+UBFYJf7QrrGFGMaUQ976PDQYx6q+tW2Pp5Hi47ICb Kst+edMHpjuvoAlESkOJCcqjpDdN9XnL0eBYu88qCw3014wyKUXznDB3hUPT/dke2wnl oNYT/4plTBFuQrG6OTL3aXuUTP7PwLrsd+7PRXWl5mSEky0OJ7ipAr7YdUDVSXmKyU9V pLig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vBaNfir7; 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 i5si11844351ejh.313.2021.03.15.11.32.19; Mon, 15 Mar 2021 11:32:41 -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=vBaNfir7; 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 S238447AbhCOOmh (ORCPT + 99 others); Mon, 15 Mar 2021 10:42:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:49558 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234278AbhCOODJ (ORCPT ); Mon, 15 Mar 2021 10:03:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7EAFE64EEE; Mon, 15 Mar 2021 14:03:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816989; bh=uEJo1uYAUKC2yFLQgXzIXbHI3oV4iq54+jSSHrfHZM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vBaNfir78hX8ZU4kyhRs2RTtwwT+sh5i7kE5YQqzBoc/8algS+J45fFvPqpyv5Qgw cDPf0x9M7YXK72QzsWfdQf52dAeQehAEkfDTRtsBVjOVqyCWuMNzQCPqyBkLTn8b0T CnQ8eHEJ7xERDAqESQ9AHctblF1yT5WaqoVVpEGg= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ian Abbott Subject: [PATCH 5.10 232/290] staging: comedi: addi_apci_1032: Fix endian problem for COS sample Date: Mon, 15 Mar 2021 14:55:25 +0100 Message-Id: <20210315135549.827289634@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@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 */