Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756143Ab2HUKGh (ORCPT ); Tue, 21 Aug 2012 06:06:37 -0400 Received: from seven.medozas.de ([5.9.24.206]:57037 "EHLO seven.medozas.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754245Ab2HUKGe (ORCPT ); Tue, 21 Aug 2012 06:06:34 -0400 Date: Tue, 21 Aug 2012 12:06:33 +0200 (CEST) From: Jan Engelhardt To: Anatol Pomozov cc: linux-kernel@vger.kernel.org, viro@ZenIV.linux.org.uk, tytso@mit.edu, Anatol Pomazau Subject: Re: [PATCH] fs: Preserve error code in get_empty_filp() In-Reply-To: <1343845147-21394-1-git-send-email-anatol.pomozov@gmail.com> Message-ID: References: <1343845147-21394-1-git-send-email-anatol.pomozov@gmail.com> User-Agent: Alpine 2.01 (LNX 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1098 Lines: 31 On Wednesday 2012-08-01 20:19, anatol.pomozov@gmail.com wrote: >Allocating a file structure in function get_empty_filp() might fail because >of several reasons: > - not enough memory for file structures > - operation is not allowed > - user is over its limit > >Currently the function returns NULL in all cases and we loose the exact >reason of the error. All callers of get_empty_filp() assume that the function >can fail with ENFILE only. > >Return error through pointer. Change all callers to preserve this error code. > percpu_counter_inc(&nr_files); > f->f_cred = get_cred(cred); >- if (security_file_alloc(f)) >+ if (security_file_alloc(f)) { >+ error = -EPERM; > goto fail_sec; >+ } You are not preserving the error code from security_file_alloc here. In particular, apparmoar/lsm.c: file_alloc_security can return -ENOMEM, for example. -- 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/