Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp448124imm; Sat, 8 Sep 2018 02:05:04 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaCE99m2tdB2kjeqoHKj4kaD4rfWsrTkGYoMTvsNIaKYvSntlSXmVjUqiGo3PUbh8wSreC3 X-Received: by 2002:a17:902:d213:: with SMTP id t19-v6mr12056246ply.63.1536397504657; Sat, 08 Sep 2018 02:05:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536397504; cv=none; d=google.com; s=arc-20160816; b=wxKie5PcNw778CHsJkgfAoGkwupPkev2HKjV4r+Xh1GPczmJj1wlYb7NParkqc5o8M W/nPPyrl81Erp/ppPMwtkowI072Kqk3xiRQXQ1ycw7XD+mdj8uGsGOs9swSllS+yzL9e V2KEH9krDnruVNYa5t66OJ3s9mnSce4J/GGJVkggUGXLYhwK4tpTe0CEJdRYV1HQqmeL Gj1RZTkOeHCSRHMB8EqoJZHIDLgKECqq07VNILinF1CNw+faoRyZTGsutRmwAd89m2Di 6tAHlDdfbCLZekz2AlXwUWYxeMApAmYWuscSFtxxbBHiqVmUxTCu+nLiPG9aPqzwPW+F p5Sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=qzgiJ3w321p4FO4gteD6TP6khasuZaq62ACWpqRQH30=; b=XB0AGYvm5Du9jm/aNFq6KVgHHnFnX2VUr8bYbDQYbSXjwTJDs89EHfblZ6PBChPTjd 9uXA87sGg+ovyLdidTx74t4hMWuYhBT6GAbFiGSDOwJ1DNhk0sq6t3w873YxRw63U1E/ djBbjf/uONTUBgk/yilSnHSwja0idhky5W3eKc2UPsuvNt8YGwzcFrzLPCkGG763F/Yq cv8Ugm22YJssx5WreTxLPXNVpNwLtSZhCQ+I52r+4WJ32S4QQlxVRJn6VVykEyBLOi0+ 72bZwrVqiC6/mekay5m09p1PFO8mIt6t8cPS0N3D0lYxOIKnBPI7LiJhXH075LJPYs0t xDnw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p14-v6si11825050pfk.275.2018.09.08.02.04.33; Sat, 08 Sep 2018 02:05:04 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726506AbeIHNrj (ORCPT + 99 others); Sat, 8 Sep 2018 09:47:39 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:54569 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726171AbeIHNrj (ORCPT ); Sat, 8 Sep 2018 09:47:39 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 194CC2874053A; Sat, 8 Sep 2018 17:02:33 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.399.0; Sat, 8 Sep 2018 17:02:31 +0800 From: zhong jiang To: , , CC: , Subject: [PATCH] s390/zcrypt: Use kmemdup to replace kmalloc + memcpy Date: Sat, 8 Sep 2018 16:50:21 +0800 Message-ID: <1536396621-19363-1-git-send-email-zhongjiang@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kmemdup has implemented the function that kmalloc() + memcpy() will do. and we prefer to use the kmemdup rather than the open coded implementation. Signed-off-by: zhong jiang --- drivers/s390/crypto/zcrypt_msgtype6.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/s390/crypto/zcrypt_msgtype6.c b/drivers/s390/crypto/zcrypt_msgtype6.c index 2101776..9ac960d 100644 --- a/drivers/s390/crypto/zcrypt_msgtype6.c +++ b/drivers/s390/crypto/zcrypt_msgtype6.c @@ -1131,10 +1131,9 @@ unsigned int get_cprb_fc(struct ica_xcRB *xcRB, ap_msg->receive = zcrypt_msgtype6_receive; ap_msg->psmid = (((unsigned long long) current->pid) << 32) + atomic_inc_return(&zcrypt_step); - ap_msg->private = kmalloc(sizeof(resp_type), GFP_KERNEL); + ap_msg->private = kmemdup(&resp_type, sizeof(resp_type), GFP_KERNEL); if (!ap_msg->private) return -ENOMEM; - memcpy(ap_msg->private, &resp_type, sizeof(resp_type)); return XCRB_msg_to_type6CPRB_msgX(ap_msg, xcRB, func_code, dom); } @@ -1187,10 +1186,9 @@ unsigned int get_ep11cprb_fc(struct ep11_urb *xcrb, ap_msg->receive = zcrypt_msgtype6_receive_ep11; ap_msg->psmid = (((unsigned long long) current->pid) << 32) + atomic_inc_return(&zcrypt_step); - ap_msg->private = kmalloc(sizeof(resp_type), GFP_KERNEL); + ap_msg->private = kmemdup(&resp_type, sizeof(resp_type), GFP_KERNEL); if (!ap_msg->private) return -ENOMEM; - memcpy(ap_msg->private, &resp_type, sizeof(resp_type)); return xcrb_msg_to_type6_ep11cprb_msgx(ap_msg, xcrb, func_code); } @@ -1282,10 +1280,9 @@ unsigned int get_rng_fc(struct ap_message *ap_msg, int *func_code, ap_msg->receive = zcrypt_msgtype6_receive; ap_msg->psmid = (((unsigned long long) current->pid) << 32) + atomic_inc_return(&zcrypt_step); - ap_msg->private = kmalloc(sizeof(resp_type), GFP_KERNEL); + ap_msg->private = kmemdup(&resp_type, sizeof(resp_type), GFP_KERNEL); if (!ap_msg->private) return -ENOMEM; - memcpy(ap_msg->private, &resp_type, sizeof(resp_type)); rng_type6CPRB_msgX(ap_msg, ZCRYPT_RNG_BUFFER_SIZE, domain); -- 1.7.12.4