From patchwork Sat Apr 22 10:04:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Shurong X-Patchwork-Id: 13220944 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C522C7EE21 for ; Sat, 22 Apr 2023 10:11:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229797AbjDVKLr (ORCPT ); Sat, 22 Apr 2023 06:11:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229780AbjDVKLn (ORCPT ); Sat, 22 Apr 2023 06:11:43 -0400 Received: from out203-205-221-250.mail.qq.com (out203-205-221-250.mail.qq.com [203.205.221.250]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADA7F1BFD; Sat, 22 Apr 2023 03:11:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1682158299; bh=+zF5ZlaKbkUYHZkMcIxweuJFjgybfbIGNceQyR/6yOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=JqamWBG9qFXnGhfDexZn6fhgbtx8eB4mAhNiER0WfO1eS3o0zD7ry6lHbDmgbHcd0 AAPhAFf0syu0My3qXof4XFMoLGphWJwpWydWU+TlELWfBW4K6TDxZVQCFwgvxNl0R7 thql9OAw7rzNpZTsZe/RKFliPsTZT/mUv2R7Dqr0= Received: from localhost.localdomain ([49.7.199.72]) by newxmesmtplogicsvrszb6-0.qq.com (NewEsmtp) with SMTP id 1402C0F4; Sat, 22 Apr 2023 18:05:00 +0800 X-QQ-mid: xmsmtpt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0tsvhwv4bBL2CZFpmU M03t2kdeiuspZJZ2OPkk2fwXuKcKBvgxjPNn/ZqFInh0gIMDzb4oIjdJ0P3dA= 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 02/10] wifi: rtw88: fix incorrect error codes in rtw_debugfs_set_read_reg Date: Sat, 22 Apr 2023 18:04:46 +0800 X-OQ-MSGID: <502797e3be90fce642692156898586dc93e7755e.1682156784.git.zhang_shurong@foxmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org If there is a failure during copy_from_user or user-provided data buffer is invalid, rtw_debugfs_set_read_reg should return negative error code instead of a positive value count. Fix this bug by returning correct error code. Signed-off-by: Zhang Shurong --- drivers/net/wireless/realtek/rtw88/debug.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/debug.c b/drivers/net/wireless/realtek/rtw88/debug.c index bc41c5a7acaf..3c3350bb2855 100644 --- a/drivers/net/wireless/realtek/rtw88/debug.c +++ b/drivers/net/wireless/realtek/rtw88/debug.c @@ -201,13 +201,16 @@ static ssize_t rtw_debugfs_set_read_reg(struct file *filp, char tmp[32 + 1]; u32 addr, len; int num; + int ret; - rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 2); + ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 2); + if (ret < 0) + return ret; num = sscanf(tmp, "%x %x", &addr, &len); if (num != 2) - return count; + return -EINVAL; if (len != 1 && len != 2 && len != 4) { rtw_warn(rtwdev, "read reg setting wrong len\n");