From: "J. Bruce Fields" <bfields@fieldses.org>
To: "Petri T. Koistinen" <petri.koistinen@iki.fi>
Cc: "David S. Miller" <davem@redhat.com>,
linux-net@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net/sunrpc/svcauth_unix.c: unix_domain_find: return NULL if kmalloc fails
Date: Mon, 26 Apr 2004 12:45:23 -0400 [thread overview]
Message-ID: <20040426164523.GA29509@fieldses.org> (raw)
In-Reply-To: <Pine.LNX.4.58.0404261913550.5531@dsl-prvgw1cc4.dial.inet.fi>
On Mon, Apr 26, 2004 at 07:17:19PM +0300, Petri T. Koistinen wrote:
> Is this correct fix? What happens when unix_domain_find return NULL?
I just noticed that the other day, and have been testing with the
identical fix; seems to work fine. All the callers check for NULL
returns and appear to do the right thing. --Bruce Fields
> --- linux-2.5/net/sunrpc/svcauth_unix.c.orig 2004-04-26 18:58:04.000000000 +0300
> +++ linux-2.5/net/sunrpc/svcauth_unix.c 2004-04-26 18:58:58.000000000 +0300
> @@ -36,36 +36,38 @@ struct unix_domain {
> struct auth_domain *unix_domain_find(char *name)
> {
> struct auth_domain *rv, ud;
> struct unix_domain *new;
>
> ud.name = name;
>
> rv = auth_domain_lookup(&ud, 0);
>
> foundit:
> if (rv && rv->flavour != RPC_AUTH_UNIX) {
> auth_domain_put(rv);
> return NULL;
> }
> if (rv)
> return rv;
>
> new = kmalloc(sizeof(*new), GFP_KERNEL);
> + if (new == NULL)
> + return NULL;
> cache_init(&new->h.h);
> atomic_inc(&new->h.h.refcnt);
> new->h.name = strdup(name);
> new->h.flavour = RPC_AUTH_UNIX;
> new->addr_changes = 0;
> new->h.h.expiry_time = NEVER;
> new->h.h.flags = 0;
>
> rv = auth_domain_lookup(&new->h, 2);
> if (rv == &new->h) {
> if (atomic_dec_and_test(&new->h.h.refcnt)) BUG();
> } else {
> auth_domain_put(&new->h);
> goto foundit;
> }
>
> return rv;
> }
> -
> 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/
next prev parent reply other threads:[~2004-04-26 16:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-26 16:17 [PATCH] net/sunrpc/svcauth_unix.c: unix_domain_find: return NULL if kmalloc fails Petri T. Koistinen
2004-04-26 16:45 ` J. Bruce Fields [this message]
2004-04-26 23:37 ` David S. Miller
2004-04-26 23:38 ` David S. Miller
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=20040426164523.GA29509@fieldses.org \
--to=bfields@fieldses.org \
--cc=davem@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-net@vger.kernel.org \
--cc=petri.koistinen@iki.fi \
/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