From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Gabriel David <ultracoolguy@tutanota.com>,
Pavel Machek <pavel@ucw.cz>,
stable@kernel.org, Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Subject: [PATCH 5.9 06/14] leds: lm3697: Fix out-of-bound access
Date: Fri, 20 Nov 2020 12:03:44 +0100 [thread overview]
Message-ID: <20201120104541.482562040@linuxfoundation.org> (raw)
In-Reply-To: <20201120104541.168007611@linuxfoundation.org>
From: Gabriel David <ultracoolguy@tutanota.com>
commit 98d278ca00bd8f62c8bc98bd9e65372d16eb6956 upstream
If both LED banks aren't used in device tree, an out-of-bounds
condition in lm3697_init occurs because of the for loop assuming that
all the banks are used. Fix it by adding a variable that contains the
number of used banks.
Signed-off-by: Gabriel David <ultracoolguy@tutanota.com>
[removed extra rename, minor tweaks]
Signed-off-by: Pavel Machek <pavel@ucw.cz>
Cc: stable@kernel.org
[sudip: use client->dev]
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/leds/leds-lm3697.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
--- a/drivers/leds/leds-lm3697.c
+++ b/drivers/leds/leds-lm3697.c
@@ -78,6 +78,7 @@ struct lm3697 {
struct mutex lock;
int bank_cfg;
+ int num_banks;
struct lm3697_led leds[];
};
@@ -180,7 +181,7 @@ static int lm3697_init(struct lm3697 *pr
if (ret)
dev_err(&priv->client->dev, "Cannot write OUTPUT config\n");
- for (i = 0; i < LM3697_MAX_CONTROL_BANKS; i++) {
+ for (i = 0; i < priv->num_banks; i++) {
led = &priv->leds[i];
ret = ti_lmu_common_set_ramp(&led->lmu_data);
if (ret)
@@ -307,8 +308,8 @@ static int lm3697_probe(struct i2c_clien
int ret;
count = device_get_child_node_count(&client->dev);
- if (!count) {
- dev_err(&client->dev, "LEDs are not defined in device tree!");
+ if (!count || count > LM3697_MAX_CONTROL_BANKS) {
+ dev_err(&client->dev, "Strange device tree!");
return -ENODEV;
}
@@ -322,6 +323,7 @@ static int lm3697_probe(struct i2c_clien
led->client = client;
led->dev = &client->dev;
+ led->num_banks = count;
led->regmap = devm_regmap_init_i2c(client, &lm3697_regmap_config);
if (IS_ERR(led->regmap)) {
ret = PTR_ERR(led->regmap);
next prev parent reply other threads:[~2020-11-20 11:08 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-20 11:03 [PATCH 5.9 00/14] 5.9.10-rc1 review Greg Kroah-Hartman
2020-11-20 11:03 ` [PATCH 5.9 01/14] selftests/powerpc: rfi_flush: disable entry flush if present Greg Kroah-Hartman
2020-11-20 11:03 ` [PATCH 5.9 02/14] powerpc/64s: flush L1D on kernel entry Greg Kroah-Hartman
2020-11-20 11:03 ` [PATCH 5.9 03/14] powerpc/64s: flush L1D after user accesses Greg Kroah-Hartman
2020-11-20 11:03 ` [PATCH 5.9 04/14] powerpc: Only include kup-radix.h for 64-bit Book3S Greg Kroah-Hartman
2020-11-20 11:03 ` [PATCH 5.9 05/14] selftests/powerpc: entry flush test Greg Kroah-Hartman
2020-11-20 11:03 ` Greg Kroah-Hartman [this message]
2020-11-20 11:03 ` [PATCH 5.9 07/14] Input: sunkbd - avoid use-after-free in teardown paths Greg Kroah-Hartman
2020-11-20 11:03 ` [PATCH 5.9 08/14] mac80211: always wind down STA state Greg Kroah-Hartman
2020-11-20 11:03 ` [PATCH 5.9 09/14] can: proc: can_remove_proc(): silence remove_proc_entry warning Greg Kroah-Hartman
2020-11-20 11:03 ` [PATCH 5.9 10/14] selftests/harness: prettify SKIP message whitespace again Greg Kroah-Hartman
2020-11-20 11:03 ` [PATCH 5.9 11/14] powerpc/smp: Call rcu_cpu_starting() earlier Greg Kroah-Hartman
2020-11-20 11:03 ` [PATCH 5.9 12/14] perf/x86/intel/uncore: Fix Add BW copypasta Greg Kroah-Hartman
2020-11-20 11:03 ` [PATCH 5.9 13/14] KVM: x86: clflushopt should be treated as a no-op by emulation Greg Kroah-Hartman
2020-11-20 11:03 ` [PATCH 5.9 14/14] ACPI: GED: fix -Wformat Greg Kroah-Hartman
2020-11-20 16:56 ` [PATCH 5.9 00/14] 5.9.10-rc1 review Jon Hunter
2020-11-22 9:18 ` Greg Kroah-Hartman
2020-11-20 17:52 ` Jeffrin Jose T
2020-11-20 22:27 ` Shuah Khan
2020-11-22 9:18 ` Greg Kroah-Hartman
2020-11-21 11:12 ` Naresh Kamboju
2020-11-22 9:18 ` Greg Kroah-Hartman
2020-11-21 18:38 ` Guenter Roeck
2020-11-22 9:19 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201120104541.482562040@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=stable@kernel.org \
--cc=stable@vger.kernel.org \
--cc=sudipm.mukherjee@gmail.com \
--cc=ultracoolguy@tutanota.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.