From patchwork Tue Nov 19 05:20:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 179682 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp163382ilf; Mon, 18 Nov 2019 21:43:17 -0800 (PST) X-Google-Smtp-Source: APXvYqyVQFjIafgAk0VKVXr5bCit3Mw/iXTkighXb13yJj8c1v06RSGDsfI8NTZGESTQrerUiJ1P X-Received: by 2002:a17:906:5959:: with SMTP id g25mr31836267ejr.248.1574142197370; Mon, 18 Nov 2019 21:43:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574142197; cv=none; d=google.com; s=arc-20160816; b=uMruDDEvSviifb4EXrVeXKWpzvQd7585fhYNx78rweqKZqR7PygkUeibAEmZ9wHNJx iMj+h2FiNk/2geLyWS5Bh7kThoS2OL35Y9f9YsQGsgAW1ojEPcRDEiXi1spbd0ahAqRQ gPrTLEVlOWG8LN6ozKp1oKtrBNoOxnVpM2SFtM+AGxFPGdHRrw8K42zRc7sBf6n8hMUK ov2+0/chobmxaXZhxD/OZcQHw6oIy9A5qLut5pJSQKoejA8S91IYBMOq5yRvv6/zXNwY j5OMiP6Y3QpXAd4mBPyJz94gR3Lte4U8mYKiz2lNBjGuVfROztV8uh2lcduEImGidmeb n/NA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5UZzJCxXW65XerNjOVYoXWEa9XHMMxhjEVVPcVAPdRk=; b=tLpAQgADYKGUW1j4iXwI7OF9WEIXgHY2CryYHGLmX4k0v1PpObor6C9GIB3l+aju4C uFjaOIWupzsUeuJdwH+SSHntPAJ2RPL7fYNfmW2Ertt7HacxSYDHwt3wmeKxgiIsJnDn DHipUVWx0x1ArGFQ40zUfxBmjHxCY83ybnqCUnNgowDexf+BSLWl/RnGu9h08xNpSiFs u/OG5UKDCxlfJlse811JGRF7q4gWZgIUbtqo3fJ7BTTFSxg3+7/CuuO4VNIVbVCtiQwz FVzdTnoCbKFxz/tYyNiYGKHOaLiUSl2kCCXEZtb5m8pSUpCNbzN5/7GKgjbon4ko5v3c KP+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hrt6b5X5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i20si14164733edq.275.2019.11.18.21.43.17; Mon, 18 Nov 2019 21:43:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=hrt6b5X5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730112AbfKSFnO (ORCPT + 26 others); Tue, 19 Nov 2019 00:43:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:37934 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730477AbfKSFnJ (ORCPT ); Tue, 19 Nov 2019 00:43:09 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D3F6021783; Tue, 19 Nov 2019 05:43:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574142188; bh=H7Djb+n3qjxbE2dVJgW6kUOuIo0sOoojYsnEGEwGFNE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hrt6b5X5bLf8QEOHXkhqIgWg3gkYInukgtxbShITANVUjqkS6+K1rADunt62MErpB AsPxeXS99ThsXO6McXUEz5nv2DkBJ0FlsGny2FctMditcy/6wfOd3oCCBTsqH0UIL/ Qf8T6zM4KT9bZ/vjTnGtItZSnxrRm04z++N6JciY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rui Miguel Silva , Sakari Ailus , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.19 419/422] media: ov2680: fix null dereference at power on Date: Tue, 19 Nov 2019 06:20:16 +0100 Message-Id: <20191119051426.345896171@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191119051400.261610025@linuxfoundation.org> References: <20191119051400.261610025@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rui Miguel Silva [ Upstream commit c45fbdf24c61a7b7a37f1b3bbd46f054637a3627 ] 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 Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/i2c/ov2680.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) -- 2.20.1 diff --git a/drivers/media/i2c/ov2680.c b/drivers/media/i2c/ov2680.c index 3ccd584568fb5..d8798fb714ba8 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;