All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wenli Looi <wlooi@ucalgary.ca>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-staging@lists.linux.dev,  linux-kernel@vger.kernel.org,
	 "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
Subject: Re: [PATCH v2] staging: rtl8723bs: Fix uninitialized variable
Date: Mon, 7 Jun 2021 23:35:04 -0700	[thread overview]
Message-ID: <CAKe_nd2-z+=6FnoUhSW0H_HZFu0MzUaBnvBg8P1eN0SjH+JG_A@mail.gmail.com> (raw)
In-Reply-To: <20210607084642.GQ1955@kadam>

I will resend the first patch. Thanks for your insightful comments. I
was wondering why every other driver seemed to be allocating "struct
station_info" using kzalloc()

On Mon, Jun 7, 2021 at 1:46 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> [△EXTERNAL]
>
>
>
> On Mon, Jun 07, 2021 at 11:35:42AM +0300, Dan Carpenter wrote:
> > On Sun, Jun 06, 2021 at 11:46:38AM -0700, Wenli Looi wrote:
> > > Uninitialized struct with invalid pointer causes BUG and prevents access
> > > point from working. Access point works once I apply this patch.
> > >
> > > This problem seems to have been present from the time the driver was
> > > added to staging. Most users probably do not use access point so they
> > > will not encounter this bug.
> > >
> > > https://forum.armbian.com/topic/14727-wifi-ap-kernel-bug-in-kernel-5444/
> > > has more details.
> > >
> > > kzalloc() seems to be what other drivers are doing in the same situation
> > > of creating struct station_info and calling cfg80211_new_sta.  In
> > > particular, other drivers like ath6kl and mwifiex will silently return
> > > when kzalloc fails, so this seems like the right behavior. (mwifiex
> > > returns -ENOMEM from the place kzalloc is called, but if you follow the
> > > chain of calls, the return value is ultimately ignored)
> > >
> > > Links to same situation in other drivers:
> > > https://github.com/torvalds/linux/blob/f5b6eb1e018203913dfefcf6fa988649ad11ad6e/drivers/net/wireless/ath/ath6kl/main.c#L488
> > > https://github.com/torvalds/linux/blob/f5b6eb1e018203913dfefcf6fa988649ad11ad6e/drivers/net/wireless/marvell/mwifiex/uap_event.c#L120
> > >
> > > Signed-off-by: Wenli Looi <wlooi@ucalgary.ca>
> > > ---
> > >
> > > v1 -> v2: Switched from large stack variable to kzalloc
> >
> >
> > Nah, v1 was better, it just needs an updated commit message.  See my
> > other email for more details.
>
> I read this again and I thought I should provide some more information.
>
> This sinfo struct used to be huge and that's why people used to allocate
> it if kzalloc() but now it's only 224 bytes so it's okay to put it on
> the stack.
>
> And the problem was never whether the variable was on the stack vs on
> the heap so changing that wasn't part of the "a patch should do one
> thing."  If you want to change it to kzalloc you have to do that in a
> separate patch (don't do that).
>
> And you were reading Greg's questions as saying the patch was wrong, but
> actually they were just questions.
>
> regards,
> dan carpenter
>

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

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-06  7:00 [PATCH] staging: rtl8723bs: Fix uninitialized variable Wenli Looi
2021-06-06  7:13 ` Greg Kroah-Hartman
2021-06-06  7:51   ` Wenli Looi
2021-06-06  8:00     ` Fabio M. De Francesco
2021-06-06  8:09       ` Wenli Looi
2021-06-06  8:09         ` Wenli Looi
2021-06-06  8:45         ` Fabio M. De Francesco
2021-06-06 18:46           ` [PATCH v2] " Wenli Looi
2021-06-07  8:35             ` Dan Carpenter
2021-06-07  8:46               ` Dan Carpenter
2021-06-08  6:35                 ` Wenli Looi [this message]
2021-06-08  6:35                   ` Wenli Looi
2021-06-07  8:33 ` [PATCH] " Dan Carpenter
2021-06-07  9:23   ` Greg Kroah-Hartman
2021-06-07 10:43     ` Dan Carpenter
2021-06-08  6:46   ` [PATCH] staging: rtl8723bs: Fix uninitialized variables Wenli Looi
2021-06-08  7:20     ` Dan Carpenter

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='CAKe_nd2-z+=6FnoUhSW0H_HZFu0MzUaBnvBg8P1eN0SjH+JG_A@mail.gmail.com' \
    --to=wlooi@ucalgary.ca \
    --cc=dan.carpenter@oracle.com \
    --cc=fmdefrancesco@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 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.