summaryrefslogtreecommitdiff
path: root/drivers/scsi/cxlflash
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2015-08-03 18:57:29 +0300
committerJames Bottomley <JBottomley@Odin.com>2015-10-27 05:09:41 +0300
commitb704f70ce2003c8046d5c0128303aeeb0d93d890 (patch)
tree8a922ccd037c8b2f9bc386623d32a18547b42266 /drivers/scsi/cxlflash
parentc42b3654f48bc06189a2d99629c9cf7bb79e8fe3 (diff)
downloadlinux-b704f70ce2003c8046d5c0128303aeeb0d93d890.tar.xz
SCSI: fix bug in scsi_dev_info_list matching
The "compatible" matching algorithm used for looking up old-style blacklist entries in a scsi_dev_info_list is buggy. The core of the algorithm looks like this: if (memcmp(devinfo->vendor, vendor, min(max, strlen(devinfo->vendor)))) /* not a match */ where max is the length of the device's vendor string after leading spaces have been removed but trailing spaces have not. Because of the min() computation, either entry could be a proper substring of the other and the code would still think that they match. In the case originally reported, the device's vendor and product strings were "Inateck " and " ". These matched against the following entry in the global device list: {"", "Scanner", "1.80", BLIST_NOLUN} because "" is a substring of "Inateck " and "" (the result of removing leading spaces from the device's product string) is a substring of "Scanner". The mistaken match prevented the system from scanning and finding the device's second Logical Unit. This patch fixes the problem by making two changes. First, the code for leading-space removal is hoisted out of the loop. (This means it will sometimes run unnecessarily, but since a large percentage of all lookups involve the "compatible" entries in global device list, this should be an overall improvement.) Second and more importantly, the patch removes trailing spaces and adds a check to verify that the two resulting strings are exactly the same length. This prevents matches where one entry is a proper substring of the other. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Reported-by: Giulio Bernardi <ugilio@gmail.com> Tested-by: Giulio Bernardi <ugilio@gmail.com> Signed-off-by: James Bottomley <JBottomley@Odin.com>
Diffstat (limited to 'drivers/scsi/cxlflash')
0 files changed, 0 insertions, 0 deletions