From patchwork Wed Sep 25 04:37:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Navid Emamdoost X-Patchwork-Id: 11160135 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9AA72912 for ; Wed, 25 Sep 2019 07:20:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 82F2421D80 for ; Wed, 25 Sep 2019 07:20:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 82F2421D80 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8D8A46EB35; Wed, 25 Sep 2019 07:19:33 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by gabe.freedesktop.org (Postfix) with ESMTPS id 07BB66E832 for ; Wed, 25 Sep 2019 04:38:16 +0000 (UTC) Received: by mail-io1-xd44.google.com with SMTP id u8so10216734iom.5 for ; Tue, 24 Sep 2019 21:38:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=5BDuZ4+Y3X5laJQOvw+qSCT7xhGoru1+k46cwYao5zs=; b=hqPO2mS5EfZKmnLeIk1g1AAE+1oL0Q7dREuT6KrAB6Sg5fyMvf8V/omaKb5t3rpq8P utWBnlYe0jh/yX+jOMoQf8+FvePnXBOCUFUlTnzgsnZ9DggX+JuBgAgC/SDPehKlFScy N8ygoym8SLgyAV9yPHNkiddiVimR9Mta9RbrEaABgKbei4ozVgTWwuPv4i0RczM+y9Hh KWkelMxdrMfv7vRdFqzPjfQYkDblj5Be3jB25w3JtpBmTI8Zj29REk9yb/voqjss4ZOE 44ru+a01GiJu3zph4YuzSJVgRAv1M1FNP66W0lm/SI+whxoBjJoDceUAy/fVKO83TQ8p U5Lw== X-Gm-Message-State: APjAAAXU78bffZbnWrtevx2tg+y2jU+YZMj4kVRq2wHsykUFDkac5eFC 1jNX4St0ZGbupV8SSkYhxko= X-Google-Smtp-Source: APXvYqzXt01BRxpe/Gpokn+Qqg4SqkmVtkWH3lUoq+gLxw/pva1ap3tM1cq/kabrKnKblef4yAbfsA== X-Received: by 2002:a5d:8ac4:: with SMTP id e4mr8009350iot.185.1569386295248; Tue, 24 Sep 2019 21:38:15 -0700 (PDT) Received: from cs-dulles.cs.umn.edu (cs-dulles.cs.umn.edu. [128.101.35.54]) by smtp.googlemail.com with ESMTPSA id g68sm33489ilh.88.2019.09.24.21.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2019 21:38:14 -0700 (PDT) From: Navid Emamdoost To: Subject: [PATCH] drm/vmwgfx: prevent memory leak in vmw_cmdbuf_res_add Date: Tue, 24 Sep 2019 23:37:58 -0500 Message-Id: <20190925043800.726-1-navid.emamdoost@gmail.com> X-Mailer: git-send-email 2.17.1 X-Mailman-Approved-At: Wed, 25 Sep 2019 07:19:29 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=5BDuZ4+Y3X5laJQOvw+qSCT7xhGoru1+k46cwYao5zs=; b=mDXySTkDaQZsdqKg5+tkUpytcg3n00Lh6czbxsojHEwUp/Jd/Z26hPuo8nvxOck/EP I5hHoTiv4HuWD4+eMmDb1xEVFPDc/3H3RESpudOWjFsM8piowjdRO7XbTiF/sjHBjAXZ usQmXob+UkL9ysO1USfkRgoN7EzuYamxCMNxiMkOnIUmstzaW6Fw7orms/3Yq70boRl+ BI0jEaXeJ4PHupSRsujX1ZF/68hTpmEVh3UpAdYli410sqwNEsJP/FKmvgyhCxJqyFq3 cqnC3WaK/+zLvqCVRCSX2Ie3+6uVJyTxl72LKAwSjM3ZYavhs0N8WRtNVwUVosfpEiMi Ml/g== 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 , David Airlie , kjlu@umn.edu, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, emamd001@umn.edu, VMware Graphics , smccaman@umn.edu, Navid Emamdoost MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In vmw_cmdbuf_res_add if drm_ht_insert_item fails the allocated memory for cres should be released. Signed-off-by: Navid Emamdoost Reviewed-by: Thomas Hellstrom --- drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c index 4ac55fc2bf97..44d858ce4ce7 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c @@ -209,8 +209,10 @@ int vmw_cmdbuf_res_add(struct vmw_cmdbuf_res_manager *man, cres->hash.key = user_key | (res_type << 24); ret = drm_ht_insert_item(&man->resources, &cres->hash); - if (unlikely(ret != 0)) + if (unlikely(ret != 0)) { + kfree(cres); goto out_invalid_key; + } cres->state = VMW_CMDBUF_RES_ADD; cres->res = vmw_resource_reference(res);