Linux wireless drivers development
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Jacob Keller <jacob.e.keller@intel.com>
Cc: Kalle Valo <kvalo@kernel.org>,
	linux-wireless@vger.kernel.org,
	Stanislav Yakovlev <stas.yakovlev@gmail.com>
Subject: Re: [PATCH 1/3] wifi: ipw2x00: convert ipw_fw_error->elem to flexible array[]
Date: Tue, 28 Feb 2023 18:46:36 +0100	[thread overview]
Message-ID: <7f996d2efd23cefd17074edaeed0a6bbbd9f1a99.camel@sipsolutions.net> (raw)
In-Reply-To: <d393ba90-ecdd-ffea-540b-d6db15571d5b@intel.com>

On Tue, 2023-02-28 at 09:44 -0800, Jacob Keller wrote:
> 
> Previous to this change, error struct has two pointers to sections of
> memory allocated at the end of the buffer.
> 
> The code used to be:
> 
> -	error = kmalloc(sizeof(*error) +
> -			sizeof(*error->elem) * elem_len +
> -			sizeof(*error->log) * log_len, GFP_ATOMIC);
> 
> i.e. the elem_len is multiplying sizeof(*error->elem).
> 
> The code is essentially trying to get two flexible arrays in the same
> allocation, and its a bit messy to do that. I don't see how elem_len
> could be anything other than "number of elems" given this code I removed.

Yeah, you're right. I was thinking of more modern HW/FW too much I
guess, I see now even in the driver we have an array walk here (and it
trusts the elem_len from firmware... ahrg!)

> I posted these mainly because I was trying to resolve all of the hits
> that were found by the coccinelle patch I made, posted at [1]. I wanted
> to get it to run clean so that we had no more struct_size hits.
> 
> Dropping this would just make that patch have some hits until the driver
> is removed, eventually...
> 
> Not really a big deal to me, I just didn't want to post a coccinelle
> patch without also trying to fix the handful of problems it reported,
> since the total number of reports was small.
> 

Makes sense. I don't think we'll drop the driver at any point soon, but
I also don't see it being changed much :)

johannes

  reply	other threads:[~2023-02-28 17:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-28 16:28 [PATCH 1/3] wifi: ipw2x00: convert ipw_fw_error->elem to flexible array[] Jacob Keller
2023-02-28 16:28 ` [PATCH 2/3] wifi: cfg80211: use struct_size and size_sub for payload length Jacob Keller
2023-02-28 17:16   ` Johannes Berg
2023-02-28 16:28 ` [PATCH 3/3] wifi: nl80211: convert cfg80211_scan_request allocation to *_size macros Jacob Keller
2023-02-28 17:16 ` [PATCH 1/3] wifi: ipw2x00: convert ipw_fw_error->elem to flexible array[] Johannes Berg
2023-02-28 17:44   ` Jacob Keller
2023-02-28 17:46     ` Johannes Berg [this message]
2023-02-28 17:48       ` Jacob Keller
2023-03-01 20:49       ` Jacob Keller
2023-03-01 20:53         ` Johannes Berg
2023-03-01 21:01           ` Jacob Keller

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=7f996d2efd23cefd17074edaeed0a6bbbd9f1a99.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=jacob.e.keller@intel.com \
    --cc=kvalo@kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=stas.yakovlev@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