Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp661463ybt; Wed, 8 Jul 2020 08:42:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJLrb6dPbvlM+xDFG+qX2wH6z7TVsQk8Jnbx0Muqy/bcWUnx9ksOm67b4XcxMd3HhlMtK2 X-Received: by 2002:a50:ce45:: with SMTP id k5mr68524250edj.80.1594222921915; Wed, 08 Jul 2020 08:42:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594222921; cv=none; d=google.com; s=arc-20160816; b=HRqw6/kDA9MOFaK8EDz8yxAA3JtklFyPiomapqgUEJDlBBaxVaRzhQV+naxXbvfHwE qFaHyco4ig7SsPXVVybLbyxHqRx+Fy7FndwUp24qosM1dVuk3hO6YjgU0IxD3ywZWgSl wbooVMug+BGowKN5GRSAU6ooSawa5unQhcpbGDXzUEEbrYrr7f/RaRSTAh1Fm/ZYaAWq Yg95OduTcMPnxPsiigY3e85qioebwgqYrTR70f0l+k2N92jbN7kBPGdr3RHtmoPzxxCj ZfDuKWatri7lej74v5t38XiaD2tEF6/mZM6jTk/R5B9ck3geRhympuLGXaJcA4IZDJE2 AwmQ== 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:dkim-signature; bh=KRC6S4U1vPLCadl7IT91rlqmmPM+OCNusMgg2i3Yl04=; b=uMu42mGAZlEFE6SmDEJ0p7t9YPgrIaYMIab3gqlelYQyKrT7ehGn/d1k+D28rDl1PM VMICiq+n6ozYBdeBQc46bAER5HrUP0c7ZrW938xn/uEGD51Y5noHDnHgo6Hcz+Dq/y4W kiE/O30UkZiXV6+ICiyJ6p1J+0f2Ur6TfXIBAlOT+Y8pdbhYb0wVQOc8yKn55HtUiOHk eQSkXrw+dpfqFMUSOMUUxuOQZz/EBKlLugrjkcbtDz1yZbMVO9KusLWHoUGQqPNM0Gyp I8ilb1prCBwIBobDNs3ofPdgIZXY8wv00sroTTy9mbmnFFCsbUdniyHdGiyzilIHoLWl r7dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ywlgMjIZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds16si141282ejc.112.2020.07.08.08.41.38; Wed, 08 Jul 2020 08:42:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ywlgMjIZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730355AbgGHPlT (ORCPT + 99 others); Wed, 8 Jul 2020 11:41:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:47628 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729858AbgGHPlT (ORCPT ); Wed, 8 Jul 2020 11:41:19 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EF399206DF; Wed, 8 Jul 2020 15:41:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594222878; bh=jWTJMZSpFMXv1eN4iBy7F5NdaPw4rqs4cZcmn3E18Tk=; h=From:To:Cc:Subject:Date:From; b=ywlgMjIZIfbK8x6qVWUDDKaSMLzbqJX32SB0BeBhYW7KwLntTVbbsIgftAB9/Elrn 88oq14MhXs7HeuPNHZcpTkZco4hpYWGOglNfzSFm/dYx7kn+IOYLJd2cM2f3NyoBdG X92c60LOpMW/IQfF7B9ANvOjjwkqHzf7deITdjhE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Bernard Zhao , Rob Clark , Sasha Levin , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.7 01/30] drm/msm: fix potential memleak in error branch Date: Wed, 8 Jul 2020 11:40:47 -0400 Message-Id: <20200708154116.3199728-1-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bernard Zhao [ Upstream commit 177d3819633cd520e3f95df541a04644aab4c657 ] In function msm_submitqueue_create, the queue is a local variable, in return -EINVAL branch, queue didn`t add to ctx`s list yet, and also didn`t kfree, this maybe bring in potential memleak. Signed-off-by: Bernard Zhao [trivial commit msg fixup] Signed-off-by: Rob Clark Signed-off-by: Sasha Levin --- drivers/gpu/drm/msm/msm_submitqueue.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/msm_submitqueue.c b/drivers/gpu/drm/msm/msm_submitqueue.c index 001fbf537440a..a1d94be7883a0 100644 --- a/drivers/gpu/drm/msm/msm_submitqueue.c +++ b/drivers/gpu/drm/msm/msm_submitqueue.c @@ -71,8 +71,10 @@ int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx, queue->flags = flags; if (priv->gpu) { - if (prio >= priv->gpu->nr_rings) + if (prio >= priv->gpu->nr_rings) { + kfree(queue); return -EINVAL; + } queue->prio = prio; } -- 2.25.1