linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: Fix build error in industrialio-core.c
@ 2011-11-23 10:13 Sasha Levin
  2011-11-23 14:17 ` Dan Carpenter
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Sasha Levin @ 2011-11-23 10:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: Sasha Levin, Jonathan Cameron, Greg Kroah-Hartman, linux-iio, devel

The error was introduced in commit b4641336 ("iio: fix a leak due to
improper use of anon_inode_getfd()").

Looks like the code wasn't even compile tested. Instead of just fixing the
error I changed the function a bit to make it nicer.

Cc: Jonathan Cameron <jic23@cam.ac.uk>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: linux-iio@vger.kernel.org
Cc: devel@driverdev.osuosl.org
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 drivers/staging/iio/industrialio-core.c |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c
index 2656409..5367914 100644
--- a/drivers/staging/iio/industrialio-core.c
+++ b/drivers/staging/iio/industrialio-core.c
@@ -242,25 +242,24 @@ static const struct file_operations iio_event_chrdev_fileops = {
 
 static int iio_event_getfd(struct iio_dev *indio_dev)
 {
+	struct iio_event_interface *ev_int = indio_dev->event_interface;
 	int fd;
 
-	if (indio_dev->event_interface == NULL)
+	if (ev_int == NULL)
 		return -ENODEV;
 
-	mutex_lock(&indio_dev->event_interface->event_list_lock);
-	if (test_and_set_bit(IIO_BUSY_BIT_POS,
-			     &indio_dev->event_interface->flags)) {
-		mutex_unlock(&indio_dev->event_interface->event_list_lock);
+	mutex_lock(&ev_int->event_list_lock);
+	if (test_and_set_bit(IIO_BUSY_BIT_POS, &ev_int->flags)) {
+		mutex_unlock(&ev_int->event_list_lock);
 		return -EBUSY;
 	}
-	mutex_unlock(&indio_dev->event_interface->event_list_lock);
-	fd = anon_inode_getfd("iio:event",
-				&iio_event_chrdev_fileops,
-				indio_dev->event_interface, O_RDONLY);
+	mutex_unlock(&ev_int->event_list_lock);
+	fd = anon_inode_getfd("iio:event", &iio_event_chrdev_fileops,
+				ev_int, O_RDONLY);
 	if (fd < 0) {
-		mutex_lock(&indio_dev->event_interface->event_list_lock);
+		mutex_lock(&ev_int->event_list_lock);
 		clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags);
-		mutex_unlock(&indio_dev->event_interface->event_list_lock);
+		mutex_unlock(&ev_int->event_list_lock);
 	}
 	return fd;
 }
-- 
1.7.8.rc3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] iio: Fix build error in industrialio-core.c
  2011-11-23 10:13 [PATCH] iio: Fix build error in industrialio-core.c Sasha Levin
@ 2011-11-23 14:17 ` Dan Carpenter
  2011-11-23 14:21   ` Sasha Levin
  2011-11-24  8:49 ` Jonathan Cameron
  2011-11-24 23:47 ` Stephen Rothwell
  2 siblings, 1 reply; 7+ messages in thread
From: Dan Carpenter @ 2011-11-23 14:17 UTC (permalink / raw)
  To: Sasha Levin
  Cc: linux-kernel, linux-iio, devel, Greg Kroah-Hartman, Jonathan Cameron

[-- Attachment #1: Type: text/plain, Size: 265 bytes --]

On Wed, Nov 23, 2011 at 12:13:59PM +0200, Sasha Levin wrote:
> The error was introduced in commit b4641336 ("iio: fix a leak due to
> improper use of anon_inode_getfd()").
> 

Which tree is that patch from?  It's not in linux-next.

regards,
dan carpenter

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] iio: Fix build error in industrialio-core.c
  2011-11-23 14:17 ` Dan Carpenter
@ 2011-11-23 14:21   ` Sasha Levin
  0 siblings, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2011-11-23 14:21 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: linux-kernel, linux-iio, devel, Greg Kroah-Hartman, Jonathan Cameron

On Wed, 2011-11-23 at 17:17 +0300, Dan Carpenter wrote:
> On Wed, Nov 23, 2011 at 12:13:59PM +0200, Sasha Levin wrote:
> > The error was introduced in commit b4641336 ("iio: fix a leak due to
> > improper use of anon_inode_getfd()").
> > 
> 
> Which tree is that patch from?  It's not in linux-next.
> 
> regards,
> dan carpenter

It's in Linus's tree:
https://github.com/torvalds/linux/commit/b46413367961c2e8bd827e067a231be982aaeee2

Which explains why sfr didn't complain about it earlier.

-- 

Sasha.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] iio: Fix build error in industrialio-core.c
  2011-11-23 10:13 [PATCH] iio: Fix build error in industrialio-core.c Sasha Levin
  2011-11-23 14:17 ` Dan Carpenter
@ 2011-11-24  8:49 ` Jonathan Cameron
  2011-11-24  8:54   ` Sasha Levin
  2011-11-24 23:47 ` Stephen Rothwell
  2 siblings, 1 reply; 7+ messages in thread
From: Jonathan Cameron @ 2011-11-24  8:49 UTC (permalink / raw)
  To: Sasha Levin, linux-kernel; +Cc: Greg Kroah-Hartman, linux-iio, devel



Sasha Levin <levinsasha928@gmail.com> wrote:

>The error was introduced in commit b4641336 ("iio: fix a leak due to
>improper use of anon_inode_getfd()").
>
>Looks like the code wasn't even compile tested. Instead of just fixing
>the
>error I changed the function a bit to make it nicer.
Minimal change would have been slightly nicer but clean up is obvious so fine. Thanks for doing this.  Andrew m has a dirty build fix in NM but he will drop that when this hits.
>Cc: Jonathan Cameron <jic23@cam.ac.uk>
>Cc: Greg Kroah-Hartman <gregkh@suse.de>
>Cc: linux-iio@vger.kernel.org
>Cc: devel@driverdev.osuosl.org
>Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
>---
> drivers/staging/iio/industrialio-core.c |   21 ++++++++++-----------
> 1 files changed, 10 insertions(+), 11 deletions(-)
>
>diff --git a/drivers/staging/iio/industrialio-core.c
>b/drivers/staging/iio/industrialio-core.c
>index 2656409..5367914 100644
>--- a/drivers/staging/iio/industrialio-core.c
>+++ b/drivers/staging/iio/industrialio-core.c
>@@ -242,25 +242,24 @@ static const struct file_operations
>iio_event_chrdev_fileops = {
> 
> static int iio_event_getfd(struct iio_dev *indio_dev)
> {
>+	struct iio_event_interface *ev_int = indio_dev->event_interface;
> 	int fd;
> 
>-	if (indio_dev->event_interface == NULL)
>+	if (ev_int == NULL)
> 		return -ENODEV;
> 
>-	mutex_lock(&indio_dev->event_interface->event_list_lock);
>-	if (test_and_set_bit(IIO_BUSY_BIT_POS,
>-			     &indio_dev->event_interface->flags)) {
>-		mutex_unlock(&indio_dev->event_interface->event_list_lock);
>+	mutex_lock(&ev_int->event_list_lock);
>+	if (test_and_set_bit(IIO_BUSY_BIT_POS, &ev_int->flags)) {
>+		mutex_unlock(&ev_int->event_list_lock);
> 		return -EBUSY;
> 	}
>-	mutex_unlock(&indio_dev->event_interface->event_list_lock);
>-	fd = anon_inode_getfd("iio:event",
>-				&iio_event_chrdev_fileops,
>-				indio_dev->event_interface, O_RDONLY);
>+	mutex_unlock(&ev_int->event_list_lock);
>+	fd = anon_inode_getfd("iio:event", &iio_event_chrdev_fileops,
>+				ev_int, O_RDONLY);
> 	if (fd < 0) {
>-		mutex_lock(&indio_dev->event_interface->event_list_lock);
>+		mutex_lock(&ev_int->event_list_lock);
> 		clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags);
>-		mutex_unlock(&indio_dev->event_interface->event_list_lock);
>+		mutex_unlock(&ev_int->event_list_lock);
> 	}
> 	return fd;
> }
>-- 
>1.7.8.rc3

-- 
Sent from my Android phone 
with K-9 Mail. Please excuse my brevity.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] iio: Fix build error in industrialio-core.c
  2011-11-24  8:49 ` Jonathan Cameron
@ 2011-11-24  8:54   ` Sasha Levin
  2011-11-24  9:11     ` Jonathan Cameron
  0 siblings, 1 reply; 7+ messages in thread
From: Sasha Levin @ 2011-11-24  8:54 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-kernel, Greg Kroah-Hartman, linux-iio, devel

On Thu, 2011-11-24 at 08:49 +0000, Jonathan Cameron wrote:
> 
> Sasha Levin <levinsasha928@gmail.com> wrote:
> 
> >The error was introduced in commit b4641336 ("iio: fix a leak due to
> >improper use of anon_inode_getfd()").
> >
> >Looks like the code wasn't even compile tested. Instead of just fixing
> >the
> >error I changed the function a bit to make it nicer.
> Minimal change would have been slightly nicer but clean up is obvious so fine. Thanks for doing this.  Andrew m has a dirty build fix in NM but he will drop that when this hits.

If you'd like I can split it into two patches, the fix and the cleanup.

-- 

Sasha.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] iio: Fix build error in industrialio-core.c
  2011-11-24  8:54   ` Sasha Levin
@ 2011-11-24  9:11     ` Jonathan Cameron
  0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2011-11-24  9:11 UTC (permalink / raw)
  To: Sasha Levin; +Cc: linux-kernel, Greg Kroah-Hartman, linux-iio, devel



Sasha Levin <levinsasha928@gmail.com> wrote:

>On Thu, 2011-11-24 at 08:49 +0000, Jonathan Cameron wrote:
>> 
>> Sasha Levin <levinsasha928@gmail.com> wrote:
>> 
>> >The error was introduced in commit b4641336 ("iio: fix a leak due to
>> >improper use of anon_inode_getfd()").
>> >
>> >Looks like the code wasn't even compile tested. Instead of just
>fixing
>> >the
>> >error I changed the function a bit to make it nicer.
>> Minimal change would have been slightly nicer but clean up is obvious
>so fine. Thanks for doing this.  Andrew m has a dirty build fix in NM
>but he will drop that when this hits.
>
>If you'd like I can split it into two patches, the fix and the cleanup.

Unless Greg wants that don't bother. I just want the fix in place!
>-- 
>
>Sasha.

-- 
Sent from my Android phone 
with K-9 Mail. Please excuse my brevity.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] iio: Fix build error in industrialio-core.c
  2011-11-23 10:13 [PATCH] iio: Fix build error in industrialio-core.c Sasha Levin
  2011-11-23 14:17 ` Dan Carpenter
  2011-11-24  8:49 ` Jonathan Cameron
@ 2011-11-24 23:47 ` Stephen Rothwell
  2 siblings, 0 replies; 7+ messages in thread
From: Stephen Rothwell @ 2011-11-24 23:47 UTC (permalink / raw)
  To: Sasha Levin
  Cc: linux-kernel, Jonathan Cameron, Greg Kroah-Hartman, linux-iio, devel

[-- Attachment #1: Type: text/plain, Size: 726 bytes --]

On Wed, 23 Nov 2011 12:13:59 +0200 Sasha Levin <levinsasha928@gmail.com> wrote:
>
> The error was introduced in commit b4641336 ("iio: fix a leak due to
> improper use of anon_inode_getfd()").
> 
> Looks like the code wasn't even compile tested. Instead of just fixing the
> error I changed the function a bit to make it nicer.
> 
> Cc: Jonathan Cameron <jic23@cam.ac.uk>
> Cc: Greg Kroah-Hartman <gregkh@suse.de>
> Cc: linux-iio@vger.kernel.org
> Cc: devel@driverdev.osuosl.org
> Signed-off-by: Sasha Levin <levinsasha928@gmail.com>

I will add this to my fixes tree today (so linux-next will build).

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-11-24 23:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-23 10:13 [PATCH] iio: Fix build error in industrialio-core.c Sasha Levin
2011-11-23 14:17 ` Dan Carpenter
2011-11-23 14:21   ` Sasha Levin
2011-11-24  8:49 ` Jonathan Cameron
2011-11-24  8:54   ` Sasha Levin
2011-11-24  9:11     ` Jonathan Cameron
2011-11-24 23:47 ` Stephen Rothwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).