diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2015-04-28 21:46:24 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2015-04-28 21:46:24 +0200 |
commit | 30c99c130dbf9d5bea342c16d5bdc4ae12e402f2 (patch) | |
tree | 995065e2f4bb014cbb92f5459b50cd0bc400f090 /pcilib | |
parent | 4f4d155d5555997a966aefe2aa1d91fc96765d2a (diff) | |
download | pcitool-30c99c130dbf9d5bea342c16d5bdc4ae12e402f2.tar.gz pcitool-30c99c130dbf9d5bea342c16d5bdc4ae12e402f2.tar.bz2 pcitool-30c99c130dbf9d5bea342c16d5bdc4ae12e402f2.tar.xz pcitool-30c99c130dbf9d5bea342c16d5bdc4ae12e402f2.zip |
Check event interface version for plugins
Diffstat (limited to 'pcilib')
-rw-r--r-- | pcilib/plugin.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/pcilib/plugin.c b/pcilib/plugin.c index 663bb27..12dbf1d 100644 --- a/pcilib/plugin.c +++ b/pcilib/plugin.c @@ -7,6 +7,7 @@ #include <sys/types.h> #include "model.h" +#include "error.h" #include "pci.h" #include "config.h" @@ -42,13 +43,22 @@ void *pcilib_plugin_get_symbol(void *plug, const char *symbol) { const pcilib_model_description_t *pcilib_get_plugin_model(pcilib_t *pcilib, void *plug, unsigned short vendor_id, unsigned short device_id, const char *model) { void *get_model; + const pcilib_model_description_t *model_info; if (!plug) return NULL; get_model = dlsym(plug, "pcilib_get_event_model"); if (!get_model) return NULL; - return ((const pcilib_model_description_t *(*)(pcilib_t *pcilib, unsigned short vendor_id, unsigned short device_id, const char *model))get_model)(pcilib, vendor_id, device_id, model); + model_info = ((const pcilib_model_description_t *(*)(pcilib_t *pcilib, unsigned short vendor_id, unsigned short device_id, const char *model))get_model)(pcilib, vendor_id, device_id, model); + if (!model_info) return model_info; + + if (model_info->interface_version != PCILIB_EVENT_INTERFACE_VERSION) { + pcilib_warning("Plugin %s exposes outdated interface version (%lu), pcitool supports (%lu)", model_info->name, model_info->interface_version, PCILIB_EVENT_INTERFACE_VERSION); + return NULL; + } + + return model_info; } const pcilib_model_description_t *pcilib_find_plugin_model(pcilib_t *pcilib, unsigned short vendor_id, unsigned short device_id, const char *model) { |