From patchwork Mon Oct 10 03:42:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: XU pengfei X-Patchwork-Id: 13002238 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDFDBC433F5 for ; Mon, 10 Oct 2022 03:42:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D86DD6B0071; Sun, 9 Oct 2022 23:42:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D364B6B0073; Sun, 9 Oct 2022 23:42:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD6B26B0074; Sun, 9 Oct 2022 23:42:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A7A5E6B0071 for ; Sun, 9 Oct 2022 23:42:50 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6AF9D120AA7 for ; Mon, 10 Oct 2022 03:42:50 +0000 (UTC) X-FDA: 80003643300.07.D803129 Received: from mail.nfschina.com (unknown [124.16.136.209]) by imf28.hostedemail.com (Postfix) with ESMTP id 0574FC0023 for ; Mon, 10 Oct 2022 03:42:48 +0000 (UTC) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id 965ED1E80D90; Mon, 10 Oct 2022 11:36:43 +0800 (CST) X-Virus-Scanned: amavisd-new at test.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (mail.nfschina.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dBUciL1iuwIY; Mon, 10 Oct 2022 11:36:41 +0800 (CST) Received: from localhost.localdomain.localdomain (unknown [219.141.250.2]) (Authenticated sender: xupengfei@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 5FD971E80D4B; Mon, 10 Oct 2022 11:36:39 +0800 (CST) From: XU pengfei To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, XU pengfei Subject: [PATCH V2] mm/mmap_lock: Remove unnecessary 'NULL' values from Pointer Date: Mon, 10 Oct 2022 11:42:38 +0800 Message-Id: <20221010034238.3604-1-xupengfei@nfschina.com> X-Mailer: git-send-email 2.18.2 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665373370; a=rsa-sha256; cv=none; b=7ZFmesI+jeK5Tx7q50VLHwNgo/cXQQE3Qju5oV3kObydP23MHnkB8j5CcKIoPrVvLKIQx7 ntTS1x6pupDBZ4hen0a98/TBWH3PWzqATPY97zVoxzQ26sGOjRuln9lXNm+i0RTyBqrZAZ KsVyxun5PJ1o5UUeaIRGTdSPXANeqQg= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; spf=none (imf28.hostedemail.com: domain of xupengfei@nfschina.com has no SPF policy when checking 124.16.136.209) smtp.mailfrom=xupengfei@nfschina.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665373370; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=u2NhwlEyUe4Xxw902zfC5vzlMXBjBlMjWjZDRYLckPo=; b=HMUepZ4dHlv607vQj92TRsD2jTFRWfjMjBnscF/7roODbq1MS+gPJ/yt++q6W+8xwP1zKL mfoi749097FYrTQMjE5c0WZ+5QIIeuyTueHjtUS/jBQ8z6P7RGmFz+en50xuAd3OKbicMD ril0ZPYl4FLsdFn8aMhT9UB1/hf8dRQ= Authentication-Results: imf28.hostedemail.com; dkim=none; spf=none (imf28.hostedemail.com: domain of xupengfei@nfschina.com has no SPF policy when checking 124.16.136.209) smtp.mailfrom=xupengfei@nfschina.com; dmarc=none X-Stat-Signature: 9bzxpuysr7x3s3bmfetusm463779jrr5 X-Rspamd-Queue-Id: 0574FC0023 X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1665373368-899705 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Pointer variables allocate memory first, and then judge. There is no need to initialize the assignment. Signed-off-by: XU pengfei Reported-by: kernel test robot --- V2: Remove goto statement mm/mmap_lock.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) 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; }