From patchwork Thu Jul 1 08:17:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Kerr X-Patchwork-Id: 1499451 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linux-fsi-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GFsTq2XcYz9sX5 for ; Thu, 1 Jul 2021 18:54:39 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GFsTp2BYGz3068 for ; Thu, 1 Jul 2021 18:54:38 +1000 (AEST) X-Original-To: linux-fsi@lists.ozlabs.org Delivered-To: linux-fsi@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=codeconstruct.com.au (client-ip=203.29.241.158; helo=codeconstruct.com.au; envelope-from=jk@codeconstruct.com.au; receiver=) Received: from codeconstruct.com.au (pi.codeconstruct.com.au [203.29.241.158]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4GFrsb0fb9z302g for ; Thu, 1 Jul 2021 18:26:42 +1000 (AEST) Received: by codeconstruct.com.au (Postfix, from userid 10000) id 9A517218F8; Thu, 1 Jul 2021 16:18:14 +0800 (AWST) From: Jeremy Kerr To: linux-fsi@lists.ozlabs.org Subject: [PATCH 1/3] fsi: core: Fix incorrect variable usage in cfam_write & cfam_read Date: Thu, 1 Jul 2021 16:17:56 +0800 Message-Id: <20210701081758.469776-1-jk@codeconstruct.com.au> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 01 Jul 2021 18:54:36 +1000 X-BeenThere: linux-fsi@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-fsi-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "linux-fsi" Currently, when calculating the length of an individual CFAM read/write operation, we use the total requested read/write length, rather than the remaining length. This change uses the remaining length instead. Signed-off-by: Jeremy Kerr Fixes: d1dcd6782576 ("fsi: Add cfam char devices") Reported-by: Luo Likang --- drivers/fsi/fsi-core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 59ddc9fd5bca..92d6d9462e96 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -708,7 +708,7 @@ static ssize_t cfam_read(struct file *filep, char __user *buf, size_t count, for (total_len = 0; total_len < count; total_len += read_len) { __be32 data; - read_len = min_t(size_t, count, 4); + read_len = min_t(size_t, count - total_len, 4); read_len -= off & 0x3; rc = fsi_slave_read(slave, off, &data, read_len); @@ -721,7 +721,7 @@ static ssize_t cfam_read(struct file *filep, char __user *buf, size_t count, } off += read_len; } - rc = count; + rc = total_len; fail: *offset = off; return rc; @@ -745,7 +745,7 @@ static ssize_t cfam_write(struct file *filep, const char __user *buf, for (total_len = 0; total_len < count; total_len += write_len) { __be32 data; - write_len = min_t(size_t, count, 4); + write_len = min_t(size_t, count - total_len, 4); write_len -= off & 0x3; rc = copy_from_user(&data, buf + total_len, write_len); @@ -758,7 +758,7 @@ static ssize_t cfam_write(struct file *filep, const char __user *buf, goto fail; off += write_len; } - rc = count; + rc = total_len; fail: *offset = off; return rc;