diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2020-05-08 16:40:22 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-08-21 10:53:01 +0200 |
commit | d4e8eb46dd704bceced662c5bc5994ede03cec1f (patch) | |
tree | f96835436e4911a43fccb76f4eda41b1cae5a446 | |
parent | 9fd0361855e70b16df637903aefb5e6fb5d08ec5 (diff) | |
download | linux-stable-d4e8eb46dd704bceced662c5bc5994ede03cec1f.tar.gz linux-stable-d4e8eb46dd704bceced662c5bc5994ede03cec1f.tar.bz2 linux-stable-d4e8eb46dd704bceced662c5bc5994ede03cec1f.zip |
media: firewire: Using uninitialized values in node_probe()
[ Upstream commit 2505a210fc126599013aec2be741df20aaacc490 ]
If fw_csr_string() returns -ENOENT, then "name" is uninitialized. So
then the "strlen(model_names[i]) <= name_len" is true because strlen()
is unsigned and -ENOENT is type promoted to a very high positive value.
Then the "strncmp(name, model_names[i], name_len)" uses uninitialized
data because "name" is uninitialized.
Fixes: 92374e886c75 ("[media] firedtv: drop obsolete backend abstraction")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | drivers/media/firewire/firedtv-fw.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/media/firewire/firedtv-fw.c b/drivers/media/firewire/firedtv-fw.c index 247f0e7cb5f7..5d634706a7ea 100644 --- a/drivers/media/firewire/firedtv-fw.c +++ b/drivers/media/firewire/firedtv-fw.c @@ -271,6 +271,8 @@ static int node_probe(struct fw_unit *unit, const struct ieee1394_device_id *id) name_len = fw_csr_string(unit->directory, CSR_MODEL, name, sizeof(name)); + if (name_len < 0) + return name_len; for (i = ARRAY_SIZE(model_names); --i; ) if (strlen(model_names[i]) <= name_len && strncmp(name, model_names[i], name_len) == 0) |