* [2.4] [PATCH] Fix possible memleaks in VIA IrDA driver
@ 2004-05-09 12:08 Oleg Drokin
0 siblings, 0 replies; only message in thread
From: Oleg Drokin @ 2004-05-09 12:08 UTC (permalink / raw)
To: marcelo.tosatti, linux-kernel
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;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-05-09 12:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-09 12:08 [2.4] [PATCH] Fix possible memleaks in VIA IrDA driver Oleg Drokin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox