]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/kernel-video.git/commitdiff
char: tpm: Add missing error check for devm_kzalloc
authorKiran Padwal <kiran.padwal@smartplayin.com>
Fri, 19 Sep 2014 07:14:39 +0000 (12:44 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Mar 2015 22:43:29 +0000 (14:43 -0800)
commit bb95cd34ba4c9467114acc78eeddd53ab1c10085 upstream.

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>
Reviewed-By: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/tpm/tpm_i2c_atmel.c
drivers/char/tpm/tpm_i2c_nuvoton.c

index 77272925dee6dd1f13679acbdacc5dd8d8f73ac9..503a85ae176cdc74c14b5631a7c918f3fa62e0e3 100644 (file)
@@ -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);
index 7b158efd49f7ad5599d96caa025921eb60e22510..23c7b137a7fdb47584b98429bc54f8e5c732d5dd 100644 (file)
@@ -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);