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

pinctrl: exynos5440: fix issues reported by prevent tool

This patch fixes issues reported by prevent tool.

Signed-off-by: Thomas Abraham <thomas.ab@samsung.com>
Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
[Drop hunk already in-tree from a patch by Wei Yongjun]
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Thomas Abraham and committed by
Linus Walleij
79bae27f 6f924b0b

+8 -5
+8 -5
drivers/pinctrl/pinctrl-exynos5440.c
··· 220 220 dev_err(dev, "failed to alloc memory for group name\n"); 221 221 goto free_map; 222 222 } 223 - sprintf(gname, "%s%s", np->name, GROUP_SUFFIX); 223 + snprintf(gname, strlen(np->name) + 4, "%s%s", np->name, GROUP_SUFFIX); 224 224 225 225 /* 226 226 * don't have config options? then skip over to creating function ··· 259 259 dev_err(dev, "failed to alloc memory for func name\n"); 260 260 goto free_cfg; 261 261 } 262 - sprintf(fname, "%s%s", np->name, FUNCTION_SUFFIX); 262 + snprintf(fname, strlen(np->name) + 4, "%s%s", np->name, 263 + FUNCTION_SUFFIX); 263 264 264 265 map[*nmaps].data.mux.group = gname; 265 266 map[*nmaps].data.mux.function = fname; ··· 714 713 dev_err(dev, "failed to alloc memory for group name\n"); 715 714 return -ENOMEM; 716 715 } 717 - sprintf(gname, "%s%s", cfg_np->name, GROUP_SUFFIX); 716 + snprintf(gname, strlen(cfg_np->name) + 4, "%s%s", cfg_np->name, 717 + GROUP_SUFFIX); 718 718 719 719 grp->name = gname; 720 720 grp->pins = pin_list; ··· 735 733 dev_err(dev, "failed to alloc memory for func name\n"); 736 734 return -ENOMEM; 737 735 } 738 - sprintf(fname, "%s%s", cfg_np->name, FUNCTION_SUFFIX); 736 + snprintf(fname, strlen(cfg_np->name) + 4, "%s%s", cfg_np->name, 737 + FUNCTION_SUFFIX); 739 738 740 739 func->name = fname; 741 740 func->groups = devm_kzalloc(dev, sizeof(char *), GFP_KERNEL); ··· 809 806 810 807 /* for each pin, set the name of the pin */ 811 808 for (pin = 0; pin < ctrldesc->npins; pin++) { 812 - sprintf(pin_names, "gpio%02d", pin); 809 + snprintf(pin_names, 6, "gpio%02d", pin); 813 810 pdesc = pindesc + pin; 814 811 pdesc->name = pin_names; 815 812 pin_names += PIN_NAME_LENGTH;