From patchwork Wed Sep 12 12:56:01 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: 1443581 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 5ECBA4025E for ; Wed, 12 Sep 2012 12:59:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758504Ab2ILM6q (ORCPT ); Wed, 12 Sep 2012 08:58:46 -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 S1758309Ab2ILM4Y (ORCPT ); Wed, 12 Sep 2012 08:56:24 -0400 Received: by mail-we0-f174.google.com with SMTP id x8so964139wey.19 for ; Wed, 12 Sep 2012 05:56:23 -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=7aoWZLU+GVW/11X6jQIf8Nv7yM8uwu5R1bGYADfdzmg=; b=eO28sOkPfXjVeml81HhNhL908IhqMDEM++MwQRWiWt1pqlny4+/PdKcsSMat1sXbLi xSBC60vJLn8X5YCM1aYT+zcehUEQunCDbaUAf5cozy3uDEpl3F65W9FU5vLv8VK70wck LGanIY9MOPTI0QtQwj5bxRauzQ4bTM0U83PCWJyG9LZPWgwNZRo1FExMmAQlUHati/hV egBVTzhgOx+4MgFKmrPJPdWGtb+/luKnwp4YYMr2NNrR7fYFgN6jD0VOIPUCV+Uwnu8f 0yW9GCLSmZ/1NTqNORcaNoQfc2JIkogMUEjYNqPH1TPQii2c+FBYAP6tz10A20KCrnt/ WrUw== Received: by 10.216.138.73 with SMTP id z51mr3953027wei.39.1347454583048; Wed, 12 Sep 2012 05:56:23 -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.20 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Sep 2012 05:56:21 -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 4/8] drivers/media/dvb-frontends/s921.c: Removes useless kfree() Date: Wed, 12 Sep 2012 14:56:01 +0200 Message-Id: <1347454564-5178-5-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/s921.c | 9 ++------- 1 file changed, 2 insertions(+), 7 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/s921.c b/drivers/media/dvb-frontends/s921.c index cd2288c..a271ac3 100644 --- a/drivers/media/dvb-frontends/s921.c +++ b/drivers/media/dvb-frontends/s921.c @@ -487,9 +487,9 @@ struct dvb_frontend *s921_attach(const struct s921_config *config, kzalloc(sizeof(struct s921_state), GFP_KERNEL); dprintk("\n"); - if (state == NULL) { + if (!state) { rc("Unable to kzalloc\n"); - goto rcor; + return NULL; } /* setup the state */ @@ -502,11 +502,6 @@ struct dvb_frontend *s921_attach(const struct s921_config *config, state->frontend.demodulator_priv = state; return &state->frontend; - -rcor: - kfree(state); - - return NULL; } EXPORT_SYMBOL(s921_attach);