From: Heiko Carstens <heiko.carstens@de.ibm.com>
To: Jose Alonso <joalonsof@gmail.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>,
Lukasz Dorau <lukasz.dorau@intel.com>,
Maciej Patelczyk <maciej.patelczyk@intel.com>,
Dave Jiang <dave.jiang@intel.com>,
Simon Horman <horms@verge.net.au>,
Magnus Damm <magnus.damm@gmail.com>,
Paul Mundt <lethal@linux-sh.org>, Christoph Hellwig <hch@lst.de>,
Jens Axboe <axboe@kernel.dk>,
Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] for_each macros correctness
Date: Tue, 28 Jan 2014 13:02:45 +0100 [thread overview]
Message-ID: <20140128120245.GB4280@osiris> (raw)
In-Reply-To: <1390733658.3059.10.camel@laptop>
On Sun, Jan 26, 2014 at 08:54:18AM -0200, Jose Alonso wrote:
>
> I observed that there are for_each macros that do an extra memory access
> beyond the defined area.
> Normally this does not cause problems.
> But, this can cause exceptions. For example: if the area is allocated at
> the end of a page and the next page is not accessible.
>
> For correctness, I suggest changing the arguments of the 'for loop' like
> others 'for_each' do in the kernel.
>
> files involved:
> drivers/s390/cio/qdio.h
> drivers/scsi/isci/host.h
> drivers/sh/clk/core.c
> include/linux/blk-mq.h
> include/linux/shdma-base.h
> sound/soc/sh/rcar/adg.c
>
>
> Signed-off-by: Jose Alonso <joalonsof@gmail.com>
> ---
> diff --git a/drivers/s390/cio/qdio.h b/drivers/s390/cio/qdio.h
> index 8acaae1..a563e4c 100644
> --- a/drivers/s390/cio/qdio.h
> +++ b/drivers/s390/cio/qdio.h
> @@ -359,14 +359,12 @@ static inline int multicast_outbound(struct qdio_q *q)
> #define need_siga_sync_out_after_pci(q) \
> (unlikely(q->irq_ptr->siga_flag.sync_out_after_pci))
>
> -#define for_each_input_queue(irq_ptr, q, i) \
> - for (i = 0, q = irq_ptr->input_qs[0]; \
> - i < irq_ptr->nr_input_qs; \
> - q = irq_ptr->input_qs[++i])
> -#define for_each_output_queue(irq_ptr, q, i) \
> - for (i = 0, q = irq_ptr->output_qs[0]; \
> - i < irq_ptr->nr_output_qs; \
> - q = irq_ptr->output_qs[++i])
> +#define for_each_input_queue(irq_ptr, q, i) \
> + for (i = 0; i < irq_ptr->nr_input_qs && \
> + ({ q = irq_ptr->input_qs[i]; 1; }); i++)
> +#define for_each_output_queue(irq_ptr, q, i) \
> + for (i = 0; i < irq_ptr->nr_output_qs && \
> + ({ q = irq_ptr->output_qs[i]; 1; }); i++)
Hi Jose,
I generated a single commit of this part of your patch and applied
it to the s390 git tree.
Thanks!
prev parent reply other threads:[~2014-01-28 12:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-26 10:54 [PATCH] for_each macros correctness Jose Alonso
2014-01-26 13:39 ` Fubo Chen
2014-01-26 18:05 ` Jose Alonso
2014-01-27 9:26 ` Dorau, Lukasz
2014-01-27 20:01 ` Jens Axboe
2014-01-28 12:02 ` Heiko Carstens [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=20140128120245.GB4280@osiris \
--to=heiko.carstens@de.ibm.com \
--cc=axboe@kernel.dk \
--cc=broonie@kernel.org \
--cc=dave.jiang@intel.com \
--cc=g.liakhovetski@gmx.de \
--cc=hch@lst.de \
--cc=horms@verge.net.au \
--cc=joalonsof@gmail.com \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=lethal@linux-sh.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lukasz.dorau@intel.com \
--cc=maciej.patelczyk@intel.com \
--cc=magnus.damm@gmail.com \
--cc=schwidefsky@de.ibm.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.