All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hartmut Knaack <knaack.h@gmx.de>
To: linux-iio@vger.kernel.org
Cc: jic23@kernel.org
Subject: [PATCH 1/2] fixes for adt7410
Date: Sun, 15 Jul 2012 22:40:33 +0200	[thread overview]
Message-ID: <50032AC1.1030207@gmx.de> (raw)

This patch adds some checks prior to accessing device attribute lists in industrialio-event.c.

Signed-off-by: Harmut Knaack <knaack.h@gmx.de>
---
diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c
index b49059d..fe68e90 100644
--- a/drivers/iio/industrialio-event.c
+++ b/drivers/iio/industrialio-event.c
@@ -425,11 +425,13 @@ int iio_device_register_eventset(struct iio_dev *indio_dev)
                *attrcount_orig);
     attrn = attrcount_orig;
     /* Add all elements from the list. */
-    list_for_each_entry(p,
-                &indio_dev->event_interface->dev_attr_list,
-                l)
-        indio_dev->event_interface->group.attrs[attrn++] =
-            &p->dev_attr.attr;
+    if (indio_dev->event_interface->dev_attr_list.next)
+        list_for_each_entry(p,
+                &indio_dev->event_interface->dev_attr_list,
+                l)
+            indio_dev->event_interface->group.attrs[attrn++] =
+                &p->dev_attr.attr;
+
     indio_dev->groups[indio_dev->groupcounter++] =
         &indio_dev->event_interface->group;
 
@@ -447,7 +449,9 @@ void iio_device_unregister_eventset(struct iio_dev *indio_dev)
 {
     if (indio_dev->event_interface == NULL)
         return;
-    __iio_remove_event_config_attrs(indio_dev);
-    kfree(indio_dev->event_interface->group.attrs);
+    if (indio_dev->event_interface->dev_attr_list.next)
+        __iio_remove_event_config_attrs(indio_dev);
+    if (indio_dev->event_interface->group.attrs)
+        kfree(indio_dev->event_interface->group.attrs);
     kfree(indio_dev->event_interface);
 }

             reply	other threads:[~2012-07-15 20:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-15 20:40 Hartmut Knaack [this message]
2012-07-15 20:59 ` [PATCH 1/2] fixes for adt7410 Lars-Peter Clausen
2012-07-15 21:50   ` Hartmut Knaack
2012-07-16 10:00     ` Lars-Peter Clausen
2012-07-16 19:26       ` Hartmut Knaack

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50032AC1.1030207@gmx.de \
    --to=knaack.h@gmx.de \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.