From patchwork Wed Sep 12 12:55:57 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: 1443611 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id D91A9DF28C for ; Wed, 12 Sep 2012 12:59:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758286Ab2ILM4W (ORCPT ); Wed, 12 Sep 2012 08:56:22 -0400 Received: from mail-we0-f174.google.com ([74.125.82.174]:37861 "EHLO mail-we0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757566Ab2ILM4S (ORCPT ); Wed, 12 Sep 2012 08:56:18 -0400 Received: by weyx8 with SMTP id x8so964139wey.19 for ; Wed, 12 Sep 2012 05:56:16 -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=zrz5yDmkJ7lwu0SeOKc/jCXSQ0N9YmKQqhP8X86m3ug=; b=G2lChuPkwATgJkDRnecazdgezXQfblqCu5uJmvULptz/4fdNItnN/ln8ayk1qBOaGb FAoBs5VdRQf+qGWspQPM5TasWuxzUCuElMtV0/qztuM3S9UI1ixkcJcT/qtArxDWgVrp ENxe6EAZhJ0U4zP/08pUddTcWKEPWLaI4cFiRXgsmb1kTxoaKWvFWtBE7cpBx9dUUNgX yAwkTgo+taxmFF4i7pq+QkSvg6BCGCyY/Y3cSL1fsMowanr6SM10mpEbrxnQBImD98kS eCZGOPIr1bbdyd+K1cshr7cToBKEDp5DQ3QiBt8wnZ2MEvF63jPTmuSjEa34D0URSb6Z AkXA== Received: by 10.180.85.167 with SMTP id i7mr32701683wiz.8.1347454576744; Wed, 12 Sep 2012 05:56:16 -0700 (PDT) Received: from localhost.localdomain (ppeter.rsr.lip6.fr. [132.227.76.16]) by mx.google.com with ESMTPS id cl8sm7933596wib.10.2012.09.12.05.56.14 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Sep 2012 05:56:15 -0700 (PDT) From: Peter Senna Tschudin To: Mauro Carvalho Chehab Cc: kernel-janitors@vger.kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 8/8] drivers/media/tuners/mt2063.c: Removes useless kfree() Date: Wed, 12 Sep 2012 14:55:57 +0200 Message-Id: <1347454564-5178-1-git-send-email-peter.senna@gmail.com> X-Mailer: git-send-email 1.7.11.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.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/media/tuners/mt2063.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/tuners/mt2063.c b/drivers/media/tuners/mt2063.c index 0ed9091..620c4fa 100644 --- a/drivers/media/tuners/mt2063.c +++ b/drivers/media/tuners/mt2063.c @@ -2249,8 +2249,8 @@ struct dvb_frontend *mt2063_attach(struct dvb_frontend *fe, dprintk(2, "\n"); state = kzalloc(sizeof(struct mt2063_state), GFP_KERNEL); - if (state == NULL) - goto error; + if (!state) + return NULL; state->config = config; state->i2c = i2c; @@ -2261,10 +2261,6 @@ struct dvb_frontend *mt2063_attach(struct dvb_frontend *fe, printk(KERN_INFO "%s: Attaching MT2063\n", __func__); return fe; - -error: - kfree(state); - return NULL; } EXPORT_SYMBOL_GPL(mt2063_attach);