Skip to contentSkip to conversation

libertas: fix data packet size errors

PATCH In review Holger Schurig 2 participants 2 messages Dec 6, 2007 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libertas: fix data packet size errors

I wondered about junk bytes at the end when using "lbsdebug +hex +host" until I noticed that firmware for the CF card sends my extranous bytes. It says "I have 20 bytes", I take 20 bytes, but the last 8 bytes of this are just data junk.

Also, in the new lbs_cmd() where was a size miscalulation that made itself clear after fixing this bug.

---
The length the low-level-driver (usb, cf, sdio) if_XXX_receive_cmdres() reports back via *len ends up in "priv->upld_len". upld_len is only used in debugging statements, all code was looking at the "__le16 size" field anyway.

We might as well remove "priv->upld_len" completely.

drivers/net/wireless/libertas/if_cs.c +3 -0
Index: wireless-2.6/drivers/net/wireless/libertas/if_cs.c
===================================================================
@@ -373,6 +373,9 @@ static int if_cs_receive_cmdres(struct l
 	if (*len & 1)
 		data[*len-1] = if_cs_read8(priv->card, IF_CS_C_CMD);
 
+	/* This is a workaround for a firmware that reports too much
+	 * bytes */
+	*len -= 8
 	ret = 0;
 out:
 	lbs_deb_leave_args(LBS_DEB_CS, "ret %d, len %d", ret, *len);
drivers/net/wireless/libertas/cmdresp.c +1 -1
Index: wireless-2.6/drivers/net/wireless/libertas/cmdresp.c
===================================================================
@@ -882,7 +882,7 @@ int lbs_process_rx_command(struct lbs_pr
 
 	if (adapter->cur_cmd->pdata_size) {
 		struct cmd_ds_gen *r = (struct cmd_ds_gen *)resp;
-		u16 sz = cpu_to_le16(resp->size);
+		u16 sz = cpu_to_le16(resp->size) - S_DS_GEN;
 		if (sz > *adapter->cur_cmd->pdata_size) {
 			lbs_pr_err("response 0x%04x doesn't fit into "
 				"buffer (%d > %d)\n", respcmd,
#1 lore raw

drivers/net/wireless/libertas/if_cs.c static int if_cs_receive_cmdres(struct l · line 379

Quoted 5 lines · Holger Schurig
drivers/net/wireless/libertas/if_cs.c +3 -0
+       /* This is a workaround for a firmware that reports too much
+        * bytes */
+       *len -= 8
        ret = 0;

You might want another semicolon somewhere in there?

And if we're not looking at the length at all, that's bad. We should probably at _least_ compare it with the size field, to make sure we got everything that was sent, and that we're not reading off the end of the buffer.

Signature · 1 line
dwmw2