RE: [PATCH]Move kzalloc() just before memset() to avoid initializing new sysfs entries wrongly

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

 



> This is manifestly wrong: it would leak memory as it circulates around
> the loop.

I don't think the memory leak happens.
As you can see below, if  a new entry is not created, kfree() is called outside while(1).

static void efivar_update_sysfs_entries(struct work_struct *work)
{
        struct efivar_entry *entry;
        int err;

        /* Add new sysfs entries */
        while (1) {
        	entry = kzalloc(sizeof(*entry), GFP_KERNEL);
        	if (!entry)
                	return;

                memset(entry, 0, sizeof(*entry));

                err = efivar_init(efivar_update_sysfs_entry, entry,
                                  true, false, &efivar_sysfs_list);
                if (!err)
                        break;

                efivar_create_sysfs_entry(entry);
        }

        kfree(entry);
}
--
To unsubscribe from this list: send the line "unsubscribe linux-efi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux