Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bb95cd34 authored by Kiran Padwal's avatar Kiran Padwal Committed by Peter Huewe
Browse files

char: tpm: Add missing error check for devm_kzalloc



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

Cc: stable@vger.kernel.org
Signed-off-by: default avatarKiran Padwal <kiran.padwal@smartplayin.com>
Reviewed-By: default avatarJason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: default avatarPeter Huewe <peterhuewe@gmx.de>
parent 398a1e71
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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);
+5 −0
Original line number Diff line number Diff line
@@ -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);