From patchwork Mon Mar 3 10:06:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 3753161 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AF17D9F1EE for ; Mon, 3 Mar 2014 10:14:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2C85820127 for ; Mon, 3 Mar 2014 10:14:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3E2722009C for ; Mon, 3 Mar 2014 10:14:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753512AbaCCKOx (ORCPT ); Mon, 3 Mar 2014 05:14:53 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:49404 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754177AbaCCKH7 (ORCPT ); Mon, 3 Mar 2014 05:07:59 -0500 Received: from [201.74.152.26] (helo=smtp.w2.samsung.com) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1WKPmu-00078V-Rd; Mon, 03 Mar 2014 10:07:57 +0000 Received: from mchehab by smtp.w2.samsung.com with local (Exim 4.80.1) (envelope-from ) id 1WKPmF-0006Wj-Au; Mon, 03 Mar 2014 07:07:15 -0300 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab Subject: [PATCH 38/79] [media] drx-j: Fix release and error path on drx39xxj.c Date: Mon, 3 Mar 2014 07:06:32 -0300 Message-Id: <1393841233-24840-39-git-send-email-m.chehab@samsung.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1393841233-24840-1-git-send-email-m.chehab@samsung.com> References: <1393841233-24840-1-git-send-email-m.chehab@samsung.com> To: unlisted-recipients:; (no To-header on input) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There are memory leaks on both DVB release and dvb attach error path. Fix them. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/drx39xyj/drx39xxj.c | 31 +++++++++++++++---------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/media/dvb-frontends/drx39xyj/drx39xxj.c b/drivers/media/dvb-frontends/drx39xyj/drx39xxj.c index e5f276f5d215..44e9bafcc9ed 100644 --- a/drivers/media/dvb-frontends/drx39xyj/drx39xxj.c +++ b/drivers/media/dvb-frontends/drx39xyj/drx39xxj.c @@ -318,6 +318,12 @@ static int drx39xxj_get_tune_settings(struct dvb_frontend *fe, static void drx39xxj_release(struct dvb_frontend *fe) { struct drx39xxj_state *state = fe->demodulator_priv; + struct drx_demod_instance *demod = state->demod; + + kfree(demod->my_ext_attr); + kfree(demod->my_common_attr); + kfree(demod->my_i2c_dev_addr); + kfree(demod); kfree(state); } @@ -378,16 +384,14 @@ struct dvb_frontend *drx39xxj_attach(struct i2c_adapter *i2c) demod->my_ext_attr = demod_ext_attr; memcpy(demod->my_ext_attr, &drxj_data_g, sizeof(struct drxj_data)); - ((struct drxj_data *)demod->my_ext_attr)->uio_sma_tx_mode = - DRX_UIO_MODE_READWRITE; + ((struct drxj_data *)demod->my_ext_attr)->uio_sma_tx_mode = DRX_UIO_MODE_READWRITE; demod->my_tuner = NULL; result = drx_open(demod); if (result != 0) { pr_err("DRX open failed! Aborting\n"); - kfree(state); - return NULL; + goto error; } /* Turn off the LNA */ @@ -395,9 +399,9 @@ struct dvb_frontend *drx39xxj_attach(struct i2c_adapter *i2c) uio_cfg.mode = DRX_UIO_MODE_READWRITE; /* Configure user-I/O #3: enable read/write */ result = drx_ctrl(demod, DRX_CTRL_UIO_CFG, &uio_cfg); - if (result != 0) { + if (result) { pr_err("Failed to setup LNA GPIO!\n"); - return NULL; + goto error; } uio_data.uio = DRX_UIO1; @@ -405,7 +409,7 @@ struct dvb_frontend *drx39xxj_attach(struct i2c_adapter *i2c) result = drx_ctrl(demod, DRX_CTRL_UIO_WRITE, &uio_data); if (result != 0) { pr_err("Failed to disable LNA!\n"); - return NULL; + goto error; } /* create dvb_frontend */ @@ -416,10 +420,12 @@ struct dvb_frontend *drx39xxj_attach(struct i2c_adapter *i2c) return &state->frontend; error: - if (state != NULL) - kfree(state); - if (demod != NULL) - kfree(demod); + kfree(demod_ext_attr); + kfree(demod_comm_attr); + kfree(demod_addr); + kfree(demod); + kfree(state); + return NULL; } EXPORT_SYMBOL(drx39xxj_attach); @@ -431,7 +437,8 @@ static struct dvb_frontend_ops drx39xxj_ops = { .frequency_stepsize = 62500, .frequency_min = 51000000, .frequency_max = 858000000, - .caps = FE_CAN_QAM_64 | FE_CAN_QAM_256 | FE_CAN_8VSB}, + .caps = FE_CAN_QAM_64 | FE_CAN_QAM_256 | FE_CAN_8VSB + }, .init = drx39xxj_init, .i2c_gate_ctrl = drx39xxj_i2c_gate_ctrl,