diff mbox series

[V2] mm/mmap_lock: Remove unnecessary 'NULL' values from Pointer

Message ID 20221010034238.3604-1-xupengfei@nfschina.com (mailing list archive)
State New
Headers show
Series [V2] mm/mmap_lock: Remove unnecessary 'NULL' values from Pointer | expand

Commit Message

XU pengfei Oct. 10, 2022, 3:42 a.m. UTC
Pointer variables allocate memory first, and then judge. There is no
need to initialize the assignment.

Signed-off-by: XU pengfei <xupengfei@nfschina.com>
Reported-by: kernel test robot <lkp@intel.com>
---
 V2: Remove goto statement

 mm/mmap_lock.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

Comments

Matthew Wilcox Oct. 10, 2022, 3:46 a.m. UTC | #1
On Mon, Oct 10, 2022 at 11:42:38AM +0800, XU pengfei wrote:
> Pointer variables allocate memory first, and then judge. There is no
> need to initialize the assignment.

This seems worse to me.
diff mbox series

Patch

diff --git a/mm/mmap_lock.c b/mm/mmap_lock.c
index 1854850b4b89..d0c2a5eae341 100644
--- a/mm/mmap_lock.c
+++ b/mm/mmap_lock.c
@@ -198,23 +198,24 @@  void trace_mmap_lock_unreg(void)
  */
 static const char *get_mm_memcg_path(struct mm_struct *mm)
 {
-	char *buf = NULL;
+	char *buf;
 	struct mem_cgroup *memcg = get_mem_cgroup_from_mm(mm);
 
 	if (memcg == NULL)
-		goto out;
-	if (unlikely(memcg->css.cgroup == NULL))
-		goto out_put;
+		return NULL;
+	if (unlikely(memcg->css.cgroup == NULL)) {
+		css_put(&memcg->css);
+		return NULL;
+	}
 
 	buf = get_memcg_path_buf();
-	if (buf == NULL)
-		goto out_put;
+	if (buf == NULL) {
+		css_put(&memcg->css);
+		return NULL;
+	}
 
 	cgroup_path(memcg->css.cgroup, buf, MEMCG_PATH_BUF_SIZE);
 
-out_put:
-	css_put(&memcg->css);
-out:
 	return buf;
 }