linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl:sunplus: Add check for kmalloc
@ 2023-05-23 10:11 Wells Lu
  2023-05-23 16:42 ` andy.shevchenko
  0 siblings, 1 reply; 12+ messages in thread
From: Wells Lu @ 2023-05-23 10:11 UTC (permalink / raw)
  To: linus.walleij, linux-gpio, linux-kernel; +Cc: wells.lu, Wells Lu

Fix Smatch static checker warning:
potential null dereference 'configs'. (kmalloc returns null)

Fixes: aa74c44be19c ("pinctrl: Add driver for Sunplus SP7021")
Signed-off-by: Wells Lu <wellslutw@gmail.com>
---
 drivers/pinctrl/sunplus/sppctl.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/pinctrl/sunplus/sppctl.c b/drivers/pinctrl/sunplus/sppctl.c
index 6bbbab3a6..f2dcc68ee 100644
--- a/drivers/pinctrl/sunplus/sppctl.c
+++ b/drivers/pinctrl/sunplus/sppctl.c
@@ -883,6 +883,8 @@ static int sppctl_dt_node_to_map(struct pinctrl_dev *pctldev, struct device_node
 			(*map)[i].data.configs.num_configs = 1;
 			(*map)[i].data.configs.group_or_pin = pin_get_name(pctldev, pin_num);
 			configs = kmalloc(sizeof(*configs), GFP_KERNEL);
+			if (!configs)
+				return -ENOMEM;
 			*configs = FIELD_GET(GENMASK(7, 0), dt_pin);
 			(*map)[i].data.configs.configs = configs;
 
@@ -896,6 +898,8 @@ static int sppctl_dt_node_to_map(struct pinctrl_dev *pctldev, struct device_node
 			(*map)[i].data.configs.num_configs = 1;
 			(*map)[i].data.configs.group_or_pin = pin_get_name(pctldev, pin_num);
 			configs = kmalloc(sizeof(*configs), GFP_KERNEL);
+			if (!configs)
+				return -ENOMEM;
 			*configs = SPPCTL_IOP_CONFIGS;
 			(*map)[i].data.configs.configs = configs;
 
-- 
2.25.1


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

end of thread, other threads:[~2023-05-26  5:19 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-23 10:11 [PATCH] pinctrl:sunplus: Add check for kmalloc Wells Lu
2023-05-23 16:42 ` andy.shevchenko
2023-05-23 17:39   ` Wells Lu 呂芳騰
2023-05-23 19:37     ` andy.shevchenko
2023-05-23 20:05       ` Christophe JAILLET
2023-05-25  3:22         ` Wells Lu 呂芳騰
2023-05-25 18:37           ` Christophe JAILLET
2023-05-25 19:42             ` Dan Carpenter
2023-05-26  2:04             ` Wells Lu 呂芳騰
2023-05-26  5:19               ` Christophe JAILLET
2023-05-25 19:19         ` Dan Carpenter
2023-05-25 20:00           ` Christophe JAILLET

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).