diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-01-02 14:56:51 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-01-02 14:56:51 +0100 |
commit | 8c9076b07c99c2a37a96b9f5265e4def47823c86 (patch) | |
tree | 368e59df54d7b7ea02d8a626ac85e751883f6836 /lib/kobject_uevent.c | |
parent | 59e73854b5fd1213fe90ae993d98c759786c3712 (diff) | |
parent | 30a7acd573899fd8b8ac39236eff6468b195ac7d (diff) |
Merge 4.15-rc6 into driver-core-next
We want the fixes in here as well.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'lib/kobject_uevent.c')
-rw-r--r-- | lib/kobject_uevent.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c index cc7e2c46273b..9fe6ec8fda28 100644 --- a/lib/kobject_uevent.c +++ b/lib/kobject_uevent.c @@ -345,7 +345,8 @@ static int kobject_uevent_net_broadcast(struct kobject *kobj, static void zap_modalias_env(struct kobj_uevent_env *env) { static const char modalias_prefix[] = "MODALIAS="; - int i; + size_t len; + int i, j; for (i = 0; i < env->envp_idx;) { if (strncmp(env->envp[i], modalias_prefix, @@ -354,11 +355,18 @@ static void zap_modalias_env(struct kobj_uevent_env *env) continue; } - if (i != env->envp_idx - 1) - memmove(&env->envp[i], &env->envp[i + 1], - sizeof(env->envp[i]) * env->envp_idx - 1); + len = strlen(env->envp[i]) + 1; + + if (i != env->envp_idx - 1) { + memmove(env->envp[i], env->envp[i + 1], + env->buflen - len); + + for (j = i; j < env->envp_idx - 1; j++) + env->envp[j] = env->envp[j + 1] - len; + } env->envp_idx--; + env->buflen -= len; } } |