Linux kernel staging patches
 help / color / mirror / Atom feed
From: Pavel Skripkin <paskripkin@gmail.com>
To: Martin Kaiser <martin@kaiser.cx>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Larry Finger <Larry.Finger@lwfinger.net>,
	Phillip Potter <phil@philpotter.co.uk>,
	Michael Straube <straube.linux@gmail.com>,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: Re: [PATCH] staging: r888eu: use dynamic allocation for efuse buffer
Date: Wed, 13 Jul 2022 13:24:41 +0300	[thread overview]
Message-ID: <5445d915-0c6c-b84f-158e-160e7645cbbd@gmail.com> (raw)
In-Reply-To: <20220713075804.140986-1-martin@kaiser.cx>

Hi Martin,

Martin Kaiser <martin@kaiser.cx> says:
> Use kmalloc to allocate the efuse buffer in ReadAdapterInfo8188EU and
> free it on exit. This is better than using a 512 byte array on the stack.
> 
> It's ok to drop the __aligned(4) qualifier. kmalloc aligns to
> ARCH_KMALLOC_MINALIGN, this is at least 8 bytes.
> 
> Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
> Suggested-by: Larry Finger <Larry.Finger@lwfinger.net>
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> ---
>   drivers/staging/r8188eu/hal/usb_halinit.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c
> index 8902dda7b8d8..421fe7c40390 100644
> --- a/drivers/staging/r8188eu/hal/usb_halinit.c
> +++ b/drivers/staging/r8188eu/hal/usb_halinit.c
> @@ -926,7 +926,7 @@ void ReadAdapterInfo8188EU(struct adapter *Adapter)
>   {
>   	struct eeprom_priv *eeprom = &Adapter->eeprompriv;
>   	struct led_priv *ledpriv = &Adapter->ledpriv;
> -	u8 efuse_buf[EFUSE_MAP_LEN_88E] __aligned(4);
> +	u8 *efuse_buf;
>   	u8 eeValue;
>   	int res;
>   
> @@ -937,7 +937,10 @@ void ReadAdapterInfo8188EU(struct adapter *Adapter)
>   
>   	eeprom->bautoload_fail_flag	= !(eeValue & EEPROM_EN);
>   
> -	memset(efuse_buf, 0xFF, sizeof(efuse_buf));
> +	efuse_buf = kmalloc(EFUSE_MAP_LEN_88E, GFP_KERNEL);
> +	if (!efuse_buf)
> +		return;

I think, it worth returning an error to caller. Functions right after 
the allocation do initialization, so leaving fields as-is seems to be 
dangerous





Thanks,
--Pavel Skripkin

  reply	other threads:[~2022-07-13 10:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-13  7:58 [PATCH] staging: r888eu: use dynamic allocation for efuse buffer Martin Kaiser
2022-07-13 10:24 ` Pavel Skripkin [this message]
2022-07-15 20:11   ` Martin Kaiser
2022-07-13 13:24 ` Larry Finger
2022-07-15  6:02 ` Michael Straube
2022-07-15  6:06   ` Michael Straube

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=5445d915-0c6c-b84f-158e-160e7645cbbd@gmail.com \
    --to=paskripkin@gmail.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=dan.carpenter@oracle.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=martin@kaiser.cx \
    --cc=phil@philpotter.co.uk \
    --cc=straube.linux@gmail.com \
    /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