From patchwork Tue Mar 12 12:27:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 2256281 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 970FE3FCF6 for ; Tue, 12 Mar 2013 12:27:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754721Ab3CLM1R (ORCPT ); Tue, 12 Mar 2013 08:27:17 -0400 Received: from moutng.kundenserver.de ([212.227.17.10]:58838 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752701Ab3CLM1R (ORCPT ); Tue, 12 Mar 2013 08:27:17 -0400 Received: from axis700.grange (dslb-094-221-122-231.pools.arcor-ip.net [94.221.122.231]) by mrelayeu.kundenserver.de (node=mrbap3) with ESMTP (Nemesis) id 0LiCNn-1UaiTw3cLT-00nOyr; Tue, 12 Mar 2013 13:27:16 +0100 Received: by axis700.grange (Postfix, from userid 1000) id 6144C40BB4; Tue, 12 Mar 2013 13:27:15 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by axis700.grange (Postfix) with ESMTP id 5A63840BB3; Tue, 12 Mar 2013 13:27:15 +0100 (CET) Date: Tue, 12 Mar 2013 13:27:15 +0100 (CET) From: Guennadi Liakhovetski X-X-Sender: lyakh@axis700.grange To: Linux Media Mailing List cc: javier Martin Subject: [PATCH] mt9m111: fix Oops - initialise context before dereferencing Message-ID: MIME-Version: 1.0 X-Provags-ID: V02:K0:i7vmmee/iCDM+FUosGPPna8XXMezUjGkQr9rXnCVzIy gOhadzHanlMLg4ZdOVVOoKEO0g0FLTEFd6OKvqyJ/KqxrnOwtf KLTT27f4JE2xT0dHxNSkdKO5jBf1vaTbKitZAGTQv2R46RZVSz LksSyQMTf3ttnDooCG6HzItDZ9GfkBK5VdghUMmps6xmH6f9rN /GcVmWykAYgcFuGm2UL61omizzChfzQ7HLLKeCoZqhx1w4CkEs 2uoAJXI2TD7H2oyB6tAYNeo4O/CCtVF8HjwNk37p1RarUCIH8f kQjnPLq+rWTa/HPtb2EQuvXTjP5wPJKQTdC2W8HVkmIKXBqxY3 Q0p203ym2VK+1a0yIV4zb4Kk5jZk598Z9CBPeF5W+rB9mCKovG 2Xi1LFYGuMqeA== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org A recent commit "[media] soc-camera: Push probe-time power management to drivers" causes an Oops during mt9m111 driver probing because its .ctx private data field is now dereferenced before it is initialised. Fix this by initialising the field earlier. Reported-by: Javier Martin Signed-off-by: Guennadi Liakhovetski --- drivers/media/i2c/soc_camera/mt9m111.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/soc_camera/mt9m111.c b/drivers/media/i2c/soc_camera/mt9m111.c index ea874ce..cfdda50 100644 --- a/drivers/media/i2c/soc_camera/mt9m111.c +++ b/drivers/media/i2c/soc_camera/mt9m111.c @@ -784,8 +784,6 @@ static int mt9m111_init(struct mt9m111 *mt9m111) struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); int ret; - /* Default HIGHPOWER context */ - mt9m111->ctx = &context_b; ret = mt9m111_enable(mt9m111); if (!ret) ret = mt9m111_reset(mt9m111); @@ -974,6 +972,9 @@ static int mt9m111_probe(struct i2c_client *client, if (!mt9m111) return -ENOMEM; + /* Default HIGHPOWER context */ + mt9m111->ctx = &context_b; + v4l2_i2c_subdev_init(&mt9m111->subdev, client, &mt9m111_subdev_ops); v4l2_ctrl_handler_init(&mt9m111->hdl, 5); v4l2_ctrl_new_std(&mt9m111->hdl, &mt9m111_ctrl_ops,