drivers/staging/mei/interface.c: take size of pointed value, not pointer
authorJulia Lawall <julia@diku.dk>
Fri, 16 Sep 2011 06:57:33 +0000 (08:57 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 16 Sep 2011 18:49:18 +0000 (20:49 +0200)
Sizeof a pointer-typed expression returns the size of the pointer, not that
of the pointed data.

The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression *e;
type T;
identifier f;
@@

f(...,(T)e,...,
-sizeof(e)
+sizeof(*e)
,...)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/mei/interface.c

index cfec92dfc1c434ec47b69e85d785417afa752867..a65dacf002131f3fd82f737a2f26d01a13877cee 100644 (file)
@@ -332,7 +332,7 @@ int mei_send_flow_control(struct mei_device *dev, struct mei_cl *cl)
        mei_hdr->reserved = 0;
 
        mei_flow_control = (struct hbm_flow_control *) &dev->wr_msg_buf[1];
-       memset(mei_flow_control, 0, sizeof(mei_flow_control));
+       memset(mei_flow_control, 0, sizeof(*mei_flow_control));
        mei_flow_control->host_addr = cl->host_client_id;
        mei_flow_control->me_addr = cl->me_client_id;
        mei_flow_control->cmd.cmd = MEI_FLOW_CONTROL_CMD;
@@ -396,7 +396,7 @@ int mei_disconnect(struct mei_device *dev, struct mei_cl *cl)
 
        mei_cli_disconnect =
            (struct hbm_client_disconnect_request *) &dev->wr_msg_buf[1];
-       memset(mei_cli_disconnect, 0, sizeof(mei_cli_disconnect));
+       memset(mei_cli_disconnect, 0, sizeof(*mei_cli_disconnect));
        mei_cli_disconnect->host_addr = cl->host_client_id;
        mei_cli_disconnect->me_addr = cl->me_client_id;
        mei_cli_disconnect->cmd.cmd = CLIENT_DISCONNECT_REQ_CMD;