Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE460C43217 for ; Wed, 24 Nov 2021 12:21:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244473AbhKXMXg (ORCPT ); Wed, 24 Nov 2021 07:23:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:36452 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243743AbhKXMSs (ORCPT ); Wed, 24 Nov 2021 07:18:48 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5DC9160FD9; Wed, 24 Nov 2021 12:11:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1637755908; bh=ONDIJZcac4CL9lqDOnMYbysGrzAfg5GcgsK5AqxiSu4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wfKN7nPvyVtNaXpOgnUioORsmYod3I+6kHn3/EeEJ68kzoJ3lgwXrJBHLSKTrPZ6Z MoecYoNBFQQGRB0Upqxc9nJJSuV0jEWXEqST/4ECUdZZywf94Rve++KKzHwjrfPCHW IZYdEIKUDfq1PY9CNephhr2eRcp5cNXQeBYT4Tmk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Rob Clark , Sasha Levin Subject: [PATCH 4.9 102/207] drm/msm: uninitialized variable in msm_gem_import() Date: Wed, 24 Nov 2021 12:56:13 +0100 Message-Id: <20211124115707.380650509@linuxfoundation.org> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211124115703.941380739@linuxfoundation.org> References: <20211124115703.941380739@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter [ Upstream commit 2203bd0e5c12ffc53ffdd4fbd7b12d6ba27e0424 ] The msm_gem_new_impl() function cleans up after itself so there is no need to call drm_gem_object_put(). Conceptually, it does not make sense to call a kref_put() function until after the reference counting has been initialized which happens immediately after this call in the drm_gem_(private_)object_init() functions. In the msm_gem_import() function the "obj" pointer is uninitialized, so it will lead to a crash. Fixes: 05b849111c07 ("drm/msm: prime support") Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/20211013081315.GG6010@kili Signed-off-by: Rob Clark Signed-off-by: Sasha Levin --- drivers/gpu/drm/msm/msm_gem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c index 983ce7965c7ff..dfce39f02f8d4 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c @@ -871,7 +871,7 @@ struct drm_gem_object *msm_gem_new(struct drm_device *dev, ret = msm_gem_new_impl(dev, size, flags, NULL, &obj); if (ret) - goto fail; + return ERR_PTR(ret); if (use_pages(obj)) { ret = drm_gem_object_init(dev, obj, size); @@ -910,7 +910,7 @@ struct drm_gem_object *msm_gem_import(struct drm_device *dev, mutex_unlock(&dev->struct_mutex); if (ret) - goto fail; + return ERR_PTR(ret); drm_gem_private_object_init(dev, obj, size); -- 2.33.0