diff options
author | Subbaraman Narayanamurthy <subbaram@codeaurora.org> | 2017-01-09 15:13:23 -0800 |
---|---|---|
committer | Subbaraman Narayanamurthy <subbaram@codeaurora.org> | 2017-01-09 16:21:51 -0800 |
commit | e17f4cf09eaf319b703efa7db4188581dae156f0 (patch) | |
tree | c02a088f870ddf671aba9e45a7880c11dda4a684 | |
parent | 79a1a55cf8ff6e4db05ff13ce5ab6fc2c0ce9dd9 (diff) |
qpnp-pin: Fix null pointer access in qpnp_pin_debugfs_create()
qpnp_pin_debugfs_create() is going through all the child nodes
to create debugfs entries whereas the allocation for q_spec is
made only for available child nodes. This leads to a null pointer
access when CONFIG_GPIO_QPNP_PIN_DEBUG is selected in defconfig.
Fix it by using number of gpios available under each gpio chip
which was populated from the available child count already.
Change-Id: I17cbeeba158d34180763087103da4b03e01f7c90
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
-rw-r--r-- | drivers/gpio/qpnp-pin.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/gpio/qpnp-pin.c b/drivers/gpio/qpnp-pin.c index 483bb9338ac3..de24d99ea34e 100644 --- a/drivers/gpio/qpnp-pin.c +++ b/drivers/gpio/qpnp-pin.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -1381,7 +1381,7 @@ static int qpnp_pin_debugfs_create(struct qpnp_pin_chip *q_chip) return -ENODEV; } - for (i = 0; i < of_get_child_count(pdev->dev.of_node); i++) { + for (i = 0; i < q_chip->gpio_chip.ngpio; i++) { q_spec = qpnp_chip_gpio_get_spec(q_chip, i); params = q_spec->params; snprintf(pmic_pin, DEBUGFS_BUF_SIZE, "%u", q_spec->pmic_pin); |