From patchwork Tue Apr 25 16:24:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Shurong X-Patchwork-Id: 677999 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 54F68C77B73 for ; Tue, 25 Apr 2023 16:24:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234206AbjDYQY2 (ORCPT ); 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-XM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+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 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';