From: Shannon Nelson <shannon.nelson@amd.com>
To: Julia Lawall <Julia.Lawall@inria.fr>
Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org,
Brett Creeley <brett.creeley@amd.com>,
drivers@pensando.io, "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 11/26] ionic: use array_size
Date: Mon, 26 Jun 2023 09:03:01 -0700 [thread overview]
Message-ID: <ed32fce5-fcef-6647-7345-1eacda217e62@amd.com> (raw)
In-Reply-To: <20230623211457.102544-12-Julia.Lawall@inria.fr>
On 6/23/23 2:14 PM, Julia Lawall wrote:
>
> Use array_size to protect against multiplication overflows.
>
> The changes were done using the following Coccinelle semantic patch:
>
> // <smpl>
> @@
> expression E1, E2;
> constant C1, C2;
> identifier alloc = {vmalloc,vzalloc};
> @@
>
> (
> alloc(C1 * C2,...)
> |
> alloc(
> - (E1) * (E2)
> + array_size(E1, E2)
> ,...)
> )
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Thanks,
Acked-by: Shannon Nelson <shannon.nelson@amd.com>
>
> ---
> drivers/net/ethernet/pensando/ionic/ionic_lif.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
> index 957027e546b3..f2e2c6853536 100644
> --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c
> +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
> @@ -560,7 +560,7 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type,
> new->q.dev = dev;
> new->flags = flags;
>
> - new->q.info = vzalloc(num_descs * sizeof(*new->q.info));
> + new->q.info = vzalloc(array_size(num_descs, sizeof(*new->q.info)));
> if (!new->q.info) {
> netdev_err(lif->netdev, "Cannot allocate queue info\n");
> err = -ENOMEM;
> @@ -581,7 +581,7 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type,
> if (err)
> goto err_out;
>
> - new->cq.info = vzalloc(num_descs * sizeof(*new->cq.info));
> + new->cq.info = vzalloc(array_size(num_descs, sizeof(*new->cq.info)));
> if (!new->cq.info) {
> netdev_err(lif->netdev, "Cannot allocate completion queue info\n");
> err = -ENOMEM;
>
> --
> You received this message because you are subscribed to the Google Groups "Pensando Drivers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to drivers+unsubscribe@pensando.io.
> To view this discussion on the web visit https://groups.google.com/a/pensando.io/d/msgid/drivers/20230623211457.102544-12-Julia.Lawall%40inria.fr.
next prev parent reply other threads:[~2023-06-26 16:03 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-23 21:14 [PATCH 00/26] use array_size Julia Lawall
2023-06-23 21:14 ` [PATCH 02/26] octeon_ep: " Julia Lawall
2023-06-24 15:46 ` Simon Horman
2023-06-24 22:28 ` Jakub Kicinski
2023-06-25 20:14 ` Christophe JAILLET
2023-06-25 20:25 ` Julia Lawall
2023-06-25 20:32 ` Christophe JAILLET
2023-06-25 20:57 ` Julia Lawall
2023-06-23 21:14 ` [PATCH 04/26] gve: " Julia Lawall
2023-06-24 15:47 ` Simon Horman
2023-06-23 21:14 ` [PATCH 09/26] pds_core: " Julia Lawall
2023-06-24 15:47 ` Simon Horman
2023-06-26 16:02 ` Shannon Nelson
2023-06-23 21:14 ` [PATCH 11/26] ionic: " Julia Lawall
2023-06-24 15:47 ` Simon Horman
2023-06-26 16:03 ` Shannon Nelson [this message]
2023-06-23 21:14 ` [PATCH 18/26] net: enetc: " Julia Lawall
2023-06-24 15:48 ` Simon Horman
2023-06-23 21:14 ` [PATCH 22/26] net: mana: " Julia Lawall
2023-06-24 15:48 ` Simon Horman
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=ed32fce5-fcef-6647-7345-1eacda217e62@amd.com \
--to=shannon.nelson@amd.com \
--cc=Julia.Lawall@inria.fr \
--cc=brett.creeley@amd.com \
--cc=davem@davemloft.net \
--cc=drivers@pensando.io \
--cc=edumazet@google.com \
--cc=keescook@chromium.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).