Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3088299pxb; Mon, 1 Mar 2021 00:58:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJy2nIFKDIOOC26NjyUGpQOQg1XiKrQJtJebxe/b9bDphyyxO/3PTvp8ubh6MEBZukTGRftQ X-Received: by 2002:a17:906:95c3:: with SMTP id n3mr14672871ejy.269.1614589089607; Mon, 01 Mar 2021 00:58:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614589089; cv=none; d=google.com; s=arc-20160816; b=p4Qimg25zdeh9g3MYtJTP3u9Xq1NZmSjWElretP3qMwZC98y3wCBb1KiuLGpH7Vbyc t50wDZXBSrDmHR46FBO43zd54dGh7kYg/7G1fE8IhU9CNLgLA0ClIPyT31dX2urDYoEA A4V/ds7/CZwXTtIlPHtsldKAtGgIMTb9NvcAlXT13ChsBasmqVFlLa92NTMGR44x3xEB F7C/XCc7GPTJ7AUGeNDd85l5x253ObB+KIAGykiM6PvlXXYvhTwpT41f1aZBKNgLbmRt 1HnVfZSnsLAueh+em3MTPhd6lJCAosQg2oMCUUccg46i1jci5sKtBent31dU+QDwNDM4 aCZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:to:subject:dkim-signature; bh=z9Lv4jcdbi26OM1Ui5humilwQXIlpCe/CsQxpgRss4E=; b=f7cY9/HXLSKekGxwTkjYyMGPhxnL8Zd4Z7iFHx+Hgzs4eDW0T2/ZkznIR4qMUdkSmh +XRXMpEz9UeA1Co8K3QKvBa2j7sAIuMaT+WZgkfeHD8PrzaCfT3Jf/Y/CwtFT3vE02QH X2+4Guim99Nh/xEDd2HQIiihUnTYiVwPbUQADxh3wjrclnnPWhed/TxU3DUkYxhkWDJG v+KmL7tY+0+d3NrUE/UxDpZ2ZTN0gm1K1KPuU1u1A1j7BJYxdXcdgqoC/FA8HWRn09aS tIJax+AshW6OHiVXnEPFqmWX4QoA57ZZuV7JE8UnnQAIW1HH8eqU+EKAZaV+7KUzZEtg z14g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QC+865VG; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i20si10983637ejb.131.2021.03.01.00.57.47; Mon, 01 Mar 2021 00:58:09 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=QC+865VG; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233697AbhCAI4B (ORCPT + 99 others); Mon, 1 Mar 2021 03:56:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233782AbhCAIxv (ORCPT ); Mon, 1 Mar 2021 03:53:51 -0500 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA020C061756; Mon, 1 Mar 2021 00:53:10 -0800 (PST) Received: by mail-lj1-x235.google.com with SMTP id q23so18461925lji.8; Mon, 01 Mar 2021 00:53:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:organization:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=z9Lv4jcdbi26OM1Ui5humilwQXIlpCe/CsQxpgRss4E=; b=QC+865VGhYqY1nnmUzvCf/Uf+JOswGXtj8VVmchliFJccyBBoqlHHhmAeJ+TU7PIzO pUT6E//Vkmz8lpo2Li/nkdpZSWwny9axmj80kAEpfAu3zfB0Wqvga02OqhvEKrM9dad3 k7UsUYLba/zlRA3MBFzIhsNXw1HsnR+vNSy+3DVuof6ibSEmRxy675rQrcfg/PoXZs+8 ujWmvSlODrs2pkZLQwI0ZWbFCJJRm6d/Jo1U04ACXqLuPzh7MClDz4BmEH0CbF2R1cIu zKrZQrQ7F2juFCftheYDsmfhKsIGY7wTVdchBsxgQkloMYbf+vwqzYp44Pn1Dtx0YNJr OiEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=z9Lv4jcdbi26OM1Ui5humilwQXIlpCe/CsQxpgRss4E=; b=pepha1odFc8YM1C27k3a/wFCsKUej/RGrjU3L9uOE87QjDvD4M5Er+RPxnmbQkii6A pShlrbUaN4MxdwAnbXAjqEnNqBcHGACXxrArIalpMAOWnfXPk7JDo5B6KYIKyR65LvWP y5WiUrc/kOgpAQd5GeMJx3cswp57IwaZeRCTaxv0Ti+DF/Hn3zZNftU5wfAzaJW06mFu PiB+7dlJjA2aHrXVIxqSd2BD2SGR6D60qWKiVlv+DC0YsmGFOnSFDF/2oGQuvs5YYOmt ujrQBmDB4/GIVG+kvIhOz3soGcRVgxMTH55nLi80vSk5hcijsGCiQ6GenIoHnGk/CEju 6ZKg== X-Gm-Message-State: AOAM5300CEgLv6iNctwmKfshNFhMMBHbUvtsb3JIpDBcd0oG0QfjLnZA owfRMenkewNoOEph9ROS3F9ks1wbp/IQFQ== X-Received: by 2002:a2e:8159:: with SMTP id t25mr8753996ljg.84.1614588787470; Mon, 01 Mar 2021 00:53:07 -0800 (PST) Received: from [192.168.1.100] ([31.173.83.37]) by smtp.gmail.com with ESMTPSA id u13sm1328368ljl.107.2021.03.01.00.53.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Mar 2021 00:53:07 -0800 (PST) Subject: Re: [PATCH] arch: mips: sibyte: Return -EFAULT if copy_to_user() fails To: Wang Qing , Thomas Bogendoerfer , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org References: <1614580437-19660-1-git-send-email-wangqing@vivo.com> From: Sergei Shtylyov Organization: Brain-dead Software Message-ID: <3a7d2007-b7d2-e428-406c-a6804bff6df0@gmail.com> Date: Mon, 1 Mar 2021 11:53:01 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <1614580437-19660-1-git-send-email-wangqing@vivo.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello! On 01.03.2021 9:33, Wang Qing wrote: > The copy_to_user() function returns the number of bytes remaining to be > copied, but we want to return -EFAULT if the copy doesn't complete. Then 'err' is hardly a good name for that variable. :-) > > Signed-off-by: Wang Qing > --- > arch/mips/sibyte/common/sb_tbprof.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/mips/sibyte/common/sb_tbprof.c b/arch/mips/sibyte/common/sb_tbprof.c > index f80d7a7..eac125f > --- a/arch/mips/sibyte/common/sb_tbprof.c > +++ b/arch/mips/sibyte/common/sb_tbprof.c > @@ -465,7 +465,7 @@ static ssize_t sbprof_tb_read(struct file *filp, char *buf, > if (err) { > *offp = cur_off + cur_count - err; > mutex_unlock(&sbp.lock); > - return err; > + return -EFAULT; > } > pr_debug(DEVNAME ": read from sample %d, %d bytes\n", > cur_sample, cur_count); MBR, Sergei