From patchwork Sat Nov 20 11:27:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12630337 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 43B8DC433F5 for ; Sat, 20 Nov 2021 11:29:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C31D6B0074; Sat, 20 Nov 2021 06:28:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 173696B0075; Sat, 20 Nov 2021 06:28:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 013CD6B0078; Sat, 20 Nov 2021 06:28:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0089.hostedemail.com [216.40.44.89]) by kanga.kvack.org (Postfix) with ESMTP id E83EC6B0074 for ; Sat, 20 Nov 2021 06:28:14 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 9E30E80882 for ; Sat, 20 Nov 2021 11:28:04 +0000 (UTC) X-FDA: 78829084488.09.9F53263 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by imf22.hostedemail.com (Postfix) with ESMTP id CF3591933 for ; Sat, 20 Nov 2021 11:28:03 +0000 (UTC) Received: by mail-pj1-f53.google.com with SMTP id np3so9882174pjb.4 for ; Sat, 20 Nov 2021 03:28:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NXvWr7/n/dn/qU7871k4jVbZ4yqRH7KsA6t+jNRxS5w=; b=bFQfNI4zaX/cX3ouONrppFc9YKLptBjPxzlAa57/2aqNreSUW7BufmQOVwKb8XlWx9 MPi+O1PqfJ7sDMHSCZ+uGA/BeAy3Vm7WUNtLXqpgmK1RZH4znPl3WNx6PArY/fqfqi5z /7goWOQq36fVMpT4QPfQORv8H2cFJQ6bjnwqc7oDhaBhrPjQYRuG1zR18Dv4Suf7k+vy 7SUtVnBYXMAW0rCY4p/HVSF01tnp0cDf9IDn4ZHiL2f3rChJWYRTU5YjMJfGvhOPGmUU fiaG8RIVrMWrz0TNV5tdYsxQTSY7dgxV+srOM8LSeDpzr4sYQi9aUff9ThJDz87hCR/k /gOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NXvWr7/n/dn/qU7871k4jVbZ4yqRH7KsA6t+jNRxS5w=; b=BOoIfmvW+uHj2oiQ/AG68vodFNoauX+aGJpL36mkt3NC+lYoW7iFe2Y/yS3K8RFN6e xvD1oVIeoBRrdzCffbLa+5TrhIdQ0VETxpw5v+QHoNOV3KZ+x504bUz7SVKSTNWcMFPS cN1Ww4hHJgy6c+wJ15MkXAa+5HJylgeZtzsNBDzmT2ASArVUo7R81fk8O4/AkboXmpTT zwtL+2Oit92CT5oBjVVcdmrrlNAMN9s4Q+veDkTgxCHfRa5DQQZN0tsauw8FWnB1CR3A WIpn2T8UwNQ0sF8A9o8INltM312hzVT76Cf7Qiwg+smgDQfa9ObewNTR2eybvRWEdz/H OZkQ== X-Gm-Message-State: AOAM530QjGxUCOdfEPiVut9bI1Ec/x0qoVeoM9E1ap4RqZkIEHbAwLPA g/6W2bJMg5uhdLYu0khGFug= X-Google-Smtp-Source: ABdhPJwckAaKVrEN2V1fZZmajViBaj+hK5R4HtJRF86XY4oxgC2JPhuSPO4Kwsq5pBFTZqBgcv/o9g== X-Received: by 2002:a17:90b:512:: with SMTP id r18mr9057016pjz.64.1637407683486; Sat, 20 Nov 2021 03:28:03 -0800 (PST) Received: from vultr.guest ([66.42.104.82]) by smtp.gmail.com with ESMTPSA id q17sm2835490pfu.117.2021.11.20.03.28.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Nov 2021 03:28:03 -0800 (PST) From: Yafang Shao To: akpm@linux-foundation.org Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, oliver.sang@intel.com, lkp@intel.com, Yafang Shao , Dennis Dalessandro , David Hildenbrand , Mathieu Desnoyers , Arnaldo Carvalho de Melo , Alexei Starovoitov , Andrii Nakryiko , Michal Miroslaw , Peter Zijlstra , Steven Rostedt , Matthew Wilcox , Al Viro , Kees Cook , Petr Mladek Subject: [PATCH v2 3/7] drivers/infiniband: replace open-coded string copy with get_task_comm Date: Sat, 20 Nov 2021 11:27:34 +0000 Message-Id: <20211120112738.45980-4-laoar.shao@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211120112738.45980-1-laoar.shao@gmail.com> References: <20211120112738.45980-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: CF3591933 X-Stat-Signature: 6xkb6omu3no97pefnbom4ydrucobt8e6 Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=bFQfNI4z; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf22.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.216.53 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com X-HE-Tag: 1637407683-159885 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: We'd better use the helper get_task_comm() rather than the open-coded strlcpy() to get task comm. As the comment above the hard-coded 16, we can replace it with TASK_COMM_LEN. Signed-off-by: Yafang Shao Acked-by: Dennis Dalessandro Reviewed-by: David Hildenbrand Cc: Mathieu Desnoyers Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: Andrii Nakryiko Cc: Michal Miroslaw Cc: Peter Zijlstra Cc: Steven Rostedt Cc: Matthew Wilcox Cc: David Hildenbrand Cc: Al Viro Cc: Kees Cook Cc: Petr Mladek --- drivers/infiniband/hw/qib/qib.h | 2 +- drivers/infiniband/hw/qib/qib_file_ops.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h index 9363bccfc6e7..a8e1c30c370f 100644 --- a/drivers/infiniband/hw/qib/qib.h +++ b/drivers/infiniband/hw/qib/qib.h @@ -196,7 +196,7 @@ struct qib_ctxtdata { pid_t pid; pid_t subpid[QLOGIC_IB_MAX_SUBCTXT]; /* same size as task_struct .comm[], command that opened context */ - char comm[16]; + char comm[TASK_COMM_LEN]; /* pkeys set by this use of this ctxt */ u16 pkeys[4]; /* so file ops can get at unit */ diff --git a/drivers/infiniband/hw/qib/qib_file_ops.c b/drivers/infiniband/hw/qib/qib_file_ops.c index 63854f4b6524..aa290928cf96 100644 --- a/drivers/infiniband/hw/qib/qib_file_ops.c +++ b/drivers/infiniband/hw/qib/qib_file_ops.c @@ -1321,7 +1321,7 @@ static int setup_ctxt(struct qib_pportdata *ppd, int ctxt, rcd->tid_pg_list = ptmp; rcd->pid = current->pid; init_waitqueue_head(&dd->rcd[ctxt]->wait); - strlcpy(rcd->comm, current->comm, sizeof(rcd->comm)); + get_task_comm(rcd->comm, current); ctxt_fp(fp) = rcd; qib_stats.sps_ctxts++; dd->freectxts--;