All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm, vmpressure: free the same pointer we allocated
@ 2017-06-13 19:18 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2017-06-13 19:18 UTC (permalink / raw)
  To: Andrew Morton, David Rientjes
  Cc: Minchan Kim, Vinayak Menon, Michal Hocko, linux-mm, kernel-janitors

We keep incrementing "spec" as we parse the args so we end up calling
kfree() on a modified of spec.  It probably works or this would have
been caught in testing, but it looks weird.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/mm/vmpressure.c b/mm/vmpressure.c
index 0781b1363e0a..1225ec5d9596 100644
--- a/mm/vmpressure.c
+++ b/mm/vmpressure.c
@@ -386,11 +386,11 @@ int vmpressure_register_event(struct mem_cgroup *memcg,
 	struct vmpressure_event *ev;
 	enum vmpressure_modes mode = VMPRESSURE_NO_PASSTHROUGH;
 	enum vmpressure_levels level = -1;
-	char *spec = NULL;
+	char *spec, *spec_orig;
 	char *token;
 	int ret = 0;
 
-	spec = kzalloc(MAX_VMPRESSURE_ARGS_LEN + 1, GFP_KERNEL);
+	spec_orig = spec = kzalloc(MAX_VMPRESSURE_ARGS_LEN + 1, GFP_KERNEL);
 	if (!spec) {
 		ret = -ENOMEM;
 		goto out;
@@ -429,7 +429,7 @@ int vmpressure_register_event(struct mem_cgroup *memcg,
 	list_add(&ev->node, &vmpr->events);
 	mutex_unlock(&vmpr->events_lock);
 out:
-	kfree(spec);
+	kfree(spec_orig);
 	return ret;
 }
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-06-15  1:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-13 19:18 [PATCH] mm, vmpressure: free the same pointer we allocated Dan Carpenter
2017-06-13 19:18 ` Dan Carpenter
2017-06-15  1:49 ` David Rientjes
2017-06-15  1:49   ` David Rientjes

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.