Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3128400ybl; Mon, 19 Aug 2019 12:42:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwxctEHQPH3zJR30b5kqNTQOUVo3IesdhEAic8W7OHX/80aYnT4+UfD2iELApRvH79vEGzX X-Received: by 2002:a63:e213:: with SMTP id q19mr21266341pgh.180.1566243732949; Mon, 19 Aug 2019 12:42:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566243732; cv=none; d=google.com; s=arc-20160816; b=xFCkJoxj8y4a8QSYXR7kDoOx93l8BMoAa6xez5gEzlcIY8DeoOI9jUd/qsJ+/V6EE5 o00drnHphSyOy+AjS5+7p+cReDk+rwi5QZAVr0tjm72uNEsz6EtWj8XnQrjbPW+srXHY Z9CL1Yzf8b7xbkq79EBlwVMJ2LfwNI9EALkKpVvXQedYM+UGWgTsL7ogAY7BOATRhT+Z c7LTpZvAYuAK3uxKy9a+KASSGx0yhmTqVQbiX1OuWSjhCVNpmyBZDIjtcrqTaNGPuBPG 3QGzqNhZTSDSdk4tyqpn4cNJmiHV7xYiNEgHpSKT5stE090zBGJ1sH/+N4hiVDIdlMMg BvbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=3jjV8Hrc7MgB8gFTbQTU8aPeFAihk9juTlaHbNEZJYw=; b=Tfi0GwYnGil5rcQbRaX3h/XME3hrnfv/c7APXliwW963yQC5hw7U5cnL+GUD+hGEki hDxUZ2ZYsAEuToLM+Vhiulmatjo78O/w6qgJ+A/wZ2QZ00POpv8FEYvP3q+ecB3dlEn5 4OdLx2G/8ssTv8YhRssh6fQ6+A6wW1AJ/w9qiaj220JKrxdxNsqtXMVPsqUL5eNAIMKE pFGVUhGTQ3xVJ6n5BB5iI94dC/bt+mp++UlOtfEqK1fe5hE+d7jhJngv3uXfBzansz0g kOpJLvmQKy6mwik39hpngalhj39i9NQSHAn9wW/tOo20p8afuVBCvMBkbGVLI+V9UNZC nGQA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v19si11037265pff.229.2019.08.19.12.41.57; Mon, 19 Aug 2019 12:42:12 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728474AbfHSTlC (ORCPT + 99 others); Mon, 19 Aug 2019 15:41:02 -0400 Received: from mail-yw1-f65.google.com ([209.85.161.65]:40885 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728349AbfHSTlC (ORCPT ); Mon, 19 Aug 2019 15:41:02 -0400 Received: by mail-yw1-f65.google.com with SMTP id z64so1278562ywe.7 for ; Mon, 19 Aug 2019 12:41:01 -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=3jjV8Hrc7MgB8gFTbQTU8aPeFAihk9juTlaHbNEZJYw=; b=eur31YbXVBwTrhA/H/3RapmG13gNxh5n3/C0H4JjKEuv8QVhjTYQKuwi+5nKDAatU5 H2oH3BbxMs+l2wfBXmT3rcm9amX46NvAfS6M5hSZIf2qRNHThvYr262LIqyqJbxvm2Kx Gyq2wygl6EBW49IV+THhlZJQ4I6hGP2otS4WPyRmSccu271utCqp+Tk9llHY0yUtF5Vj 061tJIOem+UTDXIFg1u69NwSSzvrMW05ZPEobqRfhAkkCXA03S/8pMYOtXv+pWF8WAMG dcgDCMdxMw8v5k8ACU0xYG/6fvjo8Z+sDV64QUOeLzywInHQL7mNBswZzgwsGDLZiEOz 3iiQ== X-Gm-Message-State: APjAAAVfom0jxCuT14QFYqBk39rvX78CXoqhHlPSd/NgajYDHXM3/Y9P bkfEp2q40WyVr87vfa7FOwk= X-Received: by 2002:a81:310b:: with SMTP id x11mr18009539ywx.420.1566243661057; Mon, 19 Aug 2019 12:41:01 -0700 (PDT) Received: from localhost.localdomain (24-158-240-219.dhcp.smyr.ga.charter.com. [24.158.240.219]) by smtp.gmail.com with ESMTPSA id 84sm3330637ywp.45.2019.08.19.12.40.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Aug 2019 12:41:00 -0700 (PDT) From: Wenwen Wang To: Wenwen Wang Cc: Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] drm: Fix memory leaks Date: Mon, 19 Aug 2019 14:40:49 -0500 Message-Id: <1566243649-5249-1-git-send-email-wenwen@cs.uga.edu> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In drm_universal_plane_init(), if 'format_count' is larger than 64, no cleanup is executed, leading to memory/resource leaks. To fix this issue, perform cleanup work before returning -EINVAL. Signed-off-by: Wenwen Wang --- drivers/gpu/drm/drm_plane.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index d6ad60a..2c0d0044 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -211,8 +211,11 @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane, * First driver to need more than 64 formats needs to fix this. Each * format is encoded as a bit and the current code only supports a u64. */ - if (WARN_ON(format_count > 64)) + if (WARN_ON(format_count > 64)) { + kfree(plane->format_types); + drm_mode_object_unregister(dev, &plane->base); return -EINVAL; + } if (format_modifiers) { const uint64_t *temp_modifiers = format_modifiers; -- 2.7.4