[2.4] [PATCH] Fix possible memleaks in VIA IrDA driver

From: Oleg Drokin
Date: Sun May 09 2004 - 07:09:32 EST


Hello!

Patch below fixes some possible memleaks in VIA IrDA driver, also
checks for skb->data being non-NULL are dropped since alloc_skb
cannot return such skbs as far as I can see.

Bye,

Oleg
===== drivers/net/irda/via-ircc.c 1.3 vs edited =====
--- 1.3/drivers/net/irda/via-ircc.c Fri Jan 30 21:14:14 2004
+++ edited/drivers/net/irda/via-ircc.c Sun May 9 15:01:34 2004
@@ -1142,13 +1142,16 @@
st_fifo->head++;
st_fifo->len--;

- skb = dev_alloc_skb(len + 1 - 4);
/*
- * if frame size,data ptr,or skb ptr are wrong ,the get next
+ * if frame size or data ptr are wrong ,then get next
* entry.
*/
- if ((skb == NULL) || (skb->data == NULL)
- || (self->rx_buff.data == NULL) || (len < 6)) {
+ if ((self->rx_buff.data == NULL) || (len < 6)) {
+ self->stats.rx_dropped++;
+ return TRUE;
+ }
+ skb = dev_alloc_skb(len + 1 - 4);
+ if (!skb) {
self->stats.rx_dropped++;
return TRUE;
}
@@ -1194,8 +1197,12 @@
#ifdef DBGMSG
DBG(printk(KERN_INFO "upload_rxdata: len=%x\n", len));
#endif
+ if ((len - 4) < 2) {
+ self->stats.rx_dropped++;
+ return FALSE;
+ }
skb = dev_alloc_skb(len + 1);
- if ((skb == NULL) || ((len - 4) < 2)) {
+ if (!skb) {
self->stats.rx_dropped++;
return FALSE;
}
@@ -1258,13 +1265,17 @@
st_fifo->head++;
st_fifo->len--;

- skb = dev_alloc_skb(len + 1 - 4);
/*
- * if frame size, data ptr, or skb ptr are wrong,
+ * if frame size or data ptr are wrong,
* then get next entry.
*/
- if ((skb == NULL) || (skb->data == NULL)
- || (self->rx_buff.data == NULL) || (len < 6)) {
+ if ((self->rx_buff.data == NULL) || (len < 6)) {
+ self->stats.rx_dropped++;
+ continue;
+ }
+
+ skb = dev_alloc_skb(len + 1 - 4);
+ if (!skb) {
self->stats.rx_dropped++;
continue;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/