All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Larry Finger <Larry.Finger@lwfinger.net>
Cc: gregkh@linuxfoundation.org, phil@philpotter.co.uk,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/5] staging: r8188eu: Remove wrappers for kalloc() and kzalloc()
Date: Fri, 6 Aug 2021 14:07:53 +0300	[thread overview]
Message-ID: <20210806110752.GP1931@kadam> (raw)
In-Reply-To: <20210805183717.23007-2-Larry.Finger@lwfinger.net>

On Thu, Aug 05, 2021 at 01:37:13PM -0500, Larry Finger wrote:
> diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c
> index 4ac76ca6e383..d7d33e201f37 100644
> --- a/drivers/staging/r8188eu/core/rtw_cmd.c
> +++ b/drivers/staging/r8188eu/core/rtw_cmd.c
> @@ -1947,10 +1947,13 @@ static void c2h_wk_callback(struct work_struct *work)
>  		if ((c2h_evt = (struct c2h_evt_hdr *)rtw_cbuf_pop(evtpriv->c2h_queue)) != NULL) {
>  			/* This C2H event is read, clear it */
>  			c2h_evt_clear(adapter);
> -		} else if ((c2h_evt = (struct c2h_evt_hdr *)rtw_malloc(16)) != NULL) {
> -			/* This C2H event is not read, read & clear now */
> -			if (c2h_evt_read(adapter, (u8 *)c2h_evt) != _SUCCESS)
> -				continue;
> +		} else {
> +			c2h_evt = kmalloc(16, GFP_KERNEL);
> +			if (c2h_evt) {
> +				/* This C2H event is not read, read & clear now */
> +				if (c2h_evt_read(adapter, (u8 *)c2h_evt) != _SUCCESS)
> +					continue;

Not related to your patch (don't resend, please fix this in a follow on
patch if you want to) but this isn't correct.  If the allocation fails,
it leads to a NULL dereference.  Or if the c2h_evt_read() call fails
there needs to be a kfree(c2h_evt) before the continue.

> +			}
>  		}
>  

regards,
dan carpenter


  reply	other threads:[~2021-08-06 11:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-05 18:37 [PATCH 0/5] Do more cleanups Larry Finger
2021-08-05 18:37 ` [PATCH 1/5] staging: r8188eu: Remove wrappers for kalloc() and kzalloc() Larry Finger
2021-08-06 11:07   ` Dan Carpenter [this message]
2021-08-05 18:37 ` [PATCH 2/5] staging: r8188eu: Remove wrapper around vfree Larry Finger
2021-08-05 18:37 ` [PATCH 3/5] staging: r8188eu: Remove all calls to _rtw_spinlock_free() Larry Finger
2021-08-05 18:37 ` [PATCH 4/5] staging: r8188eu: Remove more empty routines Larry Finger
2021-08-05 18:37 ` [PATCH 5/5] staging: r8188eu: Remove rtw_buf_free() Larry Finger

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=20210806110752.GP1931@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=phil@philpotter.co.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.