linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] media: fixes for Amstrad Delta camera
@ 2016-06-15 22:29 Janusz Krzysztofik
  2016-06-15 22:29 ` [PATCH 1/3] staging: media: omap1: fix null pointer dereference in omap1_cam_probe() Janusz Krzysztofik
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Janusz Krzysztofik @ 2016-06-15 22:29 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Guennadi Liakhovetski, Greg Kroah-Hartman
  Cc: Hans Verkuil, Amitoj Kaur Chawla, Arnd Bergmann, Lee Jones,
	linux-media, linux-kernel, devel, Janusz Krzysztofik

Janusz Krzysztofik (3):
  staging: media: omap1: fix null pointer dereference in
    omap1_cam_probe()
  staging: media: omap1: fix sensor probe not working anymore
  media: i2c/soc_camera: fix ov6650 sensor getting wrong clock

 drivers/media/i2c/soc_camera/ov6650.c      |  2 +-
 drivers/staging/media/omap1/omap1_camera.c | 16 ++++++++--------
 2 files changed, 9 insertions(+), 9 deletions(-)

-- 
2.7.3

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] staging: media: omap1: fix null pointer dereference in omap1_cam_probe()
  2016-06-15 22:29 [PATCH 0/3] media: fixes for Amstrad Delta camera Janusz Krzysztofik
@ 2016-06-15 22:29 ` Janusz Krzysztofik
  2016-06-15 22:29 ` [PATCH 2/3] staging: media: omap1: fix sensor probe not working anymore Janusz Krzysztofik
  2016-06-15 22:29 ` [PATCH 3/3] media: i2c/soc_camera: fix ov6650 sensor getting wrong clock Janusz Krzysztofik
  2 siblings, 0 replies; 4+ messages in thread
From: Janusz Krzysztofik @ 2016-06-15 22:29 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Guennadi Liakhovetski, Greg Kroah-Hartman
  Cc: Hans Verkuil, Amitoj Kaur Chawla, Arnd Bergmann, Lee Jones,
	linux-media, linux-kernel, devel, Janusz Krzysztofik

Commit 76e543382bd4 ("staging: media: omap1: Switch to
devm_ioremap_resource") moved assignment of struct resource *res =
platform_get_resource() several lines down. That resulted in the
following error:

[    3.793237] Unable to handle kernel NULL pointer dereference at virtual address 00000004
[    3.802198] pgd = c0004000
[    3.805202] [00000004] *pgd=00000000
[    3.809373] Internal error: Oops: c5 [#1] ARM
[    3.814070] CPU: 0 PID: 1 Comm: swapper Not tainted 4.6.0-rc1+ #70
[    3.820570] Hardware name: Amstrad E3 (Delta)
[    3.825232] task: c1819440 ti: c181e000 task.ti: c181e000
[    3.830973] PC is at omap1_cam_probe+0x48/0x2d4
[    3.835873] LR is at devres_add+0x20/0x28

Move the assignment back up where it was before - it is used to build
an argument for a subsequent devm_kzalloc(). Also, restore the check
for null value of res - it shouldn't hurt.

While being at it:
- follow the recently introduced convention of direct return
  instead of jump to return with err value assigned,
- drop no longer needed res member from the definition of struct
  omap1_cam_dev.

Created and tested on Amstrad Delta aginst Linux-4.7-rc3

Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
---
 drivers/staging/media/omap1/omap1_camera.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/media/omap1/omap1_camera.c b/drivers/staging/media/omap1/omap1_camera.c
index 54b8dd2..dc35d30 100644
--- a/drivers/staging/media/omap1/omap1_camera.c
+++ b/drivers/staging/media/omap1/omap1_camera.c
@@ -158,7 +158,6 @@ struct omap1_cam_dev {
 	int				dma_ch;
 
 	struct omap1_cam_platform_data	*pdata;
-	struct resource			*res;
 	unsigned long			pflags;
 	unsigned long			camexclk;
 
@@ -1569,11 +1568,10 @@ static int omap1_cam_probe(struct platform_device *pdev)
 	unsigned int irq;
 	int err = 0;
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	irq = platform_get_irq(pdev, 0);
-	if ((int)irq <= 0) {
-		err = -ENODEV;
-		goto exit;
-	}
+	if (!res || (int)irq <= 0)
+		return -ENODEV;
 
 	clk = devm_clk_get(&pdev->dev, "armper_ck");
 	if (IS_ERR(clk))
@@ -1614,7 +1612,6 @@ static int omap1_cam_probe(struct platform_device *pdev)
 	INIT_LIST_HEAD(&pcdev->capture);
 	spin_lock_init(&pcdev->lock);
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(base))
 		return PTR_ERR(base);
@@ -1663,7 +1660,6 @@ static int omap1_cam_probe(struct platform_device *pdev)
 
 exit_free_dma:
 	omap_free_dma(pcdev->dma_ch);
-exit:
 	return err;
 }
 
-- 
2.7.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] staging: media: omap1: fix sensor probe not working anymore
  2016-06-15 22:29 [PATCH 0/3] media: fixes for Amstrad Delta camera Janusz Krzysztofik
  2016-06-15 22:29 ` [PATCH 1/3] staging: media: omap1: fix null pointer dereference in omap1_cam_probe() Janusz Krzysztofik
@ 2016-06-15 22:29 ` Janusz Krzysztofik
  2016-06-15 22:29 ` [PATCH 3/3] media: i2c/soc_camera: fix ov6650 sensor getting wrong clock Janusz Krzysztofik
  2 siblings, 0 replies; 4+ messages in thread
From: Janusz Krzysztofik @ 2016-06-15 22:29 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Guennadi Liakhovetski, Greg Kroah-Hartman
  Cc: Hans Verkuil, Amitoj Kaur Chawla, Arnd Bergmann, Lee Jones,
	linux-media, linux-kernel, devel, Janusz Krzysztofik

After clock_start() removal from from soc_camera_probe() (commit
9aea470b39 '[media] soc-camera: switch I2C subdevice drivers to use
v4l2-clk', introduced in v3.11), it occurred omap1_camera's sensor
can't be probed successfully without its clock being turned on in
advance. Fix that by surrounding soc_camera_host_register() invocation
with clock_start() / clock_stop().

Created and tested on Amstrad Delta against Linux-4.7-rc3 with
'staging: media: omap1: fix null pointer dereference in
omap1_cam_probe()' applied.

Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
---
 drivers/staging/media/omap1/omap1_camera.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/omap1/omap1_camera.c b/drivers/staging/media/omap1/omap1_camera.c
index dc35d30..9b6140a 100644
--- a/drivers/staging/media/omap1/omap1_camera.c
+++ b/drivers/staging/media/omap1/omap1_camera.c
@@ -1650,7 +1650,11 @@ static int omap1_cam_probe(struct platform_device *pdev)
 	pcdev->soc_host.v4l2_dev.dev	= &pdev->dev;
 	pcdev->soc_host.nr		= pdev->id;
 
-	err = soc_camera_host_register(&pcdev->soc_host);
+	err = omap1_cam_clock_start(&pcdev->soc_host);
+	if (!err) {
+		err = soc_camera_host_register(&pcdev->soc_host);
+		omap1_cam_clock_stop(&pcdev->soc_host);
+	}
 	if (err)
 		return err;
 
-- 
2.7.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] media: i2c/soc_camera: fix ov6650 sensor getting wrong clock
  2016-06-15 22:29 [PATCH 0/3] media: fixes for Amstrad Delta camera Janusz Krzysztofik
  2016-06-15 22:29 ` [PATCH 1/3] staging: media: omap1: fix null pointer dereference in omap1_cam_probe() Janusz Krzysztofik
  2016-06-15 22:29 ` [PATCH 2/3] staging: media: omap1: fix sensor probe not working anymore Janusz Krzysztofik
@ 2016-06-15 22:29 ` Janusz Krzysztofik
  2 siblings, 0 replies; 4+ messages in thread
From: Janusz Krzysztofik @ 2016-06-15 22:29 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Guennadi Liakhovetski, Greg Kroah-Hartman
  Cc: Hans Verkuil, Amitoj Kaur Chawla, Arnd Bergmann, Lee Jones,
	linux-media, linux-kernel, devel, Janusz Krzysztofik

After changes to v4l2_clk API introduced in v4.1 by commits a37462b919
'[media] V4L: remove clock name from v4l2_clk API' and 4f528afcfb
'[media] V4L: add CCF support to the v4l2_clk API', ov6650 sensor
stopped responding because v4l2_clk_get(), still called with
depreciated V4L2 clock name "mclk", started to return respective CCF
clock instead of the V4l2 one registered by soc_camera. Fix it by
calling v4l2_clk_get() with NULL clock name.

Created and tested on Amstrad Delta against Linux-4.7-rc3 with
omap1_camera fixes.

Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
---
 drivers/media/i2c/soc_camera/ov6650.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/soc_camera/ov6650.c b/drivers/media/i2c/soc_camera/ov6650.c
index 1f8af1e..1e4783b 100644
--- a/drivers/media/i2c/soc_camera/ov6650.c
+++ b/drivers/media/i2c/soc_camera/ov6650.c
@@ -1033,7 +1033,7 @@ static int ov6650_probe(struct i2c_client *client,
 	priv->code	  = MEDIA_BUS_FMT_YUYV8_2X8;
 	priv->colorspace  = V4L2_COLORSPACE_JPEG;
 
-	priv->clk = v4l2_clk_get(&client->dev, "mclk");
+	priv->clk = v4l2_clk_get(&client->dev, NULL);
 	if (IS_ERR(priv->clk)) {
 		ret = PTR_ERR(priv->clk);
 		goto eclkget;
-- 
2.7.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-06-15 22:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-15 22:29 [PATCH 0/3] media: fixes for Amstrad Delta camera Janusz Krzysztofik
2016-06-15 22:29 ` [PATCH 1/3] staging: media: omap1: fix null pointer dereference in omap1_cam_probe() Janusz Krzysztofik
2016-06-15 22:29 ` [PATCH 2/3] staging: media: omap1: fix sensor probe not working anymore Janusz Krzysztofik
2016-06-15 22:29 ` [PATCH 3/3] media: i2c/soc_camera: fix ov6650 sensor getting wrong clock Janusz Krzysztofik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).