diff options
| author | Max Asbock <masbock@us.ibm.com> | 2005-06-21 20:16:36 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-21 22:07:35 -0400 |
| commit | 8818760512424f60ad9fafb7a087b007a9274eb3 (patch) | |
| tree | fb49ce398750f42803d4631a24e4a2ffe35d79d7 /drivers/misc/ibmasm/ibmasm.h | |
| parent | 278d72ae8803ffcd16070c95fe1d53f4466dc741 (diff) | |
[PATCH] ibmasm driver: fix race in command refcount logic
This patch fixes a race in the command reference counting logic by putting
spinlocks around kobject_put() in the command_put function.
- Also added debug messages.
- Changed a memcpy to memcpy_fromio since we are reading from io space.
Signed-off-by: Max Asbock <masbock@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/misc/ibmasm/ibmasm.h')
| -rw-r--r-- | drivers/misc/ibmasm/ibmasm.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/misc/ibmasm/ibmasm.h b/drivers/misc/ibmasm/ibmasm.h index 653a7d096a8b..ecce4ffd3e23 100644 --- a/drivers/misc/ibmasm/ibmasm.h +++ b/drivers/misc/ibmasm/ibmasm.h | |||
| @@ -95,12 +95,17 @@ struct command { | |||
| 95 | size_t buffer_size; | 95 | size_t buffer_size; |
| 96 | int status; | 96 | int status; |
| 97 | struct kobject kobj; | 97 | struct kobject kobj; |
| 98 | spinlock_t *lock; | ||
| 98 | }; | 99 | }; |
| 99 | #define to_command(c) container_of(c, struct command, kobj) | 100 | #define to_command(c) container_of(c, struct command, kobj) |
| 100 | 101 | ||
| 101 | static inline void command_put(struct command *cmd) | 102 | static inline void command_put(struct command *cmd) |
| 102 | { | 103 | { |
| 104 | unsigned long flags; | ||
| 105 | |||
| 106 | spin_lock_irqsave(cmd->lock, flags); | ||
| 103 | kobject_put(&cmd->kobj); | 107 | kobject_put(&cmd->kobj); |
| 108 | spin_unlock_irqrestore(cmd->lock, flags); | ||
| 104 | } | 109 | } |
| 105 | 110 | ||
| 106 | static inline void command_get(struct command *cmd) | 111 | static inline void command_get(struct command *cmd) |
| @@ -159,7 +164,7 @@ struct service_processor { | |||
| 159 | }; | 164 | }; |
| 160 | 165 | ||
| 161 | /* command processing */ | 166 | /* command processing */ |
| 162 | extern struct command *ibmasm_new_command(size_t buffer_size); | 167 | extern struct command *ibmasm_new_command(struct service_processor *sp, size_t buffer_size); |
| 163 | extern void ibmasm_exec_command(struct service_processor *sp, struct command *cmd); | 168 | extern void ibmasm_exec_command(struct service_processor *sp, struct command *cmd); |
| 164 | extern void ibmasm_wait_for_response(struct command *cmd, int timeout); | 169 | extern void ibmasm_wait_for_response(struct command *cmd, int timeout); |
| 165 | extern void ibmasm_receive_command_response(struct service_processor *sp, void *response, size_t size); | 170 | extern void ibmasm_receive_command_response(struct service_processor *sp, void *response, size_t size); |
