Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3313061pxf; Mon, 15 Mar 2021 06:58:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmA81Pu8CRfkzDIHdoNhqjhj3WU2aO+3PEgNqi2ILm+utWYa4BPkMWdJXZTm4usKoimPpN X-Received: by 2002:a17:906:4410:: with SMTP id x16mr23903911ejo.446.1615816704193; Mon, 15 Mar 2021 06:58:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615816704; cv=none; d=google.com; s=arc-20160816; b=B72SgEj3jkc1ve3Q7+XUypJvFTa26u/gyC3GAOK6kGn4OqYrlsnNzxXhsgOZUIKigs KJDTnTasSyfKvBs0B6HRURqVjP+VFizWP7MJ+heix3eDSa0ENVHyzcmhR5t4LuZX5yOQ SgUizILi+WuPa7YeZtrgolrClRv7rWscTYf1UGkrmV7V0NL+5YyQeNFT2HeBxkYd2nRi iStfv76iZxZlpjXvLUHCn0X8W6tPHUsVSm+l0AozOn5k17BFgnoqGJGXZu46d9LhzG5+ vUlGq9GuLKTqN/RCa3uFjtfspz0d7oKHzTgOkJUGWaXkYrNSl6pfR0hTqkxLWPgo2DhV ahtw== 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=FlThtxbwk5JHMQE9QTpTKTcToR4k9tOPc99qVpYNcsw=; b=uDnDX4QscWBXvypYqfhE4EnovnhSeiuR+tPmrFUNh+YbUvF6aWlucWK7YMAgqh09Ow TEvkZNvTIWBxFqipDPw1j+r8vxuBnsRHpLiWFW/RsuS79XVkR/iYcXcub1YEBH9GbsPv u6XMCWgmy83KDPpCXolmpAxbUZcCQnVzGnGgQxDRCEKvGdqKSaEZIxDz4vronXEy38yM nEb8ETSabiD28unbq9zvrf+3fNubl7wnw8S0l1q9oM8EeqVnnXnv4lGkMWul17sZmaZa lNoHi3ZfeM6aaYnbipqWsRRogO44jqLbyWD39c8KhaBPSV9WR1QNHKcnqfdHTIfVR4Wz 5/VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=S79YEYXx; 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 f3si11001291ejd.252.2021.03.15.06.58.01; Mon, 15 Mar 2021 06:58:24 -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=S79YEYXx; 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 S231179AbhCON5H (ORCPT + 99 others); Mon, 15 Mar 2021 09:57:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:57294 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231386AbhCONyJ (ORCPT ); Mon, 15 Mar 2021 09:54:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 49C4A64E89; Mon, 15 Mar 2021 13:54:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816449; bh=dyxUvkeFFAfCa9HbSej9c83vTx3J2aDdsBEsBapoT2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S79YEYXxElVZmHsRfKLO6Kes1BNhcZzWqSrSvk2sCD1dNRxXhX7Q3vQZ4G5x5XG9k Up9CXp1PN+wdokLe/vgD7YLnFDvA+aWaKvLsUwE64PGgcdGMcD4UTpocSJDhrRiHdd DOsS/FU2ErSx/U0dwrNDRdHPl7ImXp0kni+vhOc4= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ian Abbott Subject: [PATCH 4.4 51/75] staging: comedi: adv_pci1710: Fix endian problem for AI command data Date: Mon, 15 Mar 2021 14:52:05 +0100 Message-Id: <20210315135209.914501090@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 b2e78630f733a76508b53ba680528ca39c890e82 upstream. The analog input subdevice supports Comedi asynchronous commands that use Comedi's 16-bit sample format. However, the calls to `comedi_buf_write_samples()` are passing the address of a 32-bit integer variable. On bigendian machines, this will copy 2 bytes from the wrong end of the 32-bit value. Fix it by changing the type of the variables holding the sample value to `unsigned short`. The type of the `val` parameter of `pci1710_ai_read_sample()` is changed to `unsigned short *` accordingly. The type of the `val` variable in `pci1710_ai_insn_read()` is also changed to `unsigned short` since its address is passed to `pci1710_ai_read_sample()`. Fixes: a9c3a015c12f ("staging: comedi: adv_pci1710: use comedi_buf_write_samples()") Cc: # 4.0+ Signed-off-by: Ian Abbott Link: https://lore.kernel.org/r/20210223143055.257402-4-abbotti@mev.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -351,11 +351,11 @@ static int pci171x_ai_eoc(struct comedi_ static int pci171x_ai_read_sample(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int cur_chan, - unsigned int *val) + unsigned short *val) { const struct boardtype *board = dev->board_ptr; struct pci1710_private *devpriv = dev->private; - unsigned int sample; + unsigned short sample; unsigned int chan; sample = inw(dev->iobase + PCI171X_AD_DATA_REG); @@ -395,7 +395,7 @@ static int pci171x_ai_insn_read(struct c pci171x_ai_setup_chanlist(dev, s, &insn->chanspec, 1, 1); for (i = 0; i < insn->n; i++) { - unsigned int val; + unsigned short val; /* start conversion */ outw(0, dev->iobase + PCI171X_SOFTTRG_REG); @@ -516,7 +516,7 @@ static void pci1710_handle_every_sample( { struct comedi_cmd *cmd = &s->async->cmd; unsigned int status; - unsigned int val; + unsigned short val; int ret; status = inw(dev->iobase + PCI171X_STATUS_REG); @@ -576,7 +576,7 @@ static void pci1710_handle_fifo(struct c } for (i = 0; i < devpriv->max_samples; i++) { - unsigned int val; + unsigned short val; int ret; ret = pci171x_ai_read_sample(dev, s, s->async->cur_chan, &val);