* [PATCH] char: tpm: Add missing error check for devm_kzalloc
@ 2014-09-19 7:14 Kiran Padwal
2014-09-24 16:22 ` [tpmdd-devel] " Jason Gunthorpe
2014-12-02 20:51 ` Peter Hüwe
0 siblings, 2 replies; 3+ messages in thread
From: Kiran Padwal @ 2014-09-19 7:14 UTC (permalink / raw
To: peterhuewe, ashley, tpmdd
Cc: tpmdd-devel, linux-kernel, kiran.padwal21, Kiran Padwal
Currently these driver are missing a check on the return value of devm_kzalloc,
which would cause a NULL pointer dereference in a OOM situation.
This patch adds a missing check for tpm_i2c_atmel.c and tpm_i2c_nuvoton.c
Signed-off-by: Kiran Padwal <kiran.padwal@smartplayin.com>
---
drivers/char/tpm/tpm_i2c_atmel.c | 4 ++++
drivers/char/tpm/tpm_i2c_nuvoton.c | 5 +++++
2 files changed, 9 insertions(+)
diff --git a/drivers/char/tpm/tpm_i2c_atmel.c b/drivers/char/tpm/tpm_i2c_atmel.c
index 7727292..503a85a 100644
--- a/drivers/char/tpm/tpm_i2c_atmel.c
+++ b/drivers/char/tpm/tpm_i2c_atmel.c
@@ -168,6 +168,10 @@ static int i2c_atmel_probe(struct i2c_client *client,
chip->vendor.priv = devm_kzalloc(dev, sizeof(struct priv_data),
GFP_KERNEL);
+ if (!chip->vendor.priv) {
+ rc = -ENOMEM;
+ goto out_err;
+ }
/* Default timeouts */
chip->vendor.timeout_a = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c
index 7b158ef..23c7b13 100644
--- a/drivers/char/tpm/tpm_i2c_nuvoton.c
+++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
@@ -538,6 +538,11 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
chip->vendor.priv = devm_kzalloc(dev, sizeof(struct priv_data),
GFP_KERNEL);
+ if (!chip->vendor.priv) {
+ rc = -ENOMEM;
+ goto out_err;
+ }
+
init_waitqueue_head(&chip->vendor.read_queue);
init_waitqueue_head(&chip->vendor.int_queue);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [tpmdd-devel] [PATCH] char: tpm: Add missing error check for devm_kzalloc
2014-09-19 7:14 [PATCH] char: tpm: Add missing error check for devm_kzalloc Kiran Padwal
@ 2014-09-24 16:22 ` Jason Gunthorpe
2014-12-02 20:51 ` Peter Hüwe
1 sibling, 0 replies; 3+ messages in thread
From: Jason Gunthorpe @ 2014-09-24 16:22 UTC (permalink / raw
To: Kiran Padwal
Cc: peterhuewe, ashley, tpmdd, kiran.padwal21, tpmdd-devel,
linux-kernel
On Fri, Sep 19, 2014 at 12:44:39PM +0530, Kiran Padwal wrote:
> Currently these driver are missing a check on the return value of devm_kzalloc,
> which would cause a NULL pointer dereference in a OOM situation.
>
> This patch adds a missing check for tpm_i2c_atmel.c and tpm_i2c_nuvoton.c
Yes, my bad, thank you:
Reviewed-By: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
> Signed-off-by: Kiran Padwal <kiran.padwal@smartplayin.com>
> drivers/char/tpm/tpm_i2c_atmel.c | 4 ++++
> drivers/char/tpm/tpm_i2c_nuvoton.c | 5 +++++
> 2 files changed, 9 insertions(+)
>
> diff --git a/drivers/char/tpm/tpm_i2c_atmel.c b/drivers/char/tpm/tpm_i2c_atmel.c
> index 7727292..503a85a 100644
> +++ b/drivers/char/tpm/tpm_i2c_atmel.c
> @@ -168,6 +168,10 @@ static int i2c_atmel_probe(struct i2c_client *client,
>
> chip->vendor.priv = devm_kzalloc(dev, sizeof(struct priv_data),
> GFP_KERNEL);
> + if (!chip->vendor.priv) {
> + rc = -ENOMEM;
> + goto out_err;
> + }
>
> /* Default timeouts */
> chip->vendor.timeout_a = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
> diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c
> index 7b158ef..23c7b13 100644
> +++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
> @@ -538,6 +538,11 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
>
> chip->vendor.priv = devm_kzalloc(dev, sizeof(struct priv_data),
> GFP_KERNEL);
> + if (!chip->vendor.priv) {
> + rc = -ENOMEM;
> + goto out_err;
> + }
> +
> init_waitqueue_head(&chip->vendor.read_queue);
> init_waitqueue_head(&chip->vendor.int_queue);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] char: tpm: Add missing error check for devm_kzalloc
2014-09-19 7:14 [PATCH] char: tpm: Add missing error check for devm_kzalloc Kiran Padwal
2014-09-24 16:22 ` [tpmdd-devel] " Jason Gunthorpe
@ 2014-12-02 20:51 ` Peter Hüwe
1 sibling, 0 replies; 3+ messages in thread
From: Peter Hüwe @ 2014-12-02 20:51 UTC (permalink / raw
To: Kiran Padwal; +Cc: ashley, tpmdd, tpmdd-devel, linux-kernel, kiran.padwal21
Am Freitag, 19. September 2014, 09:14:39 schrieb Kiran Padwal:
> Currently these driver are missing a check on the return value of
> devm_kzalloc, which would cause a NULL pointer dereference in a OOM
> situation.
>
> This patch adds a missing check for tpm_i2c_atmel.c and tpm_i2c_nuvoton.c
>
> Signed-off-by: Kiran Padwal <kiran.padwal@smartplayin.com>
Applied to my tree:
https://github.com/PeterHuewe/linux-tpmdd for-james
Will be included in the next pull-request.
Thanks,
Peter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-12-02 20:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-19 7:14 [PATCH] char: tpm: Add missing error check for devm_kzalloc Kiran Padwal
2014-09-24 16:22 ` [tpmdd-devel] " Jason Gunthorpe
2014-12-02 20:51 ` Peter Hüwe
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.