* [PATCH] Bluetooth: btrtl: Fix a error code in rtl_load_config()
@ 2017-07-28 14:41 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2017-07-28 14:41 UTC (permalink / raw)
To: Marcel Holtmann, Larry Finger
Cc: Gustavo Padovan, Johan Hedberg, linux-bluetooth, kernel-janitors
We accidentally return success if the kmemdup() fails. It results in
a NULL dereference in the caller.
Fixes: 1110a2dbe698 ("Bluetooth: btrtl: Add RTL8822BE Bluetooth device")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
index 8279094dd713..d9a99b4302ea 100644
--- a/drivers/bluetooth/btrtl.c
+++ b/drivers/bluetooth/btrtl.c
@@ -279,6 +279,8 @@ static int rtl_load_config(struct hci_dev *hdev, const char *name, u8 **buff)
return ret;
ret = fw->size;
*buff = kmemdup(fw->data, ret, GFP_KERNEL);
+ if (!*buff)
+ ret = -ENOMEM;
release_firmware(fw);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] Bluetooth: btrtl: Fix a error code in rtl_load_config()
@ 2017-07-28 14:41 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2017-07-28 14:41 UTC (permalink / raw)
To: Marcel Holtmann, Larry Finger
Cc: Gustavo Padovan, Johan Hedberg, linux-bluetooth, kernel-janitors
We accidentally return success if the kmemdup() fails. It results in
a NULL dereference in the caller.
Fixes: 1110a2dbe698 ("Bluetooth: btrtl: Add RTL8822BE Bluetooth device")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
index 8279094dd713..d9a99b4302ea 100644
--- a/drivers/bluetooth/btrtl.c
+++ b/drivers/bluetooth/btrtl.c
@@ -279,6 +279,8 @@ static int rtl_load_config(struct hci_dev *hdev, const char *name, u8 **buff)
return ret;
ret = fw->size;
*buff = kmemdup(fw->data, ret, GFP_KERNEL);
+ if (!*buff)
+ ret = -ENOMEM;
release_firmware(fw);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Bluetooth: btrtl: Fix a error code in rtl_load_config()
2017-07-28 14:41 ` Dan Carpenter
@ 2017-07-28 16:31 ` Johan Hedberg
-1 siblings, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2017-07-28 16:31 UTC (permalink / raw)
To: Dan Carpenter
Cc: Marcel Holtmann, Larry Finger, Gustavo Padovan, linux-bluetooth,
kernel-janitors
Hi Dan,
On Fri, Jul 28, 2017, Dan Carpenter wrote:
> We accidentally return success if the kmemdup() fails. It results in
> a NULL dereference in the caller.
>
> Fixes: 1110a2dbe698 ("Bluetooth: btrtl: Add RTL8822BE Bluetooth device")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Bluetooth: btrtl: Fix a error code in rtl_load_config()
@ 2017-07-28 16:31 ` Johan Hedberg
0 siblings, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2017-07-28 16:31 UTC (permalink / raw)
To: Dan Carpenter
Cc: Marcel Holtmann, Larry Finger, Gustavo Padovan, linux-bluetooth,
kernel-janitors
Hi Dan,
On Fri, Jul 28, 2017, Dan Carpenter wrote:
> We accidentally return success if the kmemdup() fails. It results in
> a NULL dereference in the caller.
>
> Fixes: 1110a2dbe698 ("Bluetooth: btrtl: Add RTL8822BE Bluetooth device")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-07-28 16:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-28 14:41 [PATCH] Bluetooth: btrtl: Fix a error code in rtl_load_config() Dan Carpenter
2017-07-28 14:41 ` Dan Carpenter
2017-07-28 16:31 ` Johan Hedberg
2017-07-28 16:31 ` 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.