Commit 63365342 authored by Sławomir Demeszko's avatar Sławomir Demeszko Committed by Luis Henriques

staging: gdm724x: Correction of variable usage after applying ALIGN()

commit 892c89d5 upstream.

Fix regression introduced by commit <29ef8a53>. 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: default avatarSławomir Demeszko <s.demeszko@wireless-instruments.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent fead6438
...@@ -158,7 +158,7 @@ static int up_to_host(struct mux_rx *r) ...@@ -158,7 +158,7 @@ static int up_to_host(struct mux_rx *r)
unsigned int start_flag; unsigned int start_flag;
unsigned int payload_size; unsigned int payload_size;
unsigned short packet_type; unsigned short packet_type;
int dummy_cnt; int total_len;
u32 packet_size_sum = r->offset; u32 packet_size_sum = r->offset;
int index; int index;
int ret = TO_HOST_INVALID_PACKET; int ret = TO_HOST_INVALID_PACKET;
...@@ -176,10 +176,10 @@ static int up_to_host(struct mux_rx *r) ...@@ -176,10 +176,10 @@ static int up_to_host(struct mux_rx *r)
break; break;
} }
dummy_cnt = ALIGN(MUX_HEADER_SIZE + payload_size, 4); total_len = ALIGN(MUX_HEADER_SIZE + payload_size, 4);
if (len - packet_size_sum < if (len - packet_size_sum <
MUX_HEADER_SIZE + payload_size + dummy_cnt) { total_len) {
pr_err("invalid payload : %d %d %04x\n", pr_err("invalid payload : %d %d %04x\n",
payload_size, len, packet_type); payload_size, len, packet_type);
break; break;
...@@ -202,7 +202,7 @@ static int up_to_host(struct mux_rx *r) ...@@ -202,7 +202,7 @@ static int up_to_host(struct mux_rx *r)
break; break;
} }
packet_size_sum += MUX_HEADER_SIZE + payload_size + dummy_cnt; packet_size_sum += total_len;
if (len - packet_size_sum <= MUX_HEADER_SIZE + 2) { if (len - packet_size_sum <= MUX_HEADER_SIZE + 2) {
ret = r->callback(NULL, ret = r->callback(NULL,
0, 0,
...@@ -361,7 +361,6 @@ static int gdm_mux_send(void *priv_dev, void *data, int len, int tty_index, ...@@ -361,7 +361,6 @@ static int gdm_mux_send(void *priv_dev, void *data, int len, int tty_index,
struct mux_pkt_header *mux_header; struct mux_pkt_header *mux_header;
struct mux_tx *t = NULL; struct mux_tx *t = NULL;
static u32 seq_num = 1; static u32 seq_num = 1;
int dummy_cnt;
int total_len; int total_len;
int ret; int ret;
unsigned long flags; unsigned long flags;
...@@ -374,9 +373,7 @@ static int gdm_mux_send(void *priv_dev, void *data, int len, int tty_index, ...@@ -374,9 +373,7 @@ static int gdm_mux_send(void *priv_dev, void *data, int len, int tty_index,
spin_lock_irqsave(&mux_dev->write_lock, flags); spin_lock_irqsave(&mux_dev->write_lock, flags);
dummy_cnt = ALIGN(MUX_HEADER_SIZE + len, 4); total_len = ALIGN(MUX_HEADER_SIZE + len, 4);
total_len = len + MUX_HEADER_SIZE + dummy_cnt;
t = alloc_mux_tx(total_len); t = alloc_mux_tx(total_len);
if (!t) { if (!t) {
...@@ -392,7 +389,8 @@ static int gdm_mux_send(void *priv_dev, void *data, int len, int tty_index, ...@@ -392,7 +389,8 @@ static int gdm_mux_send(void *priv_dev, void *data, int len, int tty_index,
mux_header->packet_type = __cpu_to_le16(packet_type[tty_index]); mux_header->packet_type = __cpu_to_le16(packet_type[tty_index]);
memcpy(t->buf+MUX_HEADER_SIZE, data, len); memcpy(t->buf+MUX_HEADER_SIZE, data, len);
memset(t->buf+MUX_HEADER_SIZE+len, 0, dummy_cnt); memset(t->buf+MUX_HEADER_SIZE+len, 0, total_len - MUX_HEADER_SIZE -
len);
t->len = total_len; t->len = total_len;
t->callback = cb; t->callback = cb;
......
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