diff options
Diffstat (limited to 'net/caif/cfserl.c')
-rw-r--r-- | net/caif/cfserl.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/net/caif/cfserl.c b/net/caif/cfserl.c index 06029ea2da2f..a11fbd68a13d 100644 --- a/net/caif/cfserl.c +++ b/net/caif/cfserl.c | |||
@@ -14,7 +14,8 @@ | |||
14 | #define container_obj(layr) ((struct cfserl *) layr) | 14 | #define container_obj(layr) ((struct cfserl *) layr) |
15 | 15 | ||
16 | #define CFSERL_STX 0x02 | 16 | #define CFSERL_STX 0x02 |
17 | #define CAIF_MINIUM_PACKET_SIZE 4 | 17 | #define SERIAL_MINIUM_PACKET_SIZE 4 |
18 | #define SERIAL_MAX_FRAMESIZE 4096 | ||
18 | struct cfserl { | 19 | struct cfserl { |
19 | struct cflayer layer; | 20 | struct cflayer layer; |
20 | struct cfpkt *incomplete_frm; | 21 | struct cfpkt *incomplete_frm; |
@@ -59,14 +60,18 @@ static int cfserl_receive(struct cflayer *l, struct cfpkt *newpkt) | |||
59 | u8 stx = CFSERL_STX; | 60 | u8 stx = CFSERL_STX; |
60 | int ret; | 61 | int ret; |
61 | u16 expectlen = 0; | 62 | u16 expectlen = 0; |
63 | |||
62 | caif_assert(newpkt != NULL); | 64 | caif_assert(newpkt != NULL); |
63 | spin_lock(&layr->sync); | 65 | spin_lock(&layr->sync); |
64 | 66 | ||
65 | if (layr->incomplete_frm != NULL) { | 67 | if (layr->incomplete_frm != NULL) { |
66 | |||
67 | layr->incomplete_frm = | 68 | layr->incomplete_frm = |
68 | cfpkt_append(layr->incomplete_frm, newpkt, expectlen); | 69 | cfpkt_append(layr->incomplete_frm, newpkt, expectlen); |
69 | pkt = layr->incomplete_frm; | 70 | pkt = layr->incomplete_frm; |
71 | if (pkt == NULL) { | ||
72 | spin_unlock(&layr->sync); | ||
73 | return -ENOMEM; | ||
74 | } | ||
70 | } else { | 75 | } else { |
71 | pkt = newpkt; | 76 | pkt = newpkt; |
72 | } | 77 | } |
@@ -115,8 +120,8 @@ static int cfserl_receive(struct cflayer *l, struct cfpkt *newpkt) | |||
115 | /* | 120 | /* |
116 | * Frame error handling | 121 | * Frame error handling |
117 | */ | 122 | */ |
118 | if (expectlen < CAIF_MINIUM_PACKET_SIZE | 123 | if (expectlen < SERIAL_MINIUM_PACKET_SIZE |
119 | || expectlen > CAIF_MAX_FRAMESIZE) { | 124 | || expectlen > SERIAL_MAX_FRAMESIZE) { |
120 | if (!layr->usestx) { | 125 | if (!layr->usestx) { |
121 | if (pkt != NULL) | 126 | if (pkt != NULL) |
122 | cfpkt_destroy(pkt); | 127 | cfpkt_destroy(pkt); |
@@ -154,7 +159,6 @@ static int cfserl_receive(struct cflayer *l, struct cfpkt *newpkt) | |||
154 | if (layr->usestx) { | 159 | if (layr->usestx) { |
155 | if (tail_pkt != NULL) | 160 | if (tail_pkt != NULL) |
156 | pkt = cfpkt_append(pkt, tail_pkt, 0); | 161 | pkt = cfpkt_append(pkt, tail_pkt, 0); |
157 | |||
158 | /* Start search for next STX if frame failed */ | 162 | /* Start search for next STX if frame failed */ |
159 | continue; | 163 | continue; |
160 | } else { | 164 | } else { |