diff --git a/config/udev.c b/config/udev.c index bbbda802d34b280fa537ecfeea7def26b381b056..c51bda98a167d0fee1653b3c4bd8895bcf152189 100644 --- a/config/udev.c +++ b/config/udev.c @@ -477,6 +477,31 @@ config_udev_fini(void) #ifdef CONFIG_UDEV_KMS +/* Find the last occurrence of the needle in haystack */ +static char *strrstr(const char *haystack, const char *needle) +{ + char *prev, *last, *tmp; + + prev = strstr(haystack, needle); + if (!prev) + return NULL; + + last = prev; + tmp = prev + 1; + + while (tmp) { + last = strstr(tmp, needle); + if (!last) + return prev; + else { + prev = last; + tmp = prev + 1; + } + } + + return last; +} + static void config_udev_odev_setup_attribs(struct udev_device *udev_device, const char *path, const char *syspath, int major, int minor, @@ -491,7 +516,7 @@ config_udev_odev_setup_attribs(struct udev_device *udev_device, const char *path attribs->minor = minor; value = udev_device_get_property_value(udev_device, "ID_PATH"); - if (value && (str = strstr(value, "pci-"))) { + if (value && (str = strrstr(value, "pci-"))) { attribs->busid = XNFstrdup(str); attribs->busid[3] = ':'; }