linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk/ti/adpll: Add a NULL check for devm_kasprintf()
@ 2020-05-18  3:46 Xu Wang
  2020-05-18  3:55 ` Joe Perches
  2020-05-27 12:20 ` kbuild test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Xu Wang @ 2020-05-18  3:46 UTC (permalink / raw)
  To: t-kristo, mturquette, sboyd, linux-omap, linux-clk; +Cc: linux-kernel

devm_kasprintf() may fail, so we should better add a NULL check
and propagate an error on failure.

Signed-off-by: Xu Wang <vulab@iscas.ac.cn>
---
 drivers/clk/ti/adpll.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/clk/ti/adpll.c b/drivers/clk/ti/adpll.c
index bb2f283..f18a672 100644
--- a/drivers/clk/ti/adpll.c
+++ b/drivers/clk/ti/adpll.c
@@ -196,6 +196,8 @@ static const char *ti_adpll_clk_get_name(struct ti_adpll_data *d,
 	} else {
 		name = devm_kasprintf(d->dev, GFP_KERNEL, "%08lx.adpll.%s",
 				      d->pa, postfix);
+		if (!name)
+			return -ENOMEM;
 	}
 
 	return name;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] clk/ti/adpll: Add a NULL check for devm_kasprintf()
  2020-05-18  3:46 [PATCH] clk/ti/adpll: Add a NULL check for devm_kasprintf() Xu Wang
@ 2020-05-18  3:55 ` Joe Perches
  2020-05-27 12:20 ` kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: Joe Perches @ 2020-05-18  3:55 UTC (permalink / raw)
  To: Xu Wang, t-kristo, mturquette, sboyd, linux-omap, linux-clk; +Cc: linux-kernel

On Mon, 2020-05-18 at 03:46 +0000, Xu Wang wrote:
> devm_kasprintf() may fail, so we should better add a NULL check
> and propagate an error on failure.

You didn't compile this.

All the return values of this function are already checked.

> Signed-off-by: Xu Wang <vulab@iscas.ac.cn>
> ---
>  drivers/clk/ti/adpll.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/clk/ti/adpll.c b/drivers/clk/ti/adpll.c
> index bb2f283..f18a672 100644
> --- a/drivers/clk/ti/adpll.c
> +++ b/drivers/clk/ti/adpll.c
> @@ -196,6 +196,8 @@ static const char *ti_adpll_clk_get_name(struct ti_adpll_data *d,
>  	} else {
>  		name = devm_kasprintf(d->dev, GFP_KERNEL, "%08lx.adpll.%s",
>  				      d->pa, postfix);
> +		if (!name)
> +			return -ENOMEM;
>  	}
>  
>  	return name;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] clk/ti/adpll: Add a NULL check for devm_kasprintf()
  2020-05-18  3:46 [PATCH] clk/ti/adpll: Add a NULL check for devm_kasprintf() Xu Wang
  2020-05-18  3:55 ` Joe Perches
@ 2020-05-27 12:20 ` kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2020-05-27 12:20 UTC (permalink / raw)
  To: Xu Wang, t-kristo, mturquette, sboyd, linux-omap, linux-clk
  Cc: kbuild-all, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2161 bytes --]

Hi Xu,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on clk/clk-next]
[also build test WARNING on v5.7-rc7 next-20200526]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Xu-Wang/clk-ti-adpll-Add-a-NULL-check-for-devm_kasprintf/20200518-114748
base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
config: x86_64-randconfig-s021-20200527 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-13) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.1-240-gf0fe1cd9-dirty
        # save the attached .config to linux build tree
        make W=1 C=1 ARCH=x86_64 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)

>> drivers/clk/ti/adpll.c:200:32: sparse: sparse: incorrect type in return expression (different base types) @@     expected char const * @@     got int @@
   drivers/clk/ti/adpll.c:200:32: sparse:     expected char const *
   drivers/clk/ti/adpll.c:200:32: sparse:     got int

vim +200 drivers/clk/ti/adpll.c

   181	
   182	static const char *ti_adpll_clk_get_name(struct ti_adpll_data *d,
   183						 int output_index,
   184						 const char *postfix)
   185	{
   186		const char *name;
   187		int err;
   188	
   189		if (output_index >= 0) {
   190			err = of_property_read_string_index(d->np,
   191							    "clock-output-names",
   192							    output_index,
   193							    &name);
   194			if (err)
   195				return NULL;
   196		} else {
   197			name = devm_kasprintf(d->dev, GFP_KERNEL, "%08lx.adpll.%s",
   198					      d->pa, postfix);
   199			if (!name)
 > 200				return -ENOMEM;
   201		}
   202	
   203		return name;
   204	}
   205	

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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 41590 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-27 12:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-18  3:46 [PATCH] clk/ti/adpll: Add a NULL check for devm_kasprintf() Xu Wang
2020-05-18  3:55 ` Joe Perches
2020-05-27 12:20 ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).