From: Florian Westphal <fw@strlen.de>
To: Phil Oester <kernel@linuxace.com>
Cc: Florian Westphal <fw@strlen.de>,
netfilter-devel@vger.kernel.org, pablo@netfilter.org
Subject: Re: [PATCH] iptables: set errno correctly in iptcc_chain_index_alloc
Date: Thu, 4 Jul 2013 18:33:25 +0200 [thread overview]
Message-ID: <20130704163325.GD2351@breakpoint.cc> (raw)
In-Reply-To: <20130704161845.GA11465@linuxace.com>
Phil Oester <kernel@linuxace.com> wrote:
> Simulate an out of memory condition with this patch
>
> @@ -500,9 +500,11 @@ static int iptcc_chain_index_alloc(struct xtc_handle *h)
> array_elems, array_mem);
>
> h->chain_index = malloc(array_mem);
> - if (h->chain_index == NULL && array_mem > 0) {
> + //if (h->chain_index == NULL && array_mem > 0) {
> + if (1) {
> h->chain_index_sz = 0;
> With the patch, the error message returned to user:
>
> ...can't initialize iptables table `filter': Memory allocation problem
>
> without the patch:
>
> ...can't initialize iptables table `filter': Incompatible with this kernel
>
> The former seems better, no?
Yes, but malloc didn't fail, so malloc didn't set errno.
My point is, that we should not muck with errno, especially
after libc functions that usually already set it on error.
next prev parent reply other threads:[~2013-07-04 16:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-04 1:16 [PATCH] iptables: set errno correctly in iptcc_chain_index_alloc Phil Oester
2013-07-04 7:42 ` Florian Westphal
2013-07-04 16:18 ` Phil Oester
2013-07-04 16:33 ` Florian Westphal [this message]
2013-07-04 16:52 ` Phil Oester
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=20130704163325.GD2351@breakpoint.cc \
--to=fw@strlen.de \
--cc=kernel@linuxace.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.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;
as well as URLs for NNTP newsgroup(s).