From: Stanislaw Gruszka <sgruszka@redhat.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wireless@vger.kernel.org,
Grzegorz Duszy??ski <gfduszynski@gmail.com>,
Johannes Berg <johannes.berg@intel.com>
Subject: Re: [PATCH] cfg80211: remove division by size of sizeof(struct ieee80211_wmm_rule)
Date: Mon, 20 Aug 2018 12:27:10 +0200 [thread overview]
Message-ID: <20180820102710.GA2760@redhat.com> (raw)
In-Reply-To: <20180820073705.9683-1-johannes@sipsolutions.net>
On Mon, Aug 20, 2018 at 09:37:05AM +0200, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
>
> Pointer arithmetic already adjusts by the size of the struct,
> so the sizeof() calculation is wrong. This is basically the
> same as Colin King's patch for similar code in the iwlwifi
> driver.
>
> Fixes: 230ebaa189af ("cfg80211: read wmm rules from regulatory database")
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> ---
> net/wireless/reg.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/net/wireless/reg.c b/net/wireless/reg.c
> index 4fc66a117b7d..283902974fbf 100644
> --- a/net/wireless/reg.c
> +++ b/net/wireless/reg.c
> @@ -452,8 +452,7 @@ reg_copy_regd(const struct ieee80211_regdomain *src_regd)
> continue;
>
> regd->reg_rules[i].wmm_rule = d_wmm +
> - (src_regd->reg_rules[i].wmm_rule - s_wmm) /
> - sizeof(struct ieee80211_wmm_rule);
> + (src_regd->reg_rules[i].wmm_rule - s_wmm);
> }
> return regd;
> }
As side note those pointer aritmetics related with rule->wmm_rule is
really involuted in various places in reg.c . Seems would be better to
just make wmm_rule part of iee80211_reg_rule structure like this:
struct ieee80211_reg_rule {
struct ieee80211_freq_range freq_range;
struct ieee80211_power_rule power_rule;
struct ieee80211_wmm_rule wmm_rule;
u32 flags;
u32 dfs_cac_ms;
};
and use a flag to intdicate wmm_rule is valid. There should be no
big memory overhead sice there are only few reg_rules for the regdomain.
Or I'm wrong?
Regards
Stanislaw
next prev parent reply other threads:[~2018-08-20 13:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-20 7:37 [PATCH] cfg80211: remove division by size of sizeof(struct ieee80211_wmm_rule) Johannes Berg
2018-08-20 10:27 ` Stanislaw Gruszka [this message]
2018-08-21 6:23 ` Grzegorz Duszyński
2018-08-21 7:42 ` Grzegorz Duszyński
2018-08-21 9:03 ` Johannes Berg
2018-08-21 9:06 ` Grzegorz Duszyński
2018-08-21 9:07 ` Johannes Berg
2018-08-21 9:11 ` Grzegorz Duszyński
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=20180820102710.GA2760@redhat.com \
--to=sgruszka@redhat.com \
--cc=gfduszynski@gmail.com \
--cc=johannes.berg@intel.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
/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.