From: Heiko Stuebner <heiko@sntech.de>
To: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Cc: Kees Cook <keescook@chromium.org>,
David Airlie <airlied@linux.ie>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-rockchip@lists.infradead.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] drm/rockchip: Use struct_size() in devm_kzalloc()
Date: Wed, 29 Aug 2018 13:41:50 +0200 [thread overview]
Message-ID: <2639880.ggikvLCEDc@phil> (raw)
In-Reply-To: <20180826184712.GA9330@embeddedor.com>
Am Sonntag, 26. August 2018, 20:47:12 CEST schrieb Gustavo A. R. Silva:
> One of the more common cases of allocation size calculations is finding
> the size of a structure that has a zero-sized array at the end, along
> with memory for some number of elements for that array. For example:
>
> struct foo {
> int stuff;
> void *entry[];
> };
>
> instance = devm_kzalloc(dev, sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);
>
> or, like in this particular case:
>
> size = sizeof(struct foo) + sizeof(void *) * count;
> instance = devm_kzalloc(dev, size, GFP_KERNEL);
>
> Instead of leaving these open-coded and prone to type mistakes, we can
> now use the new struct_size() helper:
>
> instance = devm_kzalloc(dev, struct_size(instance, entry, count),
> GFP_KERNEL);
>
> This issue was detected with the help of Coccinelle.
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
applied to drm-misc with Kees' Review
Thanks
Heiko
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
WARNING: multiple messages have this Message-ID (diff)
From: heiko@sntech.de (Heiko Stuebner)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] drm/rockchip: Use struct_size() in devm_kzalloc()
Date: Wed, 29 Aug 2018 13:41:50 +0200 [thread overview]
Message-ID: <2639880.ggikvLCEDc@phil> (raw)
In-Reply-To: <20180826184712.GA9330@embeddedor.com>
Am Sonntag, 26. August 2018, 20:47:12 CEST schrieb Gustavo A. R. Silva:
> One of the more common cases of allocation size calculations is finding
> the size of a structure that has a zero-sized array at the end, along
> with memory for some number of elements for that array. For example:
>
> struct foo {
> int stuff;
> void *entry[];
> };
>
> instance = devm_kzalloc(dev, sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);
>
> or, like in this particular case:
>
> size = sizeof(struct foo) + sizeof(void *) * count;
> instance = devm_kzalloc(dev, size, GFP_KERNEL);
>
> Instead of leaving these open-coded and prone to type mistakes, we can
> now use the new struct_size() helper:
>
> instance = devm_kzalloc(dev, struct_size(instance, entry, count),
> GFP_KERNEL);
>
> This issue was detected with the help of Coccinelle.
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
applied to drm-misc with Kees' Review
Thanks
Heiko
WARNING: multiple messages have this Message-ID (diff)
From: Heiko Stuebner <heiko@sntech.de>
To: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Cc: Sandy Huang <hjc@rock-chips.com>, David Airlie <airlied@linux.ie>,
dri-devel@lists.freedesktop.org,
linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
Kees Cook <keescook@chromium.org>
Subject: Re: [PATCH] drm/rockchip: Use struct_size() in devm_kzalloc()
Date: Wed, 29 Aug 2018 13:41:50 +0200 [thread overview]
Message-ID: <2639880.ggikvLCEDc@phil> (raw)
In-Reply-To: <20180826184712.GA9330@embeddedor.com>
Am Sonntag, 26. August 2018, 20:47:12 CEST schrieb Gustavo A. R. Silva:
> One of the more common cases of allocation size calculations is finding
> the size of a structure that has a zero-sized array at the end, along
> with memory for some number of elements for that array. For example:
>
> struct foo {
> int stuff;
> void *entry[];
> };
>
> instance = devm_kzalloc(dev, sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);
>
> or, like in this particular case:
>
> size = sizeof(struct foo) + sizeof(void *) * count;
> instance = devm_kzalloc(dev, size, GFP_KERNEL);
>
> Instead of leaving these open-coded and prone to type mistakes, we can
> now use the new struct_size() helper:
>
> instance = devm_kzalloc(dev, struct_size(instance, entry, count),
> GFP_KERNEL);
>
> This issue was detected with the help of Coccinelle.
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
applied to drm-misc with Kees' Review
Thanks
Heiko
next prev parent reply other threads:[~2018-08-29 11:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-26 18:47 [PATCH] drm/rockchip: Use struct_size() in devm_kzalloc() Gustavo A. R. Silva
2018-08-26 18:47 ` Gustavo A. R. Silva
2018-08-26 18:47 ` Gustavo A. R. Silva
2018-08-26 22:04 ` Kees Cook
2018-08-26 22:04 ` Kees Cook
2018-08-29 11:41 ` Heiko Stuebner [this message]
2018-08-29 11:41 ` Heiko Stuebner
2018-08-29 11:41 ` Heiko Stuebner
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=2639880.ggikvLCEDc@phil \
--to=heiko@sntech.de \
--cc=airlied@linux.ie \
--cc=dri-devel@lists.freedesktop.org \
--cc=gustavo@embeddedor.com \
--cc=keescook@chromium.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.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 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.