From 378afc5093099b7e8c7b9442815027d44dcbce93 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 2baa40900..1231b226f 100644 --- a/devicemodel/hw/pci/virtio/virtio_mei.c +++ b/devicemodel/hw/pci/virtio/virtio_mei.c @@ -766,12 +766,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)