drivers: slip: Fix memory corruption when receiving packet
It is possible that the slip->last pointer is not set during the startup of the slip driver if we receive some garbage bytes. This in turn caused memory to be overwritten in random places. Jira: ZEP-1737 Change-Id: Ia2ce193b81a8f707b7ca63497d497ea70699bb32 Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
82545373ee
commit
f7a5612ba2
|
@ -313,6 +313,14 @@ static inline int slip_input_byte(struct slip_context *slip,
|
|||
break;
|
||||
}
|
||||
|
||||
/* It is possible that slip->last is not set during the startup
|
||||
* of the device. If this happens do not continue and overwrite
|
||||
* some random memory.
|
||||
*/
|
||||
if (!slip->last) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!net_buf_tailroom(slip->last)) {
|
||||
/* We need to allocate a new fragment */
|
||||
struct net_buf *frag;
|
||||
|
|
Loading…
Reference in a new issue