pinctrl: ralink: rt2880: Check for return value of devm_kcalloc()
Subsystems (2)
PATCH 1/1 pinctrl: ralink: rt2880: Check for return value of devm_kcalloc()
The memory allocation function devm_kcalloc() may return NULL pointer, so it is better to add a check for 'p->func[i]->pins' to avoid possible NULL pointer dereference.
--- drivers/pinctrl/ralink/pinctrl-rt2880.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/pinctrl/ralink/pinctrl-rt2880.c +4 -0
@@ -266,6 +266,10 @@ static int rt2880_pinmux_pins(struct rt2880_priv *p) p->func[i]->pin_count,sizeof (int ), GFP_KERNEL); + +if (!p->func[i]->pins) +continue ; +for (j =0 ; j < p->func[i]->pin_count; j++) p->func[i]->pins[j] = p->func[i]->pin_first + j;
Signature · 1 line
2.7.4
Quoted 27 lines · QintaoShen
The memory allocation function
devm_kcalloc()may return NULL pointer, so it is better to add a check for 'p->func[i]->pins' to avoid possible NULL pointer dereference.Signed-off-by QintaoShen <[email protected]>--- drivers/pinctrl/ralink/pinctrl-rt2880.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/pinctrl/ralink/pinctrl-rt2880.c +4
-0@@ -266,6 +266,10 @@ static int rt2880_pinmux_pins(struct rt2880_priv *p) p->func[i]->pin_count,sizeof (int ), GFP_KERNEL); + +if (!p->func[i]->pins) +continue ; +for (j =0 ; j < p->func[i]->pin_count; j++) p->func[i]->pins[j] = p->func[i]->pin_first + j;Signature · 1 line
2.7.4
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree.
You are receiving this message because of the following common error(s) as indicated below:
- Your patch contains warnings and/or errors noticed by the scripts/checkpatch.pl tool.
If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers.
thanks,
greg k-h's patch email bot
Quoted 2 lines · QintaoShen
The memory allocation function
devm_kcalloc()may return NULL pointer,
may --> might
Quoted 2 lines
so it is better to add a check for 'p->func[i]->pins' to avoid possible NULL pointer dereference.
...
drivers/pinctrl/ralink/pinctrl-rt2880.c static int rt2880_pinmux_pins(struct rt2880_priv *p) · line 270
Quoted 6 lines
drivers/pinctrl/ralink/pinctrl-rt2880.c +1
-0@@ -266,6 +266,10 @@ static int rt2880_pinmux_pins(struct rt2880_priv *p) p->func[i]->pin_count,sizeof (int ), GFP_KERNEL); +
Stray change. Also it seems it has trailing space character(s).
drivers/pinctrl/ralink/pinctrl-rt2880.c static int rt2880_pinmux_pins(struct rt2880_priv *p)
Quoted 3 lines
drivers/pinctrl/ralink/pinctrl-rt2880.c +2
-0+if (!p->func[i]->pins) +continue ;
Why is 'continue' the proper choice here? No clarification is given in the commit message.
Quoted 2 lines
drivers/pinctrl/ralink/pinctrl-rt2880.c +0
-0for (j =0 ; j < p->func[i]->pin_count; j++) p->func[i]->pins[j] = p->func[i]->pin_first + j;
Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 4 lines · unSimple
The main consideration of the 'continue' in the patch is that those statements are inner a loop.
The next allocation may be successful so I think it is better to use 'continue' here.
Please, do not top-post!
What you explained is logical from APIs point of view, what I was asking is about functional point of view.
Why do you think the skipping iteration is fine?
You need to explain this in the code/commit message.
Quoted 9 lines
Quoted 8 lines · Andy Shevchenko
Quoted 2 lines · QintaoShen
The memory allocation function
devm_kcalloc()may return NULL pointer,may --> might
Quoted 2 lines
so it is better to add a check for 'p->func[i]->pins' to avoid possible NULL pointer dereference.
...
Quoted 18 lines
Quoted 18 lines
drivers/pinctrl/ralink/pinctrl-rt2880.c static int rt2880_pinmux_pins(struct rt2880_priv *p) · line 270
Quoted 6 lines
drivers/pinctrl/ralink/pinctrl-rt2880.c +1
-0@@ -266,6 +266,10 @@ static int rt2880_pinmux_pins(struct rt2880_priv *p) p->func[i]->pin_count,sizeof (int ), GFP_KERNEL); +Stray change. Also it seems it has trailing space character(s).
drivers/pinctrl/ralink/pinctrl-rt2880.c static int rt2880_pinmux_pins(struct rt2880_priv *p)
Quoted 3 lines
drivers/pinctrl/ralink/pinctrl-rt2880.c +2
-0+if (!p->func[i]->pins) +continue ;Why is 'continue' the proper choice here? No clarification is given in the commit message.
Quoted 2 lines
drivers/pinctrl/ralink/pinctrl-rt2880.c +0
-0for (j =0 ; j < p->func[i]->pin_count; j++) p->func[i]->pins[j] = p->func[i]->pin_first + j;
Signature · 2 lines
With Best Regards, Andy Shevchenko