Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7202912rwr; Tue, 25 Apr 2023 09:25:10 -0700 (PDT) X-Google-Smtp-Source: AKy350bNGR/qvi1P+u+IMpENHAfNbiaO+5al/1Dlx9uxfqRFYalKJ03bH/7UDm0uuaJoFNfvi4Qt X-Received: by 2002:a17:90b:3841:b0:247:e4c:d168 with SMTP id nl1-20020a17090b384100b002470e4cd168mr17607276pjb.10.1682439909796; Tue, 25 Apr 2023 09:25:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682439909; cv=none; d=google.com; s=arc-20160816; b=vLzouwXcyKixn9Z8QcJFgR0Mfe0iNDNxLDQPGNv9wUVfXkJlx1BGa4i6B4ci5uSlFO yw9Mp5qhAc7hlmS4H8B1voFdtA+cb1gzopTk8Rfy85MynQFDrK+izA78FieRi2Ptgfux XS1HVNRGZ0vr9g23blwpS6uLHYXuoZsXioY3zXUSTBes6uShJpRAfB2yrNf6tb2I/9cW TxHeHoLaeqt2lR3Wg8VBZN/Q4nisoi4xSQd1BMkQD6f/5kbGhc8nOq8LiX3bYh6AYdhW 7PLd986tmb482evHVV2URR/GBTMUVKe9FcghaMZhUsOwfICIX9WtbcPxN8+tFDswoZI4 yDSg== 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 :references:in-reply-to:date:subject:cc:to:from:message-id :dkim-signature; bh=sQKbtorZijfrBsSbG/R4wwtRRcylsXE+DoGloP7WmT8=; b=z1l3Tz3MuWJpupvWauS9FLHp7sa+BlgB84PTXLZ8w+0Cs7P7TTFhsxzsnfbCGpmuuP y/+CH8Clss2QV1byUEmBg+iFMG7LDH1pB1Jo2ZIPVhW4hyWU1RlGSkV+vNZqrOVBYYXs kn7XNR69WyaGfVE4uGWGPT3gmvmBZ/uReVAGGV98DMlj+A5p9n3neqbNC5En8LhI2lr2 Qf0vWuUfOxQfoi70M5LA7vCf3NMcz2PNeeTwVAh2JtZwA8Yetug+njksg04bsaaDI8QL gR/dsFX4ZYlRkUZEDgqehQ9WfbVRLH2w6pb4VQMpQososE8ShGbgBK3lV9LkJ03OPaGY IBTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=bDvSD8cP; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nl15-20020a17090b384f00b0024743ec226dsi18265463pjb.70.2023.04.25.09.25.00; Tue, 25 Apr 2023 09:25:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=bDvSD8cP; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234206AbjDYQY2 (ORCPT + 63 others); Tue, 25 Apr 2023 12:24:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234620AbjDYQYZ (ORCPT ); Tue, 25 Apr 2023 12:24:25 -0400 Received: from out203-205-221-153.mail.qq.com (out203-205-221-153.mail.qq.com [203.205.221.153]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD98F10CC; Tue, 25 Apr 2023 09:24:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1682439862; bh=sQKbtorZijfrBsSbG/R4wwtRRcylsXE+DoGloP7WmT8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bDvSD8cPyDzClEriXp9+T7nNfOHOXvwcR7i8ANZ21rO9Ti0sGyn1tLqEEEJ7khEfR tiEfI70V+Fj0T80ebpxcYoKtdh7Fk9OX7CHgC4DayhRKG2No2ZvsWYQinFkaciK9pQ U2BSUwh6PVFZXU16vAHsXRHII/7kPAgStzCNdyd8= Received: from localhost.localdomain ([116.132.239.134]) by newxmesmtplogicsvrsza12-0.qq.com (NewEsmtp) with SMTP id 60F0C276; Wed, 26 Apr 2023 00:24:15 +0800 X-QQ-mid: xmsmtpt1682439858tapcj3suu Message-ID: X-QQ-XMAILINFO: Ms5xyImz3IR/EQHELcyVQRQMm9Zy5ODFWYRoClZGAUWTl9fFI3AdYshw2WYnM4 0XkfHsK59txHhl4DDcsr1capeI5a7YRxfoMJZHhtIfUu/HjqB6JRIQ9jZ9l+hgiRuW0kbyzlAgtM Bz4XjZtmQ2BXPJN/Hg+ygOGIkV9KtHcRNFg9JU6k69OTbjjfi8ZEFrVvitVNq6DN0evf7TSVz0+x P2ZkhB7BUz1jq+LOF5tkY+FGaMQgiDa/ACEp8OFqH1xFE2uDlbNDFFNFPlnqhNr8SvNPH01/fTht qJJY//R6omnQ6uMHa2kKgZf9naoKHfXMbW54xfkS3RhwebBLkwhDlwc28na6X7l6DIW9jv2PYiYP fh9EsXL2OLXFze9gECk2+FXmsAXPKw+UMnEtBtXUBLFf9/iI12DzbQKFWRsaIg0BpTC5LmI3pm+c 9r1V1yJl3Mrslt0iiKvldy3Iq3uQBETmSyjJaFF8R91C+y0QA9pOAwvWQe23Wa/cTxKS8cqJvTUH j10TSvdaDyWsNBUUzSdhdW9LQjABSfQP5ZP/zBw6rSFw7RuAe2PSEdx2PgJszYjCVDbYoSPupvQG wDLY7g2WLsjXhdrYgaOQfnOTTgDXELiM8+18iDv7XYde0aETvP9g7TDBLhFCu9uWB9btLui5Mlot fc0Tuo8TYsDbcqZVa4kJPjtwgA99zPhBwDjxS00C3U0imfOx/Bvnr0fIVegu7C8rCki1qTOwzv5O 04FXY2/ImZnxijfuhNkyPusVBnnXk3VPT/+ZECR+WgmI3bqinogOBUbefYDzfNl7mzht36MfALnJ 6SpKu3EibdhMyiytMNwy9tDcrPs5yoxq/1K4jW1/2NP8PgyUYybjQXKcp4EAMg02CSdGfB+IEjls yujzTnWT0oSWBBGLiJwpldXphiwrCIvEZg/XL9fk9c2InknFdZryjY1v7VS1zEty2K9dDmoCq4ov 0Xa3ruWfigsWAKmtdUSZM3EkayPMM9SqEZXO4D/K+vb7QE9+ulyoUQfw4jiLbnXhAv58jMY4n0+B J+NzaFXH3Vu+0NhKHz From: Zhang Shurong To: tony0620emma@gmail.com Cc: kvalo@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Zhang Shurong Subject: [PATCH v2 1/2] wifi: rtw88: fix incorrect error codes in rtw_debugfs_copy_from_user Date: Wed, 26 Apr 2023 00:24:11 +0800 X-OQ-MSGID: X-Mailer: git-send-email 2.40.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, HELO_DYNAMIC_IPADDR,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,RDNS_DYNAMIC, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org If there is a failure during copy_from_user, rtw_debugfs_copy_from_user should return negative error code instead of a positive value count. Fix this bug by returning correct error code. Moreover, the check of buffer against null is removed since it will be handled by copy_from_user. Signed-off-by: Zhang Shurong --- drivers/net/wireless/realtek/rtw88/debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/debug.c b/drivers/net/wireless/realtek/rtw88/debug.c index fa3d73b333ba..3da477e1ebd3 100644 --- a/drivers/net/wireless/realtek/rtw88/debug.c +++ b/drivers/net/wireless/realtek/rtw88/debug.c @@ -183,8 +183,8 @@ static int rtw_debugfs_copy_from_user(char tmp[], int size, tmp_len = (count > size - 1 ? size - 1 : count); - if (!buffer || copy_from_user(tmp, buffer, tmp_len)) - return count; + if (copy_from_user(tmp, buffer, tmp_len)) + return -EFAULT; tmp[tmp_len] = '\0'; -- 2.40.0