summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevansh Soni <devanshsoni874@gmail.com>2026-06-17 18:08:53 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-07-07 13:20:49 +0200
commita9a79ae0b2c747fbbfddb75ff70d37353a495f1a (patch)
treedd031fdf4052d9e01eb7d0265f3330d27e1a410c
parentb1dfea3cf9be7d1728b08bbc6cb9c84c8b9e27ed (diff)
downloadlinux-a9a79ae0b2c747fbbfddb75ff70d37353a495f1a.tar.gz
linux-a9a79ae0b2c747fbbfddb75ff70d37353a495f1a.zip
staging: rtl8723bs: remove redundant rsp_allocated_buf
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 <error27@gmail.com> Signed-off-by: Devansh Soni <devanshsoni874@gmail.com> Reviewed-by: Dan Carpenter <error27@gmail.com> Link: https://patch.msgid.link/20260617123853.63022-1-devanshsoni874@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_cmd.c9
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_cmd.h1
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 099231894d0f..818226be783a 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 28d2be1d2a85..1f822c1784eb 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;