From patchwork Thu May 3 20:18:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 10379167 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D576860159 for ; Thu, 3 May 2018 20:18:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7EA928389 for ; Thu, 3 May 2018 20:18:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA6E228418; Thu, 3 May 2018 20:18:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7924528389 for ; Thu, 3 May 2018 20:18:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1AA966B0003; Thu, 3 May 2018 16:18:12 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1599B6B0007; Thu, 3 May 2018 16:18:12 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 096B26B0009; Thu, 3 May 2018 16:18:12 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id CB60A6B0003 for ; Thu, 3 May 2018 16:18:11 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id c4so15910246pfg.22 for ; Thu, 03 May 2018 13:18:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=PbZ/10ddijXIeIyUueme8UnyoMjyA9mkjg8a4ppD/fU=; b=RQufTiO61yx+UT7W509LsqXr/9Wi6yo/WLxBpLZJ54HuDnkjpvws3mZJd1NDyubXHp KGepdJ8YxF0oUWS3r+wwmxbOef8yU6F6HcG5H4JkMxk16fkJFfOzSKIbo2PCnnaSp+bv u2kURv4hcO8wEYeBYgsETt/4ZxJ97d6kb2E2t23e0KI9+Uf9YkPBs68JKdDIO9C3P9Io tpGSV/qjS3prDGQCWdUYrp55fEe3prj51EIoN+FFKNcfvXtaFUIOfrcOLrdbC2K3b725 4gRl3zL8BZNurg4Ycy9uAhYdmERZONwi6gbBjvZHBkQuONvM7HBa267YDiaCQR1Ai8TT l3/A== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of andriy.shevchenko@linux.intel.com designates 192.55.52.120 as permitted sender) smtp.mailfrom=andriy.shevchenko@linux.intel.com X-Gm-Message-State: ALQs6tCqvtNXXJIwxw/g+z0E8EEDp83e5bZYT/strCYr2wSxGzgfWR4O wsERV2xFBVG77JB5ZJcpRYG8GUmfFmtE8FLXxqB/VUliSKvEUZUVQQNoJ8HfQOfwy93QXfFiG2y ttOZUNDLXfjtM8ZraLbakyKdgBDGgHlG7SS0+DGqBa4E21m0absN36eDdVkBg7SXpgw== X-Received: by 10.98.75.139 with SMTP id d11mr24347506pfj.244.1525378691472; Thu, 03 May 2018 13:18:11 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqK9eso/r5GchrwjK1fRY8tvplP6yJslmtScdteskTAa5x2aLHExw8oB856eY/aR4OEbQb4 X-Received: by 10.98.75.139 with SMTP id d11mr24347468pfj.244.1525378690547; Thu, 03 May 2018 13:18:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525378690; cv=none; d=google.com; s=arc-20160816; b=bfEmz24JCmJS5dBdw8UJMLViU9/8gQ7lrSndrBbcoNMsj7Bwhnfz1pfalcOlvk3yk5 8pvJWlJ/BQEUG2R7OUJSkwkCxGahuz8dtNThwAdd26dIJQrALyhdacSnZuZdoPbsYbu0 1INJZzfZ3rAvZrd4cryZP+mdRXkHeU8mm+QYLxzVZe1I4rKBxvmnsd73gYUPDO+yRc5s eSRAhYjvXeKWVQ8CwFbr9Yqetnnzx+QRhiJ4WxE42mFnfeymc4WcqdDl5ct6VVIixE3r YjCqeZ8YfuZ+CGaApbeHqCknSujFeEm+hs0vUpdxXBhdPCvlfXYh6b85gR3hLbz4J/vS UOPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=PbZ/10ddijXIeIyUueme8UnyoMjyA9mkjg8a4ppD/fU=; b=qolX3v1hPhezY7CxUaxPNVWNJ/nCO7RDEzvt8aRVhjMxagXx7gMtFKb62Em1asIrzA uF2WEJRUk2euGPHsyoKWf3nkkSftslfIIztCoipeiFLs+kxUjbqcBjG0jTR5Ocjo9Yof A5J9dmAZNFyKM2NcQTEO9krNJkht1oYvNyOp02elON8GoowppPI+GdZyLzSxpDqZJ45d mKAPwgV1vJwtAnSDv6MAsjUeX73vnGDJv28zispMuEr4uYdR5xjw6J3m7ThuowXPyIUI 3yACR9GGqXbpbLxJYlF8HD/6V4hopdq2+PtObYo8lH84yVXeHyPCyo5BwvJEZa+jjb00 BmyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of andriy.shevchenko@linux.intel.com designates 192.55.52.120 as permitted sender) smtp.mailfrom=andriy.shevchenko@linux.intel.com Received: from mga04.intel.com (mga04.intel.com. [192.55.52.120]) by mx.google.com with ESMTPS id a90-v6si8550389plc.329.2018.05.03.13.18.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 13:18:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of andriy.shevchenko@linux.intel.com designates 192.55.52.120 as permitted sender) client-ip=192.55.52.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of andriy.shevchenko@linux.intel.com designates 192.55.52.120 as permitted sender) smtp.mailfrom=andriy.shevchenko@linux.intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 May 2018 13:18:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,359,1520924400"; d="scan'208";a="46574056" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 03 May 2018 13:18:08 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id EFCF6CE; Thu, 3 May 2018 23:18:07 +0300 (EEST) From: Andy Shevchenko To: David Rientjes , linux-mm@kvack.org, Andrew Morton Cc: Andy Shevchenko Subject: [PATCH v1] mm, vmpressure: use kstrndup instead of kmalloc+strncpy Date: Thu, 3 May 2018 23:18:07 +0300 Message-Id: <20180503201807.24941-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.17.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Using kstrndup() simplifies the code. Signed-off-by: Andy Shevchenko Acked-by: Michal Hocko --- mm/vmpressure.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/vmpressure.c b/mm/vmpressure.c index 85350ce2d25d..7142207224d3 100644 --- a/mm/vmpressure.c +++ b/mm/vmpressure.c @@ -390,12 +390,11 @@ int vmpressure_register_event(struct mem_cgroup *memcg, char *token; int ret = 0; - spec_orig = spec = kzalloc(MAX_VMPRESSURE_ARGS_LEN + 1, GFP_KERNEL); + spec_orig = spec = kstrndup(args, MAX_VMPRESSURE_ARGS_LEN, GFP_KERNEL); if (!spec) { ret = -ENOMEM; goto out; } - strncpy(spec, args, MAX_VMPRESSURE_ARGS_LEN); /* Find required level */ token = strsep(&spec, ",");