diff options
author | Sławomir Demeszko <s.demeszko@wireless-instruments.com> | 2015-05-05 11:49:54 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-05-10 09:23:02 -0400 |
commit | 892c89d5d7ffd1bb794fe54d86c0eef18d215fab (patch) | |
tree | e005acc8f0235b075742812d6dc67346710f4786 | |
parent | 664a5c1d1e33cd89cb7883e8c74638cc482b5da7 (diff) |
staging: gdm724x: Correction of variable usage after applying ALIGN()
Fix regression introduced by commit <29ef8a53542a>. After it writing
AT commands to /dev/GCT-ATM0 is unsuccessful (no echo, no response)
and dmesg show "gdmtty: invalid payload : 1 16 f011".
Before that commit value of dummy_cnt was only a padding size. After using
ALIGN() this value is increased by its first argument. So the following
usage of this variable needs correction.
Signed-off-by: Sławomir Demeszko <s.demeszko@wireless-instruments.com>
Cc: stable <stable@vger.kernel.org> # 3.14+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/gdm724x/gdm_mux.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/drivers/staging/gdm724x/gdm_mux.c b/drivers/staging/gdm724x/gdm_mux.c index 8199b0a697bb..1cf24e4edf25 100644 --- a/drivers/staging/gdm724x/gdm_mux.c +++ b/drivers/staging/gdm724x/gdm_mux.c | |||
@@ -158,7 +158,7 @@ static int up_to_host(struct mux_rx *r) | |||
158 | unsigned int start_flag; | 158 | unsigned int start_flag; |
159 | unsigned int payload_size; | 159 | unsigned int payload_size; |
160 | unsigned short packet_type; | 160 | unsigned short packet_type; |
161 | int dummy_cnt; | 161 | int total_len; |
162 | u32 packet_size_sum = r->offset; | 162 | u32 packet_size_sum = r->offset; |
163 | int index; | 163 | int index; |
164 | int ret = TO_HOST_INVALID_PACKET; | 164 | int ret = TO_HOST_INVALID_PACKET; |
@@ -176,10 +176,10 @@ static int up_to_host(struct mux_rx *r) | |||
176 | break; | 176 | break; |
177 | } | 177 | } |
178 | 178 | ||
179 | dummy_cnt = ALIGN(MUX_HEADER_SIZE + payload_size, 4); | 179 | total_len = ALIGN(MUX_HEADER_SIZE + payload_size, 4); |
180 | 180 | ||
181 | if (len - packet_size_sum < | 181 | if (len - packet_size_sum < |
182 | MUX_HEADER_SIZE + payload_size + dummy_cnt) { | 182 | total_len) { |
183 | pr_err("invalid payload : %d %d %04x\n", | 183 | pr_err("invalid payload : %d %d %04x\n", |
184 | payload_size, len, packet_type); | 184 | payload_size, len, packet_type); |
185 | break; | 185 | break; |
@@ -202,7 +202,7 @@ static int up_to_host(struct mux_rx *r) | |||
202 | break; | 202 | break; |
203 | } | 203 | } |
204 | 204 | ||
205 | packet_size_sum += MUX_HEADER_SIZE + payload_size + dummy_cnt; | 205 | packet_size_sum += total_len; |
206 | if (len - packet_size_sum <= MUX_HEADER_SIZE + 2) { | 206 | if (len - packet_size_sum <= MUX_HEADER_SIZE + 2) { |
207 | ret = r->callback(NULL, | 207 | ret = r->callback(NULL, |
208 | 0, | 208 | 0, |
@@ -361,7 +361,6 @@ static int gdm_mux_send(void *priv_dev, void *data, int len, int tty_index, | |||
361 | struct mux_pkt_header *mux_header; | 361 | struct mux_pkt_header *mux_header; |
362 | struct mux_tx *t = NULL; | 362 | struct mux_tx *t = NULL; |
363 | static u32 seq_num = 1; | 363 | static u32 seq_num = 1; |
364 | int dummy_cnt; | ||
365 | int total_len; | 364 | int total_len; |
366 | int ret; | 365 | int ret; |
367 | unsigned long flags; | 366 | unsigned long flags; |
@@ -374,9 +373,7 @@ static int gdm_mux_send(void *priv_dev, void *data, int len, int tty_index, | |||
374 | 373 | ||
375 | spin_lock_irqsave(&mux_dev->write_lock, flags); | 374 | spin_lock_irqsave(&mux_dev->write_lock, flags); |
376 | 375 | ||
377 | dummy_cnt = ALIGN(MUX_HEADER_SIZE + len, 4); | 376 | total_len = ALIGN(MUX_HEADER_SIZE + len, 4); |
378 | |||
379 | total_len = len + MUX_HEADER_SIZE + dummy_cnt; | ||
380 | 377 | ||
381 | t = alloc_mux_tx(total_len); | 378 | t = alloc_mux_tx(total_len); |
382 | if (!t) { | 379 | if (!t) { |
@@ -392,7 +389,8 @@ static int gdm_mux_send(void *priv_dev, void *data, int len, int tty_index, | |||
392 | mux_header->packet_type = __cpu_to_le16(packet_type[tty_index]); | 389 | mux_header->packet_type = __cpu_to_le16(packet_type[tty_index]); |
393 | 390 | ||
394 | memcpy(t->buf+MUX_HEADER_SIZE, data, len); | 391 | memcpy(t->buf+MUX_HEADER_SIZE, data, len); |
395 | memset(t->buf+MUX_HEADER_SIZE+len, 0, dummy_cnt); | 392 | memset(t->buf+MUX_HEADER_SIZE+len, 0, total_len - MUX_HEADER_SIZE - |
393 | len); | ||
396 | 394 | ||
397 | t->len = total_len; | 395 | t->len = total_len; |
398 | t->callback = cb; | 396 | t->callback = cb; |