All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: thgarnie@google.com
Cc: linux-mm@kvack.org
Subject: re: mm: reorganize SLAB freelist randomization
Date: Mon, 6 Jun 2016 22:52:28 +0300	[thread overview]
Message-ID: <20160606195228.GA27327@mwanda> (raw)

Hello Thomas Garnier,

The patch aded650eb82e: "mm: reorganize SLAB freelist randomization"
from Jun 5, 2016, leads to the following static checker warning:

	mm/slab_common.c:1160 freelist_randomize()
	warn: why is zero skipped 'i'

mm/slab_common.c
  1146  /* Randomize a generic freelist */
  1147  static void freelist_randomize(struct rnd_state *state, unsigned int *list,
  1148                          size_t count)
  1149  {
  1150          size_t i;
  1151          unsigned int rand;
  1152  
  1153          for (i = 0; i < count; i++)
  1154                  list[i] = i;
  1155  
  1156          /* Fisher-Yates shuffle */
  1157          for (i = count - 1; i > 0; i--) {

This looks like it should be i >= 0.

  1158                  rand = prandom_u32_state(state);
  1159                  rand %= (i + 1);
  1160                  swap(list[i], list[rand]);
  1161          }
  1162  }

regards,
dan carpenter

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2016-06-06 19:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-06 19:52 Dan Carpenter [this message]
2016-06-06 20:01 ` mm: reorganize SLAB freelist randomization Thomas Garnier
2016-06-06 20:11   ` Dan Carpenter
2016-06-06 20:12     ` Thomas Garnier

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=20160606195228.GA27327@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=linux-mm@kvack.org \
    --cc=thgarnie@google.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 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.