mfd: intel_soc_pmic: Add missing error check for devm_kzalloc
authorKiran Padwal <kiran.padwal@smartplayin.com>
Wed, 11 Feb 2015 10:10:50 +0000 (15:40 +0530)
committerLee Jones <lee.jones@linaro.org>
Mon, 16 Feb 2015 17:11:43 +0000 (17:11 +0000)
This patch add a missing check on the return value of devm_kzalloc,
which would cause a NULL pointer dereference in a OOM situation.

Signed-off-by: Kiran Padwal <kiran.padwal@smartplayin.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/mfd/intel_soc_pmic_core.c

index df7b064..80cef04 100644 (file)
@@ -64,6 +64,9 @@ static int intel_soc_pmic_i2c_probe(struct i2c_client *i2c,
        config = (struct intel_soc_pmic_config *)id->driver_data;
 
        pmic = devm_kzalloc(dev, sizeof(*pmic), GFP_KERNEL);
+       if (!pmic)
+               return -ENOMEM;
+
        dev_set_drvdata(dev, pmic);
 
        pmic->regmap = devm_regmap_init_i2c(i2c, config->regmap_config);