From patchwork Wed Sep 12 12:55:59 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: 1443651 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 BAF5CDF28C for ; Wed, 12 Sep 2012 13:00:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758623Ab2ILM7m (ORCPT ); Wed, 12 Sep 2012 08:59:42 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:64800 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757721Ab2ILM4U (ORCPT ); Wed, 12 Sep 2012 08:56:20 -0400 Received: by wibhi8 with SMTP id hi8so5239798wib.1 for ; Wed, 12 Sep 2012 05:56:19 -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=MZFUeQe2io5mHzg2DjgF27PeNJoVz8Uoopx8dlIuMzA=; b=ufzrnoh3KDJAvwVbldw5aFsiq5xh45rSMoVt2XFxQdb/9WGtFAaCHmEITXeW23cLFY k5ALJLLn/NdwWz9cSPsjR3LXhWoGFIPoZCtJAQuASQVP8oe4zYrN5/ZRuKf9DvXmHoRi eU4SrmmLDLe4MhX0Su++oM+6Iu5WvuWfWXjvX/nKaGkPr/Cyk9AHeinCEV3wgDh2m95e Sa755cMBmYQdLKrxMkhSIPfQpGU6pHM5GzCmhf+zGS8TefXFLKQffxHUvbCBPf8Ii2AT 9oHWDYB7RQYU0EkeSvjHpzr4tTjzZH17/Ozh6Br83neZ6II0ko6p0Grno1O61+B5fEcO R6xg== Received: by 10.180.79.229 with SMTP id m5mr32634174wix.13.1347454579262; Wed, 12 Sep 2012 05:56:19 -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.18 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Sep 2012 05:56:18 -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 6/8] drivers/media/dvb-frontends/tda665x.c: Removes useless kfree() Date: Wed, 12 Sep 2012 14:55:59 +0200 Message-Id: <1347454564-5178-3-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/dvb-frontends/tda665x.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/dvb-frontends/tda665x.c b/drivers/media/dvb-frontends/tda665x.c index 2c1c759..63cc123 100644 --- a/drivers/media/dvb-frontends/tda665x.c +++ b/drivers/media/dvb-frontends/tda665x.c @@ -228,8 +228,8 @@ struct dvb_frontend *tda665x_attach(struct dvb_frontend *fe, struct dvb_tuner_info *info; state = kzalloc(sizeof(struct tda665x_state), GFP_KERNEL); - if (state == NULL) - goto exit; + if (!state) + return NULL; state->config = config; state->i2c = i2c; @@ -246,10 +246,6 @@ struct dvb_frontend *tda665x_attach(struct dvb_frontend *fe, printk(KERN_DEBUG "%s: Attaching TDA665x (%s) tuner\n", __func__, info->name); return fe; - -exit: - kfree(state); - return NULL; } EXPORT_SYMBOL(tda665x_attach);