CC: kbuild-...@lists.01.org
In-Reply-To: <20210210222851.232374-3-d...@beagleboard.org>
References: <20210210222851.232374-3-d...@beagleboard.org>
TO: Drew Fustini <d...@beagleboard.org>
TO: Linus Walleij <linus.wall...@linaro.org>
TO: linux-g...@vger.kernel.org
TO: linux-ker...@vger.kernel.org
TO: Tony Lindgren <t...@atomide.com>
TO: Andy Shevchenko <andy.shevche...@gmail.com>
TO: Alexandre Belloni <alexandre.bell...@bootlin.com>
TO: Geert Uytterhoeven <ge...@linux-m68k.org>
TO: Pantelis Antoniou <pantelis.anton...@konsulko.com>
TO: Jason Kridner <jkrid...@beagleboard.org>
TO: Robert Nelson <robertcnel...@beagleboard.org>

Hi Drew,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on pinctrl/devel]
[also build test WARNING on v5.11-rc7 next-20210125]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    
https://github.com/0day-ci/linux/commits/Drew-Fustini/pinctrl-pinmux-Add-pinmux-select-debugfs-file/20210211-063617
base:   
https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
:::::: branch date: 6 hours ago
:::::: commit date: 6 hours ago
config: x86_64-randconfig-m001-20210211 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <l...@intel.com>
Reported-by: Dan Carpenter <dan.carpen...@oracle.com>

smatch warnings:
drivers/pinctrl/pinmux.c:764 pinmux_select() warn: possible memory leak of 
'gname'

vim +/gname +764 drivers/pinctrl/pinmux.c

2744e8afb3b763 Linus Walleij 2011-05-02  675  
f878efc17642ce Drew Fustini  2021-02-10  676  #define PINMUX_MAX_NAME 64
f878efc17642ce Drew Fustini  2021-02-10  677  static ssize_t 
pinmux_select(struct file *file, const char __user *user_buf,
f878efc17642ce Drew Fustini  2021-02-10  678                               
size_t len, loff_t *ppos)
f878efc17642ce Drew Fustini  2021-02-10  679  {
f878efc17642ce Drew Fustini  2021-02-10  680    struct seq_file *sfile = 
file->private_data;
f878efc17642ce Drew Fustini  2021-02-10  681    struct pinctrl_dev *pctldev = 
sfile->private;
f878efc17642ce Drew Fustini  2021-02-10  682    const struct pinmux_ops *pmxops 
= pctldev->desc->pmxops;
f878efc17642ce Drew Fustini  2021-02-10  683    const char *const *groups;
f878efc17642ce Drew Fustini  2021-02-10  684    char *buf, *fname, *gname;
f878efc17642ce Drew Fustini  2021-02-10  685    unsigned int num_groups;
f878efc17642ce Drew Fustini  2021-02-10  686    int fsel, gsel, ret;
f878efc17642ce Drew Fustini  2021-02-10  687  
f878efc17642ce Drew Fustini  2021-02-10  688    if (len > (PINMUX_MAX_NAME * 
2)) {
f878efc17642ce Drew Fustini  2021-02-10  689            dev_err(pctldev->dev, 
"write too big for buffer");
f878efc17642ce Drew Fustini  2021-02-10  690            return -EINVAL;
f878efc17642ce Drew Fustini  2021-02-10  691    }
f878efc17642ce Drew Fustini  2021-02-10  692  
f878efc17642ce Drew Fustini  2021-02-10  693    buf = kzalloc(PINMUX_MAX_NAME * 
2, GFP_KERNEL);
f878efc17642ce Drew Fustini  2021-02-10  694    if (!buf)
f878efc17642ce Drew Fustini  2021-02-10  695            return -ENOMEM;
f878efc17642ce Drew Fustini  2021-02-10  696  
f878efc17642ce Drew Fustini  2021-02-10  697    fname = 
kzalloc(PINMUX_MAX_NAME, GFP_KERNEL);
f878efc17642ce Drew Fustini  2021-02-10  698    if (!fname) {
f878efc17642ce Drew Fustini  2021-02-10  699            ret = -ENOMEM;
f878efc17642ce Drew Fustini  2021-02-10  700            goto free_buf;
f878efc17642ce Drew Fustini  2021-02-10  701    }
f878efc17642ce Drew Fustini  2021-02-10  702  
f878efc17642ce Drew Fustini  2021-02-10  703    gname = 
kzalloc(PINMUX_MAX_NAME, GFP_KERNEL);
f878efc17642ce Drew Fustini  2021-02-10  704    if (!buf) {
f878efc17642ce Drew Fustini  2021-02-10  705            ret = -ENOMEM;
f878efc17642ce Drew Fustini  2021-02-10  706            goto free_fname;
f878efc17642ce Drew Fustini  2021-02-10  707    }
f878efc17642ce Drew Fustini  2021-02-10  708  
f878efc17642ce Drew Fustini  2021-02-10  709    ret = strncpy_from_user(buf, 
user_buf, PINMUX_MAX_NAME * 2);
f878efc17642ce Drew Fustini  2021-02-10  710    if (ret < 0) {
f878efc17642ce Drew Fustini  2021-02-10  711            dev_err(pctldev->dev, 
"failed to copy buffer from userspace");
f878efc17642ce Drew Fustini  2021-02-10  712            goto free_gname;
f878efc17642ce Drew Fustini  2021-02-10  713    }
f878efc17642ce Drew Fustini  2021-02-10  714    buf[len-1] = '\0';
f878efc17642ce Drew Fustini  2021-02-10  715  
f878efc17642ce Drew Fustini  2021-02-10  716    ret = sscanf(buf, "%s %s", 
fname, gname);
f878efc17642ce Drew Fustini  2021-02-10  717    if (ret != 2) {
f878efc17642ce Drew Fustini  2021-02-10  718            dev_err(pctldev->dev, 
"expected format: <function-name> <group-name>");
f878efc17642ce Drew Fustini  2021-02-10  719            goto free_gname;
f878efc17642ce Drew Fustini  2021-02-10  720    }
f878efc17642ce Drew Fustini  2021-02-10  721  
f878efc17642ce Drew Fustini  2021-02-10  722    fsel = 
pinmux_func_name_to_selector(pctldev, fname);
f878efc17642ce Drew Fustini  2021-02-10  723    if (fsel < 0) {
f878efc17642ce Drew Fustini  2021-02-10  724            dev_err(pctldev->dev, 
"invalid function %s in map table\n", fname);
f878efc17642ce Drew Fustini  2021-02-10  725            ret = -EINVAL;
f878efc17642ce Drew Fustini  2021-02-10  726            goto free_gname;
f878efc17642ce Drew Fustini  2021-02-10  727    }
f878efc17642ce Drew Fustini  2021-02-10  728  
f878efc17642ce Drew Fustini  2021-02-10  729    ret = 
pmxops->get_function_groups(pctldev, fsel, &groups, &num_groups);
f878efc17642ce Drew Fustini  2021-02-10  730    if (ret) {
f878efc17642ce Drew Fustini  2021-02-10  731            dev_err(pctldev->dev, 
"no groups for function %d (%s)", fsel, fname);
f878efc17642ce Drew Fustini  2021-02-10  732            goto free_gname;
f878efc17642ce Drew Fustini  2021-02-10  733  
f878efc17642ce Drew Fustini  2021-02-10  734    }
f878efc17642ce Drew Fustini  2021-02-10  735  
f878efc17642ce Drew Fustini  2021-02-10  736    ret = match_string(groups, 
num_groups, gname);
f878efc17642ce Drew Fustini  2021-02-10  737    if (ret < 0) {
f878efc17642ce Drew Fustini  2021-02-10  738            dev_err(pctldev->dev, 
"invalid group %s", gname);
f878efc17642ce Drew Fustini  2021-02-10  739            goto free_gname;
f878efc17642ce Drew Fustini  2021-02-10  740    }
f878efc17642ce Drew Fustini  2021-02-10  741  
f878efc17642ce Drew Fustini  2021-02-10  742    ret = 
pinctrl_get_group_selector(pctldev, gname);
f878efc17642ce Drew Fustini  2021-02-10  743    if (ret < 0) {
f878efc17642ce Drew Fustini  2021-02-10  744            dev_err(pctldev->dev, 
"failed to get group selectorL %s", gname);
f878efc17642ce Drew Fustini  2021-02-10  745            goto free_gname;
f878efc17642ce Drew Fustini  2021-02-10  746    }
f878efc17642ce Drew Fustini  2021-02-10  747    gsel = ret;
f878efc17642ce Drew Fustini  2021-02-10  748  
f878efc17642ce Drew Fustini  2021-02-10  749    ret = pmxops->set_mux(pctldev, 
fsel, gsel);
f878efc17642ce Drew Fustini  2021-02-10  750    if (ret) {
f878efc17642ce Drew Fustini  2021-02-10  751            dev_err(pctldev->dev, 
"set_mux() failed: %d", ret);
f878efc17642ce Drew Fustini  2021-02-10  752            goto free_gname;
f878efc17642ce Drew Fustini  2021-02-10  753    }
f878efc17642ce Drew Fustini  2021-02-10  754  
f878efc17642ce Drew Fustini  2021-02-10  755    return len;
f878efc17642ce Drew Fustini  2021-02-10  756  
f878efc17642ce Drew Fustini  2021-02-10  757  free_gname:
f878efc17642ce Drew Fustini  2021-02-10  758    devm_kfree(pctldev->dev, gname);
f878efc17642ce Drew Fustini  2021-02-10  759  free_fname:
f878efc17642ce Drew Fustini  2021-02-10  760    devm_kfree(pctldev->dev, fname);
f878efc17642ce Drew Fustini  2021-02-10  761  free_buf:
f878efc17642ce Drew Fustini  2021-02-10  762    devm_kfree(pctldev->dev, buf);
f878efc17642ce Drew Fustini  2021-02-10  763  
f878efc17642ce Drew Fustini  2021-02-10 @764    return ret;
f878efc17642ce Drew Fustini  2021-02-10  765  }
f878efc17642ce Drew Fustini  2021-02-10  766  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-le...@lists.01.org

Reply via email to