Commit 34dcf6a1 authored by swkhack's avatar swkhack Committed by David S. Miller

net: caif: fix the value of size argument of snprintf

Because the function snprintf write at most size bytes(including the
null byte).So the value of the argument size need not to minus one.
Signed-off-by: default avatarswkhack <swkhack@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 510e2ced
...@@ -26,7 +26,7 @@ struct cflayer *cfdbgl_create(u8 channel_id, struct dev_info *dev_info) ...@@ -26,7 +26,7 @@ struct cflayer *cfdbgl_create(u8 channel_id, struct dev_info *dev_info)
cfsrvl_init(dbg, channel_id, dev_info, false); cfsrvl_init(dbg, channel_id, dev_info, false);
dbg->layer.receive = cfdbgl_receive; dbg->layer.receive = cfdbgl_receive;
dbg->layer.transmit = cfdbgl_transmit; dbg->layer.transmit = cfdbgl_transmit;
snprintf(dbg->layer.name, CAIF_LAYER_NAME_SZ - 1, "dbg%d", channel_id); snprintf(dbg->layer.name, CAIF_LAYER_NAME_SZ, "dbg%d", channel_id);
return &dbg->layer; return &dbg->layer;
} }
......
...@@ -33,8 +33,7 @@ struct cflayer *cfdgml_create(u8 channel_id, struct dev_info *dev_info) ...@@ -33,8 +33,7 @@ struct cflayer *cfdgml_create(u8 channel_id, struct dev_info *dev_info)
cfsrvl_init(dgm, channel_id, dev_info, true); cfsrvl_init(dgm, channel_id, dev_info, true);
dgm->layer.receive = cfdgml_receive; dgm->layer.receive = cfdgml_receive;
dgm->layer.transmit = cfdgml_transmit; dgm->layer.transmit = cfdgml_transmit;
snprintf(dgm->layer.name, CAIF_LAYER_NAME_SZ - 1, "dgm%d", channel_id); snprintf(dgm->layer.name, CAIF_LAYER_NAME_SZ, "dgm%d", channel_id);
dgm->layer.name[CAIF_LAYER_NAME_SZ - 1] = '\0';
return &dgm->layer; return &dgm->layer;
} }
......
...@@ -33,7 +33,7 @@ struct cflayer *cfutill_create(u8 channel_id, struct dev_info *dev_info) ...@@ -33,7 +33,7 @@ struct cflayer *cfutill_create(u8 channel_id, struct dev_info *dev_info)
cfsrvl_init(util, channel_id, dev_info, true); cfsrvl_init(util, channel_id, dev_info, true);
util->layer.receive = cfutill_receive; util->layer.receive = cfutill_receive;
util->layer.transmit = cfutill_transmit; util->layer.transmit = cfutill_transmit;
snprintf(util->layer.name, CAIF_LAYER_NAME_SZ - 1, "util1"); snprintf(util->layer.name, CAIF_LAYER_NAME_SZ, "util1");
return &util->layer; return &util->layer;
} }
......
...@@ -32,7 +32,7 @@ struct cflayer *cfvei_create(u8 channel_id, struct dev_info *dev_info) ...@@ -32,7 +32,7 @@ struct cflayer *cfvei_create(u8 channel_id, struct dev_info *dev_info)
cfsrvl_init(vei, channel_id, dev_info, true); cfsrvl_init(vei, channel_id, dev_info, true);
vei->layer.receive = cfvei_receive; vei->layer.receive = cfvei_receive;
vei->layer.transmit = cfvei_transmit; vei->layer.transmit = cfvei_transmit;
snprintf(vei->layer.name, CAIF_LAYER_NAME_SZ - 1, "vei%d", channel_id); snprintf(vei->layer.name, CAIF_LAYER_NAME_SZ, "vei%d", channel_id);
return &vei->layer; return &vei->layer;
} }
......
...@@ -29,7 +29,7 @@ struct cflayer *cfvidl_create(u8 channel_id, struct dev_info *dev_info) ...@@ -29,7 +29,7 @@ struct cflayer *cfvidl_create(u8 channel_id, struct dev_info *dev_info)
cfsrvl_init(vid, channel_id, dev_info, false); cfsrvl_init(vid, channel_id, dev_info, false);
vid->layer.receive = cfvidl_receive; vid->layer.receive = cfvidl_receive;
vid->layer.transmit = cfvidl_transmit; vid->layer.transmit = cfvidl_transmit;
snprintf(vid->layer.name, CAIF_LAYER_NAME_SZ - 1, "vid1"); snprintf(vid->layer.name, CAIF_LAYER_NAME_SZ, "vid1");
return &vid->layer; return &vid->layer;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment