From: Jan Kara <jack@suse.cz>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Divyesh Shah <dpshah@google.com>, Jens Axboe <axboe@kernel.dk>,
linux-kernel@vger.kernel.org
Subject: Re: question about blkio_get_stat()
Date: Sat, 7 Apr 2012 10:28:30 +0200 [thread overview]
Message-ID: <20120407082830.GB2584@quack.suse.cz> (raw)
In-Reply-To: <20120402135455.GA15588@elgon.mountain>
Hi,
On Mon 02-04-12 16:54:56, Dan Carpenter wrote:
> Smatch complains that we go outside the array in blkio_get_stat().
>
> block/blk-cgroup.c
> 731 if (type == BLKIO_STAT_DEQUEUE)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^
> BLKIO_STAT_DEQUEUE is 9.
>
> 732 return blkio_fill_stat(key_str, MAX_KEY_LEN - 1,
> 733 blkg->stats.dequeue, cb, dev);
> 734 #endif
> 735
> 736 for (sub_type = BLKIO_STAT_READ; sub_type < BLKIO_STAT_TOTAL;
> 737 sub_type++) {
> 738 blkio_get_key_name(sub_type, dev, key_str, MAX_KEY_LEN, false);
> 739 cb->fill(cb, key_str, blkg->stats.stat_arr[type][sub_type]);
> ^^^^^^^^^^^^^^^^^^^^
> This array only has 4 elements and if "type" is 9 we're past the end of
> array.
>
> 740 }
>
> It's odd that Smatch only started complaining about this now, but this
> code has been there for years. I'm puzzled by what changed. Sorry if
> there is something obvious I have missed.
It seems that BLKIO_STAT_... values larger than BLK_IO_STAT_QUEUE are
defined only if CONFIG_DEBUG_BLK_CGROUP is defined. And in that case they
are also handled by blkio_get_stat() in a special way so we never get to
computing blkg->stats.stat_arr[type][sub_type]. So everything seems fine.
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
prev parent reply other threads:[~2012-04-10 15:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-02 13:54 question about blkio_get_stat() Dan Carpenter
2012-04-07 8:28 ` Jan Kara [this message]
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=20120407082830.GB2584@quack.suse.cz \
--to=jack@suse.cz \
--cc=axboe@kernel.dk \
--cc=dan.carpenter@oracle.com \
--cc=dpshah@google.com \
--cc=linux-kernel@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