From patchwork Thu Sep 7 09:55:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 1830822 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=BFe7kI6I; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linux-fsi-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RhF4K1Jgwz1yh1 for ; Thu, 7 Sep 2023 19:56:01 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=BFe7kI6I; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4RhF4J0ZCQz3bw4 for ; Thu, 7 Sep 2023 19:56:00 +1000 (AEST) X-Original-To: linux-fsi@lists.ozlabs.org Delivered-To: linux-fsi@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=BFe7kI6I; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linaro.org (client-ip=2a00:1450:4864:20::430; helo=mail-wr1-x430.google.com; envelope-from=dan.carpenter@linaro.org; receiver=lists.ozlabs.org) Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4RhF4C4B2cz300g for ; Thu, 7 Sep 2023 19:55:53 +1000 (AEST) Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-31c4d5bd69cso795272f8f.3 for ; Thu, 07 Sep 2023 02:55:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694080550; x=1694685350; darn=lists.ozlabs.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=7+oeYHhCCZf4UqPQvsghd+Ar5QM+qfPLVMJj3atC+1c=; b=BFe7kI6Ip/ig2Ol+CFkopvkonLOXqtpx+8LVoOOhr4BmUxyasSWZkSnF+QVWM/JdTG zK2oRiqFyxfPr5bVwo6cW47Q1VKESIEEB2b6999VjZ8Z9nElJFrSoRdoNM1gHNAMMQO7 fPAC9V78mQUg5eiQyWKbAbOZs6KsD/JsAAhpDoEbSt+BFRNUaImd+W+DvpXwLaVy5b10 r7Pse1iOr2EkRmXZ9o1Zlp4El0QCFEc9cIn4Xe1YyxeG158bistFWyah493yhT3FZlft HNjkypMtBCILzdtK4aA7XmnsZkwpENECw4VaRxA2nRfKa1pgKVqoI6dFRT5ZP4zZ7FKh lh3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1694080550; x=1694685350; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7+oeYHhCCZf4UqPQvsghd+Ar5QM+qfPLVMJj3atC+1c=; b=ZC5gbQ38Dj1F8s9K2WttfowMkO9YF4vcsUxYkmcu+g+2VVICnuMdXIvNtFqpiluu8Z nNXho2BKoRSCqOx9/G63tuvaVRl4DZAD8bjMPxpdtQvxLETut8T0WmN+u6+Eop3GDugy oB5uXPq9JtsIy6XtiK1miTXkcZ9FpnjDi2TwYcaYhQE3XGAIJwkQ3QCsz6KThvrCMpma 3mvTTJPyEIqP/YnWL9T798qTX3NQ1m52Fh2lGgZmu5x1uVFdrbkVJIjThZresLoLwtMy YPOs3wXRDV3guThfXtIARQBv5OZYnBjiHQM2edjf4IkuE4AKT0yuCh7+3Vxluzu+dXvy hyDQ== X-Gm-Message-State: AOJu0YzSnQM18Urhvi5JaXMXlibBOLM1+6VfICOFR1ycfYfP1rAn8AAr f1e1dNPy7VNvTCFzFqHbWdrykg== X-Google-Smtp-Source: AGHT+IEUCqT/4Qvl7BteIhCYfFd+u2xnC6HQNrqjt2oIdRyQrjNUNt43eRhSqUZxSCuOAp+rQ/F7EQ== X-Received: by 2002:adf:ee08:0:b0:317:5e73:7594 with SMTP id y8-20020adfee08000000b003175e737594mr4534863wrn.28.1694080549826; Thu, 07 Sep 2023 02:55:49 -0700 (PDT) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id d18-20020a5d5392000000b0031c6e1ea4c7sm22973928wrv.90.2023.09.07.02.55.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 02:55:49 -0700 (PDT) Date: Thu, 7 Sep 2023 12:55:46 +0300 From: Dan Carpenter To: Eddie James Subject: [PATCH] fsi: i2cr-scom: Fix error code in read/write Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding 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: , Cc: Alistar Popple , linux-fsi@lists.ozlabs.org, kernel-janitors@vger.kernel.org Errors-To: linux-fsi-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "linux-fsi" The copy_to/from_user() functions return the number of bytes that they were not able to copy but we want to return negative -EFAULT to the user. Fixes: c0b34bed0bbf ("fsi: Add I2C Responder SCOM driver") Signed-off-by: Dan Carpenter Reviewed-by: Eddie James --- drivers/fsi/i2cr-scom.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/fsi/i2cr-scom.c b/drivers/fsi/i2cr-scom.c index cb7e02213032..df1e1df40332 100644 --- a/drivers/fsi/i2cr-scom.c +++ b/drivers/fsi/i2cr-scom.c @@ -45,9 +45,8 @@ static ssize_t i2cr_scom_read(struct file *filep, char __user *buf, size_t len, if (ret) return ret; - ret = copy_to_user(buf, &data, len); - if (ret) - return ret; + if (copy_to_user(buf, &data, len)) + return -EFAULT; return len; } @@ -62,9 +61,8 @@ static ssize_t i2cr_scom_write(struct file *filep, const char __user *buf, size_ if (len != sizeof(data)) return -EINVAL; - ret = copy_from_user(&data, buf, len); - if (ret) - return ret; + if (copy_from_user(&data, buf, len)) + return -EFAULT; ret = fsi_master_i2cr_write(scom->i2cr, (u32)*offset, data); if (ret)