Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3528236pxf; Mon, 15 Mar 2021 11:33:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpRX84D5MT2rFGvHrOpyyZaNEu39rtfRGRhEWq9d4legEuzJA1aTtXUNXuDfxM2GR+KsyZ X-Received: by 2002:a17:906:e48:: with SMTP id q8mr13803053eji.84.1615833223946; Mon, 15 Mar 2021 11:33:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833223; cv=none; d=google.com; s=arc-20160816; b=RWnSFpO2HvIhTvRT6S7WuZBMlH07S/julCoZc/D+KS7pj5t94vo3/SbqouWXBh7Km8 yfmx4f+KvlkDpYZNoehCFQrkXkuwXRaCj8OQeY/ATEHnzr9QtCvZrKuBmYAQVuEKGxTv brytbNeEaAN00WaWnSeqrXWHpRfA0NjDepdHf3aV+b0QKTWjam/x8ibvOMSr5kdSCO0u 8e2o6kksjXShajljrndF+S8ALgikum8QNYvRudWWrgP1zFtKZ694PNTFO4g55mtQP2rX tU94IZjahXEnImZHbWmQ6Uk3zOD2Nu656sxxTYBqQi3gB0BDVGlwnNPm8yeUpgB3KKCW jwvQ== 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=KtoF+BeghCqIrripulhJt9LAb1+aeU0qXRKwkrdWRfbHbO5wQPYICOaQ4CtY9jUfeW 7Unmug+z7nwZWm5Y1ewj5+U6H92gvs0oZNl7bdNG5m8C3/ynaiC9c+xyPM6ORhSJZZH2 JRnUggekrn2Fov1maQDFfGPU/ZhajUqzx8PCLfhofc+1MI3ltd3mje3KwEIO9QD2TIu1 BPicIfGwWPs3Bh49caIHWQo/9nn3dL2fW9RE6sxe39x5m3pKTX6K5d2bD8uuQGk3yLnP W/lxbkEXDA9X5HoN6X7FH2U6nZj3nbOMU3ng4gmiO6kxvZdc8CaeCIdyGtLRfGNUeb2/ n5sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kAmpeX+r; 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 gz11si11558637ejc.745.2021.03.15.11.33.21; Mon, 15 Mar 2021 11:33:43 -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=kAmpeX+r; 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 S237416AbhCOOkw (ORCPT + 99 others); Mon, 15 Mar 2021 10:40:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:49186 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233929AbhCOOCi (ORCPT ); Mon, 15 Mar 2021 10:02:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C977F64E89; Mon, 15 Mar 2021 14:02:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816957; bh=uEJo1uYAUKC2yFLQgXzIXbHI3oV4iq54+jSSHrfHZM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kAmpeX+rrmZYKZtAoDzUQ3lHuv12fmWRGO5LtQFNDr4q+blAW3yCFr0Tx2ikK11nb sPAJq9LxpGwXoEhbcNnoTfoF1I+Sij5WPGi7wxaF4nu7XLa/2tTSIgoxMt3AwQhJ3c Q2McOtF6rSQkhrwnbh7oJ2DMB74z1nJRAvCBNr/o= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ian Abbott Subject: [PATCH 5.11 228/306] staging: comedi: addi_apci_1032: Fix endian problem for COS sample Date: Mon, 15 Mar 2021 14:54:51 +0100 Message-Id: <20210315135515.330784775@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@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 */