Commit cc9b2e9f authored by James Bottomley's avatar James Bottomley

[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: default avatarArtur Wojcik <artur.wojcik@intel.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent c982c368
...@@ -391,6 +391,7 @@ static const char *const enclosure_status [] = { ...@@ -391,6 +391,7 @@ static const char *const enclosure_status [] = {
[ENCLOSURE_STATUS_NOT_INSTALLED] = "not installed", [ENCLOSURE_STATUS_NOT_INSTALLED] = "not installed",
[ENCLOSURE_STATUS_UNKNOWN] = "unknown", [ENCLOSURE_STATUS_UNKNOWN] = "unknown",
[ENCLOSURE_STATUS_UNAVAILABLE] = "unavailable", [ENCLOSURE_STATUS_UNAVAILABLE] = "unavailable",
[ENCLOSURE_STATUS_MAX] = NULL,
}; };
static const char *const enclosure_type [] = { static const char *const enclosure_type [] = {
......
...@@ -42,6 +42,8 @@ enum enclosure_status { ...@@ -42,6 +42,8 @@ enum enclosure_status {
ENCLOSURE_STATUS_NOT_INSTALLED, ENCLOSURE_STATUS_NOT_INSTALLED,
ENCLOSURE_STATUS_UNKNOWN, ENCLOSURE_STATUS_UNKNOWN,
ENCLOSURE_STATUS_UNAVAILABLE, ENCLOSURE_STATUS_UNAVAILABLE,
/* last element for counting purposes */
ENCLOSURE_STATUS_MAX
}; };
/* SFF-8485 activity light settings */ /* SFF-8485 activity light settings */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment