Skip to content

Commit

Permalink
[SCSI] enclosure: fix oops while iterating enclosure_status array
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
James Bottomley authored and James Bottomley committed Dec 10, 2009
1 parent c982c36 commit cc9b2e9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/misc/enclosure.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ static const char *const enclosure_status [] = {
[ENCLOSURE_STATUS_NOT_INSTALLED] = "not installed",
[ENCLOSURE_STATUS_UNKNOWN] = "unknown",
[ENCLOSURE_STATUS_UNAVAILABLE] = "unavailable",
[ENCLOSURE_STATUS_MAX] = NULL,
};

static const char *const enclosure_type [] = {
Expand Down
2 changes: 2 additions & 0 deletions include/linux/enclosure.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ enum enclosure_status {
ENCLOSURE_STATUS_NOT_INSTALLED,
ENCLOSURE_STATUS_UNKNOWN,
ENCLOSURE_STATUS_UNAVAILABLE,
/* last element for counting purposes */
ENCLOSURE_STATUS_MAX
};

/* SFF-8485 activity light settings */
Expand Down

0 comments on commit cc9b2e9

Please sign in to comment.