From patchwork Wed Sep 12 15:06:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Senna Tschudin X-Patchwork-Id: 1446341 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id AE7BC3FE79 for ; Wed, 12 Sep 2012 20:00:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AB3239EB06 for ; Wed, 12 Sep 2012 13:00:30 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com [74.125.82.41]) by gabe.freedesktop.org (Postfix) with ESMTP id E72EB9EB0F for ; Wed, 12 Sep 2012 08:07:13 -0700 (PDT) Received: by wgbds1 with SMTP id ds1so2708583wgb.0 for ; Wed, 12 Sep 2012 08:07:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=VDmsgc6WH6eVHEZ+KLpB/xEjHQ1SRjffIFrWdkF6grk=; b=VsvfnKgggbg0nrXZ1jA9IbyAWS6T5zJMMNaqBl/YnJuJAtluHOHYcSUcQ5DNnsE2dB zrVINN8bNuvlJMw5YUIUoELbycy1e2+XJZgqlcKhHsx3ZTKiF4WfI9Hqs4KCQsud+vcK NWzVUxle0YkTREgWGvYkfjEnPvhdBeRU7z05A5XVObesvl1ZsJ6nULHXxB5VRvLqX5HW rLmoZpzhj6ew9Vvo15Qki6fNYwpMXrwn9076vxQrTbfyi+OLOL4BTJ9CnuPnBWcZK+w6 6rUYesHSVtnrKler2Abp6OLCuEWXNKLjcoQUPSEuqO6reAH8L66r25PwUZ99eBxrpJyc Oqzg== Received: by 10.180.91.169 with SMTP id cf9mr39093465wib.1.1347462432973; Wed, 12 Sep 2012 08:07:12 -0700 (PDT) Received: from localhost.localdomain (ppeter.rsr.lip6.fr. [132.227.76.16]) by mx.google.com with ESMTPS id j6sm12770614wiy.4.2012.09.12.08.07.12 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Sep 2012 08:07:12 -0700 (PDT) From: Peter Senna Tschudin To: David Airlie Subject: [PATCH 3/9] drivers/gpu/drm/ttm/ttm_page_alloc_dma.c: Remove useless kfree Date: Wed, 12 Sep 2012 17:06:41 +0200 Message-Id: <1347462407-13499-3-git-send-email-peter.senna@gmail.com> X-Mailer: git-send-email 1.7.11.4 X-Mailman-Approved-At: Wed, 12 Sep 2012 13:00:04 -0700 Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org From: Peter Senna Tschudin Remove useless kfree() and clean up code related to the removal. The semantic patch that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @r exists@ position p1,p2; expression x; @@ if (x@p1 == NULL) { ... kfree@p2(x); ... return ...; } @unchanged exists@ position r.p1,r.p2; expression e <= r.x,x,e1; iterator I; statement S; @@ if (x@p1 == NULL) { ... when != I(x,...) S when != e = e1 when != e += e1 when != e -= e1 when != ++e when != --e when != e++ when != e-- when != &e kfree@p2(x); ... return ...; } @ok depends on unchanged exists@ position any r.p1; position r.p2; expression x; @@ ... when != true x@p1 == NULL kfree@p2(x); @depends on !ok && unchanged@ position r.p2; expression x; @@ *kfree@p2(x); // Signed-off-by: Peter Senna Tschudin --- drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c index 4f9e548..969d765 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c @@ -1060,7 +1060,7 @@ int ttm_dma_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages) _manager = kzalloc(sizeof(*_manager), GFP_KERNEL); if (!_manager) - goto err_manager; + goto err; mutex_init(&_manager->lock); INIT_LIST_HEAD(&_manager->pools); @@ -1078,9 +1078,6 @@ int ttm_dma_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages) } ttm_dma_pool_mm_shrink_init(_manager); return 0; -err_manager: - kfree(_manager); - _manager = NULL; err: return ret; }