netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] can: dev: fix nlmsg size calculation in can_get_size()
@ 2013-10-05 19:25 Marc Kleine-Budde
  2013-10-05 20:50 ` Wolfgang Grandegger
  2013-10-07 19:56 ` David Miller
  0 siblings, 2 replies; 6+ messages in thread
From: Marc Kleine-Budde @ 2013-10-05 19:25 UTC (permalink / raw)
  To: netdev; +Cc: linux-can, kernel, Wolfgang Grandegger, Marc Kleine-Budde

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?

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;
 }
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] can: dev: fix nlmsg size calculation in can_get_size()
  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
  2013-10-07 14:14   ` Marc Kleine-Budde
  2013-10-07 19:56 ` David Miller
  1 sibling, 1 reply; 6+ messages in thread
From: Wolfgang Grandegger @ 2013-10-05 20:50 UTC (permalink / raw)
  To: Marc Kleine-Budde, netdev; +Cc: linux-can, kernel

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;
>  }
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] can: dev: fix nlmsg size calculation in can_get_size()
  2013-10-05 20:50 ` Wolfgang Grandegger
@ 2013-10-07 14:14   ` Marc Kleine-Budde
  2013-10-07 14:24     ` Wolfgang Grandegger
  0 siblings, 1 reply; 6+ messages in thread
From: Marc Kleine-Budde @ 2013-10-07 14:14 UTC (permalink / raw)
  To: Wolfgang Grandegger; +Cc: netdev, linux-can, kernel

[-- Attachment #1: Type: text/plain, Size: 1045 bytes --]

On 10/05/2013 10:50 PM, Wolfgang Grandegger wrote:
> 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

Is this an Acked-by? :)

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] can: dev: fix nlmsg size calculation in  can_get_size()
  2013-10-07 14:14   ` Marc Kleine-Budde
@ 2013-10-07 14:24     ` Wolfgang Grandegger
  2013-10-07 14:26       ` Marc Kleine-Budde
  0 siblings, 1 reply; 6+ messages in thread
From: Wolfgang Grandegger @ 2013-10-07 14:24 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: netdev, linux-can, kernel

On Mon, 07 Oct 2013 16:14:36 +0200, Marc Kleine-Budde <mkl@pengutronix.de>

wrote:

> On 10/05/2013 10:50 PM, Wolfgang Grandegger wrote:

>> 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

> 

> Is this an Acked-by? :)



Yep, obviously a long time ago that I did something for Linux-CAN :(.



Wolfgang.



> 

> Marc

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] can: dev: fix nlmsg size calculation in  can_get_size()
  2013-10-07 14:24     ` Wolfgang Grandegger
@ 2013-10-07 14:26       ` Marc Kleine-Budde
  0 siblings, 0 replies; 6+ messages in thread
From: Marc Kleine-Budde @ 2013-10-07 14:26 UTC (permalink / raw)
  To: Wolfgang Grandegger; +Cc: netdev, linux-can, kernel

[-- Attachment #1: Type: text/plain, Size: 500 bytes --]

On 10/07/2013 04:24 PM, Wolfgang Grandegger wrote:

>> Is this an Acked-by? :)
> Yep, obviously a long time ago that I did something for Linux-CAN :(.

Thx, there are some netlink related patches coming soon :)

Marc
-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] can: dev: fix nlmsg size calculation in can_get_size()
  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
@ 2013-10-07 19:56 ` David Miller
  1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2013-10-07 19:56 UTC (permalink / raw)
  To: mkl; +Cc: netdev, linux-can, kernel, wg

From: Marc Kleine-Budde <mkl@pengutronix.de>
Date: Sat,  5 Oct 2013 21:25:17 +0200

> 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>

Applied and queued up for -stable, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-10-07 19:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2013-10-07 14:14   ` Marc Kleine-Budde
2013-10-07 14:24     ` Wolfgang Grandegger
2013-10-07 14:26       ` Marc Kleine-Budde
2013-10-07 19:56 ` David Miller

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).