Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4535892ybv; Mon, 10 Feb 2020 21:59:15 -0800 (PST) X-Google-Smtp-Source: APXvYqw23RTjtEsUELN3PFqjWfLYfYtYoe6V74NuyAn46CGqzP7oKU/FkZncqJLlSxrOM/v7Vq7I X-Received: by 2002:aca:b808:: with SMTP id i8mr1829931oif.66.1581400754830; Mon, 10 Feb 2020 21:59:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581400754; cv=none; d=google.com; s=arc-20160816; b=UMY6mco5eZpqQg8QTDO87AjRPxhNAD0Vdepfg2cEA6avBkyRF3Vfaw4hWQQ/14PnwH T+QUQUk+3zHFCXwHEuFCy/+onhf0FtBtSEYQ3ZoXzQYwE5sRp92fdg0KUD2VVw9+Xm8O c487UGHn134dtDsePVtzq7cAZdSwq/NXuut6J8SHG78DIHr611Dx8pOooN+lIdkGpFw3 ORDTR6K2UenmBeVXi5vv+wdOHkDcSAw4rC1M2rWkNBzpybib/TG75+ZKWo7gPRmGmkqD a/3ohvt/7392Z3Syfxug6uuoLT1Rl6gtonD3DAimUkBAR2wJDVFtQimzLKvSnMh1/Ujx uD1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=v3U0+mIdjkZxFjMRlAz4nRXwWSZ5YduhY1Fp2CazuTc=; b=ty4R5537hySiXxNBtm8fiQsFixSBPoOuQsQ91JRWKFas+MttsxdFvjKUKA1IeUWOzV /fpr8orqlGzq2q5JXKCjO/S4At4cOfIpjVRix9rGknX8/58X8t9C75jSEUcSxtKCgirk S0gdxRYYudrSylyjU/tqtDVK1dAIugtG/HESaHGz7Mx+lU0wh+Q6CKLqCfzYRE3CLCn+ vTgyaRBe+leW8hqdkHTT6BzU02P8qb5lF3je36P+vMZdgbrIgCJAYwCLoR+Uu4xXS4KA 8vGmN34UB0MVCOK47TWAhEWRe/GDfk9pteV+haFtYx0lPqKh35WvvydzaxrCpzaEmcCs Ww7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a25si1497765otr.39.2020.02.10.21.59.03; Mon, 10 Feb 2020 21:59:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728078AbgBKFYV (ORCPT + 99 others); Tue, 11 Feb 2020 00:24:21 -0500 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:41683 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727557AbgBKFYU (ORCPT ); Tue, 11 Feb 2020 00:24:20 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04397;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0TpeDbVp_1581398649; Received: from localhost(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0TpeDbVp_1581398649) by smtp.aliyun-inc.com(127.0.0.1); Tue, 11 Feb 2020 13:24:18 +0800 From: Yang Shi To: akpm@linux-foundation.org Cc: yang.shi@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] mm: vmpressure: don't need call kfree if kstrndup fails Date: Tue, 11 Feb 2020 13:24:08 +0800 Message-Id: <1581398649-125989-1-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When kstrndup fails (returns NULL) there is no memory is allocated by kmalloc, so no need to call kfree(). Signed-off-by: Yang Shi --- mm/vmpressure.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mm/vmpressure.c b/mm/vmpressure.c index 4bac22f..0590f00 100644 --- a/mm/vmpressure.c +++ b/mm/vmpressure.c @@ -371,10 +371,8 @@ int vmpressure_register_event(struct mem_cgroup *memcg, int ret = 0; spec_orig = spec = kstrndup(args, MAX_VMPRESSURE_ARGS_LEN, GFP_KERNEL); - if (!spec) { - ret = -ENOMEM; - goto out; - } + if (!spec) + return -ENOMEM; /* Find required level */ token = strsep(&spec, ","); -- 1.8.3.1