[PATCH v2] staging: mt7621-pinctrl: initialize 'num_maps' variable to zero

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Function 'rt2880_pinctrl_dt_node_to_map' calls internally
'pinctrl_utils_reserve_map' which expects 'num_maps' to be initialized.
It does a memory allocation based on the value, and triggers the following
warning if is not properly set:

if (unlikely(order >= MAX_ORDER)) {
        WARN_ON_ONCE(!(gfp_mask & __GFP_NOWARN));
        return NULL;
}

Initialize it to zero to avoid this problem.

Fixes: e12a1a6e087b ("staging: mt7621-pinctrl: refactor rt2880_pinctrl_dt_node_to_map function")
Reported-by: NeilBrown <neil@xxxxxxxxxx>
Tested-by: NeilBrown <neil@xxxxxxxxxx>
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@xxxxxxxxx>
---
Changes v2:
    - Collect Tested-by tags. See:
http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2018-December/130259.html

 drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
index aa98fbb17013..b663ca43a525 100644
--- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
+++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
@@ -88,6 +88,7 @@ static int rt2880_pinctrl_dt_node_to_map(struct pinctrl_dev *pctrldev,
 	for_each_node_with_property(np_config, "group")
 		ngroups++;
 
+	*num_maps = 0;
 	*map = NULL;
 	ret = pinctrl_utils_reserve_map(pctrldev, map, &reserved_maps,
 					num_maps, ngroups);
-- 
2.19.1

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux