From patchwork Wed Nov 21 10:59:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Miguel Silva X-Patchwork-Id: 151655 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1772697ljp; Wed, 21 Nov 2018 03:00:31 -0800 (PST) X-Google-Smtp-Source: AFSGD/XT4yhpadAN+3Rh2296Jkrg4nPG+Eqtq1YAbt5lteGRBftj2yYEa3iGnJGgiUR1n5CKQdHs X-Received: by 2002:a17:902:4a0c:: with SMTP id w12-v6mr6224231pld.63.1542798031141; Wed, 21 Nov 2018 03:00:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542798031; cv=none; d=google.com; s=arc-20160816; b=du70zR+scXEHckzqbvcJmCBkNDPnAyionT6dv/hUXTFxKL3I7FyBYiXvnO3fxQS4x8 DplkxIQ+LZ4rd/f+WklIIXxglPPhZcgemEf5TRPx1RWUxfu7X6lpPwQYx3uELTQL5Nsl Caya6SiD/+EsOcT8rR0sg60tAMLuQQd45pp0e2ikROyW5olguQMiMfIjijq763wlyvvr aossN2qifW8ziGeN2YNMpbZQuAJrUUIklrgEwEn/0aVVbNC8hOY/LOeaMjyAYMEdHYml Xn9AuKpRtFeTeKBtk6V4ox0KGiqOlOAZz/kyx1D/fRTyHl+YztkwfXPx6zG88JQnEBbV r96w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=PXCGK9Ve8iSu7XzE/ltFaekKuCzhH8LEUlwpQxSrky4=; b=p8njS+YC5j4QQdFlhbjUGPPEMYScFimDVveOfDp1zBDGmZIqvRuAIGjDCPxqsPFl9X CdwPH0D7P1OeiKSjQq39CuCdFzR01qjbyB3JQE46j7M2jKpn3NLjFQZAgKXpKDkfvNZl JB3SXu0TPGY8E72VzV8VTA2FwyIA7io4fZa4gyOibAMgMFKyRAsBt8LkkGPiQzAtF/Gk U05WF/pOQMEF4Ov4vjTA9JpwVoowW72ufesKxWQ5CpCCyBFCuxi14wCv5bMvcfrOCsPx pRytym7sf0fhkbq48QO7zrgf2NgQPCniRI/9Bcuip9qIG/QtEceKUK/HET9SRQmLY0L8 n2HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BPrxSlkd; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r18si43525242pgb.491.2018.11.21.03.00.30; Wed, 21 Nov 2018 03:00:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BPrxSlkd; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729353AbeKUVe0 (ORCPT + 4 others); Wed, 21 Nov 2018 16:34:26 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:34665 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726172AbeKUVeZ (ORCPT ); Wed, 21 Nov 2018 16:34:25 -0500 Received: by mail-wr1-f67.google.com with SMTP id j2so5206921wrw.1 for ; Wed, 21 Nov 2018 03:00:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=PXCGK9Ve8iSu7XzE/ltFaekKuCzhH8LEUlwpQxSrky4=; b=BPrxSlkd+Kh9mBa2F0NaEv/ZANFF3MHOu5kwKUabTug8o7gkoYE7VyNx0L09VA6NwG RDOVxSMQPJCtFQaTe9croNk3mVaEfOXMSR8hQc38EKOVcU/M+e0pULqX1fbo4MWUYwZQ fZkMEwXhuQZ8xtg7a8SN0T9so3Y8CcpSv6ARQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=PXCGK9Ve8iSu7XzE/ltFaekKuCzhH8LEUlwpQxSrky4=; b=C61oKA5c22sV/qlPwWGK1NYYgzaFK7qODnyinbipJt+4llm7krXjEocdWMq7SnQDOX Kk54ta/Vq8uMMoPpX6319l9FShFgAT7Rb6cRis8qbGNyzTLiYWF7aOp8xSI6Tpr4IuIE evla19EJ/QQdAqNLW4UkztpFgfbF98bjZ1A9aiMCKc0SAG1mHAR2C1kFm5rlgp1ZH3b2 0WoORx8DgaKZuSuiZUaGIJOpyNCcsqREinEFmt1et3/4njLnYj/MWRcbYQivW8yQ19O9 Q68Vbxvl5Wmk/HBMX0+bun3906mUkyqIbvN40JFJ1A0rWeBbEBEqjTsHKZdWzpjNFS3a LFaA== X-Gm-Message-State: AA+aEWYZoNvQQoU67CuTF5nIIKBeHZ+twYNsuftibV+TW+uYw6oe8Pp/ Iiis4lw8EeBRjJxeTCHQZAPwQw== X-Received: by 2002:adf:e64d:: with SMTP id b13mr5453821wrn.276.1542798028491; Wed, 21 Nov 2018 03:00:28 -0800 (PST) Received: from arch-late.local (a109-49-46-234.cpe.netcabo.pt. [109.49.46.234]) by smtp.gmail.com with ESMTPSA id 3-v6sm27493662wrs.44.2018.11.21.03.00.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 03:00:28 -0800 (PST) From: Rui Miguel Silva To: sakari.ailus@linux.intel.com Cc: linux-media@vger.kernel.org, Javier Martinez Canillas , Rui Miguel Silva Subject: [PATCH] media: ov2680: fix null dereference at power on Date: Wed, 21 Nov 2018 10:59:55 +0000 Message-Id: <20181121105955.9217-1-rui.silva@linaro.org> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Swapping the order between v4l2 subdevice registration and checking chip id in b7a417628abf ("media: ov2680: don't register the v4l2 subdevice before checking chip ID") makes the mode restore to use the sensor controls before they are set, so move the mode restore call to s_power after the handler setup for controls is done. This remove also the need for the error code path in power on function. Fixes: b7a417628abf ("media: ov2680: don't register the v4l2 subdevice before checking chip ID") Signed-off-by: Rui Miguel Silva --- drivers/media/i2c/ov2680.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) -- 2.19.1 diff --git a/drivers/media/i2c/ov2680.c b/drivers/media/i2c/ov2680.c index 0e34e15b67b3..b10bcfabaeeb 100644 --- a/drivers/media/i2c/ov2680.c +++ b/drivers/media/i2c/ov2680.c @@ -568,10 +568,6 @@ static int ov2680_power_on(struct ov2680_dev *sensor) if (ret < 0) return ret; - ret = ov2680_mode_restore(sensor); - if (ret < 0) - goto disable; - sensor->is_enabled = true; /* Set clock lane into LP-11 state */ @@ -580,12 +576,6 @@ static int ov2680_power_on(struct ov2680_dev *sensor) ov2680_stream_disable(sensor); return 0; - -disable: - dev_err(dev, "failed to enable sensor: %d\n", ret); - ov2680_power_off(sensor); - - return ret; } static int ov2680_s_power(struct v4l2_subdev *sd, int on) @@ -606,6 +596,8 @@ static int ov2680_s_power(struct v4l2_subdev *sd, int on) ret = v4l2_ctrl_handler_setup(&sensor->ctrls.handler); if (ret < 0) return ret; + + ret = ov2680_mode_restore(sensor); } return ret;