From 2067a3d5aa940dac237d388131e661da137799fa Mon Sep 17 00:00:00 2001 From: Alexander Usyskin Date: Mon, 19 Nov 2018 10:24:08 +0200 Subject: [PATCH] dm: mei: fix clients scan in sysfs Fix the prefix comparison, we need to compare on prefix length, not on devpath len, otherwise we always fail. Tracked-On: #1848 Signed-off-by: Alexander Usyskin Signed-off-by: Tomas Winkler Acked-by: Acked-by: Yu Wang --- devicemodel/hw/pci/virtio/virtio_mei.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/devicemodel/hw/pci/virtio/virtio_mei.c b/devicemodel/hw/pci/virtio/virtio_mei.c index ba4bdb8e7..f50c587a1 100644 --- a/devicemodel/hw/pci/virtio/virtio_mei.c +++ b/devicemodel/hw/pci/virtio/virtio_mei.c @@ -793,12 +793,13 @@ static int mei_sysfs_read_properties(char *devpath, size_t size, size_t offset, return 0; } + static bool is_prefix(const char *prfx, const char *str, size_t maxlen) { - if (!prfx || !str || prfx[0] == '\0') + if (!prfx || !str) return false; - return strncmp(prfx, str, maxlen); + return strncmp(prfx, str, strnlen(prfx, maxlen)) == 0; } static int vmei_me_client_scan_list(struct virtio_mei *vmei)