Merge pull request #641 from joe-lawrence/sparse_smatch

Fix static code analyzer complaints
This commit is contained in:
Jessica Yu 2016-12-16 16:50:34 -08:00 committed by GitHub
commit 86e21e9b9e
2 changed files with 9 additions and 6 deletions

View File

@ -66,7 +66,7 @@ static DEFINE_HASHTABLE(kpatch_func_hash, KPATCH_HASH_BITS);
static DEFINE_SEMAPHORE(kpatch_mutex);
LIST_HEAD(kpmod_list);
static LIST_HEAD(kpmod_list);
static int kpatch_num_patched;
@ -641,11 +641,11 @@ static int kpatch_write_relocations(struct kpatch_module *kpmod,
( LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) && \
UTS_UBUNTU_RELEASE_ABI >= 7 ) \
)
unsigned long core = (unsigned long)kpmod->mod->core_layout.base;
unsigned long core_size = kpmod->mod->core_layout.size;
unsigned long core = (unsigned long)kpmod->mod->core_layout.base;
unsigned long core_size = kpmod->mod->core_layout.size;
#else
unsigned long core = (unsigned long)kpmod->mod->module_core;
unsigned long core_size = kpmod->mod->core_size;
unsigned long core = (unsigned long)kpmod->mod->module_core;
unsigned long core_size = kpmod->mod->core_size;
#endif
list_for_each_entry(dynrela, &object->dynrelas, list) {

View File

@ -93,8 +93,10 @@ void *kpatch_shadow_alloc(void *obj, char *var, size_t size, gfp_t gfp)
shadow->obj = obj;
shadow->var = kstrdup(var, gfp);
if (!shadow->var)
if (!shadow->var) {
kfree(shadow);
return NULL;
}
if (size <= sizeof(shadow->data)) {
shadow->data = &shadow->data;
@ -103,6 +105,7 @@ void *kpatch_shadow_alloc(void *obj, char *var, size_t size, gfp_t gfp)
shadow->data = kmalloc(size, gfp);
if (!shadow->data) {
kfree(shadow->var);
kfree(shadow);
return NULL;
}
}