From patchwork Wed Sep 12 12:56:02 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: 1443551 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 3786A40AB5 for ; Wed, 12 Sep 2012 12:58:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758498Ab2ILM5Y (ORCPT ); Wed, 12 Sep 2012 08:57:24 -0400 Received: from mail-wi0-f178.google.com ([209.85.212.178]:50909 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758327Ab2ILM40 (ORCPT ); Wed, 12 Sep 2012 08:56:26 -0400 Received: by wibhr14 with SMTP id hr14so2053153wib.1 for ; Wed, 12 Sep 2012 05:56:24 -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=4K9zafHlhzMMMy6bKCLTBu40wW12TFOCcF0W1yOGvT0=; b=fK9/2RZ9mY0+8rWFgel9mGuHpIfNTzQyqYR+23oh+5hYgW6j9hTnaCjPD7zKR3tDhG mGzjRtP6+gXdbDzj8JxJfK2celR1b9XtLMNGYZyVO6IhgKDIbC+p3llPMlYtx0uGIvx1 QWPCTdbmSFqQkD97tIcaSANJcxkVkCcTlsE0Jk4hu2SvSfH1MjIsxlW2DouSCByrJChS u9suiuGC1FwzcItRLH48EQy+fS3w8HHocmeT/cYhAkjUcfIZTSwRQZdHLU8Tb4hrFCz9 p5eKelD1OrOyQCOzje4f8LPBbGhZE8MxoumZOWOJrgrVto8Md0MvvIyKvBNkDv0N14rw gVew== Received: by 10.180.97.135 with SMTP id ea7mr32652037wib.11.1347454584671; Wed, 12 Sep 2012 05:56:24 -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.23 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Sep 2012 05:56:23 -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 3/8] drivers/media/dvb-frontends/s5h1432.c: Removes useless kfree() Date: Wed, 12 Sep 2012 14:56:02 +0200 Message-Id: <1347454564-5178-6-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/s5h1432.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/s5h1432.c b/drivers/media/dvb-frontends/s5h1432.c index 8352ce1..6ec16a2 100644 --- a/drivers/media/dvb-frontends/s5h1432.c +++ b/drivers/media/dvb-frontends/s5h1432.c @@ -351,8 +351,8 @@ struct dvb_frontend *s5h1432_attach(const struct s5h1432_config *config, printk(KERN_INFO " Enter s5h1432_attach(). attach success!\n"); /* allocate memory for the internal state */ state = kmalloc(sizeof(struct s5h1432_state), GFP_KERNEL); - if (state == NULL) - goto error; + if (!state) + return NULL; /* setup the state */ state->config = config; @@ -367,10 +367,6 @@ struct dvb_frontend *s5h1432_attach(const struct s5h1432_config *config, state->frontend.demodulator_priv = state; return &state->frontend; - -error: - kfree(state); - return NULL; } EXPORT_SYMBOL(s5h1432_attach);