From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8EBFB3EBF07 for ; Wed, 17 Jun 2026 12:39:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781699959; cv=none; b=ibczir9JWlLgoTUL5JSbNRcb8D+omJZct9CyC1jGwipmjkLdi9S99QnrTOnQVMjvs9x9kIOr77TzfJqW6atYT1paml//On3hV3rE3hQN2x0OGfRZoeyTUtaRXf1r4Vym1niC8u0Ln5L7tWYt1/hiUY3ajLOyh8j61zOQWE6y3oU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781699959; c=relaxed/simple; bh=NcsDi0WbKxtelMi3XRaHd4Jluu/RZs+o0DpezKoA/zo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=mWhppGugch4Kq0GbTOHXN/EfEhWx4z9aC08p/Nisu7RjM8oQsJChy9U/jYI+wg/JwrdgJxbiB1BkIuMJ3d5GmocxJYuJu0mjsRhkl7CNAGWxzxHHGeU9iIPkxr9BC0ElFcUmkBEwUT7iagnXOR23dMMJ0a2qcxM8ee7pMtQUbeY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bb4CQysk; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bb4CQysk" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2bf1f074a12so56566945ad.0 for ; Wed, 17 Jun 2026 05:39:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781699957; x=1782304757; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=hzctF27Iyg9fnRtO/uZ/bqvQv0xKnTwQfF38gzGnHM8=; b=bb4CQysk2Q22R6okP5+L2iTcJQf8IYgOOo1c8qrzuNVoeZUKtz3t+/uCGSP1TiPVen AMfJ/LoXOwFXiC36KFUXVUTxRhDAvB22AyKoX5xP3joy2RpvSc6VJr/nnraGyay8qeFx vJ4tj1VCGgtnFf1T0eaqbl3kliQ57QGpUd56YNp820Qi/FhEVkpHUk7tTx5UasIF5xSD pG1Eilt8nDQdHo31Ij/Y8Dh2s3uyogtsHY3B4njNdC4szU6c4pGnb4i6Ey9PtVVaB61P ZLGUDaU0tQnp+2n/hb2OK8OXjg1dEM5EkY70dDpjfQqVEg/jjR14/Gz+HCaiDf1GNYSu dRXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781699957; x=1782304757; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=hzctF27Iyg9fnRtO/uZ/bqvQv0xKnTwQfF38gzGnHM8=; b=MWHITji/88C03kLzrB+wWXpodaTdQfc4wbG14mftgDvounWIYpY4rq5go0oI8rz/2d lNgQMVSrwwUs4iWULDj6qrbPWoS3kU3scPSX5rK0nnma8vJeHQKWcDQllSjkb0ntsuTY HW59HYIxey4W1HqKZqvd2RtjTl/SyNy23Ft+6BLUg7vKpWaEY5m0XZoqZ7Ilyj9dBX2a SVew4mYJTBlK0FJ+m6oQgP6QdL+GpA+52Bsq9BTFGb9hgBFqT6cqXjtUZrzCdEA+Mjrb 8wJmZVcYoBrMi8Z3B2Q/qz9BaZQhLy20620kVshIC9rONMUjOifcR9R7h74Sd8L+yIiw wQ0Q== X-Forwarded-Encrypted: i=1; AFNElJ+ULy0HH839wsrWR766z9fHeWBgOuzvI6j/VTZcl0hJxQQ60uVIqxC4YwtGQ5OhHAQgn1AOcK20nJUrK+I=@vger.kernel.org X-Gm-Message-State: AOJu0YwEMajRGUs4MhAQ63/tb3DGRxHov9CSZC7JyzLNVz0EFHgED9rZ 7TiP1FuT446i6kAjRH/w54+EkmOpibt3It6I3mpd19jRgRb5ABcNkK0bN9Ci2f78/9I= X-Gm-Gg: AfdE7ckQw3yeLeEjD4HfZ70rOveZHxS8o3Jh+t3AYYsVrrnG8yX9MOUlUYscMfO6QW9 b9R7ACZZZ1Gqg+B7LMBSrXANnVqWxLjNU5u9J1YctLCrpyyYoqNDAmzUgPk/jXzI+gVerdrRIfn Nk2t1GO5KBLuLzRNfQbsTsOyVcwLeIyYCJOJ16D6pFrOZJH/yo13vJgWccTI9BofKrS9e9h6Wo/ ijOei2Yuz1VIo/4cgPieYCigdd5mxBOh1SiQLy8aHROnZ7dnvieRZtsBS8WQll7dnrfajbMRXS1 f/YP+zo9dJCGc1lAFWWz7YxsQaC/RU2s9Hqx5RN/QRKbSWIU49BLjv/v+BwLUyb6FgBgEpl3CT/ FtJhMetuTMAHCC18CED8fiCPDCfY6ViyogpG3HpvkHlECCgixqiFlzzfwTlaWbyL02yPhgv5OOm wOstq7Qv4WkaRv5+gKpjtaN/nuPnyEykPfTpWYDdg8GmL1NeQKmiw= X-Received: by 2002:a17:903:2310:b0:2c6:b3dc:b831 with SMTP id d9443c01a7336-2c6bc23de6emr39519415ad.27.1781699956861; Wed, 17 Jun 2026 05:39:16 -0700 (PDT) Received: from localhost.localdomain ([103.87.58.149]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c432c8c1f9sm167722655ad.59.2026.06.17.05.39.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 17 Jun 2026 05:39:16 -0700 (PDT) From: Devansh Soni To: gregkh@linuxfoundation.org Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Devansh Soni , Dan Carpenter Subject: [PATCH v4] staging: rtl8723bs: remove redundant rsp_allocated_buf Date: Wed, 17 Jun 2026 18:08:53 +0530 Message-ID: <20260617123853.63022-1-devanshsoni874@gmail.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The original code allocated extra memory and manually aligned the rsp_buf pointer to a 4-byte boundary, however kzalloc() guarantees a minimum of 8-byte alignment so this was unnecessary. Also, because the pointer was shifted, the original pointer had to be stored in rsp_allocated_buf just so it could be passed to kfree() later. Remove the redundant alignment math, remove the extra 4 bytes of padding from kzalloc() call, and assign memory directly to rsp_buf. This allows us to remove the rsp_allocated_buf variable from cmd_priv struct. Suggested-by: Dan Carpenter Signed-off-by: Devansh Soni --- Changes in v4: - Dropped PTR_ALIGN() entirely as kzalloc() 8-byte alignment is sufficient. - Removed the +4 byte padding from kzalloc(). - Completely removed the rsp_allocated_buf tracking variable and updated kfree(). Changes in v3: - Replaced manual bitwise math with PTR_ALIGN() macro based on feedback from v1. - Updated commit message to detail kzalloc() 8-byte alignment guarantees. Changes in v2: - Wrapped commit log text to resolve line length issue noted by Greg. drivers/staging/rtl8723bs/core/rtw_cmd.c | 9 +++------ drivers/staging/rtl8723bs/include/rtw_cmd.h | 1 - 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index b932670f5..fd1ba1b4e 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -178,15 +178,12 @@ int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv) pcmdpriv->cmd_buf = PTR_ALIGN(pcmdpriv->cmd_allocated_buf, CMDBUFF_ALIGN_SZ); - pcmdpriv->rsp_allocated_buf = kzalloc(MAX_RSPSZ + 4, GFP_ATOMIC); - if (!pcmdpriv->rsp_allocated_buf) { + pcmdpriv->rsp_buf = kzalloc(MAX_RSPSZ, GFP_ATOMIC); + if (!pcmdpriv->rsp_buf) { kfree(pcmdpriv->cmd_allocated_buf); return -ENOMEM; } - pcmdpriv->rsp_buf = pcmdpriv->rsp_allocated_buf + 4 - - ((SIZE_PTR)(pcmdpriv->rsp_allocated_buf) & 3); - pcmdpriv->cmd_issued_cnt = 0; pcmdpriv->cmd_done_cnt = 0; pcmdpriv->rsp_cnt = 0; @@ -232,7 +229,7 @@ void _rtw_free_cmd_priv(struct cmd_priv *pcmdpriv) if (pcmdpriv) { kfree(pcmdpriv->cmd_allocated_buf); - kfree(pcmdpriv->rsp_allocated_buf); + kfree(pcmdpriv->rsp_buf); mutex_destroy(&pcmdpriv->sctx_mutex); } diff --git a/drivers/staging/rtl8723bs/include/rtw_cmd.h b/drivers/staging/rtl8723bs/include/rtw_cmd.h index f78aa0d7a..66b970955 100644 --- a/drivers/staging/rtl8723bs/include/rtw_cmd.h +++ b/drivers/staging/rtl8723bs/include/rtw_cmd.h @@ -45,7 +45,6 @@ u8 *cmd_buf; /* shall be non-paged, and 4 bytes aligned */ u8 *cmd_allocated_buf; u8 *rsp_buf; /* shall be non-paged, and 4 bytes aligned */ - u8 *rsp_allocated_buf; u32 cmd_issued_cnt; u32 cmd_done_cnt; u32 rsp_cnt; -- 2.54.0