All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexey Khoroshilov <khoroshilov@ispras.ru>
To: Vyacheslav Dubeyko <slava@dubeyko.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	Artem Bityutskiy <artem.bityutskiy@linux.intel.com>,
	Christoph Hellwig <hch@lst.de>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	ldv-project@linuxtesting.org,
	Hin-Tak Leung <htl10@users.sourceforge.net>
Subject: Re: [PATCH] hfs: add error checking for hfs_find_init()
Date: Sun, 07 Apr 2013 01:13:33 +0400	[thread overview]
Message-ID: <51608FFD.2020706@ispras.ru> (raw)
In-Reply-To: <0D203BE4-D965-42FE-ADA7-831070860222@dubeyko.com>

Hi Vyacheslav,

On 03/30/2013 03:35 PM, Vyacheslav Dubeyko wrote:
>> Found by Linux Driver Verification project (linuxtesting.org).
>>
>> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
>> ---
>> fs/hfs/catalog.c |   12 +++++++++---
>> fs/hfs/dir.c     |    8 ++++++--
>> fs/hfs/extent.c  |   48 +++++++++++++++++++++++++++++++++---------------
>> fs/hfs/hfs_fs.h  |    2 +-
>> fs/hfs/inode.c   |   11 +++++++++--
>> fs/hfs/super.c   |    4 +++-
>> 6 files changed, 61 insertions(+), 24 deletions(-)
>>
>> diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c
>> index 424b033..9569b39 100644
>> --- a/fs/hfs/catalog.c
>> +++ b/fs/hfs/catalog.c
>> @@ -92,7 +92,9 @@ int hfs_cat_create(u32 cnid, struct inode *dir, struct qstr *str, struct inode *
>> 		return -ENOSPC;
>>
>> 	sb = dir->i_sb;
>> -	hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
>> +	err = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
>> +	if (err)
>> +		return err;
>>
>> 	hfs_cat_build_key(sb, fd.search_key, cnid, NULL);
>> 	entry_size = hfs_cat_build_thread(sb, &entry, S_ISDIR(inode->i_mode) ?
>> @@ -214,7 +216,9 @@ int hfs_cat_delete(u32 cnid, struct inode *dir, struct qstr *str)
>>
>> 	dprint(DBG_CAT_MOD, "delete_cat: %s,%u\n", str ? str->name : NULL, cnid);
>> 	sb = dir->i_sb;
>> -	hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
>> +	res = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
>> +	if (res)
>> +		return res;
>>
>> 	hfs_cat_build_key(sb, fd.search_key, dir->i_ino, str);
>> 	res = hfs_brec_find(&fd);
>> @@ -281,7 +285,9 @@ int hfs_cat_move(u32 cnid, struct inode *src_dir, struct qstr *src_name,
>> 	dprint(DBG_CAT_MOD, "rename_cat: %u - %lu,%s - %lu,%s\n", cnid, src_dir->i_ino, src_name->name,
>> 		dst_dir->i_ino, dst_name->name);
>> 	sb = src_dir->i_sb;
>> -	hfs_find_init(HFS_SB(sb)->cat_tree, &src_fd);
>> +	err = hfs_find_init(HFS_SB(sb)->cat_tree, &src_fd);
>> +	if (err)
>> +		return err;
>> 	dst_fd = src_fd;
>>
>> 	/* find the old dir entry and read the data */
>> diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
>> index 5f7f1ab..e1c8048 100644
>> --- a/fs/hfs/dir.c
>> +++ b/fs/hfs/dir.c
>> @@ -25,7 +25,9 @@ static struct dentry *hfs_lookup(struct inode *dir, struct dentry *dentry,
>> 	struct inode *inode = NULL;
>> 	int res;
>>
>> -	hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
>> +	res = hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
>> +	if (res)
>> +		return ERR_PTR(res);
>> 	hfs_cat_build_key(dir->i_sb, fd.search_key, dir->i_ino, &dentry->d_name);
>> 	res = hfs_brec_read(&fd, &rec, sizeof(rec));
>> 	if (res) {
>> @@ -63,7 +65,9 @@ static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
>> 	if (filp->f_pos >= inode->i_size)
>> 		return 0;
>>
>> -	hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
>> +	err = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
>> +	if (err)
>> +		return err;
>> 	hfs_cat_build_key(sb, fd.search_key, inode->i_ino, NULL);
>> 	err = hfs_brec_find(&fd);
>> 	if (err)
>> diff --git a/fs/hfs/extent.c b/fs/hfs/extent.c
>> index a67955a..813447b 100644
>> --- a/fs/hfs/extent.c
>> +++ b/fs/hfs/extent.c
>> @@ -107,7 +107,7 @@ static u16 hfs_ext_lastblock(struct hfs_extent *ext)
>> 	return be16_to_cpu(ext->block) + be16_to_cpu(ext->count);
>> }
>>
>> -static void __hfs_ext_write_extent(struct inode *inode, struct hfs_find_data *fd)
>> +static int __hfs_ext_write_extent(struct inode *inode, struct hfs_find_data *fd)
>> {
>> 	int res;
>>
>> @@ -116,26 +116,31 @@ static void __hfs_ext_write_extent(struct inode *inode, struct hfs_find_data *fd
>> 	res = hfs_brec_find(fd);
>> 	if (HFS_I(inode)->flags & HFS_FLG_EXT_NEW) {
>> 		if (res != -ENOENT)
>> -			return;
>> +			return res;
>> 		hfs_brec_insert(fd, HFS_I(inode)->cached_extents, sizeof(hfs_extent_rec));
>> 		HFS_I(inode)->flags &= ~(HFS_FLG_EXT_DIRTY|HFS_FLG_EXT_NEW);
>> 	} else {
>> 		if (res)
>> -			return;
>> +			return res;
>> 		hfs_bnode_write(fd->bnode, HFS_I(inode)->cached_extents, fd->entryoffset, fd->entrylength);
>> 		HFS_I(inode)->flags &= ~HFS_FLG_EXT_DIRTY;
>> 	}
>> +	return 0;
>> }
> As I see, this fix makes sense and for hfsplus also. Please, make it and for hfsplus.
Sorry, I did not catch which fix do you mean. Could you please clarify it.

Thank you,
Alexey

  parent reply	other threads:[~2013-04-06 21:13 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-29 21:44 [PATCH] hfs: add error checking for hfs_find_init() Alexey Khoroshilov
2013-03-30 11:35 ` Vyacheslav Dubeyko
2013-03-30 14:01   ` Hin-Tak Leung
2013-04-06 21:13   ` Alexey Khoroshilov [this message]
2013-04-07  9:31     ` Vyacheslav Dubeyko
2013-04-07 21:21       ` [PATCH 1/2] hfsplus: add error propagation to __hfsplus_ext_write_extent() Alexey Khoroshilov
2013-04-07 21:21         ` [PATCH 2/2] hfsplus: add printk to log allocation failure in hfs_find_init() Alexey Khoroshilov
2013-04-07 22:00           ` Joe Perches
2013-04-08  6:08             ` Vyacheslav Dubeyko
2013-04-08 16:37               ` [PATCH 0/2] hfs/hfsplus: Modernize logging styles Joe Perches
2013-04-08 16:37                 ` [PATCH 1/2] hfs/hfsplus: Convert dprint to hfs_dbg Joe Perches
2013-04-09  7:08                   ` Vyacheslav Dubeyko
2013-04-15  0:53                   ` Hin-Tak Leung
2013-04-15  0:53                     ` Hin-Tak Leung
2013-04-15  1:51                     ` Joe Perches
2013-04-15  1:56                       ` Hin-Tak Leung
2013-04-15  2:06                         ` Joe Perches
2013-04-15  3:46                           ` Hin-Tak Leung
2013-04-15  3:46                             ` Hin-Tak Leung
2013-04-15  4:00                             ` Joe Perches
2013-04-15  4:22                               ` Hin-Tak Leung
2013-04-15  4:38                                 ` Joe Perches
2013-04-08 16:37                 ` [PATCH 2/2] hfs/hfsplus: Convert printks to pr_<level> Joe Perches
2013-04-09  7:08                   ` Vyacheslav Dubeyko
2013-04-09  7:08                 ` [PATCH 0/2] hfs/hfsplus: Modernize logging styles Vyacheslav Dubeyko
2013-04-09 10:39                   ` Joe Perches
2013-04-09 11:06                     ` Vyacheslav Dubeyko
2013-04-08  5:55         ` [PATCH 1/2] hfsplus: add error propagation to __hfsplus_ext_write_extent() Vyacheslav Dubeyko
2013-04-08  5:55           ` Vyacheslav Dubeyko
2013-04-09 18:14           ` [PATCH 1/2] hfs: add error checking for hfs_find_init() Alexey Khoroshilov
2013-04-09 18:14             ` [PATCH 2/2] hfsplus: add error propagation to __hfsplus_ext_write_extent() Alexey Khoroshilov
2013-04-10  6:40               ` Vyacheslav Dubeyko
2013-04-10  6:40             ` [PATCH 1/2] hfs: add error checking for hfs_find_init() Vyacheslav Dubeyko

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=51608FFD.2020706@ispras.ru \
    --to=khoroshilov@ispras.ru \
    --cc=artem.bityutskiy@linux.intel.com \
    --cc=hch@lst.de \
    --cc=htl10@users.sourceforge.net \
    --cc=ldv-project@linuxtesting.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=slava@dubeyko.com \
    --cc=viro@zeniv.linux.org.uk \
    /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.