Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932543AbbDIIVQ (ORCPT ); Thu, 9 Apr 2015 04:21:16 -0400 Received: from cantor2.suse.de ([195.135.220.15]:56896 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751986AbbDIIVJ (ORCPT ); Thu, 9 Apr 2015 04:21:09 -0400 Date: Thu, 9 Apr 2015 10:21:04 +0200 From: Jan Kara To: Fabian Frederick Cc: linux-kernel@vger.kernel.org, Jan Kara Subject: Re: [PATCH V2 1/9 linux-next] udf: udf_get_filename(): return -ENOMEM when allocation fails Message-ID: <20150409082104.GA18044@quack.suse.cz> References: <1428521039-18491-1-git-send-email-fabf@skynet.be> <1428521039-18491-2-git-send-email-fabf@skynet.be> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1428521039-18491-2-git-send-email-fabf@skynet.be> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3294 Lines: 110 On Wed 08-04-15 21:23:51, Fabian Frederick wrote: > udf_pc_to_char() now returns error accordingly. > udf_readdir() and udf_find_entry() process is done on > positive result. Thanks. Added to my tree with improved changelog. Honza > > Signed-off-by: Fabian Frederick > --- > fs/udf/dir.c | 2 +- > fs/udf/namei.c | 3 ++- > fs/udf/symlink.c | 3 +++ > fs/udf/unicode.c | 12 +++++++----- > 4 files changed, 13 insertions(+), 7 deletions(-) > > diff --git a/fs/udf/dir.c b/fs/udf/dir.c > index 541a12b..fcf227e 100644 > --- a/fs/udf/dir.c > +++ b/fs/udf/dir.c > @@ -168,7 +168,7 @@ static int udf_readdir(struct file *file, struct dir_context *ctx) > } > > flen = udf_get_filename(sb, nameptr, lfi, fname, UDF_NAME_LEN); > - if (!flen) > + if (flen <= 0) > continue; > > tloc = lelb_to_cpu(cfi.icb.extLocation); > diff --git a/fs/udf/namei.c b/fs/udf/namei.c > index fbf3d90..59b340c 100644 > --- a/fs/udf/namei.c > +++ b/fs/udf/namei.c > @@ -234,7 +234,8 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir, > continue; > > flen = udf_get_filename(sb, nameptr, lfi, fname, UDF_NAME_LEN); > - if (flen && udf_match(flen, fname, child->len, child->name)) > + if ((flen > 0) && udf_match(flen, fname, child->len, > + child->name)) > goto out_ok; > } > > diff --git a/fs/udf/symlink.c b/fs/udf/symlink.c > index 8dfbc40..862535b 100644 > --- a/fs/udf/symlink.c > +++ b/fs/udf/symlink.c > @@ -82,6 +82,9 @@ static int udf_pc_to_char(struct super_block *sb, unsigned char *from, > comp_len = udf_get_filename(sb, pc->componentIdent, > pc->lengthComponentIdent, > p, tolen); > + if (comp_len < 0) > + return comp_len; > + > p += comp_len; > tolen -= comp_len; > if (tolen == 0) > diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c > index b84fee3..4911c1d 100644 > --- a/fs/udf/unicode.c > +++ b/fs/udf/unicode.c > @@ -338,15 +338,17 @@ int udf_get_filename(struct super_block *sb, uint8_t *sname, int slen, > uint8_t *dname, int dlen) > { > struct ustr *filename, *unifilename; > - int len = 0; > + int ret = 0; > > filename = kmalloc(sizeof(struct ustr), GFP_NOFS); > if (!filename) > - return 0; > + return -ENOMEM; > > unifilename = kmalloc(sizeof(struct ustr), GFP_NOFS); > - if (!unifilename) > + if (!unifilename) { > + ret = -ENOMEM; > goto out1; > + } > > if (udf_build_ustr_exact(unifilename, sname, slen)) > goto out2; > @@ -367,14 +369,14 @@ int udf_get_filename(struct super_block *sb, uint8_t *sname, int slen, > } else > goto out2; > > - len = udf_translate_to_linux(dname, dlen, > + ret = udf_translate_to_linux(dname, dlen, > filename->u_name, filename->u_len, > unifilename->u_name, unifilename->u_len); > out2: > kfree(unifilename); > out1: > kfree(filename); > - return len; > + return ret; > } > > int udf_put_filename(struct super_block *sb, const uint8_t *sname, > -- > 1.9.1 > -- Jan Kara SUSE Labs, CR -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/