* [PATCH] input/hog: Fix crash if uhid is not enabled
@ 2016-04-01 19:58 Szymon Janc
2016-04-02 7:48 ` Johan Hedberg
0 siblings, 1 reply; 2+ messages in thread
From: Szymon Janc @ 2016-04-01 19:58 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
If /dev/uhid is not present bt_hog_new_default() returns NULL.
This was resulting in NULL pointer dereference in attio_connected_cb.
---
profiles/input/hog.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/profiles/input/hog.c b/profiles/input/hog.c
index 4dba83f..a934c62 100644
--- a/profiles/input/hog.c
+++ b/profiles/input/hog.c
@@ -107,8 +107,13 @@ static struct hog_device *hog_device_new(struct btd_device *device,
product, version);
dev = new0(struct hog_device, 1);
- dev->device = btd_device_ref(device);
dev->hog = bt_hog_new_default(name, vendor, product, version, prim);
+ if (!dev->hog) {
+ free(dev);
+ return NULL;
+ }
+
+ dev->device = btd_device_ref(device);
/*
* TODO: Remove attio callback and use .accept once using
@@ -189,6 +194,9 @@ static int hog_probe(struct btd_service *service)
continue;
dev = hog_device_new(device, prim);
+ if (!dev)
+ break;
+
btd_service_set_user_data(service, dev);
return 0;
}
--
2.6.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] input/hog: Fix crash if uhid is not enabled
2016-04-01 19:58 [PATCH] input/hog: Fix crash if uhid is not enabled Szymon Janc
@ 2016-04-02 7:48 ` Johan Hedberg
0 siblings, 0 replies; 2+ messages in thread
From: Johan Hedberg @ 2016-04-02 7:48 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth
Hi Szymon,
On Fri, Apr 01, 2016, Szymon Janc wrote:
> If /dev/uhid is not present bt_hog_new_default() returns NULL.
> This was resulting in NULL pointer dereference in attio_connected_cb.
> ---
> profiles/input/hog.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
Applied. Thanks.
Johan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-04-02 7:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-01 19:58 [PATCH] input/hog: Fix crash if uhid is not enabled Szymon Janc
2016-04-02 7:48 ` Johan Hedberg
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.