Linux EXT4 FS development
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: andreas.dilger@intel.com
Cc: linux-ext4@vger.kernel.org
Subject: [bug report] ext4: xattr-in-inode support
Date: Fri, 30 Jun 2017 10:53:40 +0300	[thread overview]
Message-ID: <20170630075340.jzksfxareq4a4t66@mwanda> (raw)

Hello Andreas Dilger,

The patch 2851a40a5d71: "ext4: xattr-in-inode support" from Jun 21,
2017, leads to the following static checker warning:

	fs/ext4/xattr.c:1333 ext4_xattr_inode_write()
	error: 'bh' dereferencing possible ERR_PTR()

fs/ext4/xattr.c
  1301          block = 0;
  1302          while (wsize < bufsize) {
  1303                  if (bh != NULL)
  1304                          brelse(bh);
  1305                  csize = (bufsize - wsize) > blocksize ? blocksize :
  1306                                                                  bufsize - wsize;
  1307                  bh = ext4_getblk(handle, ea_inode, block, 0);
  1308                  if (IS_ERR(bh)) {
  1309                          ret = PTR_ERR(bh);
  1310                          goto out;
                                ^^^^^^^^
This will cause an oops.

  1311                  }
  1312                  ret = ext4_journal_get_write_access(handle, bh);
  1313                  if (ret)
  1314                          goto out;
  1315  
  1316                  memcpy(bh->b_data, buf, csize);
  1317                  set_buffer_uptodate(bh);
  1318                  ext4_handle_dirty_metadata(handle, ea_inode, bh);
  1319  
  1320                  buf += csize;
  1321                  wsize += csize;
  1322                  block += 1;
  1323          }
  1324  
  1325          inode_lock(ea_inode);
  1326          i_size_write(ea_inode, wsize);
  1327          ext4_update_i_disksize(ea_inode, wsize);
  1328          inode_unlock(ea_inode);
  1329  
  1330          ext4_mark_inode_dirty(handle, ea_inode);
  1331  
  1332  out:
  1333          brelse(bh);
  1334  
  1335          return ret;
  1336  }

regards,
dan carpenter

                 reply	other threads:[~2017-06-30  7:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20170630075340.jzksfxareq4a4t66@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=andreas.dilger@intel.com \
    --cc=linux-ext4@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox