From patchwork Sat Sep 22 16:51:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antti Palosaari X-Patchwork-Id: 1494411 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 ECF6CDF2D2 for ; Sat, 22 Sep 2012 16:52:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752482Ab2IVQwk (ORCPT ); Sat, 22 Sep 2012 12:52:40 -0400 Received: from mail.kapsi.fi ([217.30.184.167]:39811 "EHLO mail.kapsi.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752112Ab2IVQwk (ORCPT ); Sat, 22 Sep 2012 12:52:40 -0400 Received: from dyn3-82-128-186-237.psoas.suomi.net ([82.128.186.237] helo=localhost.localdomain) by mail.kapsi.fi with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1TFSwY-0006RH-2q; Sat, 22 Sep 2012 19:52:38 +0300 From: Antti Palosaari To: linux-media@vger.kernel.org Cc: Antti Palosaari Subject: [PATCH 4/5] e4000: fix crash when attach fails Date: Sat, 22 Sep 2012 19:51:39 +0300 Message-Id: <1348332700-10267-4-git-send-email-crope@iki.fi> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1348332700-10267-1-git-send-email-crope@iki.fi> References: <1348332700-10267-1-git-send-email-crope@iki.fi> X-SA-Exim-Connect-IP: 82.128.186.237 X-SA-Exim-Mail-From: crope@iki.fi X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Callbacks were set even attach failed. This leads calling .release() in error case and resulted crash. Reported-by: Oliver Schinagl Signed-off-by: Antti Palosaari --- drivers/media/tuners/e4000.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/media/tuners/e4000.c b/drivers/media/tuners/e4000.c index ffaa482..1b33ed3 100644 --- a/drivers/media/tuners/e4000.c +++ b/drivers/media/tuners/e4000.c @@ -366,9 +366,6 @@ struct dvb_frontend *e4000_attach(struct dvb_frontend *fe, priv->cfg = cfg; priv->i2c = i2c; - fe->tuner_priv = priv; - memcpy(&fe->ops.tuner_ops, &e4000_tuner_ops, - sizeof(struct dvb_tuner_ops)); /* check if the tuner is there */ ret = e4000_rd_reg(priv, 0x02, &chip_id); @@ -389,6 +386,10 @@ struct dvb_frontend *e4000_attach(struct dvb_frontend *fe, "%s: Elonics E4000 successfully identified\n", KBUILD_MODNAME); + fe->tuner_priv = priv; + memcpy(&fe->ops.tuner_ops, &e4000_tuner_ops, + sizeof(struct dvb_tuner_ops)); + if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);