linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: gwingerde@kpnplanet.nl
Cc: linux-wireless@vger.kernel.org
Subject: re: rt2x00: Fix queue related oops in case of deselected mac80211 multi-queue feature.
Date: Mon, 8 Feb 2016 20:55:59 +0300	[thread overview]
Message-ID: <20160208175559.GA13933@mwanda> (raw)

Hello Gertjan van Wingerde,

I have a question about patch 61448f88078e: "rt2x00: Fix queue related
oops in case of deselected mac80211 multi-queue feature." from May 10,
2008 because I think there is an off by one.

drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
  1239          /*
  1240           * We need the following queues:
  1241           * RX: 1
  1242           * TX: ops->tx_queues
  1243           * Beacon: 1
  1244           * Atim: 1 (if required)
  1245           */
  1246          rt2x00dev->data_queues = 2 + rt2x00dev->ops->tx_queues + req_atim;
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
We allocate everything at once in once chunk of memory.

  1247  
  1248          queue = kcalloc(rt2x00dev->data_queues, sizeof(*queue), GFP_KERNEL);
  1249          if (!queue) {
  1250                  rt2x00_err(rt2x00dev, "Queue allocation failed\n");
  1251                  return -ENOMEM;
  1252          }
  1253  
  1254          /*
  1255           * Initialize pointers
  1256           */
  1257          rt2x00dev->rx = queue;

This is equivalent to &queue[0].  It's actually helpful to static
checkers and people reading the code if you write it that because we
are talking about the first element only and not the whole buffer.
Meanwhile, people do it the reverse way and refer to &foo->start to talk
about that whole "foo" buffer...  :/

  1258          rt2x00dev->tx = &queue[1];
  1259          rt2x00dev->bcn = &queue[1 + rt2x00dev->ops->tx_queues];

There are 2 ->tx_queues, I think so we skipped one queue.  We should
have put it at &queue[2].  I looked at it briefly and I didn't see where
the second queue is ever used so maybe this is harmless beyond the
slight waste of memory.

  1260          rt2x00dev->atim = req_atim ? &queue[2 + rt2x00dev->ops->tx_queues] : NULL;
  1261  
  1262          /*

regards,
dan carpenter

             reply	other threads:[~2016-02-08 17:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-08 17:55 Dan Carpenter [this message]
     [not found] ` <CAL1gcdOU7q1hgvVbfpzMroMxrMueaVHiAhyYz5A467+8e1oTbw@mail.gmail.com>
     [not found]   ` <CAL1gcdOcXLq+A54xRy1fHYpwcBWMcGSoY77buWPPy+4j_ty3yA@mail.gmail.com>
2016-02-09 10:51     ` rt2x00: Fix queue related oops in case of deselected mac80211 multi-queue feature Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2016-02-09  7:30 Gertjan van Wingerde

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=20160208175559.GA13933@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=gwingerde@kpnplanet.nl \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).