Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753158AbeABNZI (ORCPT + 1 other); Tue, 2 Jan 2018 08:25:08 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:42229 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753133AbeABNZH (ORCPT ); Tue, 2 Jan 2018 08:25:07 -0500 X-Google-Smtp-Source: ACJfBovS3DxJS5VocW2Q5DPjboZN2pMb38XV1SyPKmt37u9w1JuBImalI/tY4N84Fg3NxAzBbr/bTA== From: Xiongwei Song To: christian.koenig@amd.com, Hongbo.He@amd.com, airlied@linux.ie Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v3] drm/ttm: check the return value of kzalloc Date: Tue, 2 Jan 2018 21:24:55 +0800 Message-Id: <20180102132455.5413-1-sxwjean@gmail.com> X-Mailer: git-send-email 2.15.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: In the function ttm_page_alloc_init, kzalloc call is made for variable _manager, we need to check its return value, it may return NULL. Signed-off-by: Xiongwei Song --- v2->v3: delete goto expression v1->v2: delete kfree _manager --- drivers/gpu/drm/ttm/ttm_page_alloc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index b5ba6441489f..5d252fb27a82 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c @@ -1007,6 +1007,8 @@ int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages) pr_info("Initializing pool allocator\n"); _manager = kzalloc(sizeof(*_manager), GFP_KERNEL); + if (!_manager) + return -ENOMEM; ttm_page_pool_init_locked(&_manager->wc_pool, GFP_HIGHUSER, "wc", 0); -- 2.15.1