Re: [PATCH 2/3] clk: bcm281xx: add initial clock framework support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Wed, Dec 04, 2013 at 01:57:39PM +0000, Alex Elder wrote:
> On 12/04/2013 07:06 AM, Alex Elder wrote:
> >>> +       name_size = strlen(node->name) + 1;
> >>> >> +       ccu = kzalloc(sizeof(*ccu) + name_size, GFP_KERNEL);
> >>> >> +       if (!ccu) {
> >>> >> +               pr_err("%s: unable to map allocate CCU struct for %s\n",
> >>> >> +                       __func__, node->name);
> >>> >> +               return;
> >>> >> +       }
> >>> >> +       memcpy((char *)ccu->name, node->name, name_size);
> >> > 
> >> > You could simplify this with kstrdup.
> > You are correct, and I will make that change.  I think at
> > one point I needed the length but that doesn't appear to
> > be the case here.
> 
> On second thought, no, you may have missed what was happening here.
> I was avoiding two kmallocs() by setting aside space at the end
> of the structure to hold its name.  It may seem silly, but this
> avoids a possible (well, conceivable) failure case.

Yes, I'd misunderstood. Sorry about that.

> 
> However, based on your earlier question about "what about freeing
> ccu->name?" I am going to use kstrdup() here.  I'd rather the code
> put you at ease than look weird just to avoid an unlikely failure.

I'm happy either way.

Mark.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux