All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Tao Ma <boyu.mt@taobao.com>
Cc: Fengguang Wu <fengguang.wu@intel.com>,
	kbuild@01.org, "Theodore Ts'o" <tytso@mit.edu>,
	linux-ext4@vger.kernel.org
Subject: [ext4:dev 40/60] fs/ext4/inode.c:1953 __ext4_journalled_writepage() error: potential NULL dereference 'page_bufs'.
Date: Tue, 4 Dec 2012 14:10:27 +0300	[thread overview]
Message-ID: <20121204111011.GD22569@mwanda> (raw)

Hi Tao,

FYI, there are new smatch warnings show up in

tree:   git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
head:   e9f49e454264c1cdd793552bfeb44f337508201b
commit: 97bb0f99e9d2b047c7a6010771c41d5f0d2ed80c [40/60] ext4: add journalled write support for inline data

+ fs/ext4/inode.c:1953 __ext4_journalled_writepage() error: potential NULL dereference 'page_bufs'.

git remote update ext4
git checkout 97bb0f99e9d2b047c7a6010771c41d5f0d2ed80c
vim +1953 +/page_bufs fs/ext4/inode.c

62e086be Aneesh Kumar K.V 2009-06-14  1937  	unlock_page(page);
62e086be Aneesh Kumar K.V 2009-06-14  1938  
62e086be Aneesh Kumar K.V 2009-06-14  1939  	handle = ext4_journal_start(inode, ext4_writepage_trans_blocks(inode));
62e086be Aneesh Kumar K.V 2009-06-14  1940  	if (IS_ERR(handle)) {
62e086be Aneesh Kumar K.V 2009-06-14  1941  		ret = PTR_ERR(handle);
62e086be Aneesh Kumar K.V 2009-06-14  1942  		goto out;
62e086be Aneesh Kumar K.V 2009-06-14  1943  	}
62e086be Aneesh Kumar K.V 2009-06-14  1944  
441c8508 Curt Wohlgemuth  2011-08-13  1945  	BUG_ON(!ext4_handle_valid(handle));
441c8508 Curt Wohlgemuth  2011-08-13  1946  
97bb0f99 Tao Ma           2012-12-02  1947  	if (ext4_has_inline_data(inode) && inode_bh) {

If we have inline data but inode_bh is NULL then it will lead to a
NULL dereference.  Btw, smatch will still complain about this even
after we fix the code.

97bb0f99 Tao Ma           2012-12-02  1948  		ret = ext4_journal_get_write_access(handle, inode_bh);
97bb0f99 Tao Ma           2012-12-02  1949  
97bb0f99 Tao Ma           2012-12-02  1950  		err = ext4_handle_dirty_metadata(handle, inode, inode_bh);
97bb0f99 Tao Ma           2012-12-02  1951  
97bb0f99 Tao Ma           2012-12-02  1952  	} else {
97bb0f99 Tao Ma           2012-12-02 @1953  		ret = walk_page_buffers(handle, page_bufs, 0, len, NULL,
97bb0f99 Tao Ma           2012-12-02  1954  					do_journal_get_write_access);
97bb0f99 Tao Ma           2012-12-02  1955  
97bb0f99 Tao Ma           2012-12-02  1956  		err = walk_page_buffers(handle, page_bufs, 0, len, NULL,
97bb0f99 Tao Ma           2012-12-02  1957  					write_end_fn);
97bb0f99 Tao Ma           2012-12-02  1958  	}
62e086be Aneesh Kumar K.V 2009-06-14  1959  
62e086be Aneesh Kumar K.V 2009-06-14  1960  	if (ret == 0)
62e086be Aneesh Kumar K.V 2009-06-14  1961  		ret = err;

---
0-DAY kernel build testing backend         Open Source Technology Center
Fengguang Wu, Yuanhan Liu                              Intel Corporation

             reply	other threads:[~2012-12-04 11:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-04 11:10 Dan Carpenter [this message]
2012-12-04 13:25 ` [ext4:dev 40/60] fs/ext4/inode.c:1953 __ext4_journalled_writepage() error: potential NULL dereference 'page_bufs' Tao Ma
2012-12-04 13:56   ` Dan Carpenter
2012-12-05  5:41     ` Theodore Ts'o
2012-12-05  8:31       ` Dan Carpenter
2012-12-05 16:25         ` Theodore Ts'o

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=20121204111011.GD22569@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=boyu.mt@taobao.com \
    --cc=fengguang.wu@intel.com \
    --cc=kbuild@01.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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.