linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] To add NULL pointer check
@ 2013-04-02 12:57 P J P
  2013-04-03  3:03 ` Jaegeuk Kim
  0 siblings, 1 reply; 9+ messages in thread
From: P J P @ 2013-04-02 12:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-fsdevel, Petr Matousek

    Hello,

Commit - fa9150a84c - replaces a call to generic_writepages() in 
f2fs_write_data_pages() with write_cache_pages(), with a function pointer 
argument pointing to routine: __f2fs_writepage.

  -> https://git.kernel.org/linus/fa9150a84ca333f68127097c4fa1eda4b3913a22

The patch below adds a NULL pointer check, from generic_writepages(), to avoid 
a possible NULL pointer dereference, in case if - mapping->a_ops->writepage - 
is NULL.

===
$ git diff
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 7bd22a2..9841372 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -550,9 +550,16 @@ redirty_out:
  static int __f2fs_writepage(struct page *page, struct writeback_control *wbc,
                         void *data)
  {
+       int ret = 0;
         struct address_space *mapping = data;
-       int ret = mapping->a_ops->writepage(page, wbc);
+
+       /* deal with chardevs and other special file */
+       if (!mapping->a_ops->writepage)
+               return ret;
+
+       ret = mapping->a_ops->writepage(page, wbc);
         mapping_set_error(mapping, ret);
+
         return ret;
  }
===


Thank you.
--
Prasad J Pandit / Red Hat Security Response Team
DB7A 84C5 D3F9 7CD1 B5EB  C939 D048 7860 3655 602B

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

end of thread, other threads:[~2013-04-04  5:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-02 12:57 [PATCH] To add NULL pointer check P J P
2013-04-03  3:03 ` Jaegeuk Kim
2013-04-03  4:25   ` Namjae Jeon
2013-04-03  6:39   ` P J P
2013-04-03  7:00   ` P J P
2013-04-03  7:54     ` Jaegeuk Kim
2013-04-03  9:13       ` P J P
2013-04-04  0:14         ` Jaegeuk Kim
2013-04-04  5:28           ` P J P

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).