public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi_devinfo: fixup string compare
@ 2017-08-04  9:40 Hannes Reinecke
  2017-08-04 15:32 ` Bart Van Assche
  0 siblings, 1 reply; 5+ messages in thread
From: Hannes Reinecke @ 2017-08-04  9:40 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	Hannes Reinecke

When checking the model and vendor string we need to use the
minimum value of either string, otherwise we'll miss out on
wildcard matches.
Without this patch certain Hitachi arrays will not be presenting
VPD pages correctly.

Fixes: 5e7ff2c ("SCSI: fix new bug in scsi_dev_info_list string matching")
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/scsi_devinfo.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
index 28fea83..f8a302f 100644
--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -456,11 +456,13 @@ static struct scsi_dev_info_list *scsi_dev_info_list_find(const char *vendor,
 			/*
 			 * Behave like the older version of get_device_flags.
 			 */
-			if (memcmp(devinfo->vendor, vskip, vmax) ||
+			if (memcmp(devinfo->vendor, vskip,
+				   min(vmax, strlen(devinfo->vendor))) ||
 					(vmax < sizeof(devinfo->vendor) &&
 						devinfo->vendor[vmax]))
 				continue;
-			if (memcmp(devinfo->model, mskip, mmax) ||
+			if (memcmp(devinfo->model, mskip,
+				   min(mmax, strlen(devinfo->model))) ||
 					(mmax < sizeof(devinfo->model) &&
 						devinfo->model[mmax]))
 				continue;
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-08-08 14:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-04  9:40 [PATCH] scsi_devinfo: fixup string compare Hannes Reinecke
2017-08-04 15:32 ` Bart Van Assche
2017-08-04 16:28   ` Hannes Reinecke
2017-08-04 16:38     ` Bart Van Assche
2017-08-08 14:28       ` Hannes Reinecke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox