Re: [Pcihpd-discuss] [PATCH 5/6]: hotplug/ia64: SN Hotplug Driver - SN Hotplug Driver code

From: Rolf Eike Beer <eike-hotplug_at_sf-tec.de>
Date: 2005-05-19 18:00:54
Prarit Bhargava wrote:
> Prarit Bhargava wrote:
> > Prarit Bhargava wrote:
> >>> D_B_S alone should be a unique identifier, so please don't use
> >>> anything more if you don't need it to make the slot name unique.
> >>
> >> On Altix, since the system can be cabled in a number of ways a pointer
> >> to the rack ID is definately useful and helps to uniquely identify the
> >> slot.  I'm going to use a 2 digit rack id, followed by the DDDD:BB:SS
> >> value.
> >
> > Err .. uh .. unless there are any strenous objections of course ;

> New patch after comments from Eike and Greg.

Something I missed in the previous patch:

+static int sn_hp_slot_private_alloc(struct hotplug_slot *bss_hotplug_slot,
+                                   struct pci_bus *pci_bus, int device)
+{
+       struct pcibus_info *pcibus_info;
+       struct slot *slot;
+
+       pcibus_info = SN_PCIBUS_BUSSOFT_INFO(pci_bus);
+
+       bss_hotplug_slot->private = kcalloc(1, sizeof(struct slot),
+                                           GFP_KERNEL);
+       if (!bss_hotplug_slot->private)
+               return -ENOMEM;
+       slot = bss_hotplug_slot->private;
+

Better do it this way:

slot = kcalloc(1, sizeof(*slot), GFP_KERNEL);
bss_hotplug_slot->private = slot;

This way the size of the memory area is always the correct one (which is the 
preferred way of operating *g*).

I think it's really time for something like kmalloc0() or whatever to stop 
this type of kcalloc() abuse.

Eike

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

Received on Thu May 19 03:56:07 2005

This archive was generated by hypermail 2.1.8 : 2005-08-02 09:20:39 EST