Re: [PATCH V5] hwmon: add fan/pwm driver for corsair h100i platinum

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> > > +             fan->fan_channel = fan_id;
> > > +             fan->mode = 0;
> > > +             data->channel_data[fan_id] = fan;
> > > +     }
> > > +
> > > +     hwmon_info->ops = &i_pro_ops;
> > > +     hwmon_info->info = hdev->config->hwmon_info;
> > > +
> > > +     data->hdev = hdev;
> > > +     hwmon_dev = devm_hwmon_device_register_with_info(
> > > +             &hdev->udev->dev, hdev->config->name, data, hwmon_info, NULL);
> > > +     if (IS_ERR(hwmon_dev))
> > > +             return PTR_ERR(hwmon_dev);
> > > +
> > > +     dev_info(&hdev->udev->dev, "setup hwmon for %s\n", hdev->config->name);
> > > +     return 0;
> > > +}
> >
> > It is still possible that hwmon_init() leaks memory on failure.
>
> you mean the allocated memory doesn't get deallocated until
> the driver detaches? I can't free the memory myself because
> when the driver does detach it will double-free.
> I have looked at how other drivers handle this, none of them
> deallocate any memory.
> If you mean error check the allocations, I added those now.
>

Sorry, my bad, the devm_ part went over my head when reading. I also forgot to
mention that in astk_probe() you use kmalloc() to allocate the IO buffers,
but those are not freed if init_device() or hwmon_init() fails.


Barnabás Pőcze




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux