Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1176175ybi; Fri, 21 Jun 2019 15:37:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqw+AzP3nKYk2YEl5hPousGdaJK9EgiCaAw8E+ZsP4Q8BjGFO4/1a5RJnPCM0ppAr0SmMPze X-Received: by 2002:a17:90a:3ae8:: with SMTP id b95mr9325343pjc.68.1561156636160; Fri, 21 Jun 2019 15:37:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561156636; cv=none; d=google.com; s=arc-20160816; b=mbI12UD8xHfRdCCMbs/1/WQlxYJTjjTUdvmrmN9OsCcn+6zMMPeUGJbm2k3Hh58VJJ TrOd655zPFGN3Xl1opF9EN0S86xgmYPj0h+reRtSuWfe5oJn2mQZPwO/xrhOwmWKnCAC 8cyKrv7p6nFO76FfftLUXvdEHIp5x+jXhowanpwjR0PycC50fmTBAFi+3G62SagJF2X/ 5T+kRCZZQKdoFCzGFlqTdNfpEZhOxbB4FdGY/BYnsWnYLBK5MGSmOLX00dhl3Asf+6of CDnEFOXBvnso3vNeTk/LwY9dzmeH4TLdxNzZYCBZ1sY83kVZe0KwN/kuM9o5w9pNBuRr mmcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=RsFR46F8TDhfLe5xwtJ/JXY3QIsPAXKXEzXEwriAAjI=; b=att3ZLyNd7/YiaNLnNmw8vkrVDhyniBmZjzAyHuJD5ixcNIjtLMy+7I2f3nypMzWju 0o61+W4dHqxNABm4SPj7qxfBr2oXZ6fqPDlIgJx4I+wrKjL8Fiuteh5IihEUm2phm+JV PFlS7y6HMUpq3UwhWx0X5PKrFGq65fShrXJB2mHpFNGMlk0f9FpbgZt7axnA7aVdqUk+ xE0HiqSCmLkTKPx7K9hC27t+mBE9bvvX1XFDJHjacK8f2FbadXXJEnIAAVFMKdpFGWQl hZNkrnu1G8tLwKjti/TPONnTYqqhfis5yE0jVXS0OsMGV4wNpoymzjymMPcRWh2e2ElC b7qw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y1si3660082pjr.109.2019.06.21.15.37.00; Fri, 21 Jun 2019 15:37:16 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726121AbfFUWfi (ORCPT + 99 others); Fri, 21 Jun 2019 18:35:38 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:43714 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726018AbfFUWfi (ORCPT ); Fri, 21 Jun 2019 18:35:38 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1heS86-0000Or-EG; Fri, 21 Jun 2019 22:35:34 +0000 From: Colin King To: VMware Graphics , Thomas Hellstrom , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/vmwgfx: fix memory leak when too many retries have occurred Date: Fri, 21 Jun 2019 23:35:34 +0100 Message-Id: <20190621223534.14283-1-colin.king@canonical.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King Currently when too many retries have occurred there is a memory leak on the allocation for reply on the error return path. Fix this by kfree'ing reply before returning. Addresses-Coverity: ("Resource leak") Fixes: a9cd9c044aa9 ("drm/vmwgfx: Add a check to handle host message failure") Signed-off-by: Colin Ian King --- drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c index 8b9270f31409..8b61f16f50cf 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c @@ -301,8 +301,10 @@ static int vmw_recv_msg(struct rpc_channel *channel, void **msg, break; } - if (retries == RETRIES) + if (retries == RETRIES) { + kfree(reply); return -EINVAL; + } *msg_len = reply_len; *msg = reply; -- 2.20.1