[Xenomai-git] Jan Kiszka : vfile: Fix NULL pointer exception on shapshot restarts

2011-04-20 Thread GIT version control
Module: xenomai-head
Branch: master
Commit: 2e57bc50a9bb6c0e13cc324ca7585409f67d8627
URL:
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=2e57bc50a9bb6c0e13cc324ca7585409f67d8627

Author: Jan Kiszka 
Date:   Wed Apr 20 20:09:59 2011 +0200

vfile: Fix NULL pointer exception on shapshot restarts

The following changes since commit cf683ac01817bb19ae5429df4ca9e0e57d78b5b1:

  arm: clean-up context switch (2011-04-16 12:47:50 +0200)

are available in the git repository at:
  git://git.xenomai.org/xenomai-jki.git for-upstream

Jan Kiszka (1):
  vfile: Fix NULL pointer exception on shapshot restarts

 ksrc/nucleus/vfile.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

---

 ksrc/nucleus/vfile.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/ksrc/nucleus/vfile.c b/ksrc/nucleus/vfile.c
index c553480..d8ac398 100644
--- a/ksrc/nucleus/vfile.c
+++ b/ksrc/nucleus/vfile.c
@@ -205,7 +205,6 @@ redo:
 * a NULL return from ->rewind() tells us that the vfile won't
 * output any snapshot data via ->show().
 */
-   it->endfn = ops->end;
nrdata = 0;
if (ops->rewind) {
nrdata = ops->rewind(it);
@@ -239,8 +238,10 @@ redo:
kfree(it);
return -ENOMEM;
}
-   if (data != VFILE_SEQ_EMPTY)
+   if (data != VFILE_SEQ_EMPTY) {
it->databuf = data;
+   it->endfn = ops->end;
+   }
} else if (nrdata > 0 && vfile->datasz > 0) {
/* We have a hint for auto-allocation. */
data = kmalloc(vfile->datasz * nrdata, GFP_KERNEL);


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Jan Kiszka : vfile: Fix NULL pointer exception on shapshot restarts

2011-04-20 Thread GIT version control
Module: xenomai-jki
Branch: for-upstream
Commit: 5d21b9a355feb7b010656f50d7f5bf786b3be34e
URL:
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=5d21b9a355feb7b010656f50d7f5bf786b3be34e

Author: Jan Kiszka 
Date:   Wed Apr 20 20:02:47 2011 +0200

vfile: Fix NULL pointer exception on shapshot restarts

it->endfn is only accessed if if->databuf is non-NULL. But we are
writing endfn on every snapshot restart. If ops->end is NULL but databuf
was set during a previous run, calling endfd will oops.

Fix it by only setting endfn when databuf is initialized.

Signed-off-by: Jan Kiszka 

---

 ksrc/nucleus/vfile.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/ksrc/nucleus/vfile.c b/ksrc/nucleus/vfile.c
index c553480..d8ac398 100644
--- a/ksrc/nucleus/vfile.c
+++ b/ksrc/nucleus/vfile.c
@@ -205,7 +205,6 @@ redo:
 * a NULL return from ->rewind() tells us that the vfile won't
 * output any snapshot data via ->show().
 */
-   it->endfn = ops->end;
nrdata = 0;
if (ops->rewind) {
nrdata = ops->rewind(it);
@@ -239,8 +238,10 @@ redo:
kfree(it);
return -ENOMEM;
}
-   if (data != VFILE_SEQ_EMPTY)
+   if (data != VFILE_SEQ_EMPTY) {
it->databuf = data;
+   it->endfn = ops->end;
+   }
} else if (nrdata > 0 && vfile->datasz > 0) {
/* We have a hint for auto-allocation. */
data = kmalloc(vfile->datasz * nrdata, GFP_KERNEL);


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git