diff options
author | James Bottomley <James.Bottomley@suse.de> | 2009-11-26 10:50:20 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2009-12-10 09:54:14 -0500 |
commit | cc9b2e9f6603190c009e5d2629ce8e3f99571346 (patch) | |
tree | 922a81bd0d58261927da86342f005201cc1087a5 | |
parent | c982c368bb90adbd312faa05d0cfd842e9ab45a7 (diff) |
[SCSI] enclosure: fix oops while iterating enclosure_status array
Based on patch originally by Jeff Mahoney <jeffm@suse.com>
enclosure_status is expected to be a NULL terminated array of strings
but isn't actually NULL terminated. When writing an invalid value to
/sys/class/enclosure/.../.../status, it goes off the end of the array
and Oopses.
Fix by making the assumption true and adding NULL at the end.
Reported-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
-rw-r--r-- | drivers/misc/enclosure.c | 1 | ||||
-rw-r--r-- | include/linux/enclosure.h | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c index e9eae4a78402..1eac626e710a 100644 --- a/drivers/misc/enclosure.c +++ b/drivers/misc/enclosure.c | |||
@@ -391,6 +391,7 @@ static const char *const enclosure_status [] = { | |||
391 | [ENCLOSURE_STATUS_NOT_INSTALLED] = "not installed", | 391 | [ENCLOSURE_STATUS_NOT_INSTALLED] = "not installed", |
392 | [ENCLOSURE_STATUS_UNKNOWN] = "unknown", | 392 | [ENCLOSURE_STATUS_UNKNOWN] = "unknown", |
393 | [ENCLOSURE_STATUS_UNAVAILABLE] = "unavailable", | 393 | [ENCLOSURE_STATUS_UNAVAILABLE] = "unavailable", |
394 | [ENCLOSURE_STATUS_MAX] = NULL, | ||
394 | }; | 395 | }; |
395 | 396 | ||
396 | static const char *const enclosure_type [] = { | 397 | static const char *const enclosure_type [] = { |
diff --git a/include/linux/enclosure.h b/include/linux/enclosure.h index 90d1c2184112..9a33c5f7e126 100644 --- a/include/linux/enclosure.h +++ b/include/linux/enclosure.h | |||
@@ -42,6 +42,8 @@ enum enclosure_status { | |||
42 | ENCLOSURE_STATUS_NOT_INSTALLED, | 42 | ENCLOSURE_STATUS_NOT_INSTALLED, |
43 | ENCLOSURE_STATUS_UNKNOWN, | 43 | ENCLOSURE_STATUS_UNKNOWN, |
44 | ENCLOSURE_STATUS_UNAVAILABLE, | 44 | ENCLOSURE_STATUS_UNAVAILABLE, |
45 | /* last element for counting purposes */ | ||
46 | ENCLOSURE_STATUS_MAX | ||
45 | }; | 47 | }; |
46 | 48 | ||
47 | /* SFF-8485 activity light settings */ | 49 | /* SFF-8485 activity light settings */ |