public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* dpt_i2o.c memleak/incorrectness
@ 2003-03-13 18:28 Oleg Drokin
  2003-03-13 19:44 ` Alan Cox
  0 siblings, 1 reply; 15+ messages in thread
From: Oleg Drokin @ 2003-03-13 18:28 UTC (permalink / raw)
  To: alan, linux-kernel; +Cc: deanna_bonds

Hello!

   There is something strange going on in drivers/scsi/dpt_i2o.c in both
   2.4 and 2.5. adpt_i2o_reset_hba() function allocates 4 bytes 
   for "status" stuff, then tries to reset controller, then 
   if timeout on first reset stage is reached, frees "status" and returns,
   otherwise it proceeds to monitor "status" (which is modified by hardware
   now, btw), and if timeout is reached, just exits.
   On the first thought I just thought it is trivial memleak that can be
   fixed with patch below, but after some more thining I just thought
   "what if after some time controller awakes and modifies status,
   but it is already allocated for other purposes", scary eh?
   So may be we shold not free those four bytes on timeout at all just
   for safeness reasons?

   Found with help of smatch + enhanced unfree script.

Bye,
    Oleg

===== drivers/scsi/dpt_i2o.c 1.9 vs edited =====
--- 1.9/drivers/scsi/dpt_i2o.c	Wed Jan  8 18:26:13 2003
+++ edited/drivers/scsi/dpt_i2o.c	Thu Mar 13 21:17:10 2003
@@ -1336,6 +1336,7 @@
 			}
 			if(time_after(jiffies,timeout)){
 				printk(KERN_ERR "%s:Timeout waiting for IOP Reset.\n",pHba->name);
+				kfree(status);
 				return -ETIMEDOUT;
 			}
 		} while (m == EMPTY_QUEUE);

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2003-03-15 18:09 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-03-13 18:28 dpt_i2o.c memleak/incorrectness Oleg Drokin
2003-03-13 19:44 ` Alan Cox
2003-03-13 18:41   ` dpt_i2o.c fix for possibly memory corruption on reset timeout Oleg Drokin
2003-03-13 18:51     ` Randy.Dunlap
2003-03-13 18:56       ` Oleg Drokin
2003-03-14  9:18         ` Denis Vlasenko
2003-03-14 12:02           ` Joern Engel
2003-03-14 14:19           ` Alan Cox
2003-03-14 13:39             ` Joern Engel
2003-03-14 13:43               ` Oleg Drokin
2003-03-14 15:26                 ` Alan Cox
2003-03-13 18:58   ` dpt_i2o.c memleak/incorrectness Bryan Andersen
2003-03-15 16:15     ` Horst von Brand
2003-03-13 19:38   ` Now i2o_core.c memleak/incorrectness? Oleg Drokin
2003-03-14  0:42     ` Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox