Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5803394rwb; Mon, 5 Dec 2022 04:27:55 -0800 (PST) X-Google-Smtp-Source: AA0mqf6q/y2sO1zfbLf4wJNA8g8F7jv/0Z+fSq2L+ZvnwrvzsQRRiHqfDgrgSus463ZMB7e0zo1+ X-Received: by 2002:a17:906:fa89:b0:7c0:bc68:c00a with SMTP id lt9-20020a170906fa8900b007c0bc68c00amr13823389ejb.665.1670243274926; Mon, 05 Dec 2022 04:27:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670243274; cv=none; d=google.com; s=arc-20160816; b=Nd6l47YCQqEIUEPbSNYfWTrbslq4G8mgJIvqyHuE1zQWiW8aWXUGLP2R18J6Gl66c7 hrfed+WrEVcPcV/FuGmcP2sghYRTBMgALSIOAeFjtwyF6VXekbKJuKMen4INzPdbP1cH HcMuWQ8U+77hAH8L3Vl5aVq91E5/uQabfmhkag7E3IH3T7pXbhwINmmBnCZ8GFjm2Knl QKE7gEy1UoIEqCrPx6BcWihAsX9HaeATPR2YgY4URouSJAz0vpv8oXH+VDZ6F517ukOL RAHxR7xOsglmg2ilZfzqpnOdFihSbJ9BClJuHE3XhJLp8VVAxIuSkRIF+jw6H/3XAI6W GiUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:mime-version:message-id:date; bh=c135bsxN81pmfK8SohkMpnWHfIerwYAsB99v6em89Y4=; b=UoBSBxg1BVztwKKgcXW/kRKY/hHxEiQ5LPhpHsbpP8+EZo825iT/ydrtZpoyAX2ywg JgE5yWhz43xcX36mfA4aKEdUB+Bi5SJykBr5/Jkuz+F72MBSkdG+SxgaNOs2pxUUX09V wrPA4R4DRg0Zsz6fi1biMwB8MejYydCk+8iXmNfD0+z1segIGo7echgjkdl7ueG3e01S LeQc5kSjQ7wu/7hZmZSUnVmEYQI9g3EOuV1/5HQDAI6+SheX/79xPky8aw9k/bBFn006 +CIL+Z0lCWvyq7SNVpeTGc9z4RM7ELmd7GGjJbt4FAfrqIN+t1Uq6OJVGmnBTfYRaNJU cZPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ww1-20020a170907084100b007826de24087si10456748ejb.228.2022.12.05.04.27.34; Mon, 05 Dec 2022 04:27:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230465AbiLELd6 (ORCPT + 82 others); Mon, 5 Dec 2022 06:33:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230110AbiLELd4 (ORCPT ); Mon, 5 Dec 2022 06:33:56 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 070EE6367 for ; Mon, 5 Dec 2022 03:33:56 -0800 (PST) Received: from mse-fl2.zte.com.cn (unknown [10.5.228.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4NQhJf5HRvz5BNRf; Mon, 5 Dec 2022 19:33:54 +0800 (CST) Received: from szxlzmapp06.zte.com.cn ([10.5.230.252]) by mse-fl2.zte.com.cn with SMTP id 2B5BXmkP074067; Mon, 5 Dec 2022 19:33:48 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp02[null]) by mapi (Zmail) with MAPI id mid14; Mon, 5 Dec 2022 19:33:50 +0800 (CST) Date: Mon, 5 Dec 2022 19:33:50 +0800 (CST) X-Zmail-TransId: 2b04638dd71e1939a789 X-Mailer: Zmail v1.0 Message-ID: <202212051933509509270@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , Subject: =?UTF-8?B?W1BBVENIIGxpbnV4LW5leHRdIGJ1czogZnNsLW1jOiB1c2Ugc3Ryc2NweSgpIHRvIGluc3RlYWQgb2Ygc3RybmNweSgp?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl2.zte.com.cn 2B5BXmkP074067 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.138.novalocal with ID 638DD722.000 by FangMail milter! X-FangMail-Envelope: 1670240034/4NQhJf5HRvz5BNRf/638DD722.000/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 638DD722.000/4NQhJf5HRvz5BNRf X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xu Panda The implementation of strscpy() is more robust and safer. That's now the recommended way to copy NUL terminated strings. Signed-off-by: Xu Panda Signed-off-by: Yang Yang --- drivers/bus/fsl-mc/dprc.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/bus/fsl-mc/dprc.c b/drivers/bus/fsl-mc/dprc.c index d129338b8bc0..d095d1e044e7 100644 --- a/drivers/bus/fsl-mc/dprc.c +++ b/drivers/bus/fsl-mc/dprc.c @@ -450,10 +450,8 @@ int dprc_get_obj(struct fsl_mc_io *mc_io, obj_desc->ver_major = le16_to_cpu(rsp_params->version_major); obj_desc->ver_minor = le16_to_cpu(rsp_params->version_minor); obj_desc->flags = le16_to_cpu(rsp_params->flags); - strncpy(obj_desc->type, rsp_params->type, 16); - obj_desc->type[15] = '\0'; - strncpy(obj_desc->label, rsp_params->label, 16); - obj_desc->label[15] = '\0'; + strscpy(obj_desc->type, rsp_params->type, 16); + strscpy(obj_desc->label, rsp_params->label, 16); return 0; } EXPORT_SYMBOL_GPL(dprc_get_obj); @@ -491,8 +489,7 @@ int dprc_set_obj_irq(struct fsl_mc_io *mc_io, cmd_params->irq_addr = cpu_to_le64(irq_cfg->paddr); cmd_params->irq_num = cpu_to_le32(irq_cfg->irq_num); cmd_params->obj_id = cpu_to_le32(obj_id); - strncpy(cmd_params->obj_type, obj_type, 16); - cmd_params->obj_type[15] = '\0'; + strscpy(cmd_params->obj_type, obj_type, 16); /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -564,8 +561,7 @@ int dprc_get_obj_region(struct fsl_mc_io *mc_io, cmd_params = (struct dprc_cmd_get_obj_region *)cmd.params; cmd_params->obj_id = cpu_to_le32(obj_id); cmd_params->region_index = region_index; - strncpy(cmd_params->obj_type, obj_type, 16); - cmd_params->obj_type[15] = '\0'; + strscpy(cmd_params->obj_type, obj_type, 16); /* send command to mc*/ err = mc_send_command(mc_io, &cmd); -- 2.15.2