[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAK5ve-KEqTcHLhhT6s262xC6xAgt20n7jsW7Wkg7sWi91GN=+Q@mail.gmail.com>
Date: Wed, 14 Nov 2012 16:13:03 -0800
From: Bryan Wu <cooloney@...il.com>
To: Fabio Baltieri <fabio.baltieri@...il.com>,
Bryan Wu <cooloney@...il.com>, linux-leds@...r.kernel.org,
linux-kernel@...r.kernel.org, Richard Purdie <rpurdie@...ys.net>,
Kurt Van Dijck <kurt.van.dijck@....be>
Subject: Re: [PATCH v2 RESEND] leds: add led_trigger_rename function
OK, I will apply this patch to my tree.
Thanks,
-Bryan
On Wed, Nov 14, 2012 at 12:30 AM, Fabio Baltieri
<fabio.baltieri@...il.com> wrote:
> Hi Bryan,
>
> On Tue, Nov 13, 2012 at 04:33:14PM -0800, Bryan Wu wrote:
>> > +void led_trigger_rename_static(const char *name, struct led_trigger *trig)
>> > +{
>> > + /* new name must be on a temporary string to prevent races */
>> > + BUG_ON(name == trig->name);
>> > +
>> > + down_write(&triggers_list_lock);
>> > + /* this assumes that trig->name was originaly allocated to
>> > + * non constant storage */
>> > + strcpy((char *)trig->name, name);
>>
>> Is this strcpy() safe here? Probably strncpy() or strlcpy() is safer.
>
> Actually the LED subsystem is not aware of the string allocation size,
> so I guess that strcpy is the only option here.
>
> On the other side, the caller, who originally allocated the string,
> should do the check properly, such as in:
>
> snprintf(name, sizeof(name), "%s-tx", netdev->name);
> led_trigger_rename_static(name, priv->tx_led_trig);
>
>> > +extern void led_trigger_rename_static(const char *name,
>> > + struct led_trigger *trig);
>> > +
>>
>> Any example how to use this new API?
>
> Sure! That was developed as part of CANBUS LED triggers to have trigger
> name follow can interfaces name changes.
>
> Original patch using this function, including the whole discussion
> behind it, was posted here:
>
> https://lkml.org/lkml/2012/9/10/544
>
> or you can find the complete set on my github branch:
>
> http://github.com/fabiobaltieri/linux.git can-leds-devel
>
> Fabio
>
> --
> Fabio Baltieri
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists