Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

pinctrl: pinconf-generic: Fully validate 'pinmux' property

The pinconf_generic_parse_dt_pinmux() assumes that the 'pinmux' property
is not empty when present. This might be not true. With that, the allocator
will give a special value in return and not NULL which lead to the crash
when trying to access that (invalid) memory. Fix that by fully validating
'pinmux' value, including its length.

Fixes: 7112c05fff83 ("pinctrl: pinconf-generic: Add API for pinmux propertity in DTS file")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Linus Walleij <linusw@kernel.org>

authored by

Andy Shevchenko and committed by
Linus Walleij
c98324ea d4530869

+6 -1
+6 -1
drivers/pinctrl/pinconf-generic.c
··· 325 325 return -ENOENT; 326 326 } 327 327 328 + npins_t = prop->length / sizeof(u32); 329 + if (npins_t == 0) { 330 + dev_info(dev, "pinmux property doesn't have entries\n"); 331 + return -ENODATA; 332 + } 333 + 328 334 if (!pid || !pmux || !npins) { 329 335 dev_err(dev, "parameters error\n"); 330 336 return -EINVAL; 331 337 } 332 338 333 - npins_t = prop->length / sizeof(u32); 334 339 pid_t = devm_kcalloc(dev, npins_t, sizeof(*pid_t), GFP_KERNEL); 335 340 pmux_t = devm_kcalloc(dev, npins_t, sizeof(*pmux_t), GFP_KERNEL); 336 341 if (!pid_t || !pmux_t) {