* [PATCH] Bluetooth: add a check for kmalloc() failure
@ 2017-05-02 9:29 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2017-05-02 9:29 UTC (permalink / raw)
To: Marcel Holtmann, Salvatore Benedetto
Cc: Gustavo Padovan, Johan Hedberg, David S. Miller, linux-bluetooth,
kernel-janitors
We should check to see if this kmalloc() fails.
Fixes: e7c404c96c74 ("Bluetooth: allocate data for kpp on heap")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/net/bluetooth/ecdh_helper.c b/net/bluetooth/ecdh_helper.c
index 80184476ff74..c8535845813d 100644
--- a/net/bluetooth/ecdh_helper.c
+++ b/net/bluetooth/ecdh_helper.c
@@ -59,11 +59,15 @@ bool compute_ecdh_secret(const u8 public_key[64], const u8 private_key[32],
struct ecdh p;
struct ecdh_completion result;
struct scatterlist src, dst;
- u8 *tmp = kmalloc(64, GFP_KERNEL);
+ u8 *tmp;
u8 *buf;
unsigned int buf_len;
int err = -ENOMEM;
+ tmp = kmalloc(64, GFP_KERNEL);
+ if (!tmp)
+ goto out;
+
tfm = crypto_alloc_kpp("ecdh", CRYPTO_ALG_INTERNAL, 0);
if (IS_ERR(tfm)) {
pr_err("alg: kpp: Failed to load tfm for kpp: %ld\n",
@@ -130,6 +134,7 @@ bool compute_ecdh_secret(const u8 public_key[64], const u8 private_key[32],
crypto_free_kpp(tfm);
free_tmp:
kfree(tmp);
+out:
return (err == 0);
}
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] Bluetooth: add a check for kmalloc() failure
@ 2017-05-02 9:29 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2017-05-02 9:29 UTC (permalink / raw)
To: Marcel Holtmann, Salvatore Benedetto
Cc: Gustavo Padovan, Johan Hedberg, David S. Miller, linux-bluetooth,
kernel-janitors
We should check to see if this kmalloc() fails.
Fixes: e7c404c96c74 ("Bluetooth: allocate data for kpp on heap")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/net/bluetooth/ecdh_helper.c b/net/bluetooth/ecdh_helper.c
index 80184476ff74..c8535845813d 100644
--- a/net/bluetooth/ecdh_helper.c
+++ b/net/bluetooth/ecdh_helper.c
@@ -59,11 +59,15 @@ bool compute_ecdh_secret(const u8 public_key[64], const u8 private_key[32],
struct ecdh p;
struct ecdh_completion result;
struct scatterlist src, dst;
- u8 *tmp = kmalloc(64, GFP_KERNEL);
+ u8 *tmp;
u8 *buf;
unsigned int buf_len;
int err = -ENOMEM;
+ tmp = kmalloc(64, GFP_KERNEL);
+ if (!tmp)
+ goto out;
+
tfm = crypto_alloc_kpp("ecdh", CRYPTO_ALG_INTERNAL, 0);
if (IS_ERR(tfm)) {
pr_err("alg: kpp: Failed to load tfm for kpp: %ld\n",
@@ -130,6 +134,7 @@ bool compute_ecdh_secret(const u8 public_key[64], const u8 private_key[32],
crypto_free_kpp(tfm);
free_tmp:
kfree(tmp);
+out:
return (err = 0);
}
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Bluetooth: add a check for kmalloc() failure
2017-05-02 9:29 ` Dan Carpenter
@ 2017-05-02 17:58 ` Marcel Holtmann
-1 siblings, 0 replies; 6+ messages in thread
From: Marcel Holtmann @ 2017-05-02 17:58 UTC (permalink / raw)
To: Dan Carpenter
Cc: Salvatore Benedetto, Gustavo F. Padovan, Johan Hedberg,
David S. Miller, Linux Bluetooth, kernel-janitors
Hi Dan,
> We should check to see if this kmalloc() fails.
>
> Fixes: e7c404c96c74 ("Bluetooth: allocate data for kpp on heap")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/net/bluetooth/ecdh_helper.c b/net/bluetooth/ecdh_helper.c
> index 80184476ff74..c8535845813d 100644
> --- a/net/bluetooth/ecdh_helper.c
> +++ b/net/bluetooth/ecdh_helper.c
> @@ -59,11 +59,15 @@ bool compute_ecdh_secret(const u8 public_key[64], const u8 private_key[32],
> struct ecdh p;
> struct ecdh_completion result;
> struct scatterlist src, dst;
> - u8 *tmp = kmalloc(64, GFP_KERNEL);
> + u8 *tmp;
> u8 *buf;
> unsigned int buf_len;
> int err = -ENOMEM;
>
> + tmp = kmalloc(64, GFP_KERNEL);
> + if (!tmp)
> + goto out;
> +
I thought that I already fixed this. Is this issue still present in bluetooth-next tree?
Regards
Marcel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Bluetooth: add a check for kmalloc() failure
@ 2017-05-02 17:58 ` Marcel Holtmann
0 siblings, 0 replies; 6+ messages in thread
From: Marcel Holtmann @ 2017-05-02 17:58 UTC (permalink / raw)
To: Dan Carpenter
Cc: Salvatore Benedetto, Gustavo F. Padovan, Johan Hedberg,
David S. Miller, Linux Bluetooth, kernel-janitors
Hi Dan,
> We should check to see if this kmalloc() fails.
>
> Fixes: e7c404c96c74 ("Bluetooth: allocate data for kpp on heap")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/net/bluetooth/ecdh_helper.c b/net/bluetooth/ecdh_helper.c
> index 80184476ff74..c8535845813d 100644
> --- a/net/bluetooth/ecdh_helper.c
> +++ b/net/bluetooth/ecdh_helper.c
> @@ -59,11 +59,15 @@ bool compute_ecdh_secret(const u8 public_key[64], const u8 private_key[32],
> struct ecdh p;
> struct ecdh_completion result;
> struct scatterlist src, dst;
> - u8 *tmp = kmalloc(64, GFP_KERNEL);
> + u8 *tmp;
> u8 *buf;
> unsigned int buf_len;
> int err = -ENOMEM;
>
> + tmp = kmalloc(64, GFP_KERNEL);
> + if (!tmp)
> + goto out;
> +
I thought that I already fixed this. Is this issue still present in bluetooth-next tree?
Regards
Marcel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Bluetooth: add a check for kmalloc() failure
2017-05-02 17:58 ` Marcel Holtmann
@ 2017-05-02 18:34 ` Dan Carpenter
-1 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2017-05-02 18:34 UTC (permalink / raw)
To: Marcel Holtmann
Cc: Salvatore Benedetto, Gustavo F. Padovan, Johan Hedberg,
David S. Miller, Linux Bluetooth, kernel-janitors
On Tue, May 02, 2017 at 07:58:11PM +0200, Marcel Holtmann wrote:
> Hi Dan,
>
> > We should check to see if this kmalloc() fails.
> >
> > Fixes: e7c404c96c74 ("Bluetooth: allocate data for kpp on heap")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> > diff --git a/net/bluetooth/ecdh_helper.c b/net/bluetooth/ecdh_helper.c
> > index 80184476ff74..c8535845813d 100644
> > --- a/net/bluetooth/ecdh_helper.c
> > +++ b/net/bluetooth/ecdh_helper.c
> > @@ -59,11 +59,15 @@ bool compute_ecdh_secret(const u8 public_key[64], const u8 private_key[32],
> > struct ecdh p;
> > struct ecdh_completion result;
> > struct scatterlist src, dst;
> > - u8 *tmp = kmalloc(64, GFP_KERNEL);
> > + u8 *tmp;
> > u8 *buf;
> > unsigned int buf_len;
> > int err = -ENOMEM;
> >
> > + tmp = kmalloc(64, GFP_KERNEL);
> > + if (!tmp)
> > + goto out;
> > +
>
> I thought that I already fixed this. Is this issue still present in bluetooth-next tree?
>
Ah yeah. You already fixed this.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Bluetooth: add a check for kmalloc() failure
@ 2017-05-02 18:34 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2017-05-02 18:34 UTC (permalink / raw)
To: Marcel Holtmann
Cc: Salvatore Benedetto, Gustavo F. Padovan, Johan Hedberg,
David S. Miller, Linux Bluetooth, kernel-janitors
On Tue, May 02, 2017 at 07:58:11PM +0200, Marcel Holtmann wrote:
> Hi Dan,
>
> > We should check to see if this kmalloc() fails.
> >
> > Fixes: e7c404c96c74 ("Bluetooth: allocate data for kpp on heap")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> > diff --git a/net/bluetooth/ecdh_helper.c b/net/bluetooth/ecdh_helper.c
> > index 80184476ff74..c8535845813d 100644
> > --- a/net/bluetooth/ecdh_helper.c
> > +++ b/net/bluetooth/ecdh_helper.c
> > @@ -59,11 +59,15 @@ bool compute_ecdh_secret(const u8 public_key[64], const u8 private_key[32],
> > struct ecdh p;
> > struct ecdh_completion result;
> > struct scatterlist src, dst;
> > - u8 *tmp = kmalloc(64, GFP_KERNEL);
> > + u8 *tmp;
> > u8 *buf;
> > unsigned int buf_len;
> > int err = -ENOMEM;
> >
> > + tmp = kmalloc(64, GFP_KERNEL);
> > + if (!tmp)
> > + goto out;
> > +
>
> I thought that I already fixed this. Is this issue still present in bluetooth-next tree?
>
Ah yeah. You already fixed this.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-05-02 18:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-02 9:29 [PATCH] Bluetooth: add a check for kmalloc() failure Dan Carpenter
2017-05-02 9:29 ` Dan Carpenter
2017-05-02 17:58 ` Marcel Holtmann
2017-05-02 17:58 ` Marcel Holtmann
2017-05-02 18:34 ` Dan Carpenter
2017-05-02 18:34 ` Dan Carpenter
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.