Linux kernel staging patches
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Devansh Soni <devanshsoni874@gmail.com>
Cc: gregkh@linuxfoundation.org, linux-staging@lists.linux.dev,
	linux-kernel@vger.kernel.org, dan.carpenter@linaro.org
Subject: Re: [PATCH v3] staging: rtl8723bs: use PTR_ALIGN() for rsp_buf
Date: Tue, 16 Jun 2026 16:02:18 +0300	[thread overview]
Message-ID: <ajFJWhuEDnPgQjcs@stanley.mountain> (raw)
In-Reply-To: <20260616123528.44278-1-devanshsoni874@gmail.com>

On Tue, Jun 16, 2026 at 06:05:28PM +0530, Devansh Soni wrote:
> diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c
> index c1185c25e..38ce3156c 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
> @@ -184,7 +184,7 @@ int rtw_init_cmd_priv(struct	cmd_priv *pcmdpriv)
>  		return -ENOMEM;
>  	}
>  
> -	pcmdpriv->rsp_buf = pcmdpriv->rsp_allocated_buf + 4 - ((SIZE_PTR)(pcmdpriv->rsp_allocated_buf) & 3);
> +	pcmdpriv->rsp_buf = PTR_ALIGN(pcmdpriv->rsp_allocated_buf, 4);

You're working against an old version of the kernel.  You should be
working against linux-next or devel-next.

The commit message mentions 8-byte aligned memory, but the code is still
doing PTR_ALIGN().  The kmalloc() alignment is determined by
ARCH_KMALLOC_MINALIGN and it's always at least 8 but it can be higher.
Here the code is trying to ensure that it is 4 byte aligned, and 8 is
already a multiple of 4.  You could just delete the PTR_ALIGN() along
with the related code.

1. It allocates 4 extra bytes.  "MAX_RSPSZ + 4" bytes.  It could instead
   just allocate MAX_RSPSZ bytes.
2. This pcmdpriv->rsp_buf = PTR_ALIGN() can be removed.
3. The pcmdpriv->rsp_allocated_buf pointer only exists to store the
   unaligned pointer.  Just get rid of it.

The early part of function which does CMDBUFF_ALIGN_SZ is more complicated
because that is 512 bytes.  It's trying to ensure that the pointers are
aligned enough for DMA.  The proper alignment in that case is probably
ARCH_DMA_MINALIGN but I'm less familiar with how that works.

regards,
dan carpenter


      reply	other threads:[~2026-06-16 13:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-16 12:35 [PATCH v3] staging: rtl8723bs: use PTR_ALIGN() for rsp_buf Devansh Soni
2026-06-16 13:02 ` Dan Carpenter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ajFJWhuEDnPgQjcs@stanley.mountain \
    --to=error27@gmail.com \
    --cc=dan.carpenter@linaro.org \
    --cc=devanshsoni874@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox