Re: [PATCH v4] IBM power meter driver

Roel Kluin
2007-10-09T16:44:31Z

Mark M. Hoffman wrote:
>> +static void ibmpex_register_bmc(int iface, struct device *dev)
>> +{
>> + struct ibmpex_bmc_data *data;
>> + int err;
>> +
>> + data = kzalloc(sizeof(*data), GFP_KERNEL);
>> + if (!data) {
>> + printk(KERN_ERR DRVNAME ": Insufficient memory for BMC "
>> + "interface %d.\n", data->interface);
>> + return;
>> + }
>> +
>> + data->address.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
>> + data->address.channel = IPMI_BMC_CHANNEL;
>> + data->address.data[0] = 0;
>> + data->interface = iface;
>> + data->bmc_device = dev;
>> +
>> + /* Create IPMI messaging interface user */
>> + err = ipmi_create_user(data->interface, &driver_data.ipmi_hndlrs,
>> + data, &data->user);
>> + if (err < 0) {
>> + printk(KERN_ERR DRVNAME ": Error, unable to register user with "
>> + "ipmi interface %d\n",
>> + data->interface);
>> + goto out;
>> + }
>> +
>> + mutex_init(&data->lock);
>> +
>> + /* Initialize message */
>> + data->tx_msgid = 0;
>> + init_completion(&data->read_complete);
>> + data->tx_message.netfn = PEX_NET_FUNCTION;
>> + data->tx_message.cmd = PEX_COMMAND;
>> + data->tx_message.data = data->tx_msg_data;
>> +
>> + /* Does this BMC support PowerExecutive? */
>> + err = ibmpex_ver_check(data);
>> + if (err)
>> + goto out_user;
>> +
>> + /* Register the BMC as a HWMON class device */
>> + data->hwmon_dev = hwmon_device_register(data->bmc_device);
>> +
>> + if (IS_ERR(data->hwmon_dev)) {
>> + printk(KERN_ERR DRVNAME ": Error, unable to register hwmon "
>> + "class device for interface %d\n",
>> + data->interface);
>> + kfree(data);
>> + return;

don't you want to goto out_user here instead?

>> + }
>> +
>> + /* finally add the new bmc data to the bmc data list */
>> + dev_set_drvdata(dev, data);
>> + list_add_tail(&data->list, &driver_data.bmc_data);
>> +
>> + /* Now go find all the sensors */
>> + err = ibmpex_find_sensors(data);
>> + if (err) {
>> + printk(KERN_ERR "Error %d allocating memory\n", err);
>> + goto out_register;
>> + }
>> +
>> + return;
>> +
>> +out_register:
>> + hwmon_device_unregister(data->hwmon_dev);
>> +out_user:
>> + ipmi_destroy_user(data->user);
>> +out:
>> + kfree(data);
>> +}