From patchwork Wed May 23 14:54:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 10421715 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 8F6396053B for ; Wed, 23 May 2018 14:55:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DC7928868 for ; Wed, 23 May 2018 14:55:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7279E2888A; Wed, 23 May 2018 14:55: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=-5.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 EE4C528868 for ; Wed, 23 May 2018 14:55:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D72DF6E518; Wed, 23 May 2018 14:55:12 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0055.outbound.protection.outlook.com [104.47.41.55]) by gabe.freedesktop.org (Postfix) with ESMTPS id 44C2D6E518 for ; Wed, 23 May 2018 14:55:11 +0000 (UTC) Received: from fedoratest.localdomain (155.4.205.56) by DM6PR05MB4588.namprd05.prod.outlook.com (2603:10b6:5:9f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.797.5; Wed, 23 May 2018 14:55:08 +0000 From: Thomas Hellstrom To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/3] drm/vmwgfx: Fix host logging / guestinfo reading error paths Date: Wed, 23 May 2018 16:54:20 +0200 Message-Id: <20180523145421.2501-2-thellstrom@vmware.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180523145421.2501-1-thellstrom@vmware.com> References: <20180523145421.2501-1-thellstrom@vmware.com> MIME-Version: 1.0 X-Originating-IP: [155.4.205.56] X-ClientProxiedBy: HE1PR09CA0082.eurprd09.prod.outlook.com (2603:10a6:7:3d::26) To DM6PR05MB4588.namprd05.prod.outlook.com (2603:10b6:5:9f::25) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:DM6PR05MB4588; X-Microsoft-Exchange-Diagnostics: 1; DM6PR05MB4588; 3:pjMhXl7fFXhGEcjLuZxpudAsG4bl9FT+e/WWksHrVXeCPyuF7DUxR4vmuY3HCKHE39Pzy3j/7Ofr5oxv2D+8F/gKkTlRj2NfJfMdBXHdm9vE153QromJPV6FJ+O7mugXzsVrhvloGgzV/kaDZBPxDaOYZ/h/Ao+iy4okQvMn6GqXWXLc7fesMG9wI1hSNUZkOQFRvMlS5PJ725gaaptYuHPqYyec66eigCzV8H3p3WMjsrypQggDjFaeFk1g0UQr; 25:4uYOuRL7trXeOqPlYpx48BQ6DE071Cs4LzUYDPlWISNwnr7BZMDNtEY7tVV5EmZ7qVFs5TaARUzIV9vZGX3fLfXJOzsyzy89snQF+aeLHaWWTUqd+Yd64eU4Q8vK25oFNLVzksJNQMN05rchDRs4n89Gt+A0HpVRW23gcBxnGtnVWMgg/SmNs07R8bMX03tEEU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l8vd2KVnlON4OFGTTRBAXkEHeGB3flqbwXzWSP+602HkTFSi59UtigFY/ssYFZJu+5znboaEzNRKLJwW7zaz4WhfpupCj+5fBwbyKQaDyplDtiG+gF6lJW8yk5JXdbTjkfIXPxrTLeGO4Pj2ibOzHyMnGNWfUze+Eukn82ssYFxd2Gwa+ihr9IZxUzWjWixELk5C64gjFvVbE7y/xkeyJV1UdmDIodHheQT9nSM9cvf+t6YZ6qIy5Zv5SbJ3huOuxnsmM8uv9CsIVc= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(61668805478150)(9452136761055); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231254)(944501410)(52105095)(10201501046)(3002001)(149027)(150027)(6041310)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:DM6PR05MB4588; BCL:0; PCL:0; RULEID:; SRVR:DM6PR05MB4588; X-Forefront-PRVS: 06818431B9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(39860400002)(39380400002)(376002)(346002)(366004)(189003)(199004)(478600001)(7736002)(305945005)(48376002)(50466002)(68736007)(4326008)(25786009)(36756003)(5660300001)(6486002)(53936002)(6116002)(3846002)(6512007)(1076002)(106356001)(8936002)(105586002)(2351001)(50226002)(2361001)(81166006)(81156014)(8676002)(6666003)(6916009)(2906002)(97736004)(59450400001)(386003)(6506007)(186003)(16526019)(11346002)(956004)(2616005)(446003)(316002)(26005)(47776003)(86362001)(66066001)(16586007)(51416003)(52116002)(76176011)(486006)(476003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR05MB4588; H:fedoratest.localdomain; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM6PR05MB4588; 23:Omna9KiAzrPGy8LejnnSp8KaRKNtjvtj8MyELR6nY?= =?us-ascii?Q?z8ssU5ZaFg83F057uYp3NQ8foU0foI+bHPjDeg4jrRSQRw74LH7nhPKGfTai?= =?us-ascii?Q?ehxOy2gUVIYP5L32E8FCARMGCWTlWMMj/Bl9TKXo/y5BQ65KPb17I2u4iSfM?= =?us-ascii?Q?PjWTs7H3kaFoH8j7PC4rg7xzt3DnO33Sp7p1OFz67j/I/xy9EbmrZ2td/FXb?= =?us-ascii?Q?IW6N6xATD0Jr8LIQkBfidzcJRfZv421xU2PLmJJWwmA6Re/bWxNJCm53p7WF?= =?us-ascii?Q?1noeYDzbN29PVKDi3bUduIjpQ4v7DtuQeDQXOOF4sEhRxx7rA7bEJnknrUdo?= =?us-ascii?Q?SQCHwAbXzqmp6LZs1nkiBP9q4+Gsy86J6Y8diW9nQ1faileeeiQ3R1Ke8pRd?= =?us-ascii?Q?5c+8pl+IPjpn1xLypuJsdRMccw63g1bl3ebO0cDuOzE/pB1EtkoDikiz9Hp5?= =?us-ascii?Q?C+lVFRjlvvykO+X0UKuDT14cxsL5xA+2frXNDfF9Y7oaBRGz0+wu4GNAefFc?= =?us-ascii?Q?nGmvVrp7HUQn5nrQtg0tE5lUGyC2bZeAwUOZ0QC0AbQPOz2HHdnyPNyvtTYy?= =?us-ascii?Q?H5JFTM6mVqWGxprSrIkifMQaVSTZoRG7NC4dzY57DUwE8rwXaMT3pn7vfcNl?= =?us-ascii?Q?JpFc0xZ6de68qjg39ag11WSTbY2omAFd07lxlZW5l7nx/8LedwUa3oF1M8PE?= =?us-ascii?Q?GAM7gWfEw60Zm6RdOPqMGSpXx2OpI3TU1g3HyPLPpm0xOzFufFgbM+qQsuEk?= =?us-ascii?Q?ExmTMfJb4tQmYGNnHJPzORlTUKkaIKlV7rJQ/Da/7h3uwEPHqbnO5ltB2rfl?= =?us-ascii?Q?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ipIfqmpXvqF8TSNz0ckLx1HMpKzu1rf0vprFHvQtJ1PAX8WD7muIwJVUZx1NxM5F3Wvg4IrpBTDKVIbYzh2zgg9nzConwIVgq7bYFWLBNwU7nlvInB5vJipIoF4+xzTvRMguKHihr3Z7PPxF1L9zq46tOVLriWo2kr2EvcFkGSpb8l4Jp/Qkk6oLxaVbnDtuo9u3gorvhd5l/5AG3wjyUmTw==; 5:/tX7sxa+pFqGWuPFJIOfHz5JbyHqeOs35QMctZIt0Y0m3EsSh/I1PgMP/k15u7YYjDgMkMOlymly39QYBHPhBIW9FjXCfjD8Rif6KM0v5dNCO+ObxcfXA6mJqrva427ChPsrZH8PsLm+oIUWM8/RVg/zQAb3HYt2mxSZTtKpMNs=; 24:TCXjbQJOpnjqRxTZeOUSqshrrRQOcI+C8fOpWgvT36531Ht0CA5bpUvaf6cod4fLHliK1YDUYvieC4KIGXGMxh1okVtiLvY9/4u0ZnidQFM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM6PR05MB4588; 7:frfInPn21rLULGAnPHg2Z8Fcda1nDga4HqIKmYi9Hw818bkDZ9OjbKQsn9B3t5NPwdUOwURv79jaRRgdBKeAU8mowqenL1+uv4ZP5UWdQNmW1RjT0oRVC09HeOahtTJEuvNgVAD3jJBMNOZKvDNVqy6hQxtsMpR2XbA/+JoR915w83tAnDGqYrZ449s7cLGlcbR6pWb80sgE3GWLpykmXQjIdwwQ9dUHZRORwh9yR5/ZUa1RRl33Vh56dGrVtaR9; 20:UQz6jNG4qwopugRfv96dXwYKqUEIgd+vC45ri+IGR0yUPg/jmWnpEVvgcQLTCuTfdVggWN+RThuzx2rh6Tk9ERIlc5lamtYBO6jKkioCYqxoos3hPmzrf1OO9UUzH+YV8BvzpulGuhycw7N6GRkRt/yQq4YKEgvtZihbWCgy/Oc= X-MS-Office365-Filtering-Correlation-Id: f117e11f-227a-45da-85d7-08d5c0bd2dec X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2018 14:55:08.6183 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f117e11f-227a-45da-85d7-08d5c0bd2dec X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR05MB4588 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: , Cc: Thomas Hellstrom , stable@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The error paths were leaking opened channels. Fix by using dedicated error paths. Cc: Signed-off-by: Thomas Hellstrom Reviewed-by: Brian Paul Reviewed-by: Sinclair Yeh --- drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 48 +++++++++++++++++++---------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c index cdff99211602..21d746bdc922 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c @@ -329,8 +329,6 @@ int vmw_host_get_guestinfo(const char *guest_info_param, struct rpc_channel channel; char *msg, *reply = NULL; size_t reply_len = 0; - int ret = 0; - if (!vmw_msg_enabled) return -ENODEV; @@ -344,15 +342,14 @@ int vmw_host_get_guestinfo(const char *guest_info_param, return -ENOMEM; } - if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM) || - vmw_send_msg(&channel, msg) || - vmw_recv_msg(&channel, (void *) &reply, &reply_len) || - vmw_close_channel(&channel)) { - DRM_ERROR("Failed to get %s", guest_info_param); + if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM)) + goto out_open; - ret = -EINVAL; - } + if (vmw_send_msg(&channel, msg) || + vmw_recv_msg(&channel, (void *) &reply, &reply_len)) + goto out_msg; + vmw_close_channel(&channel); if (buffer && reply && reply_len > 0) { /* Remove reply code, which are the first 2 characters of * the reply @@ -369,7 +366,17 @@ int vmw_host_get_guestinfo(const char *guest_info_param, kfree(reply); kfree(msg); - return ret; + return 0; + +out_msg: + vmw_close_channel(&channel); + kfree(reply); +out_open: + *length = 0; + kfree(msg); + DRM_ERROR("Failed to get %s", guest_info_param); + + return -EINVAL; } @@ -400,15 +407,22 @@ int vmw_host_log(const char *log) return -ENOMEM; } - if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM) || - vmw_send_msg(&channel, msg) || - vmw_close_channel(&channel)) { - DRM_ERROR("Failed to send log\n"); + if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM)) + goto out_open; - ret = -EINVAL; - } + if (vmw_send_msg(&channel, msg)) + goto out_msg; + vmw_close_channel(&channel); kfree(msg); - return ret; + return 0; + +out_msg: + vmw_close_channel(&channel); +out_open: + kfree(msg); + DRM_ERROR("Failed to send log\n"); + + return -EINVAL; }