From patchwork Thu Mar 22 10:23:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 10301203 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 EB5B260386 for ; Thu, 22 Mar 2018 10:25:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC95E29AA1 for ; Thu, 22 Mar 2018 10:25:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D162F29AA4; Thu, 22 Mar 2018 10:25:11 +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=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CB42129AA1 for ; Thu, 22 Mar 2018 10:25:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 67CF46EBDF; Thu, 22 Mar 2018 10:24:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0043.outbound.protection.outlook.com [104.47.40.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6F2C26EBD6 for ; Thu, 22 Mar 2018 10:24:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=onevmw.onmicrosoft.com; s=selector1-vmware-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=8FdyNzw8R/AKvQshsA/ry/N4q0v6QW5bu/3sjFe4sKY=; b=SMjYFM6WSdHl/hjDfEC7FUDjfaO4NlZjLddfDiHqtpvrHDtXl1CBSiXqSqjbyszaeYdrlOJoJYI9/8mJMNJaZTJX1bkDnXaESULjn4A18KUKFvhFsCdnawEp+5fxKfLpkOMYhAZ1REjYQNxhKRrh+UyVBwGu8+GKTGNKL8Q7HAY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=thellstrom@vmware.com; Received: from localhost.localdomain (155.4.205.56) by DM2PR05MB767.namprd05.prod.outlook.com (2a01:111:e400:244d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.609.6; Thu, 22 Mar 2018 10:24:42 +0000 From: Thomas Hellstrom To: dri-devel@lists.freedesktop.org, linux-graphics-maintainer@vmware.com Subject: [PATCH -next 07/11] drm/vmwgfx: Use kasprintf Date: Thu, 22 Mar 2018 11:23:48 +0100 Message-Id: <20180322102352.2881-7-thellstrom@vmware.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180322102352.2881-1-thellstrom@vmware.com> References: <20180322102352.2881-1-thellstrom@vmware.com> MIME-Version: 1.0 X-Originating-IP: [155.4.205.56] X-ClientProxiedBy: HE1PR0502CA0021.eurprd05.prod.outlook.com (2603:10a6:3:e3::31) To DM2PR05MB767.namprd05.prod.outlook.com (2a01:111:e400:244d::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 99235131-267a-4069-d062-08d58fdf2105 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:DM2PR05MB767; X-Microsoft-Exchange-Diagnostics: 1; DM2P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u4hMK6rewFqerZDS2mJa5AdmECTh0Cr/AhopLGqEt6yNuKYcfuWmnqDztZDcq7gRsNtLZLMMdMxh7RKA+UYY4j1S3NGjpOnOaIXmVDf8cqcOAUSKUpVw6t+htLshyAGsug+dVQUgHwpUTuSP+FukuvVIEiv4TWul/uC4mWH+VqOCltlHD14kHwCb1FC5U3nEFcjKKHhFHJ1CnZYVz13gdlAQ0bnDswPDFgkLB3z2gNGskdmZh6t3t23DbRoLYHoE8v23UmvAXFRHvmVJSpIXhIr8xYmQ9Y7gaA9jq5MGnWzWNRmH0zTi4vrbRD3tMmP38mHBQkhGvJVLKSfDbcp8QIcvtcuM5ux7JcGQZdc8An8oBxCl3aEBDzCxgMlcIxSrddG5h8VFYug6SaIk1OHnjAjiUUgJEE9Grh4RUVgGL9Kb+7lKCVu; 4:+BiPVgKQARizpVZ4UBFraod2hDj68TBzo8sWfzVeFG04kJ+kNpFEbs+xECcr0i/HGsjz5ZhM+Hkyy6LoaBdIPuKYA6/kdILQnIrar7XWDpInLZ3x1MfAqDKdQV8kCfGZMnY4E7IL3Gtmnk3/JHMVmyMAwTUjPeevFxhaBn4jfohYa3ji0KkrmdcBHmffJXe1rxmadaoC+dcZQljpaQTXXPJndqKTw1a6P0oHzyfVeGRSQ89YEBlUPKEI/yZbpMr2Z9CrXiXYV/ln8Np/9QsP5yWOZID6lUOHH+DfveNx0/OhmFUA0lC/WoFGmv1A/syJ61MGwA6NtFCePMn4pe5EbQU9Zt5rDSS/Q2ZE3VMCaHA= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(61668805478150)(85827821059158); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(10201501046)(3002001)(93006095)(93001095)(6041310)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(6072148)(201708071742011); SRVR:DM2PR05MB767; BCL:0; PCL:0; RULEID:; SRVR:DM2PR05MB767; X-Forefront-PRVS: 0619D53754 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(346002)(39380400002)(376002)(396003)(39860400002)(366004)(199004)(189003)(76176011)(59450400001)(8676002)(81156014)(316002)(68736007)(5660300001)(305945005)(8936002)(50226002)(16586007)(36756003)(81166006)(86362001)(50466002)(6486002)(48376002)(186003)(16526019)(6512007)(53936002)(6636002)(6506007)(386003)(2950100002)(25786009)(6116002)(52116002)(106356001)(105586002)(51416003)(47776003)(3846002)(26005)(1076002)(2906002)(97736004)(7736002)(66066001)(478600001)(446003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR05MB767; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR05MB767; 23:XgDYbmOVr63dOASwiQXGboBn9ls/w9NVD3ueiDyEc3?= =?us-ascii?Q?Iao+A6RMO//LcJJZ3gOqSsGpVAi5HVUJSnyV1d8YaQaT/VvQH5l2iedT5glx?= =?us-ascii?Q?Ljl5zNJzissyfLmRkz3Zkb+QAXIJ00TxB165laH8aUYFO24XUX9rBrHyg//5?= =?us-ascii?Q?uBeRpvSdyqCYTiXSmjUdgHbj9hb9Absd2r8OFmb/4X1L5KeKi5TTc2cH28vT?= =?us-ascii?Q?f1zm1k/tunOr48TFs6z7RmOBqr91MbLsfuwEDJJOQ710Ple2febXqm1b1IVK?= =?us-ascii?Q?9+fjb+v/e/kr/vM1MhMtNB1c9EDhQklUrtNZCxkVI6oN4XQnF9JX3gHwEtD5?= =?us-ascii?Q?lZsWYGBbF5Qd7OsgxJhO7IO1U10q7oE4P5tHcfOrv/VheJ+ua8mdZYe75N5c?= =?us-ascii?Q?Af6b2B1lgCjXQIaaLvssfIqWkrzKakBF/jndzjHhSglHWcUeyspiG25p+0SB?= =?us-ascii?Q?SHPz2QXgpPSMxZL4gHo9ovQMpmFDtioJH2/ZQQ/YRFe6IWgEA8goK3FFCJzw?= =?us-ascii?Q?0F95Wklirc9BWMZimP6eSwbsryTQx12A7tHptyRifVGsuzvqgSWf8KCSg2NA?= =?us-ascii?Q?Xi6n0G8tvktHSPimQTVbKSWb3LvzRTP9SnziUiwIP4qqtW5Gm1XxgBTSYVav?= =?us-ascii?Q?VyEs+RIYux19moeGQx2J5l2tuZFJxN9FkyXSMnPdXLtfc33jwmoOgogVoWdn?= =?us-ascii?Q?pH7x1jANFEn3AnVgK+uYElj7oEze2YPk3AfoPOa+unUTHrRJcjLkBdpNAYZs?= =?us-ascii?Q?Ok49AnqfZqd2p9PJqSoawG/2LIjKklFmJI4AlkWpVScvC3Fr3HO5mjcXiZ6K?= =?us-ascii?Q?TPR7dGR9LoLcO751RKx28gjsXoWFZdUfbmu0U6DXR8QveWuJRduBFNNHkAkF?= =?us-ascii?Q?7r75UGdeHbE41MUUyzSe8e2A/WXv64MqmhXVjygl597R4lCWlqKGucGQebtg?= =?us-ascii?Q?SBS+5LFBOnMjufIop1nFsxY64w20X37SvnyiyCEviE0PfGnXs4YeAFph3UWv?= =?us-ascii?Q?O/p6K6fNwNbfPeXjTeqJH/97ReuJk4un3pNSSsex/S5yffaDvSMqFgFiVx7E?= =?us-ascii?Q?xoiB5o28Y+fHpAo5khzu7deR8qx0bbwEsazRO252PMIAPVKa/u7DrzGZekDE?= =?us-ascii?Q?wBjQwcLRAFtNSOHnq+2JW5blfRtD0r?= X-Microsoft-Antispam-Message-Info: KekYnGtWSpYeo6a7Vs3RtADrjX8d+ScgUoaitjsBaBEQsJ6zugo+/sv2pvzi2r+4kVdAh0m+Cq0TJPr8bIGqaEaPuRBKe6c51Dx5Gdq4tTHbAyQcrlRrRgUvOsU/qMGHEG9yI9uffuBPgKCg3hGJUU0bBszfAbtVCS1NHVx735QmSKpdzP6yWV6NxVQVWNeT X-Microsoft-Exchange-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hEKfKSKG7TmcvJXEa9bsIpOi+wLwRD46v2zTBAXfNj; 20:jig4x1wSrtBadx4Shwx8HhdWTPhKVC6CeNdBOlPd64S0gKeQhh+bErHIbRdnGmGYMMZQJ51pvkk5moXw5NrSp8cftBH9aQrf1ORCikoMlTAmtGKZoLWfAClq+myH62Rihp9f/irUMJrjUADUd5SFYp5sR3Pg7MlphgzUy2597ow= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2018 10:24:42.9245 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 99235131-267a-4069-d062-08d58fdf2105 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR05MB767 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Himanshu Jha Use kasprintf instead of combination of kmalloc and sprintf. Also, remove the local variables used for storing the string length as they are not required now. Signed-off-by: Himanshu Jha Reviewed-by: Sinclair Yeh Signed-off-by: Thomas Hellstrom --- drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c index 97000996b8dc..cdff99211602 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c @@ -328,7 +328,7 @@ int vmw_host_get_guestinfo(const char *guest_info_param, { struct rpc_channel channel; char *msg, *reply = NULL; - size_t msg_len, reply_len = 0; + size_t reply_len = 0; int ret = 0; @@ -338,15 +338,12 @@ int vmw_host_get_guestinfo(const char *guest_info_param, if (!guest_info_param || !length) return -EINVAL; - msg_len = strlen(guest_info_param) + strlen("info-get ") + 1; - msg = kzalloc(msg_len, GFP_KERNEL); + msg = kasprintf(GFP_KERNEL, "info-get %s", guest_info_param); if (!msg) { DRM_ERROR("Cannot allocate memory to get %s", guest_info_param); return -ENOMEM; } - sprintf(msg, "info-get %s", guest_info_param); - if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM) || vmw_send_msg(&channel, msg) || vmw_recv_msg(&channel, (void *) &reply, &reply_len) || @@ -388,7 +385,6 @@ int vmw_host_log(const char *log) { struct rpc_channel channel; char *msg; - int msg_len; int ret = 0; @@ -398,15 +394,12 @@ int vmw_host_log(const char *log) if (!log) return ret; - msg_len = strlen(log) + strlen("log ") + 1; - msg = kzalloc(msg_len, GFP_KERNEL); + msg = kasprintf(GFP_KERNEL, "log %s", log); if (!msg) { DRM_ERROR("Cannot allocate memory for log message\n"); return -ENOMEM; } - sprintf(msg, "log %s", log); - if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM) || vmw_send_msg(&channel, msg) || vmw_close_channel(&channel)) {