Sean Young [Thu, 12 Oct 2017 22:02:57 +0000 (18:02 -0400)]
media: merge ir_tx_z8f0811_haup and ir_rx_z8f0811_haup i2c devices
These two devices ids are really just one device with multiple
addresses. Probing becomes much simpler if we simply fold this into
one i2c device with two address.
Note that this breaks the lirc_zilog driver, however we will teach
ir-kbd-i2c to do what lirc_zilog does in a later commit.
Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Akinobu Mita [Thu, 12 Oct 2017 16:04:44 +0000 (12:04 -0400)]
media: xilinx-video: fix bad of_node_put() on endpoint error
When iterating through all endpoints using of_graph_get_next_endpoint(),
the refcount of the returned endpoint node is incremented and the refcount
of the node which is passed as previous endpoint is decremented.
So the caller doesn't need to call of_node_put() for each iterated node
except for error exit paths. Otherwise we get "OF: ERROR: Bad
of_node_put() on ..." messages.
Colin Ian King [Wed, 20 Sep 2017 22:19:59 +0000 (18:19 -0400)]
media: dvb_ca_en50221: sanity check slot number from userspace
Currently a user can pass in an unsanitized slot number which
will lead to and out of range index into ca->slot_info. Fix this
by checking that the slot number is no more than the allowed
maximum number of slots. Seems that this bug has been in the driver
forever.
Detected by CoverityScan, CID#139381 ("Untrusted pointer read")
Signed-off-by: Colin Ian King <colin.king@canonical.com> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Jasmin Jessich <jasmin@anw.at> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Add suffix ULL to constant 65535 in order to avoid a potential
integer overflow. This constant is used in a context that
expects an expression of type u64.
Stefan Brüns [Fri, 17 Feb 2017 00:55:33 +0000 (19:55 -0500)]
media: dvbsky: MyGica T230C support
Mygica T230 DVB-T/T2/C USB stick support. It uses the same FX2/Si2168
bridge/demodulator combo as the other devices supported by the driver,
but uses the Si2141 tuner.
Several DVB-T (MPEG2) and DVB-T2 (H.265) channels were tested, as well as
the included remote control.
Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Daniel Scheller [Wed, 6 Dec 2017 17:59:14 +0000 (12:59 -0500)]
media: ddbridge: improve error handling logic on fe attach failures
This change makes sure that demod frontends are always detached whenever
a tuner frontend attach failed. Achieve this by moving the detach-on-
failure logic at the end of dvb_input_attach(), and adding a goto to this
block on every tuner attach failure case, so if an error occurs, there are
no stray attached frontends left. As a side effect, this removes some
duplicated code.
Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Jaedon Shin [Fri, 1 Dec 2017 12:31:30 +0000 (07:31 -0500)]
media: dvb_frontend: Add commands implementation for compat ioct
The dtv_properties structure and the dtv_property structure are
different sizes in 32-bit and 64-bit system. This patch provides
FE_SET_PROPERTY and FE_GET_PROPERTY ioctl commands implementation for
32-bit user space applications.
drivers/media/dvb-core/dvb_frontend.c:154:2-7: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.
NULL check before some freeing functions is not needed.
Based on checkpatch warning
"kfree(NULL) is safe this check is probably not required"
and kfreeaddr.cocci by Julia Lawall.
Daniel Scheller [Sun, 26 Nov 2017 13:00:06 +0000 (08:00 -0500)]
media: dvb-frontends/stv0910: remove unneeded check/call to get_if_freq
The result (if any) isn't used anywhere besides being assigned to a local
variable (and the only current companion stv6111 doesn't even implement
get_if_frequency()), thus remove the ptr check and the call, and also
remove the now unused iffreq variable.
Reported-by: Richard Scobie <rascobie@slingshot.co.nz> Cc: Ralph Metzler <rjkm@metzlerbros.de> Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Tested-by: Richard Scobie <rascobie@slingshot.co.nz> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Daniel Scheller [Sun, 26 Nov 2017 13:00:04 +0000 (08:00 -0500)]
media: dvb-frontends/stv0910: WARN_ON() on consecutive mutex_unlock()
Stack dump when gate_ctrl() is called in a way that consecutive unlocks
happen. This is a clear indication that other drivers interfacing with
the stv0910 driver don't do things properly or don't check for failures,
so dump stack so that those drivers can be identified and fixed.
Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Tested-by: Richard Scobie <rascobie@slingshot.co.nz> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Daniel Scheller [Sun, 26 Nov 2017 13:00:03 +0000 (08:00 -0500)]
media: frontends/stv0910: add field offsets to field defines
Each field (FSTV0910_XX) is declared as reg/off/unused/sign/mask. Add
the missing offset value to the defines.
Picked up from dddvb master, commit 8a1f27c3d22c ("add field offset to
field defines") by Ralph Metzler <rjkm@metzlerbros.de>, adapted to
match the comment style in the mainline driver.
Cc: Ralph Metzler <rjkm@metzlerbros.de> Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Vasyl Gomonovych [Mon, 20 Nov 2017 22:46:47 +0000 (17:46 -0500)]
media: c8sectpfe: Use resource_size function on memory resource
To adapt fei->sram_size calculation via resource_size for memory size
calculation before, in fei->sram = devm_ioremap_resource(dev, res).
And make memory initialization range in
memset_io for fei->sram appropriate
media: c8sectpfe: fix potential NULL pointer dereference in c8sectpfe_timer_interrupt
_channel_ is being dereferenced before it is null checked, hence there is a
potential null pointer dereference. Fix this by moving the pointer dereference
after _channel_ has been null checked.
This issue was detected with the help of Coccinelle.
Fixes: c5f5d0f99794 ("[media] c8sectpfe: STiH407/10 Linux DVB demux support") Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com> Acked-by: Patrice Chotard <patrice.chotard@st.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
The correct error code when a function is not defined is
-ENOTSUPP. It was typoed wrong as -EOPNOTSUPP, with,
unfortunately, exists, but it is not used by the DVB core.
Thanks-to: Geert Uytterhoeven <geert@linux-m68k.org> Thanks-to: Arnd Bergmann <arnd@arndb.de>
To make me revisit this code.
Fixes: a9cb97c3e628 ("media: dvb_frontend: be sure to init dvb_frontend_handle_ioctl() return code") Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
The logic at V4L2 led core assumes that the flash struct
can be null. However, it doesn't check for null while
trying to set, causing some smatch to warn:
drivers/media/v4l2-core/v4l2-flash-led-class.c:210 v4l2_flash_s_ctrl() error: we previously assumed 'fled_cdev' could be null (see line 200)
media: dvb_frontend: be sure to init dvb_frontend_handle_ioctl() return code
As smatch warned:
drivers/media/dvb-core/dvb_frontend.c:2468 dvb_frontend_handle_ioctl() error: uninitialized symbol 'err'.
The ioctl handler actually got a regression here: before changeset d73dcf0cdb95 ("media: dvb_frontend: cleanup ioctl handling logic"),
the code used to return -EOPNOTSUPP if an ioctl handler was not
implemented on a driver. After the change, it may return a random
value.
As reported by smatch:
drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c:485 mxl111sf_demod_read_signal_strength() error: uninitialized symbol 'modulation'.
The mxl111sf_demod_read_signal_strength() just ignores if something
gets wrong while reading snr or modulation.
As warned by smatch:
drivers/media/dvb-frontends/drxd_hard.c:989 HI_Command() error: uninitialized symbol 'waitCmd'.
drivers/media/dvb-frontends/drxd_hard.c:1306 SC_WaitForReady() error: uninitialized symbol 'curCmd'.
drivers/media/dvb-frontends/drxd_hard.c:1322 SC_SendCommand() error: uninitialized symbol 'errCode'.
drivers/media/dvb-frontends/drxd_hard.c:1339 SC_ProcStartCommand() error: uninitialized symbol 'scExec'.
The error handling on several places are somewhat flawed, as
they don't check if Read16() returns an error.
media: cxd2841er: ensure that status will always be available
The loop with read status use a dynamic timeout value, calculated
from symbol rate. It should run the loop at least one time for
the status to be handled after the loop.
While this should, in practice, happen every time, it doesn't
hurt to change the logic to make it explicit.
This solves a smatch warning:
drivers/media/dvb-frontends/cxd2841er.c:3350 cxd2841er_set_frontend_s() error: uninitialized symbol 'status'.
Smatch gives two bogus warnings on this driver:
drivers/media/usb/dvb-usb-v2/dvbsky.c:336 dvbsky_s960_attach() error: uninitialized symbol 'i2c_adapter'.
drivers/media/usb/dvb-usb-v2/dvbsky.c:459 dvbsky_s960c_attach() error: uninitialized symbol 'i2c_adapter'.
media: m88rs2000: handle the case where tuner doesn't have get_frequency
If the tuner doesn't have get_frequency() callback, the current
code will place a random value as the frequency offset. That
doesn't seem right! The better is to just assume that, on such
case, the tuner was able to set the exact frequency that was
requested.
Fixes a smatch warning:
drivers/media/dvb-frontends/m88rs2000.c:639 m88rs2000_set_frontend() error: uninitialized symbol 'tuner_freq'.
media: pt1: fix logic when pt1_nr_tables is zero or negative
pt1_nr_tables is a modprobe parameter. The way the logic
handles it, it can't be negative. However, user can
set it to zero.
If set to zero, however, it will cause troubles at
pt1_init_tables(), as reported by smatch:
drivers/media/pci/pt1/pt1.c:468 pt1_init_tables() error: uninitialized symbol 'first_pfn'.
The smatch logic gets confused with the syntax used to check if the
ov9650x_read() reads succedded:
drivers/media/i2c/ov9650.c:895 __g_volatile_ctrl() error: uninitialized symbol 'reg2'.
drivers/media/i2c/ov9650.c:895 __g_volatile_ctrl() error: uninitialized symbol 'reg1'.
There's nothing wrong with the original logic, except that
it is a little more harder to review.
So, let's stick with the syntax that won't cause read
issues.
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> Reviewed-by: Nicholas Mc Guire <hofrat@osadl.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
As warned by smatch:
drivers/media/dvb-frontends/mb86a16.c:1690 mb86a16_read_ber() error: uninitialized symbol 'timer'.
drivers/media/dvb-frontends/mb86a16.c:1706 mb86a16_read_ber() error: uninitialized symbol 'timer'.
There is a potential risk of doing a division by zero if
timer is not handled well. Enforce it by setting a bit mask
for the values used to select the timer.
It should be noticed that I don't have mb86a16 datasheet. So,
the bitmask was guessed based on the existing checks for
the field. At worse case scenario, it will just show a
badly calculated bit error rate, but it won't crash.
While here, optimize the logic to prevent uneeded tests.
media: mb86a16: be more resilient if I2C fails on sync
If the I2C read fails while check for sync, there's no point
on doing adjusting the tuner due to a random value that might
be at VIRM var. So, set VIRM to zero, as that makes the caller
for check_sync() to return an error.
Fix those smatch warnings:
drivers/media/dvb-frontends/mb86a16.c:1460 mb86a16_set_fe() error: uninitialized symbol 'VIRM'.
drivers/media/dvb-frontends/mb86a16.c:1461 mb86a16_set_fe() error: uninitialized symbol 'VIRM'.
media: imx274: don't randomly return if range_count is zero
As smatch reported:
drivers/media/i2c/imx274.c:659 imx274_regmap_util_write_table_8() error: uninitialized symbol 'err'.
There is a bug at imx274_regmap_util_write_table_8() with causes
it to randomly return a random error if range_count is zero.
Worse than that, the logic there starts with range_count
equal to zero, and periodically resets it to zero again.
As it is a way more likely that err assumes a non-zero value,
I suspect that the chance of this code to run is very small,
so, it would be worth to review the entire function.
Anyway, clearly it shouldn't be returning error if range_count
is zero. So, let's fix it.
media: stv090x: Only print tuner lock if get_status is available
The current code doesn't report tuner lock properly if the
tuner get_status callback is not available, as reported by
smatch:
drivers/media/dvb-frontends/stv090x.c:2220 stv090x_get_coldlock() error: uninitialized symbol 'reg'.
media: radio-si476x: fix behavior when seek->range* are defined
The logic at si476x_radio_s_hw_freq_seek() checks if the
frequency range that will be used to handle hardware seek
has the minimal frequency under rangelow. That works fine
if userspace zeros both fields. However, if userspace
fills either seek->rangelow or seek-rangehigh, it won't
read the corresponding range from the device, causing the
values to be unitialized, as warned by smatch:
drivers/media/radio/radio-si476x.c:789 si476x_radio_s_hw_freq_seek() error: uninitialized symbol 'rangelow'.
drivers/media/radio/radio-si476x.c:789 si476x_radio_s_hw_freq_seek() error: uninitialized symbol 'rangehigh'.
Fix it by initializing those vars from the values present at
the struct v4l2_hw_freq_seek.
While here, simplify the logic which reads such values from
the hardware limits.
The logic at qt1010_init_meas1() and qt1010_init_meas2()
are too complex for static analizers to identify that
some vars are always be initialized.
That causes smatch to produce the following warnings:
drivers/media/tuners/qt1010.c:248 qt1010_init_meas1() error: uninitialized symbol 'val2'.
drivers/media/tuners/qt1010.c:282 qt1010_init_meas2() error: uninitialized symbol 'val'.
So, add annotations to prevent those bogus warnings.
The tuning logic at tda8290 relies on agc_stat and
adc_sat to be initialized. However, as warned by smatch:
drivers/media/tuners/tda8290.c:261 tda8290_set_params() error: uninitialized symbol 'agc_stat'.
drivers/media/tuners/tda8290.c:261 tda8290_set_params() error: uninitialized symbol 'adc_sat'.
drivers/media/tuners/tda8290.c:262 tda8290_set_params() error: uninitialized symbol 'adc_sat'.
That could cause an erratic behavior if PLL is not locked,
as the code will only work if
!(pll_stat & 0x80) && (adc_sat < 20)
So, initialize it to zero, in order to let the code below
to be called, with should give more chances to adjust the
tuner gain, in order to get a PLL lock.
media: atmel-isc: avoid returning a random value at isc_parse_dt()
As warned by smatch:
drivers/media/platform/atmel/atmel-isc.c:2097 isc_parse_dt() error: uninitialized symbol 'ret'.
The problem here is that of_graph_get_next_endpoint() can
potentially return NULL on its first pass, with would make
it return a random value, as ret is not initialized.
While here, use while(1) instead of for(; ;), as while is
the preferred syntax for such kind of loops.
media: em28xx: Fix use-after-free when disconnecting
Fix bug by moving the i2c_unregister_device calls after deregistration
of dvb frontend.
The new style i2c drivers already destroys the frontend object at
i2c_unregister_device time.
When the dvb frontend is unregistered afterwards it leads to this oops:
drivers/media/pci/ddbridge/ddbridge-ci.c:321:5: warning: no previous prototype for 'ddb_ci_attach' [-Wmissing-prototypes]
int ddb_ci_attach(struct ddb_port *port, u32 bitrate)
^~~~~~~~~~~~~
Daniel Scheller [Sun, 15 Oct 2017 20:51:51 +0000 (16:51 -0400)]
media: ddbridge: fixup checkpatch-strict issues
Fixes several alignment, braces, space-before-cast, camelcase et al issues
reported by checkpatch --strict, plus a few more checkpatch didn't report.
Three checks are left after this though:
- one CamelCase in ddbridge-core, related to defines/vars/enums referenced
from the stv090x demod driver
- one macro argument reuse in ddbridge-core aswell
- one unbalanced braces around else in ddbridge-main, which is due to
#ifdefs related to CONFIG_PCI_MSI, which preferrably should be kept
as-is for readability.
Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Daniel Scheller [Sun, 15 Oct 2017 20:51:50 +0000 (16:51 -0400)]
media: ddbridge: remove unneeded *fe vars from attach functions
These are only used in C/T demod attach functions, don't add any real
benefit (ie. line length savings) and in case of cxd28xx_attach aren't
even used consequently. Remove them.
Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
media: cx25840: fix a possible divide by zero in set_fmt callback
If set_fmt callback is called with format->width or format->height set to
zero and HACTIVE_CNT or VACTIVE_CNT bits (respectively) in chip are zero
we will divide by zero later in this callback when we try to calculate
HSC or VSC values.
Fix this by explicitly rejecting these values.
Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
media: cx25840: describe standard for 0b1100 value in AFD_FMT_STAT bits
A 0b1100 value in 4 LSBs of "General Status 1" register (AFD_FMT_STAT) has
known meaning for CX2584x-series chips - it means that a SECAM signal is
currently detected by the chip.
Use this opportunity to also fix wrong binary values that were present
as comments attached to some entries in an array where
chip register -> V4L2 standard mappings are stored.
Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Russell King [Fri, 29 Sep 2017 21:41:59 +0000 (17:41 -0400)]
media: imx-csi: fix burst size
Setting a burst size of "8" doesn't work for IMX219 with 8-bit bayer,
but a burst size of "16" does. Fix this.
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Acked-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Russell King [Fri, 29 Sep 2017 21:38:39 +0000 (17:38 -0400)]
media: staging/imx: fix complete handler
The complete handler walks all entities, expecting to find an imx
subdevice for each and every entity.
However, camera drivers such as smiapp can themselves contain multiple
entities, for which there will not be an imx subdevice. This causes
imx_media_find_subdev_by_sd() to fail, making the imx capture system
unusable with such cameras.
Work around this by killing the error entirely, thereby allowing
the imx capture to be used with such cameras.
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Acked-by: Steve Longerbeam <steve_longerbeam@mentor.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
media: dvb-usb-v2: lmedm04: move ts2020 attach to dm04_lme2510_tuner
When the tuner was split from m88rs2000 the attach function is in wrong
place.
Move to dm04_lme2510_tuner to trap errors on failure and removing
a call to lme_coldreset.
Prevents driver starting up without any tuner connected.
Fixes to trap for ts2020 fail.
LME2510(C): FE Found M88RS2000
ts2020: probe of 0-0060 failed with error -11
...
LME2510(C): TUN Found RS2000 tuner
kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] PREEMPT SMP KASAN
As we're now using SPDX identifiers, add the proper SPDX,
better identifying the licenses whith apply to the source code.
As we're now using the short license, it doesn't make sense to
keep the original license text.
Also, fix MODULE_LICENSE to properly identify GPL v2
at the Siano's common driver. Some codes there are licensed
on GPL v2 or latter, while others are GPL v2 only. So,
in order to reflect the common license that applies to
everything, the module itself should be GPLv2 only.
While here, use the Kernel's coding style for the comments
with copyright info.
Laurent Pinchart [Tue, 17 Oct 2017 17:15:54 +0000 (13:15 -0400)]
media: uvcvideo: Stream error events carry no data
According to the UVC specification, stream error events carry no data.
Fix a buffer overflow (that should be harmless given data alignment)
when reporting the stream error event by removing the data byte from the
message.