Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3527493pxf; Mon, 15 Mar 2021 11:32:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDxe4Hy14n9/W0XrIE6PS4z8SckLdPfPwzAFdw9E1sX00V02EVDe+6Kg9xaE+hioQm/SEX X-Received: by 2002:a17:906:1f93:: with SMTP id t19mr25796801ejr.443.1615833165213; Mon, 15 Mar 2021 11:32:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833165; cv=none; d=google.com; s=arc-20160816; b=c/SynXJoDJy/RvgTGPV/NreiZXg7fIDxmKlywWwACUoKNT+hkYiQvK615ijaYEGWZY U0k+OhNVTk8C+ZCkxJNEFGm1xAAekR3YWOVpfS06mPj1JFn0dF9pmVf69Cehyec3RUh3 sfcpZxHiTPEe4l6ElkS2ioBWma9KN4MLwHudyKWVIpasWGZVvqPKdc36TXaZxojifQDC mYktuJYBa8/2Kfuc45MGziX76192jrB31nidxPBWaq6UB4ouaXoEja/qt7nLnowIfJJv E7QPhT3s2moS0vqHi2TsK8YZ0yE+czXw59GwJRwE1q4q2jEEvr54eLZ+8qRGyWfbBRhD KgLw== 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=wlao6IA5gLaly+9Jc+bKuAsyUf+QGjJTv1KqIlqbH4Ym+/w1PcBwtH+jVkuM6+/9xM XCd/6YuJPvksbINnAXB4x1klcZBUbEerzSXslfBla6lXjUvMM7oHVAI1Fgf7OV+K4tkc 4ZfaM5C3Lwu2M3hhiwzYbfGvzOC9H7KJ8E7bYJinmh5HbyG16N+B6A+yuIJPWEx0AsvC MOeRe/7XqoXZEIwvaozuS20vuBhA1NoY/45mPJ2gOPq2HYyUsd8aBnmLZnexGH5pAA+B 5bsk43BF4+Kj3/IsPOLz5+PH1rGc4YSurC9AVg87+cnC1OB6hq9g3EeV4VOs6m1CZT/H DUnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sq3OpH8m; 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 y12si1753697eda.74.2021.03.15.11.32.22; Mon, 15 Mar 2021 11:32:45 -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=sq3OpH8m; 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 S238552AbhCOOmm (ORCPT + 99 others); Mon, 15 Mar 2021 10:42:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:49594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234318AbhCOODM (ORCPT ); Mon, 15 Mar 2021 10:03:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 169B064DAD; Mon, 15 Mar 2021 14:03:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816992; bh=V7viz8xu8N8sJYEkw/htq8X3o9dPilKEp2U4S6NTMI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sq3OpH8mX7mNXkyX8bUg4UT734sepzJ1xfg/0XnyxPEmcKmZNqS3iglX8f8xUq2A/ ufAGjhU/GrMkLghrEARr2fEh+IJxtSDBE7S/KW7d9eF7xrUiGEPpMdojPspgbRdmDr XxlNvipSWq1v6Em6VBh8TjiYlCow/x5LLgB2E4yE= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ian Abbott Subject: [PATCH 5.10 234/290] staging: comedi: adv_pci1710: Fix endian problem for AI command data Date: Mon, 15 Mar 2021 14:55:27 +0100 Message-Id: <20210315135549.892348450@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 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);