ibmasm driver: don't use previously freed pointer
PATCH 1/1 ibmasm driver: don't use previously freed pointer
ibmasm driver:
Fix the command_put() function which uses a pointer for a spinlock that can be freed before dereferencing it.
---
drivers/misc/ibmasm/ibmasm.h +3 -2
@@ -101,10 +101,11 @@ struct command {static inline void command_put (struct command *cmd) {unsigned long flags; +spinlock_t *lock = cmd->lock; -spin_lock_irqsave (cmd->lock, flags); +spin_lock_irqsave (lock, flags);kobject_put (&cmd->kobj); -spin_unlock_irqrestore (cmd->lock, flags); +spin_unlock_irqrestore (lock, flags); }static inline void command_get (struct command *cmd)
Quoted 13 lines · Max Asbock
ibmasm driver:
Fix thecommand_put()function which uses a pointer for a spinlock that can be freed before dereferencing it.Signed-off-by Max Asbock [email protected]---
diff -burpN
linux-2.6.16-rc1/drivers/misc/ibmasm/ibmasm.hlinux-2.6.16-rc1.ibmasm/drivers/misc/ibmasm/ibmasm.hdrivers/misc/ibmasm/ibmasm.h +0
-0@@ -101,10 +101,11 @@ struct command {static inline void command_put (struct command *cmd)
drivers/misc/ibmasm/ibmasm.h struct command { · line 109
Quoted 10 lines
drivers/misc/ibmasm/ibmasm.h +3
-2{unsigned long flags; +spinlock_t *lock = cmd->lock; -spin_lock_irqsave (cmd->lock, flags); +spin_lock_irqsave (lock, flags);kobject_put (&cmd->kobj); -spin_unlock_irqrestore (cmd->lock, flags); +spin_unlock_irqrestore (lock, flags); }
If this patch is true, doesn't the spinlock the pointer is pointing out still get deleted?
Yes you save a pointer off, but it looks like the problem is still present.
Or am I missing something?
thanks,
greg k-h
Quoted 28 lines · Greg KH
Quoted 13 lines · Max Asbock
ibmasm driver:
Fix thecommand_put()function which uses a pointer for a spinlock that can be freed before dereferencing it.Signed-off-by Max Asbock [email protected]---
diff -burpN
linux-2.6.16-rc1/drivers/misc/ibmasm/ibmasm.hlinux-2.6.16-rc1.ibmasm/drivers/misc/ibmasm/ibmasm.hdrivers/misc/ibmasm/ibmasm.h +0
-0@@ -101,10 +101,11 @@ struct command {static inline void command_put (struct command *cmd)drivers/misc/ibmasm/ibmasm.h struct command { · line 109
Quoted 10 lines
drivers/misc/ibmasm/ibmasm.h +3
-2{unsigned long flags; +spinlock_t *lock = cmd->lock; -spin_lock_irqsave (cmd->lock, flags); +spin_lock_irqsave (lock, flags);kobject_put (&cmd->kobj); -spin_unlock_irqrestore (cmd->lock, flags); +spin_unlock_irqrestore (lock, flags); }If this patch is true, doesn't the spinlock the pointer is pointing out still get deleted?
Quoted 5 lines
Yes you save a pointer off, but it looks like the problem is still present.
Or am I missing something?
The lock pointer in struct command points to a spinlock outside the structure that doesn't get deleted.
max
Quoted 29 lines · Max Asbock
Quoted 28 lines · Greg KH
Quoted 13 lines · Max Asbock
ibmasm driver:
Fix thecommand_put()function which uses a pointer for a spinlock that can be freed before dereferencing it.Signed-off-by Max Asbock [email protected]---
diff -burpN
linux-2.6.16-rc1/drivers/misc/ibmasm/ibmasm.hlinux-2.6.16-rc1.ibmasm/drivers/misc/ibmasm/ibmasm.hdrivers/misc/ibmasm/ibmasm.h +0
-0@@ -101,10 +101,11 @@ struct command {static inline void command_put (struct command *cmd)drivers/misc/ibmasm/ibmasm.h struct command { · line 109
Quoted 10 lines
drivers/misc/ibmasm/ibmasm.h +3
-2{unsigned long flags; +spinlock_t *lock = cmd->lock; -spin_lock_irqsave (cmd->lock, flags); +spin_lock_irqsave (lock, flags);kobject_put (&cmd->kobj); -spin_unlock_irqrestore (cmd->lock, flags); +spin_unlock_irqrestore (lock, flags); }If this patch is true, doesn't the spinlock the pointer is pointing out still get deleted?
Quoted 8 lines
Quoted 5 lines
Yes you save a pointer off, but it looks like the problem is still present.
Or am I missing something?
The lock pointer in struct command points to a spinlock outside the structure that doesn't get deleted.
Ok, that's what I was missing, nevermind then :)
thanks,
greg k-h