Message ID | 20240904014803.2034939-1-lihongbo22@huawei.com (mailing list archive) |
---|---|
State | Handled Elsewhere |
Headers | show |
Series | [-next] dmaengine: Loongson1: Annotate struct ls1x_dma_chan with __counted_by() | expand |
On Wed, Sep 4, 2024 at 9:39 AM Hongbo Li <lihongbo22@huawei.com> wrote: > > Add the __counted_by compiler attribute to the flexible array member > entries to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and > CONFIG_FORTIFY_SOURCE. > > Signed-off-by: Hongbo Li <lihongbo22@huawei.com> > --- > drivers/dma/loongson1-apb-dma.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/dma/loongson1-apb-dma.c b/drivers/dma/loongson1-apb-dma.c > index ca43c67a8203..be0dbda84dd2 100644 > --- a/drivers/dma/loongson1-apb-dma.c > +++ b/drivers/dma/loongson1-apb-dma.c > @@ -78,7 +78,7 @@ struct ls1x_dma_chan { > struct ls1x_dma { > struct dma_device ddev; > unsigned int nr_chans; > - struct ls1x_dma_chan chan[]; > + struct ls1x_dma_chan chan[] __counted_by(nr_chans); > }; > > static irqreturn_t ls1x_dma_irq_handler(int irq, void *data); > -- > 2.34.1 > Reviewed-by: Keguang Zhang <keguang.zhang@gmail.com>
diff --git a/drivers/dma/loongson1-apb-dma.c b/drivers/dma/loongson1-apb-dma.c index ca43c67a8203..be0dbda84dd2 100644 --- a/drivers/dma/loongson1-apb-dma.c +++ b/drivers/dma/loongson1-apb-dma.c @@ -78,7 +78,7 @@ struct ls1x_dma_chan { struct ls1x_dma { struct dma_device ddev; unsigned int nr_chans; - struct ls1x_dma_chan chan[]; + struct ls1x_dma_chan chan[] __counted_by(nr_chans); }; static irqreturn_t ls1x_dma_irq_handler(int irq, void *data);
Add the __counted_by compiler attribute to the flexible array member entries to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE. Signed-off-by: Hongbo Li <lihongbo22@huawei.com> --- drivers/dma/loongson1-apb-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)