lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 17 Jul 2013 16:45:57 +0300
From:	Oleksandr Kozaruk <oleksandr.kozaruk@...com>
To:	Lars-Peter Clausen <lars@...afoo.de>
CC:	"tony@...mide.com" <tony@...mide.com>,
	"benoit.cousson@...aro.org" <benoit.cousson@...aro.org>,
	"Nayak, Rajendra" <rnayak@...com>,
	"Ujfalusi, Peter" <peter.ujfalusi@...com>,
	"ABRAHAM, KISHON VIJAY" <kishon@...com>,
	"jic23@....ac.uk" <jic23@....ac.uk>,
	"grant.likely@...aro.org" <grant.likely@...aro.org>,
	"rob.herring@...xeda.com" <rob.herring@...xeda.com>,
	"sameo@...ux.intel.com" <sameo@...ux.intel.com>,
	"ch.naveen@...sung.com" <ch.naveen@...sung.com>,
	"poeschel@...onage.de" <poeschel@...onage.de>,
	"Kim, Milo" <Milo.Kim@...com>,
	"Krishnamoorthy, Balaji T" <balajitk@...com>,
	"gg@...mlogic.co.uk" <gg@...mlogic.co.uk>,
	"linux-arm-kernel@...ts.infradead.org" 
	<linux-arm-kernel@...ts.infradead.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"linux-iio@...r.kernel.org" <linux-iio@...r.kernel.org>,
	"devicetree-discuss@...ts.ozlabs.org" 
	<devicetree-discuss@...ts.ozlabs.org>,
	"linux-omap@...r.kernel.org" <linux-omap@...r.kernel.org>
Subject: Re: [PATCH v3 2/2] iio: twl6030-gpadc: TWL6030, TWL6032 GPADC driver

On Mon, Jul 15, 2013 at 01:33:53PM +0200, Lars-Peter Clausen wrote:
 > On 07/15/2013 01:09 PM, Kozaruk, Oleksandr wrote:
 > [...]
 > >
 > >>> +     ret = devm_request_threaded_irq(dev, irq, NULL,
 > >>> + twl6030_gpadc_irq_handler,
 > >>> + IRQF_ONESHOT, "twl6030_gpadc", gpadc);
 > >>
 > >> You access memory in the interrupt handler which is freed before 
the interrupt
 > >> handler is freed.
 > > Thanks for pointing this. devm_* will free memory for irq after the 
driver
 > > is removed and memory for the device is freed. I took me awhile to 
understand
 > > this. Is there going to be something like devm_iio_device_alloc? 
whould it be helpfull?
 > >
 >
 > Yes, I think it certainly makes sense to add a 
devm_iio_device_alloc(), care
 > to send a patch?

Anything like this? (of course it's not a patch)

struct iio_dev *devm_iio_device_alloc(struct device *dev, int sizeof_priv)
{
     struct iio_dev *indio_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 32-byte alignment of whole construct ? */
     alloc_size += IIO_ALIGN - 1;

     indio_dev = devm_kzalloc(dev, alloc_size, GFP_KERNEL);
     if (indio_dev) {
         indio_dev->dev.groups = indio_dev->groups;
         indio_dev->dev.type = &iio_device_type;
         indio_dev->dev.bus = &iio_bus_type;
         device_initialize(&indio_dev->dev);
         dev_set_drvdata(&indio_dev->dev, (void *)indio_dev);
         mutex_init(&indio_dev->mlock);
         mutex_init(&indio_dev->info_exist_lock);
         INIT_LIST_HEAD(&indio_dev->channel_attr_list);

         indio_dev->id = ida_simple_get(&iio_ida, 0, 0, GFP_KERNEL);
         if (indio_dev->id < 0) {
             /* cannot use a dev_err as the name isn't available */
             printk(KERN_ERR "Failed to get id\n");
             kfree(dev);
             return NULL;
         }
         dev_set_name(&indio_dev->dev, "iio:device%d", indio_dev->id);
         INIT_LIST_HEAD(&indio_dev->buffer_list);
     }

     return indio_dev;
}
EXPORT_SYMBOL(devm_iio_device_alloc);

Regards,
OK
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ