All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/14] Fixes for smatch/sparse/sysbot/compiler warnings
@ 2021-01-20  9:42 Hans Verkuil
  2021-01-20  9:42 ` [PATCH 01/14] atomisp/pci/hmm: fix wrong printk format Hans Verkuil
                   ` (14 more replies)
  0 siblings, 15 replies; 17+ messages in thread
From: Hans Verkuil @ 2021-01-20  9:42 UTC (permalink / raw)
  To: linux-media

The first patch fixes a compiler warning for i686, the second
patch fixes a sysbot error, the last patch fixes a sparse warning
and all others fix smatch warnings.

Regards,

	Hans

Hans Verkuil (14):
  atomisp/pci/hmm: fix wrong printk format
  v4l2-ctrls.c: fix shift-out-of-bounds in std_validate
  meson/ge2d: set ret to -ENOMEM
  davinci/vpbe.c: ret contains the return code, not err
  tuners/it913x.c: fix missing error code
  i2c/ov8865.c: fix error checks using wrong variable
  sti/c8sectpfe: set correct return code
  sti/hva: add missing clk_disable_unprepare()
  pci/ivtv: release memory regions on error
  usb/dvb-usb-v2/rtl28xxu.c: clean up code to fix smatch warning
  dvb-frontends/rtl2832.c: fix missing error code
  dvb-frontends/af9033.c: fix missing error codes
  atomisp/pci: add missing include
  i2c/ov02a10.c: add cast to fix type mismatch

 drivers/media/dvb-frontends/af9033.c          |  2 ++
 drivers/media/dvb-frontends/rtl2832.c         |  1 +
 drivers/media/i2c/ov02a10.c                   |  2 +-
 drivers/media/i2c/ov8865.c                    |  6 ++--
 drivers/media/pci/ivtv/ivtv-driver.c          |  5 +++
 drivers/media/platform/davinci/vpbe.c         |  2 +-
 drivers/media/platform/meson/ge2d/ge2d.c      |  1 +
 .../platform/sti/c8sectpfe/c8sectpfe-core.c   |  1 +
 drivers/media/platform/sti/hva/hva-hw.c       |  1 +
 drivers/media/tuners/it913x.c                 |  1 +
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c       | 35 +++++++------------
 drivers/media/v4l2-core/v4l2-ctrls.c          |  3 +-
 drivers/staging/media/atomisp/pci/hmm/hmm.c   |  2 +-
 .../media/atomisp/pci/ia_css_firmware.h       |  1 +
 14 files changed, 34 insertions(+), 29 deletions(-)

-- 
2.29.2


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

* [PATCH 01/14] atomisp/pci/hmm: fix wrong printk format
  2021-01-20  9:42 [PATCH 00/14] Fixes for smatch/sparse/sysbot/compiler warnings Hans Verkuil
@ 2021-01-20  9:42 ` Hans Verkuil
  2021-01-20  9:42 ` [PATCH 02/14] v4l2-ctrls.c: fix shift-out-of-bounds in std_validate Hans Verkuil
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2021-01-20  9:42 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

Fix this compiler warning on i686:

In file included from include/linux/printk.h:409,
                 from include/linux/kernel.h:16,
                 from drivers/staging/media/atomisp/pci/hmm/hmm.c:23:
drivers/staging/media/atomisp/pci/hmm/hmm.c: In function 'hmm_alloc':
drivers/staging/media/atomisp/pci/hmm/hmm.c:272:3: warning: format '%ld' expects argument of type 'long int', but argument 6 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
  272 |   "%s: pages: 0x%08x (%ld bytes), type: %d from highmem %d, user ptr %p, cached %d\n",
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Use %zu instead of %ld.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
 drivers/staging/media/atomisp/pci/hmm/hmm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/pci/hmm/hmm.c b/drivers/staging/media/atomisp/pci/hmm/hmm.c
index e0eaff0f8a22..6a5ee4607089 100644
--- a/drivers/staging/media/atomisp/pci/hmm/hmm.c
+++ b/drivers/staging/media/atomisp/pci/hmm/hmm.c
@@ -269,7 +269,7 @@ ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type,
 		hmm_set(bo->start, 0, bytes);
 
 	dev_dbg(atomisp_dev,
-		"%s: pages: 0x%08x (%ld bytes), type: %d from highmem %d, user ptr %p, cached %d\n",
+		"%s: pages: 0x%08x (%zu bytes), type: %d from highmem %d, user ptr %p, cached %d\n",
 		__func__, bo->start, bytes, type, from_highmem, userptr, cached);
 
 	return bo->start;
-- 
2.29.2


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

* [PATCH 02/14] v4l2-ctrls.c: fix shift-out-of-bounds in std_validate
  2021-01-20  9:42 [PATCH 00/14] Fixes for smatch/sparse/sysbot/compiler warnings Hans Verkuil
  2021-01-20  9:42 ` [PATCH 01/14] atomisp/pci/hmm: fix wrong printk format Hans Verkuil
@ 2021-01-20  9:42 ` Hans Verkuil
  2021-01-20  9:42 ` [PATCH 03/14] meson/ge2d: set ret to -ENOMEM Hans Verkuil
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2021-01-20  9:42 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil, syzbot+42d8c7c3d3e594b34346

If a menu has more than 64 items, then don't check menu_skip_mask
for items 65 and up.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reported-by: syzbot+42d8c7c3d3e594b34346@syzkaller.appspotmail.com
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index f7b310240af2..016cf6204cbb 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -2181,7 +2181,8 @@ static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx,
 	case V4L2_CTRL_TYPE_INTEGER_MENU:
 		if (ptr.p_s32[idx] < ctrl->minimum || ptr.p_s32[idx] > ctrl->maximum)
 			return -ERANGE;
-		if (ctrl->menu_skip_mask & (1ULL << ptr.p_s32[idx]))
+		if (ptr.p_s32[idx] < BITS_PER_LONG_LONG &&
+		    (ctrl->menu_skip_mask & BIT_ULL(ptr.p_s32[idx])))
 			return -EINVAL;
 		if (ctrl->type == V4L2_CTRL_TYPE_MENU &&
 		    ctrl->qmenu[ptr.p_s32[idx]][0] == '\0')
-- 
2.29.2


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

* [PATCH 03/14] meson/ge2d: set ret to -ENOMEM
  2021-01-20  9:42 [PATCH 00/14] Fixes for smatch/sparse/sysbot/compiler warnings Hans Verkuil
  2021-01-20  9:42 ` [PATCH 01/14] atomisp/pci/hmm: fix wrong printk format Hans Verkuil
  2021-01-20  9:42 ` [PATCH 02/14] v4l2-ctrls.c: fix shift-out-of-bounds in std_validate Hans Verkuil
@ 2021-01-20  9:42 ` Hans Verkuil
  2021-01-20  9:42 ` [PATCH 04/14] davinci/vpbe.c: ret contains the return code, not err Hans Verkuil
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2021-01-20  9:42 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil, Neil Armstrong

Fix this smatch warning:

drivers/media/platform/meson/ge2d/ge2d.c:991 ge2d_probe() warn: missing error code 'ret'

when video_device_alloc() returns NULL.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: Neil Armstrong <narmstrong@baylibre.com>
---
 drivers/media/platform/meson/ge2d/ge2d.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/meson/ge2d/ge2d.c b/drivers/media/platform/meson/ge2d/ge2d.c
index f526501bd473..153612ca96fc 100644
--- a/drivers/media/platform/meson/ge2d/ge2d.c
+++ b/drivers/media/platform/meson/ge2d/ge2d.c
@@ -988,6 +988,7 @@ static int ge2d_probe(struct platform_device *pdev)
 	vfd = video_device_alloc();
 	if (!vfd) {
 		v4l2_err(&ge2d->v4l2_dev, "Failed to allocate video device\n");
+		ret = -ENOMEM;
 		goto unreg_v4l2_dev;
 	}
 
-- 
2.29.2


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

* [PATCH 04/14] davinci/vpbe.c: ret contains the return code, not err
  2021-01-20  9:42 [PATCH 00/14] Fixes for smatch/sparse/sysbot/compiler warnings Hans Verkuil
                   ` (2 preceding siblings ...)
  2021-01-20  9:42 ` [PATCH 03/14] meson/ge2d: set ret to -ENOMEM Hans Verkuil
@ 2021-01-20  9:42 ` Hans Verkuil
  2021-01-20  9:42 ` [PATCH 05/14] tuners/it913x.c: fix missing error code Hans Verkuil
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2021-01-20  9:42 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil, Lad, Prabhakar

Fixes this smatch warning:

drivers/media/platform/davinci/vpbe.c:632 vpbe_initialize() warn: missing error code 'ret'

The function returns 'ret', but instead 'err' was set to -ENOMEM.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
---
 drivers/media/platform/davinci/vpbe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/davinci/vpbe.c b/drivers/media/platform/davinci/vpbe.c
index fe9468b180e6..5f0aeb744e81 100644
--- a/drivers/media/platform/davinci/vpbe.c
+++ b/drivers/media/platform/davinci/vpbe.c
@@ -628,7 +628,7 @@ static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev)
 		if (err) {
 			v4l2_err(&vpbe_dev->v4l2_dev,
 				 "unable to initialize the OSD device");
-			err = -ENOMEM;
+			ret = -ENOMEM;
 			goto fail_dev_unregister;
 		}
 	}
-- 
2.29.2


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

* [PATCH 05/14] tuners/it913x.c: fix missing error code
  2021-01-20  9:42 [PATCH 00/14] Fixes for smatch/sparse/sysbot/compiler warnings Hans Verkuil
                   ` (3 preceding siblings ...)
  2021-01-20  9:42 ` [PATCH 04/14] davinci/vpbe.c: ret contains the return code, not err Hans Verkuil
@ 2021-01-20  9:42 ` Hans Verkuil
  2021-01-20  9:42 ` [PATCH 06/14] i2c/ov8865.c: fix error checks using wrong variable Hans Verkuil
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2021-01-20  9:42 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

Fixes this smatch warning:

drivers/media/tuners/it913x.c:65 it913x_init() warn: missing error code 'ret'

Set ret to -EINVAL if the clock identifier was invalid.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
 drivers/media/tuners/it913x.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/tuners/it913x.c b/drivers/media/tuners/it913x.c
index e8e66390be41..7696a28fe407 100644
--- a/drivers/media/tuners/it913x.c
+++ b/drivers/media/tuners/it913x.c
@@ -62,6 +62,7 @@ static int it913x_init(struct dvb_frontend *fe)
 		break;
 	default:
 		dev_err(&pdev->dev, "unknown clock identifier %d\n", utmp);
+		ret = -EINVAL;
 		goto err;
 	}
 
-- 
2.29.2


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

* [PATCH 06/14] i2c/ov8865.c: fix error checks using wrong variable
  2021-01-20  9:42 [PATCH 00/14] Fixes for smatch/sparse/sysbot/compiler warnings Hans Verkuil
                   ` (4 preceding siblings ...)
  2021-01-20  9:42 ` [PATCH 05/14] tuners/it913x.c: fix missing error code Hans Verkuil
@ 2021-01-20  9:42 ` Hans Verkuil
  2021-01-23 22:39   ` Sakari Ailus
  2021-01-20  9:42 ` [PATCH 07/14] sti/c8sectpfe: set correct return code Hans Verkuil
                   ` (8 subsequent siblings)
  14 siblings, 1 reply; 17+ messages in thread
From: Hans Verkuil @ 2021-01-20  9:42 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil, kernel test robot, Dan Carpenter

Fix two typos: dvdd -> dovdd and dvdd -> avdd

Both clearly copy-and-paste mistakes.

Fixes this smatch warning:

drivers/media/i2c/ov8865.c:2852 ov8865_probe() warn: passing zero to 'PTR_ERR'

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/media/i2c/ov8865.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c
index fda5a55979aa..72ef300c0b67 100644
--- a/drivers/media/i2c/ov8865.c
+++ b/drivers/media/i2c/ov8865.c
@@ -2839,9 +2839,9 @@ static int ov8865_probe(struct i2c_client *client)
 
 	/* DOVDD: digital I/O */
 	sensor->dovdd = devm_regulator_get(dev, "dovdd");
-	if (IS_ERR(sensor->dvdd)) {
+	if (IS_ERR(sensor->dovdd)) {
 		dev_err(dev, "cannot get DOVDD (digital I/O) regulator\n");
-		ret = PTR_ERR(sensor->dvdd);
+		ret = PTR_ERR(sensor->dovdd);
 		goto error_endpoint;
 	}
 
@@ -2849,7 +2849,7 @@ static int ov8865_probe(struct i2c_client *client)
 	sensor->avdd = devm_regulator_get(dev, "avdd");
 	if (IS_ERR(sensor->avdd)) {
 		dev_err(dev, "cannot get AVDD (analog) regulator\n");
-		ret = PTR_ERR(sensor->dvdd);
+		ret = PTR_ERR(sensor->avdd);
 		goto error_endpoint;
 	}
 
-- 
2.29.2


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

* [PATCH 07/14] sti/c8sectpfe: set correct return code
  2021-01-20  9:42 [PATCH 00/14] Fixes for smatch/sparse/sysbot/compiler warnings Hans Verkuil
                   ` (5 preceding siblings ...)
  2021-01-20  9:42 ` [PATCH 06/14] i2c/ov8865.c: fix error checks using wrong variable Hans Verkuil
@ 2021-01-20  9:42 ` Hans Verkuil
  2021-01-20  9:43 ` [PATCH 08/14] sti/hva: add missing clk_disable_unprepare() Hans Verkuil
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2021-01-20  9:42 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

Fixes this smatch warning:

drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c:829 c8sectpfe_probe() warn: missing error code 'ret'

Set ret to -EINVAL if the reset gpio was not found.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
 drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
index 5ceb366648b3..a7a6ea666740 100644
--- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
+++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
@@ -826,6 +826,7 @@ static int c8sectpfe_probe(struct platform_device *pdev)
 			dev_err(dev,
 				"reset gpio for tsin%d not valid (gpio=%d)\n",
 				tsin->tsin_id, tsin->rst_gpio);
+			ret = -EINVAL;
 			goto err_node_put;
 		}
 
-- 
2.29.2


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

* [PATCH 08/14] sti/hva: add missing clk_disable_unprepare()
  2021-01-20  9:42 [PATCH 00/14] Fixes for smatch/sparse/sysbot/compiler warnings Hans Verkuil
                   ` (6 preceding siblings ...)
  2021-01-20  9:42 ` [PATCH 07/14] sti/c8sectpfe: set correct return code Hans Verkuil
@ 2021-01-20  9:43 ` Hans Verkuil
  2021-01-20  9:43 ` [PATCH 09/14] pci/ivtv: release memory regions on error Hans Verkuil
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2021-01-20  9:43 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil, Jean-Christophe Trotin

Fixes this smatch warning:

drivers/media/platform/sti/hva/hva-hw.c:453 hva_hw_runtime_resume() warn: 'hva->clk' not released on lines: 450.

Call clk_disable_unprepare() when clk_set_rate() fails.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: Jean-Christophe Trotin <jean-christophe.trotin@st.com>
---
 drivers/media/platform/sti/hva/hva-hw.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/sti/hva/hva-hw.c b/drivers/media/platform/sti/hva/hva-hw.c
index 43f279e2a6a3..f59811e27f51 100644
--- a/drivers/media/platform/sti/hva/hva-hw.c
+++ b/drivers/media/platform/sti/hva/hva-hw.c
@@ -447,6 +447,7 @@ int hva_hw_runtime_resume(struct device *dev)
 	if (clk_set_rate(hva->clk, CLK_RATE)) {
 		dev_err(dev, "%s     failed to set clock frequency\n",
 			HVA_PREFIX);
+		clk_disable_unprepare(hva->clk);
 		return -EINVAL;
 	}
 
-- 
2.29.2


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

* [PATCH 09/14] pci/ivtv: release memory regions on error
  2021-01-20  9:42 [PATCH 00/14] Fixes for smatch/sparse/sysbot/compiler warnings Hans Verkuil
                   ` (7 preceding siblings ...)
  2021-01-20  9:43 ` [PATCH 08/14] sti/hva: add missing clk_disable_unprepare() Hans Verkuil
@ 2021-01-20  9:43 ` Hans Verkuil
  2021-01-20  9:43 ` [PATCH 10/14] usb/dvb-usb-v2/rtl28xxu.c: clean up code to fix smatch warning Hans Verkuil
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2021-01-20  9:43 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

Fix this smatch warning:

drivers/media/pci/ivtv/ivtv-driver.c:900 ivtv_setup_pci() warn: 'itv->base_addr' not released on lines: 876.

One error path didn't release the memory regions.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
 drivers/media/pci/ivtv/ivtv-driver.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
index 28acb14490d5..6e448cb3b51c 100644
--- a/drivers/media/pci/ivtv/ivtv-driver.c
+++ b/drivers/media/pci/ivtv/ivtv-driver.c
@@ -873,6 +873,11 @@ static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *pdev,
 		pci_read_config_word(pdev, PCI_COMMAND, &cmd);
 		if (!(cmd & PCI_COMMAND_MASTER)) {
 			IVTV_ERR("Bus Mastering is not enabled\n");
+			if (itv->has_cx23415)
+				release_mem_region(itv->base_addr + IVTV_DECODER_OFFSET,
+						   IVTV_DECODER_SIZE);
+			release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE);
+			release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE);
 			return -ENXIO;
 		}
 	}
-- 
2.29.2


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

* [PATCH 10/14] usb/dvb-usb-v2/rtl28xxu.c: clean up code to fix smatch warning
  2021-01-20  9:42 [PATCH 00/14] Fixes for smatch/sparse/sysbot/compiler warnings Hans Verkuil
                   ` (8 preceding siblings ...)
  2021-01-20  9:43 ` [PATCH 09/14] pci/ivtv: release memory regions on error Hans Verkuil
@ 2021-01-20  9:43 ` Hans Verkuil
  2021-01-20  9:43 ` [PATCH 11/14] dvb-frontends/rtl2832.c: fix missing error code Hans Verkuil
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2021-01-20  9:43 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

Fixes this smatch warning:

drivers/media/usb/dvb-usb-v2/rtl28xxu.c:1040 rtl2832u_frontend_attach() warn: missing error code 'ret'

It is actually a bogus warning since in this particular case ret isn't
meant to be set. But by reworking the code a bit the code is actually
a lot more understandable and it fixes this warning.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 35 +++++++++----------------
 1 file changed, 13 insertions(+), 22 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index 3952cc534b4a..97ed17a141bb 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -944,12 +944,6 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
 	if (dev->slave_demod) {
 		struct i2c_board_info info = {};
 
-		/*
-		 * We continue on reduced mode, without DVB-T2/C, using master
-		 * demod, when slave demod fails.
-		 */
-		ret = 0;
-
 		/* attach slave demodulator */
 		if (dev->slave_demod == SLAVE_DEMOD_MN88472) {
 			struct mn88472_config mn88472_config = {};
@@ -964,14 +958,11 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
 			info.platform_data = &mn88472_config;
 			request_module(info.type);
 			client = i2c_new_client_device(&d->i2c_adap, &info);
-			if (!i2c_client_has_driver(client)) {
-				dev->slave_demod = SLAVE_DEMOD_NONE;
+			if (!i2c_client_has_driver(client))
 				goto err_slave_demod_failed;
-			}
 
 			if (!try_module_get(client->dev.driver->owner)) {
 				i2c_unregister_device(client);
-				dev->slave_demod = SLAVE_DEMOD_NONE;
 				goto err_slave_demod_failed;
 			}
 
@@ -986,14 +977,11 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
 			info.platform_data = &mn88473_config;
 			request_module(info.type);
 			client = i2c_new_client_device(&d->i2c_adap, &info);
-			if (!i2c_client_has_driver(client)) {
-				dev->slave_demod = SLAVE_DEMOD_NONE;
+			if (!i2c_client_has_driver(client))
 				goto err_slave_demod_failed;
-			}
 
 			if (!try_module_get(client->dev.driver->owner)) {
 				i2c_unregister_device(client);
-				dev->slave_demod = SLAVE_DEMOD_NONE;
 				goto err_slave_demod_failed;
 			}
 
@@ -1009,10 +997,8 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
 			adap->fe[1] = dvb_attach(cxd2841er_attach_t_c,
 						 &cxd2837er_config,
 						 &d->i2c_adap);
-			if (!adap->fe[1]) {
-				dev->slave_demod = SLAVE_DEMOD_NONE;
+			if (!adap->fe[1])
 				goto err_slave_demod_failed;
-			}
 			adap->fe[1]->id = 1;
 			dev->i2c_client_slave_demod = NULL;
 		} else {
@@ -1029,14 +1015,11 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
 			info.platform_data = &si2168_config;
 			request_module(info.type);
 			client = i2c_new_client_device(&d->i2c_adap, &info);
-			if (!i2c_client_has_driver(client)) {
-				dev->slave_demod = SLAVE_DEMOD_NONE;
+			if (!i2c_client_has_driver(client))
 				goto err_slave_demod_failed;
-			}
 
 			if (!try_module_get(client->dev.driver->owner)) {
 				i2c_unregister_device(client);
-				dev->slave_demod = SLAVE_DEMOD_NONE;
 				goto err_slave_demod_failed;
 			}
 
@@ -1047,10 +1030,18 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
 		}
 	}
 	return 0;
-err_slave_demod_failed:
+
 err:
 	dev_dbg(&d->intf->dev, "failed=%d\n", ret);
 	return ret;
+
+err_slave_demod_failed:
+	/*
+	 * We continue on reduced mode, without DVB-T2/C, using master
+	 * demod, when slave demod fails.
+	 */
+	dev->slave_demod = SLAVE_DEMOD_NONE;
+	return 0;
 }
 
 static int rtl28xxu_frontend_attach(struct dvb_usb_adapter *adap)
-- 
2.29.2


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

* [PATCH 11/14] dvb-frontends/rtl2832.c: fix missing error code
  2021-01-20  9:42 [PATCH 00/14] Fixes for smatch/sparse/sysbot/compiler warnings Hans Verkuil
                   ` (9 preceding siblings ...)
  2021-01-20  9:43 ` [PATCH 10/14] usb/dvb-usb-v2/rtl28xxu.c: clean up code to fix smatch warning Hans Verkuil
@ 2021-01-20  9:43 ` Hans Verkuil
  2021-01-20  9:43 ` [PATCH 12/14] dvb-frontends/af9033.c: fix missing error codes Hans Verkuil
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2021-01-20  9:43 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

Fixes this smatch warning:

drivers/media/dvb-frontends/rtl2832.c:702 rtl2832_read_status() warn: missing error code 'ret'

'ret' is indeed not set, so set it to -EINVAL so a proper error
code is returned.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
 drivers/media/dvb-frontends/rtl2832.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/dvb-frontends/rtl2832.c b/drivers/media/dvb-frontends/rtl2832.c
index 01dcc7f1b9b2..dcbeb9f5e12a 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -698,6 +698,7 @@ static int rtl2832_read_status(struct dvb_frontend *fe, enum fe_status *status)
 			goto err;
 
 		constellation = (u8tmp >> 2) & 0x03; /* [3:2] */
+		ret = -EINVAL;
 		if (constellation > CONSTELLATION_NUM - 1)
 			goto err;
 
-- 
2.29.2


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

* [PATCH 12/14] dvb-frontends/af9033.c: fix missing error codes
  2021-01-20  9:42 [PATCH 00/14] Fixes for smatch/sparse/sysbot/compiler warnings Hans Verkuil
                   ` (10 preceding siblings ...)
  2021-01-20  9:43 ` [PATCH 11/14] dvb-frontends/rtl2832.c: fix missing error code Hans Verkuil
@ 2021-01-20  9:43 ` Hans Verkuil
  2021-01-20  9:43 ` [PATCH 13/14] atomisp/pci: add missing include Hans Verkuil
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2021-01-20  9:43 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

Fixes two smatch warnings:

drivers/media/dvb-frontends/af9033.c:128 af9033_init() warn: missing error code 'ret'
drivers/media/dvb-frontends/af9033.c:855 af9033_read_snr() warn: missing error code 'ret'

Set error codes correctly.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
 drivers/media/dvb-frontends/af9033.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/dvb-frontends/af9033.c b/drivers/media/dvb-frontends/af9033.c
index 6a8d78b6edac..785c49b3d307 100644
--- a/drivers/media/dvb-frontends/af9033.c
+++ b/drivers/media/dvb-frontends/af9033.c
@@ -125,6 +125,7 @@ static int af9033_init(struct dvb_frontend *fe)
 	if (i == ARRAY_SIZE(clock_adc_lut)) {
 		dev_err(&client->dev, "Couldn't find ADC config for clock %d\n",
 			dev->cfg.clock);
+		ret = -ENODEV;
 		goto err;
 	}
 
@@ -852,6 +853,7 @@ static int af9033_read_snr(struct dvb_frontend *fe, u16 *snr)
 				*snr = *snr * 0xffff / 32;
 				break;
 			default:
+				ret = -EINVAL;
 				goto err;
 			}
 		}
-- 
2.29.2


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

* [PATCH 13/14] atomisp/pci: add missing include
  2021-01-20  9:42 [PATCH 00/14] Fixes for smatch/sparse/sysbot/compiler warnings Hans Verkuil
                   ` (11 preceding siblings ...)
  2021-01-20  9:43 ` [PATCH 12/14] dvb-frontends/af9033.c: fix missing error codes Hans Verkuil
@ 2021-01-20  9:43 ` Hans Verkuil
  2021-01-20  9:43 ` [PATCH 14/14] i2c/ov02a10.c: add cast to fix type mismatch Hans Verkuil
  2021-01-23 22:36 ` [PATCH 00/14] Fixes for smatch/sparse/sysbot/compiler warnings Sakari Ailus
  14 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2021-01-20  9:43 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

Fix two smatch warnings:

drivers/staging/media/atomisp//pci/ia_css_firmware.h:52:29: warning: 'struct device' declared inside parameter list will not be visible outside of this definition or declaration
drivers/staging/media/atomisp//pci/ia_css_control.h:49:24: warning: 'struct device' declared inside parameter list will not be visible outside of this definition or declaration

Add '#include <linux/device.h>' to ia_css_firmware.h so struct device is defined.

ia_css_control.h includes ia_css_firmware.h, so it is sufficient to
just modify ia_css_firmware.h.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
 drivers/staging/media/atomisp/pci/ia_css_firmware.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/media/atomisp/pci/ia_css_firmware.h b/drivers/staging/media/atomisp/pci/ia_css_firmware.h
index edab72256494..e5e2f6fb37e0 100644
--- a/drivers/staging/media/atomisp/pci/ia_css_firmware.h
+++ b/drivers/staging/media/atomisp/pci/ia_css_firmware.h
@@ -20,6 +20,7 @@
  * This file contains firmware loading/unloading support functionality
  */
 
+#include <linux/device.h>
 #include "ia_css_err.h"
 #include "ia_css_env.h"
 
-- 
2.29.2


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

* [PATCH 14/14] i2c/ov02a10.c: add cast to fix type mismatch
  2021-01-20  9:42 [PATCH 00/14] Fixes for smatch/sparse/sysbot/compiler warnings Hans Verkuil
                   ` (12 preceding siblings ...)
  2021-01-20  9:43 ` [PATCH 13/14] atomisp/pci: add missing include Hans Verkuil
@ 2021-01-20  9:43 ` Hans Verkuil
  2021-01-23 22:36 ` [PATCH 00/14] Fixes for smatch/sparse/sysbot/compiler warnings Sakari Ailus
  14 siblings, 0 replies; 17+ messages in thread
From: Hans Verkuil @ 2021-01-20  9:43 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

By adding this cast '(__force __le16)' this sparse warning
is fixed:

drivers/media/i2c/ov02a10.c:391:19: warning: cast to restricted __le16

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
 drivers/media/i2c/ov02a10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/ov02a10.c b/drivers/media/i2c/ov02a10.c
index 8683ffd3287a..60b4bc645334 100644
--- a/drivers/media/i2c/ov02a10.c
+++ b/drivers/media/i2c/ov02a10.c
@@ -388,7 +388,7 @@ static int ov02a10_check_sensor_id(struct ov02a10 *ov02a10)
 	if (ret < 0)
 		return ret;
 
-	chip_id = le16_to_cpu(ret);
+	chip_id = le16_to_cpu((__force __le16)ret);
 
 	if ((chip_id & OV02A10_ID_MASK) != OV02A10_ID) {
 		dev_err(&client->dev, "unexpected sensor id(0x%04x)\n", chip_id);
-- 
2.29.2


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

* Re: [PATCH 00/14] Fixes for smatch/sparse/sysbot/compiler warnings
  2021-01-20  9:42 [PATCH 00/14] Fixes for smatch/sparse/sysbot/compiler warnings Hans Verkuil
                   ` (13 preceding siblings ...)
  2021-01-20  9:43 ` [PATCH 14/14] i2c/ov02a10.c: add cast to fix type mismatch Hans Verkuil
@ 2021-01-23 22:36 ` Sakari Ailus
  14 siblings, 0 replies; 17+ messages in thread
From: Sakari Ailus @ 2021-01-23 22:36 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media

Hi Hans,

On Wed, Jan 20, 2021 at 10:42:52AM +0100, Hans Verkuil wrote:
> The first patch fixes a compiler warning for i686, the second
> patch fixes a sysbot error, the last patch fixes a sparse warning
> and all others fix smatch warnings.

Please add on patches 6 and 14:

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

-- 
Sakari Ailus

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

* Re: [PATCH 06/14] i2c/ov8865.c: fix error checks using wrong variable
  2021-01-20  9:42 ` [PATCH 06/14] i2c/ov8865.c: fix error checks using wrong variable Hans Verkuil
@ 2021-01-23 22:39   ` Sakari Ailus
  0 siblings, 0 replies; 17+ messages in thread
From: Sakari Ailus @ 2021-01-23 22:39 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, kernel test robot, Dan Carpenter

Hi Hans,

On Wed, Jan 20, 2021 at 10:42:58AM +0100, Hans Verkuil wrote:
> Fix two typos: dvdd -> dovdd and dvdd -> avdd
> 
> Both clearly copy-and-paste mistakes.
> 
> Fixes this smatch warning:
> 
> drivers/media/i2c/ov8865.c:2852 ov8865_probe() warn: passing zero to 'PTR_ERR'
> 
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/media/i2c/ov8865.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c
> index fda5a55979aa..72ef300c0b67 100644
> --- a/drivers/media/i2c/ov8865.c
> +++ b/drivers/media/i2c/ov8865.c
> @@ -2839,9 +2839,9 @@ static int ov8865_probe(struct i2c_client *client)
>  
>  	/* DOVDD: digital I/O */
>  	sensor->dovdd = devm_regulator_get(dev, "dovdd");
> -	if (IS_ERR(sensor->dvdd)) {
> +	if (IS_ERR(sensor->dovdd)) {
>  		dev_err(dev, "cannot get DOVDD (digital I/O) regulator\n");
> -		ret = PTR_ERR(sensor->dvdd);
> +		ret = PTR_ERR(sensor->dovdd);
>  		goto error_endpoint;
>  	}
>  
> @@ -2849,7 +2849,7 @@ static int ov8865_probe(struct i2c_client *client)
>  	sensor->avdd = devm_regulator_get(dev, "avdd");
>  	if (IS_ERR(sensor->avdd)) {
>  		dev_err(dev, "cannot get AVDD (analog) regulator\n");
> -		ret = PTR_ERR(sensor->dvdd);
> +		ret = PTR_ERR(sensor->avdd);

This change is already in Julia's patch on which I've sent a pull request.

Could you omit it, leaving only the dovdd check to avoid a conflict?

>  		goto error_endpoint;
>  	}
>  

-- 
Regards,

Sakari Ailus

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

end of thread, other threads:[~2021-01-23 22:43 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-20  9:42 [PATCH 00/14] Fixes for smatch/sparse/sysbot/compiler warnings Hans Verkuil
2021-01-20  9:42 ` [PATCH 01/14] atomisp/pci/hmm: fix wrong printk format Hans Verkuil
2021-01-20  9:42 ` [PATCH 02/14] v4l2-ctrls.c: fix shift-out-of-bounds in std_validate Hans Verkuil
2021-01-20  9:42 ` [PATCH 03/14] meson/ge2d: set ret to -ENOMEM Hans Verkuil
2021-01-20  9:42 ` [PATCH 04/14] davinci/vpbe.c: ret contains the return code, not err Hans Verkuil
2021-01-20  9:42 ` [PATCH 05/14] tuners/it913x.c: fix missing error code Hans Verkuil
2021-01-20  9:42 ` [PATCH 06/14] i2c/ov8865.c: fix error checks using wrong variable Hans Verkuil
2021-01-23 22:39   ` Sakari Ailus
2021-01-20  9:42 ` [PATCH 07/14] sti/c8sectpfe: set correct return code Hans Verkuil
2021-01-20  9:43 ` [PATCH 08/14] sti/hva: add missing clk_disable_unprepare() Hans Verkuil
2021-01-20  9:43 ` [PATCH 09/14] pci/ivtv: release memory regions on error Hans Verkuil
2021-01-20  9:43 ` [PATCH 10/14] usb/dvb-usb-v2/rtl28xxu.c: clean up code to fix smatch warning Hans Verkuil
2021-01-20  9:43 ` [PATCH 11/14] dvb-frontends/rtl2832.c: fix missing error code Hans Verkuil
2021-01-20  9:43 ` [PATCH 12/14] dvb-frontends/af9033.c: fix missing error codes Hans Verkuil
2021-01-20  9:43 ` [PATCH 13/14] atomisp/pci: add missing include Hans Verkuil
2021-01-20  9:43 ` [PATCH 14/14] i2c/ov02a10.c: add cast to fix type mismatch Hans Verkuil
2021-01-23 22:36 ` [PATCH 00/14] Fixes for smatch/sparse/sysbot/compiler warnings Sakari Ailus

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.