hwmon: (adm1275) Free allocated memory if probe function fails
Probe function did not free allocated memory if it failed. Fix it. Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Reviewed-by: Robert Coulson <robert.coulson@ericsson.com>
This commit is contained in:
parent
7f2c0662e5
commit
3b33ca4122
1 changed files with 13 additions and 3 deletions
|
@ -32,6 +32,7 @@ static int adm1275_probe(struct i2c_client *client,
|
||||||
const struct i2c_device_id *id)
|
const struct i2c_device_id *id)
|
||||||
{
|
{
|
||||||
int config;
|
int config;
|
||||||
|
int ret;
|
||||||
struct pmbus_driver_info *info;
|
struct pmbus_driver_info *info;
|
||||||
|
|
||||||
if (!i2c_check_functionality(client->adapter,
|
if (!i2c_check_functionality(client->adapter,
|
||||||
|
@ -43,8 +44,10 @@ static int adm1275_probe(struct i2c_client *client,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
config = i2c_smbus_read_byte_data(client, ADM1275_PMON_CONFIG);
|
config = i2c_smbus_read_byte_data(client, ADM1275_PMON_CONFIG);
|
||||||
if (config < 0)
|
if (config < 0) {
|
||||||
return config;
|
ret = config;
|
||||||
|
goto err_mem;
|
||||||
|
}
|
||||||
|
|
||||||
info->pages = 1;
|
info->pages = 1;
|
||||||
info->direct[PSC_VOLTAGE_IN] = true;
|
info->direct[PSC_VOLTAGE_IN] = true;
|
||||||
|
@ -76,7 +79,14 @@ static int adm1275_probe(struct i2c_client *client,
|
||||||
else
|
else
|
||||||
info->func[0] |= PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT;
|
info->func[0] |= PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT;
|
||||||
|
|
||||||
return pmbus_do_probe(client, id, info);
|
ret = pmbus_do_probe(client, id, info);
|
||||||
|
if (ret)
|
||||||
|
goto err_mem;
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
err_mem:
|
||||||
|
kfree(info);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int adm1275_remove(struct i2c_client *client)
|
static int adm1275_remove(struct i2c_client *client)
|
||||||
|
|
Loading…
Add table
Reference in a new issue