All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfgang Grandegger <wg@grandegger.com>
To: Marc Kleine-Budde <mkl@pengutronix.de>, netdev@vger.kernel.org
Cc: linux-can@vger.kernel.org, kernel@pengutronix.de
Subject: Re: [PATCH] can: dev: fix nlmsg size calculation in can_get_size()
Date: Sat, 05 Oct 2013 22:50:05 +0200	[thread overview]
Message-ID: <52507B7D.6030008@grandegger.com> (raw)
In-Reply-To: <1381001117-19624-1-git-send-email-mkl@pengutronix.de>

On 10/05/2013 09:25 PM, Marc Kleine-Budde wrote:
> This patch fixes the calculation of the nlmsg size, by adding the missing
> nla_total_size().
> 
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> ---
> Hello,
> 
> this patch touches the rtnl_link_ops get_size() callback:
> 
>     static struct rtnl_link_ops can_link_ops __read_mostly = {
>     ...
>     	.get_size	= can_get_size,
>     ...
>     };
> 
> By looking at other nlmsg size calculation I think a nla_total_size() for all
> contributers is needed. Am I correct?

Yes, seems so, nla_put() calls this code:

  http://lxr.free-electrons.com/source/lib/nlattr.c#L328

Wolfgang.

> regards,
> Marc
> 
>  drivers/net/can/dev.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
> index f9cba41..1870c47 100644
> --- a/drivers/net/can/dev.c
> +++ b/drivers/net/can/dev.c
> @@ -705,14 +705,14 @@ static size_t can_get_size(const struct net_device *dev)
>  	size_t size;
>  
>  	size = nla_total_size(sizeof(u32));   /* IFLA_CAN_STATE */
> -	size += sizeof(struct can_ctrlmode);  /* IFLA_CAN_CTRLMODE */
> +	size += nla_total_size(sizeof(struct can_ctrlmode));  /* IFLA_CAN_CTRLMODE */
>  	size += nla_total_size(sizeof(u32));  /* IFLA_CAN_RESTART_MS */
> -	size += sizeof(struct can_bittiming); /* IFLA_CAN_BITTIMING */
> -	size += sizeof(struct can_clock);     /* IFLA_CAN_CLOCK */
> +	size += nla_total_size(sizeof(struct can_bittiming)); /* IFLA_CAN_BITTIMING */
> +	size += nla_total_size(sizeof(struct can_clock));     /* IFLA_CAN_CLOCK */
>  	if (priv->do_get_berr_counter)        /* IFLA_CAN_BERR_COUNTER */
> -		size += sizeof(struct can_berr_counter);
> +		size += nla_total_size(sizeof(struct can_berr_counter));
>  	if (priv->bittiming_const)	      /* IFLA_CAN_BITTIMING_CONST */
> -		size += sizeof(struct can_bittiming_const);
> +		size += nla_total_size(sizeof(struct can_bittiming_const));
>  
>  	return size;
>  }
> 


  reply	other threads:[~2013-10-05 20:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-05 19:25 [PATCH] can: dev: fix nlmsg size calculation in can_get_size() Marc Kleine-Budde
2013-10-05 20:50 ` Wolfgang Grandegger [this message]
2013-10-07 14:14   ` Marc Kleine-Budde
2013-10-07 14:24     ` Wolfgang Grandegger
2013-10-07 14:24       ` Wolfgang Grandegger
2013-10-07 14:26       ` Marc Kleine-Budde
2013-10-07 19:56 ` David Miller

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=52507B7D.6030008@grandegger.com \
    --to=wg@grandegger.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=netdev@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 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.