Linux Hardening
 help / color / mirror / Atom feed
From: Arend van Spriel <arend.vanspriel@broadcom.com>
To: Erick Archer <erick.archer@outlook.com>,
	Kalle Valo <kvalo@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	Yajun Deng <yajun.deng@linux.dev>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	Dmitry Antipov <dmantipov@yandex.ru>,
	Johannes Berg <johannes.berg@intel.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Jonas Gorski <jonas.gorski@gmail.com>,
	Artem Chernyshev <artem.chernyshev@red-soft.ru>,
	Kees Cook <keescook@chromium.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Justin Stitt <justinstitt@google.com>
Cc: linux-wireless@vger.kernel.org, brcm80211@lists.linux.dev,
	brcm80211-dev-list.pdl@broadcom.com,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH] wifi: brcm80211: use sizeof(*pointer) instead of sizeof(type)
Date: Mon, 27 May 2024 14:55:14 +0200	[thread overview]
Message-ID: <088d5c85-01dc-4c29-9a3c-cd7e2c6b0224@broadcom.com> (raw)
In-Reply-To: <AS8PR02MB7237C3696881F79EAEE8D02E8BF72@AS8PR02MB7237.eurprd02.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 2796 bytes --]

On 5/26/2024 5:53 PM, Erick Archer wrote:
> It is preferred to use sizeof(*pointer) instead of sizeof(type)
> due to the type of the variable can change and one needs not
> change the former (unlike the latter). This patch has no effect
> on runtime behavior.

Thanks. A bit long list, but mostly trivial. Just a few remarks...

Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
> Signed-off-by: Erick Archer <erick.archer@outlook.com>
> ---
>   .../broadcom/brcm80211/brcmfmac/bcmsdh.c      |  4 ++--
>   .../broadcom/brcm80211/brcmfmac/btcoex.c      |  2 +-
>   .../broadcom/brcm80211/brcmfmac/sdio.c        |  2 +-
>   .../broadcom/brcm80211/brcmfmac/usb.c         |  2 +-
>   .../broadcom/brcm80211/brcmsmac/aiutils.c     |  2 +-
>   .../broadcom/brcm80211/brcmsmac/ampdu.c       |  2 +-
>   .../broadcom/brcm80211/brcmsmac/antsel.c      |  2 +-
>   .../broadcom/brcm80211/brcmsmac/channel.c     |  2 +-
>   .../broadcom/brcm80211/brcmsmac/dma.c         |  2 +-
>   .../broadcom/brcm80211/brcmsmac/mac80211_if.c |  2 +-
>   .../broadcom/brcm80211/brcmsmac/main.c        | 23 +++++++++----------
>   .../broadcom/brcm80211/brcmsmac/phy/phy_cmn.c |  4 ++--
>   .../broadcom/brcm80211/brcmsmac/phy/phy_lcn.c |  2 +-
>   .../broadcom/brcm80211/brcmsmac/phy_shim.c    |  2 +-
>   14 files changed, 26 insertions(+), 27 deletions(-)

[...]

> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
> index aae2cf95fe95..8696061bf2dd 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
> @@ -4968,7 +4968,7 @@ bool wlc_phy_attach_lcnphy(struct brcms_phy *pi)
>   {
>   	struct brcms_phy_lcnphy *pi_lcn;
>   
> -	pi->u.pi_lcnphy = kzalloc(sizeof(struct brcms_phy_lcnphy), GFP_ATOMIC);
> +	pi->u.pi_lcnphy = kzalloc(sizeof(*pi->u.pi_lcnphy), GFP_ATOMIC);
Better use pi_lcn here and assign it to pi->u.pi_lcnphy after the 
if-statement.

>   	if (pi->u.pi_lcnphy == NULL)
>   		return false;
>   
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy_shim.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy_shim.c
> index b72381791536..4b916f3a087b 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy_shim.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy_shim.c
> @@ -40,7 +40,7 @@ struct phy_shim_info *wlc_phy_shim_attach(struct brcms_hardware *wlc_hw,
>   					  struct brcms_c_info *wlc) {
>   	struct phy_shim_info *physhim = NULL;

While at it please remove the redundant NULL initialization.

> -	physhim = kzalloc(sizeof(struct phy_shim_info), GFP_ATOMIC);
> +	physhim = kzalloc(sizeof(*physhim), GFP_ATOMIC);
>   	if (!physhim)
>   		return NULL;
>   

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4219 bytes --]

      reply	other threads:[~2024-05-27 12:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-26 15:53 [PATCH] wifi: brcm80211: use sizeof(*pointer) instead of sizeof(type) Erick Archer
2024-05-27 12:55 ` Arend van Spriel [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=088d5c85-01dc-4c29-9a3c-cd7e2c6b0224@broadcom.com \
    --to=arend.vanspriel@broadcom.com \
    --cc=arnd@arndb.de \
    --cc=artem.chernyshev@red-soft.ru \
    --cc=brcm80211-dev-list.pdl@broadcom.com \
    --cc=brcm80211@lists.linux.dev \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=dmantipov@yandex.ru \
    --cc=erick.archer@outlook.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=gustavoars@kernel.org \
    --cc=johannes.berg@intel.com \
    --cc=jonas.gorski@gmail.com \
    --cc=justinstitt@google.com \
    --cc=keescook@chromium.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=kvalo@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=ulf.hansson@linaro.org \
    --cc=yajun.deng@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