From patchwork Thu Mar 29 10:40:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 132562 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1577619ljb; Thu, 29 Mar 2018 03:40:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx48mLrqs8hoikypZQc1yIFWBJhfltE7uG1sacbeCGSWBpyzK1aXjYSCDhzr20fEJe5KnRe30 X-Received: by 10.99.171.11 with SMTP id p11mr5050150pgf.176.1522320050966; Thu, 29 Mar 2018 03:40:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522320050; cv=none; d=google.com; s=arc-20160816; b=00wSCEnkP5NMoC0Btvg2aIg7dQNS9zHaZ6fnPPvtgQbYeRr7KCU8jb7MNqzrWZn8Sq UyaAx3rmJppUps0zzksikZlObyOu6Vlqkak0391XiEYAnNiKTtS4Ihu9ql82mK6FovuE e3XP5kOM3hGMAMyYZVqNxExZSuIgnW+haDbHpxMTED2GwtJR18XYGVAQMmMKvPbWqyxo oGVks1bkv+a85xK5xWsxzhCsg9j2DJxCcZAQcmdaQG/2eKu1/aZsfeYU9Al02neb5saX bTiYfTf/DhlfGZ+nBshTEfRHoqn2KS7KTmE5HpuE9eCJnk7pjr92a3SAmh13SRO721y+ qmQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to :arc-authentication-results; bh=MtZiu4MvwIk0BY1VsWcfCS/JzGNtON6ihsokR16/tes=; b=q7xAnGOvkNavV5hJ2N5qwKmWUC6SXpxOmKfkv5eWvKhJyok9ESP1Kk+gYW1/p4k0BN lajGWWN9iUB+PD4EBNUr1nlp2uMS54lvQcukG9DZxdLRF5YyRGc6zJFy5nR5CQEK/V3E gL7LAAlraLQkCiMob6yaGJvsEY60Zm2jXfkW9UY79ApMJ/du/iWUUHjXwf223y6ND2ul Jlf4rtd2MP5zycc7XGPzo3T7Xl3PZW6s5ifcWiXqxuivTZFnFVcUWe2PR4N1XgphA5Qr uV4KmSvSmj+6evnLIkw3bemHarB7tMDcj1TGnFyHcVClOpFQm0RSsAkimKEkDOlIwaDj Fc3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=H4ByTTm6; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id d6-v6si5402395plo.661.2018.03.29.03.40.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 29 Mar 2018 03:40:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=H4ByTTm6; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 07AF06E6E9; Thu, 29 Mar 2018 10:40:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lelnx194.ext.ti.com (lelnx194.ext.ti.com [198.47.27.80]) by gabe.freedesktop.org (Postfix) with ESMTPS id ECCC06E6AD for ; Thu, 29 Mar 2018 10:40:45 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id w2TAehOh000864; Thu, 29 Mar 2018 05:40:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1522320043; bh=q+2O/CFnMnXYvSj9vwyuBHDlYvG3+1bartSnyvDxjng=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=H4ByTTm6ZhTQEevzNJk3xNjWeszzXWhAZFVpD77uv9+QZ3CjuMX2Nq4fHPq+Ca6Sa BP4+IA0JfWidAAdqORdtD6N9jJ98Nh8pik2CbDcZSRCpqBoOEiU71kHhKUN3gehdxN 3Th/KBujx7R5PbfjAQRqqVNkyhuy5pty6xRe9+jo= Received: from DLEE106.ent.ti.com (dlee106.ent.ti.com [157.170.170.36]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w2TAehOJ003155; Thu, 29 Mar 2018 05:40:43 -0500 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Thu, 29 Mar 2018 05:40:43 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Thu, 29 Mar 2018 05:40:43 -0500 Received: from deskari.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w2TAeeE5012628; Thu, 29 Mar 2018 05:40:42 -0500 From: Tomi Valkeinen To: Subject: [PATCH 2/3] drm/omap: fix possible NULL ref issue in tiler_reserve_2d Date: Thu, 29 Mar 2018 13:40:37 +0300 Message-ID: <20180329104038.29154-2-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180329104038.29154-1-tomi.valkeinen@ti.com> References: <20180329104038.29154-1-tomi.valkeinen@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 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: Tomi Valkeinen , Laurent Pinchart Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" tiler_reserve_2d allocates memory but does not check if it got the memory. Add the check and return ENOMEM on failure. Signed-off-by: Tomi Valkeinen Reviewed-by: Emil Velikov Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c index c40f90d2db82..28d93ece191e 100644 --- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c +++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c @@ -532,6 +532,9 @@ struct tiler_block *tiler_reserve_2d(enum tiler_fmt fmt, u16 w, unsigned long flags; u32 slot_bytes; + if (!block) + return ERR_PTR(-ENOMEM); + BUG_ON(!validfmt(fmt)); /* convert width/height to slots */