diff options
author | Mingkai Hu <Mingkai.hu@freescale.com> | 2012-04-15 22:05:06 -0400 |
---|---|---|
committer | Kumar Gala <galak@kernel.crashing.org> | 2012-04-19 15:55:56 -0400 |
commit | e0a5a6c38190a5016bcb0f1267324a19b846a35a (patch) | |
tree | 7b8c6f20b23303f6d6cca4d32010fab70bc73b7b /arch/powerpc/sysdev | |
parent | bdce27c7f7bc7cf5c3a264bab9de056bd9cb0c9d (diff) |
powerpc/mpic_msgr: add lock for MPIC message global variable
Also fix issue of accessing invalid msgr pointer issue. The local
msgr pointer in fucntion mpic_msgr_get will be accessed before
getting a valid address which will cause kernel crash.
Signed-off-by: Mingkai Hu <Mingkai.hu@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/sysdev')
-rw-r--r-- | arch/powerpc/sysdev/mpic_msgr.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/arch/powerpc/sysdev/mpic_msgr.c b/arch/powerpc/sysdev/mpic_msgr.c index 6e7fa386e76a..dc1cfe380070 100644 --- a/arch/powerpc/sysdev/mpic_msgr.c +++ b/arch/powerpc/sysdev/mpic_msgr.c | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | static struct mpic_msgr **mpic_msgrs; | 28 | static struct mpic_msgr **mpic_msgrs; |
29 | static unsigned int mpic_msgr_count; | 29 | static unsigned int mpic_msgr_count; |
30 | static DEFINE_RAW_SPINLOCK(msgrs_lock); | ||
30 | 31 | ||
31 | static inline void _mpic_msgr_mer_write(struct mpic_msgr *msgr, u32 value) | 32 | static inline void _mpic_msgr_mer_write(struct mpic_msgr *msgr, u32 value) |
32 | { | 33 | { |
@@ -56,12 +57,11 @@ struct mpic_msgr *mpic_msgr_get(unsigned int reg_num) | |||
56 | if (reg_num >= mpic_msgr_count) | 57 | if (reg_num >= mpic_msgr_count) |
57 | return ERR_PTR(-ENODEV); | 58 | return ERR_PTR(-ENODEV); |
58 | 59 | ||
59 | raw_spin_lock_irqsave(&msgr->lock, flags); | 60 | raw_spin_lock_irqsave(&msgrs_lock, flags); |
60 | if (mpic_msgrs[reg_num]->in_use == MSGR_FREE) { | 61 | msgr = mpic_msgrs[reg_num]; |
61 | msgr = mpic_msgrs[reg_num]; | 62 | if (msgr->in_use == MSGR_FREE) |
62 | msgr->in_use = MSGR_INUSE; | 63 | msgr->in_use = MSGR_INUSE; |
63 | } | 64 | raw_spin_unlock_irqrestore(&msgrs_lock, flags); |
64 | raw_spin_unlock_irqrestore(&msgr->lock, flags); | ||
65 | 65 | ||
66 | return msgr; | 66 | return msgr; |
67 | } | 67 | } |