From: Stephen Hemminger <shemminger@vyatta•com>
To: David Miller <davem@davemloft•net>
Cc: netdev@vger•kernel.org
Subject: Re: [PATCH] net: network device name ifalias support
Date: Mon, 22 Sep 2008 20:47:18 -0700 [thread overview]
Message-ID: <20080922204718.2782b5b6@extreme> (raw)
In-Reply-To: <20080922.194423.116365505.davem@davemloft.net>
On Mon, 22 Sep 2008 19:44:23 -0700 (PDT)
David Miller <davem@davemloft•net> wrote:
> From: Stephen Hemminger <shemminger@vyatta•com>
> Date: Mon, 22 Sep 2008 17:43:46 -0700
>
> > + dev->ifalias = krealloc(dev->ifalias, len+1, GFP_KERNEL);
> > + if (!dev->ifalias)
> > + return -ENOMEM;
> > +
> > + strlcpy(dev->ifalias, alias, len+1);
> > + return len;
>
> It might be cleaner to use kstrdup() and free the old pointer, if
> any, here.
>
> char *new = kstrdup(alias, GFP_KERNEL);
> if (!new)
> return -ENOMEM;
> kfree(dev->ifalias);
> dev->ifalias = new;
> return len;
>
> That way all of this "len+1" stuff goes away.
Won't work because input string is not necessarily null-terminated.
In the sysfs case we want there is a trailing newline, and this
way avoids copying once there and then copying again.
next prev parent reply other threads:[~2008-09-23 3:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-23 0:43 [PATCH] net: network device name ifalias support Stephen Hemminger
2008-09-23 2:44 ` David Miller
2008-09-23 3:47 ` Stephen Hemminger [this message]
2008-09-23 4:28 ` David Miller
2008-09-23 19:52 ` [PATCH net-next]: net: remove ifalias on empty given alias Oliver Hartkopp
2008-09-23 20:14 ` Stephen Hemminger
2008-09-24 4:23 ` David 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=20080922204718.2782b5b6@extreme \
--to=shemminger@vyatta$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=netdev@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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