Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3522752pxf; Mon, 15 Mar 2021 11:26:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQpxXkytoYr6LaO3NlwzoKoRSh/qzsW1pPX8j0wEdXefkJkDf9ZSm/Iv5t3PSqKvIajJI4 X-Received: by 2002:a17:906:b297:: with SMTP id q23mr25466074ejz.315.1615832794587; Mon, 15 Mar 2021 11:26:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832794; cv=none; d=google.com; s=arc-20160816; b=YfmMC94m2We/qmLBjhrgPcZGvznvvAY6F2cYcGratNHC7GNlI2VbFLAkCPzdUfk+Gm 03g4+3pDobB5o9K/wkwefev2rIhU6PimJjYevkafizW3HrJhwUmC4uvGUZZ/32PM3jNn ihnzzDrMTJO7H+MLe70uOXRpwWcJFLsaDi83Dvl7ILnCMixs5WDPteFg2tCsnZXS8ZzZ hYXX82rKTV36QXO+Evikty1k2C6yrHPf8J874C6nJjRX3jRoavvknhWwKN50C4ePJJFs xcBr76z8V7CdMfw1Jln6ni4BUiyW+cW2VEzsjZ1d996MGo7FkpwZDkDH0jfqpKTn22I9 /Sxw== 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=A+rOo7S3hMyZBh+EFb6OlpHDNKuBy/+nIzLl0QnhVeU=; b=odqUeWEvWPScIQp0NHDp/XkRlkSbTO7ip8nHusA5gOxkmsaQbO0VscyOCENqbUX0nv z+E1Q+QJGtXUDAbncuocZ/jgivLC0vwYlFUYMRIX33extbRxrFIWvTIoKfNDIs38Z4iN TAho1a2LGtoxt9763gl1uSTmas/Y2i3U/StQaeq7QfxrWqxKzZl9qUwX3PexPYYfm0+k m3Khku3EeQ/wiNpygSgS/lsnXPnUA5ADbEOLs1hZ0xUDOIdmChTQLryO9ot+WqWuhuuP HAN1aydYhMCnSLCBq30yvBmxNMLucTziPN4l4MoUkpsjHcn5rmzlGJpTbYksFrQR3mWn im/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hqQME57t; 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 w25si11673080eja.753.2021.03.15.11.26.01; Mon, 15 Mar 2021 11:26:34 -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=hqQME57t; 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 S239064AbhCOO1m (ORCPT + 99 others); Mon, 15 Mar 2021 10:27:42 -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 S233099AbhCOOAi (ORCPT ); Mon, 15 Mar 2021 10:00:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BA9A764F8C; Mon, 15 Mar 2021 14:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816825; bh=V7viz8xu8N8sJYEkw/htq8X3o9dPilKEp2U4S6NTMI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hqQME57thoK1jMIv5Quble2EJWBRGIotC5xU9VYVso5pfm75xYMn/is4OEcAfiOSG CpUbOzKZnQ5xMruY8wY1U7T8gxmv9Z3NLxnO1bANxb58TXxNjfpUU2Q3qF9VOawsY4 8/80WFHp3GiMwVV8m0IUUHGNnXG6YIWjw4UJTNAk= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ian Abbott Subject: [PATCH 5.4 136/168] staging: comedi: adv_pci1710: Fix endian problem for AI command data Date: Mon, 15 Mar 2021 14:56:08 +0100 Message-Id: <20210315135554.810219910@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 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 @@ -300,11 +300,11 @@ static int pci1710_ai_eoc(struct comedi_ static int pci1710_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); @@ -345,7 +345,7 @@ static int pci1710_ai_insn_read(struct c pci1710_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); @@ -395,7 +395,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); @@ -455,7 +455,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 = pci1710_ai_read_sample(dev, s, s->async->cur_chan, &val);