Skip to content

Commit

Permalink
pinctrl: fix pinmux_hog_maps when ctrl_dev_name is not set
Browse files Browse the repository at this point in the history
The ctrl_dev_name is optional for struct pinmux_map assuming
that ctrl_dev is set. Without this patch we can get:

Unable to handle kernel NULL pointer dereference at virtual
address 00000000
...
(pinmux_hog_maps+0xa4/0x20c)
(pinctrl_register+0x2a4/0x378)
...

Fix this by adding adding a test for map->ctrl_dev.
Additionally move the test for map->ctrl_dev earlier
to optimize out the loop a bit.

Signed-off-by: Tony Lindgren <tony@atomide.com>
Acked-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Tony Lindgren authored and Linus Walleij committed Jan 26, 2012
1 parent de849ee commit 9e2551e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/pinctrl/pinmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -978,9 +978,12 @@ int pinmux_hog_maps(struct pinctrl_dev *pctldev)
for (i = 0; i < pinmux_maps_num; i++) {
struct pinmux_map const *map = &pinmux_maps[i];

if (((map->ctrl_dev == dev) ||
!strcmp(map->ctrl_dev_name, devname)) &&
map->hog_on_boot) {
if (!map->hog_on_boot)
continue;

if ((map->ctrl_dev == dev) ||
(map->ctrl_dev_name &&
!strcmp(map->ctrl_dev_name, devname))) {
/* OK time to hog! */
ret = pinmux_hog_map(pctldev, map);
if (ret)
Expand Down

0 comments on commit 9e2551e

Please sign in to comment.