All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] HID: nvidia-shield: Add some null pointer checks to the hid-nvidia-shield.c
@ 2024-01-19  6:07 Kunwu Chan
  2024-01-19  6:19 ` Rahul Rameshbabu
  0 siblings, 1 reply; 3+ messages in thread
From: Kunwu Chan @ 2024-01-19  6:07 UTC (permalink / raw)
  To: rrameshbabu, jikos, benjamin.tissoires
  Cc: linux-input, linux-kernel, Kunwu Chan

devm_kasprintf() returns a pointer to dynamically allocated memory
which can be NULL upon failure. Ensure the allocation was successful
by checking the pointer validity.

Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
---
 drivers/hid/hid-nvidia-shield.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/hid/hid-nvidia-shield.c b/drivers/hid/hid-nvidia-shield.c
index 82d0a77359c4..58b15750dbb0 100644
--- a/drivers/hid/hid-nvidia-shield.c
+++ b/drivers/hid/hid-nvidia-shield.c
@@ -800,6 +800,8 @@ static inline int thunderstrike_led_create(struct thunderstrike *ts)
 
 	led->name = devm_kasprintf(&ts->base.hdev->dev, GFP_KERNEL,
 				   "thunderstrike%d:blue:led", ts->id);
+	if (!led->name)
+		return -ENOMEM;
 	led->max_brightness = 1;
 	led->flags = LED_CORE_SUSPENDRESUME | LED_RETAIN_AT_SHUTDOWN;
 	led->brightness_get = &thunderstrike_led_get_brightness;
@@ -831,6 +833,8 @@ static inline int thunderstrike_psy_create(struct shield_device *shield_dev)
 	shield_dev->battery_dev.desc.name =
 		devm_kasprintf(&ts->base.hdev->dev, GFP_KERNEL,
 			       "thunderstrike_%d", ts->id);
+	if (!shield_dev->battery_dev.desc.name)
+		return -ENOMEM;
 
 	shield_dev->battery_dev.psy = power_supply_register(
 		&hdev->dev, &shield_dev->battery_dev.desc, &psy_cfg);
-- 
2.39.2


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

* Re: [PATCH] HID: nvidia-shield: Add some null pointer checks to the hid-nvidia-shield.c
  2024-01-19  6:07 [PATCH] HID: nvidia-shield: Add some null pointer checks to the hid-nvidia-shield.c Kunwu Chan
@ 2024-01-19  6:19 ` Rahul Rameshbabu
  2024-01-23 10:23   ` Jiri Kosina
  0 siblings, 1 reply; 3+ messages in thread
From: Rahul Rameshbabu @ 2024-01-19  6:19 UTC (permalink / raw)
  To: Kunwu Chan; +Cc: jikos, benjamin.tissoires, linux-input, linux-kernel

On Fri, 19 Jan, 2024 14:07:14 +0800 Kunwu Chan <chentao@kylinos.cn> wrote:
> devm_kasprintf() returns a pointer to dynamically allocated memory
> which can be NULL upon failure. Ensure the allocation was successful
> by checking the pointer validity.
>
> Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
> ---

Just one comment about the subject for future submissions (this one is
fine). I would just leave the subject as "HID: nvidia-shield: Add some
null pointer checks". We know what file is being edited from the commit
content, so the additional filename detail isn't necessary.

Thanks for the patch. Really appreciate it.

Reviewed-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>

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

* Re: [PATCH] HID: nvidia-shield: Add some null pointer checks to the hid-nvidia-shield.c
  2024-01-19  6:19 ` Rahul Rameshbabu
@ 2024-01-23 10:23   ` Jiri Kosina
  0 siblings, 0 replies; 3+ messages in thread
From: Jiri Kosina @ 2024-01-23 10:23 UTC (permalink / raw)
  To: Rahul Rameshbabu
  Cc: Kunwu Chan, benjamin.tissoires, linux-input, linux-kernel

On Thu, 18 Jan 2024, Rahul Rameshbabu wrote:

> > devm_kasprintf() returns a pointer to dynamically allocated memory
> > which can be NULL upon failure. Ensure the allocation was successful
> > by checking the pointer validity.
> >
> > Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
> > ---
> 
> Just one comment about the subject for future submissions (this one is
> fine). I would just leave the subject as "HID: nvidia-shield: Add some
> null pointer checks". We know what file is being edited from the commit
> content, so the additional filename detail isn't necessary.
> 
> Thanks for the patch. Really appreciate it.
> 
> Reviewed-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>

I have tweaked the changelog a little bit and applied, thanks.

-- 
Jiri Kosina
SUSE Labs


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

end of thread, other threads:[~2024-01-23 10:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-19  6:07 [PATCH] HID: nvidia-shield: Add some null pointer checks to the hid-nvidia-shield.c Kunwu Chan
2024-01-19  6:19 ` Rahul Rameshbabu
2024-01-23 10:23   ` Jiri Kosina

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.