Skip to content

Commit

Permalink
drivers: slip: Consistently log pkt/buf allocation failures
Browse files Browse the repository at this point in the history
There are 3 cases of possible allocation failures, only 1 of them
was logged. Now, all the cases are logged: 1) failure to allocate
net_pkt; 2) failure to allocate very first net_buf for it; 3)
failure to allocate additional net_buf for it (this latter was
the only one logged previously).

Signed-off-by: Paul Sokolovsky <[email protected]>
  • Loading branch information
pfalcon authored and jukkar committed Oct 16, 2017
1 parent 49c8958 commit 1ca4f1a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/slip/slip.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,15 @@ static inline int slip_input_byte(struct slip_context *slip,

slip->rx = net_pkt_get_reserve_rx(0, K_NO_WAIT);
if (!slip->rx) {
SYS_LOG_ERR("[%p] cannot allocate pkt",
slip);
return 0;
}

slip->last = net_pkt_get_frag(slip->rx, K_NO_WAIT);
if (!slip->last) {
SYS_LOG_ERR("[%p] cannot allocate 1st data frag",
slip);
net_pkt_unref(slip->rx);
slip->rx = NULL;
return 0;
Expand All @@ -340,7 +344,7 @@ static inline int slip_input_byte(struct slip_context *slip,

frag = net_pkt_get_reserve_rx_data(0, K_NO_WAIT);
if (!frag) {
SYS_LOG_ERR("[%p] cannot allocate data fragment",
SYS_LOG_ERR("[%p] cannot allocate next data frag",
slip);
net_pkt_unref(slip->rx);
slip->rx = NULL;
Expand Down

0 comments on commit 1ca4f1a

Please sign in to comment.