[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4F29584F.1060503@free-electrons.com>
Date: Wed, 01 Feb 2012 16:20:47 +0100
From: Maxime Ripard <maxime.ripard@...e-electrons.com>
To: jic23@....ac.uk
CC: linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
guenter.roeck@...csson.com, khali@...ux-fr.org,
dmitry.torokhov@...il.com, broonie@...nsource.wolfsonmicro.com,
gregkh@...e.de, alan@...rguk.ukuu.org.uk, arnd@...db.de,
linus.walleij@...aro.org, lars@...afoo.de
Subject: Re: [PATCH 1/6] IIO: Core sysfs only support.
Hi,
I know that this patchset is probably a bit outdated but still...
On 07/11/2011 15:52, jic23@....ac.uk wrote:
> From: Jonathan Cameron <jic23@....ac.uk>
>
> Add support for simple sysfs only interfaces.
>
> Bulk of patch is concerned with taking struct iio_chan_spec
> arrays and generating all the relevant interfaces from them.
>
> Signed-off-by: Jonathan Cameron <jic23@....ac.uk>
First, you can add my
Tested-by: Maxime Ripard <maxime.ripard@...e-electrons.com>
I have encountered a bug during my tests though, see below
> +struct iio_dev *iio_device_allocate(int sizeof_priv)
> +{
> + struct iio_dev *dev;
> + size_t alloc_size;
> +
> + alloc_size = sizeof(struct iio_dev);
> + if (sizeof_priv) {
> + alloc_size = ALIGN(alloc_size, IIO_ALIGN);
> + alloc_size += sizeof_priv;
> + }
> + /* ensure cacheline alignment of whole construct */
> + alloc_size += IIO_ALIGN - 1;
> +
> + dev = kzalloc(alloc_size, GFP_KERNEL);
> +
> + if (dev) {
> + dev->dev.groups = dev->groups;
> + dev->dev.type = &iio_dev_type;
> + dev->dev.bus = &iio_bus_type;
> + device_initialize(&dev->dev);
> + dev_set_drvdata(&dev->dev, (void *)dev);
> + mutex_init(&dev->mlock);
> + }
> +
> + return dev;
> +}
> +EXPORT_SYMBOL_GPL(iio_device_allocate);
> +
> +void iio_device_free(struct iio_dev *dev)
> +{
> + if (dev)
> + iio_put_device(dev);
> +}
> +EXPORT_SYMBOL_GPL(iio_device_free);
Here, the iio_put_device is called in free, but get_device is never
called, but seem to be called in iio_device_register, which, if you ever
encounter an error in the probe function, you will never have called the
iio_device_register function, before calling the iio_device_free
function, which leads to a segfault.
Maxime
--
Maxime Ripard, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists