All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: Greg K H <gregkh@linuxfoundation.org>
Cc: Linux Edac Mailing List <linux-edac@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 01/14] edac: rewrite the sysfs code to use struct device
Date: Thu, 29 Mar 2012 20:19:08 -0300	[thread overview]
Message-ID: <4F74EDEC.5020804@redhat.com> (raw)
In-Reply-To: <20120329220300.GA16491@kroah.com>

Em 29-03-2012 19:03, Greg K H escreveu:
> On Thu, Mar 29, 2012 at 02:06:48PM -0300, Mauro Carvalho Chehab wrote:
>> +static void mci_attr_release(struct device *device)
>>  {
>> -	int err;
>> -
>> -	debugf4("%s()\n", __func__);
>> -
>> -	while (sysfs_attrib) {
>> -		debugf4("%s() sysfs_attrib = %p\n",__func__, sysfs_attrib);
>> -		if (sysfs_attrib->grp) {
>> -			struct mcidev_sysfs_group_kobj *grp_kobj;
>> -
>> -			grp_kobj = kzalloc(sizeof(*grp_kobj), GFP_KERNEL);
>> -			if (!grp_kobj)
>> -				return -ENOMEM;
>> -
>> -			grp_kobj->grp = sysfs_attrib->grp;
>> -			grp_kobj->mci = mci;
>> -			list_add_tail(&grp_kobj->list, &mci->grp_kobj_list);
>> -
>> -			debugf0("%s() grp %s, mci %p\n", __func__,
>> -				sysfs_attrib->grp->name, mci);
>> -
>> -			err = kobject_init_and_add(&grp_kobj->kobj,
>> -						&ktype_inst_grp,
>> -						&mci->edac_mci_kobj,
>> -						sysfs_attrib->grp->name);
>> -			if (err < 0) {
>> -				printk(KERN_ERR "kobject_init_and_add failed: %d\n", err);
>> -				return err;
>> -			}
>> -			err = edac_create_mci_instance_attributes(mci,
>> -					grp_kobj->grp->mcidev_attr,
>> -					&grp_kobj->kobj);
>> -
>> -			if (err < 0)
>> -				return err;
>> -		} else if (sysfs_attrib->attr.name) {
>> -			debugf4("%s() file %s\n", __func__,
>> -				sysfs_attrib->attr.name);
>> -
>> -			err = sysfs_create_file(kobj, &sysfs_attrib->attr);
>> -			if (err < 0) {
>> -				printk(KERN_ERR "sysfs_create_file failed: %d\n", err);
>> -				return err;
>> -			}
>> -		} else
>> -			break;
>> -
>> -		sysfs_attrib++;
>> -	}
>> -
>> -	return 0;
>> +	debugf1("Releasing mci device %s\n", dev_name(device));
>>  }
> 
> Sweet, as per the documentation in the Documentation/kobjects.txt file,
> I get to publically mock you for thinking you are smarter than the
> kernel and this is an acceptable way to "outwhit" the driver core from
> spitting errors at you when the kobject is released.

There's nothing there to free: all EDAC structures are allocated once
(see edac_mc_alloc() and edac_align_ptr() logic, at drivers/edac/edac_mc.c).

Even the struct device for all csrows/channels/mcu is done on a single alloc
there. Trying to free it earlier would cause a segfault.

I didn't wrote that logic, nor I was tempted to change it: as this subsystem 
is focused on memory error detection, having every data structure used there
on a single page helps to minimize the probability of having an error at the 
memory used to store the EDAC data.
> 
> Please fix this up, it's unacceptable.
> 
>> +static void mc_attr_release(struct device *device)
>> +{
>> +	debugf1("Releasing device %s\n", dev_name(device));
>> +}
> 
> Hey, you did it again, not nice :(
> 
> You also just leaked memory as well :(

There's no memory leak. The allocated memory is freed at edac_mc_del_mc()
(also at drivers/edac/edac_mc.c).

> 
> Please fix.
> 
> greg k-h
> --
> To unsubscribe from this list: send the line "unsubscribe linux-edac" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


  reply	other threads:[~2012-03-29 23:19 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-29 17:06 [PATCH 00/14] Fix the EDAC API Mauro Carvalho Chehab
2012-03-29 17:06 ` [PATCH 01/14] edac: rewrite the sysfs code to use struct device Mauro Carvalho Chehab
2012-03-29 22:03   ` Greg K H
2012-03-29 23:19     ` Mauro Carvalho Chehab [this message]
2012-03-29 23:40       ` Greg K H
2012-03-30  2:13         ` Mauro Carvalho Chehab
2012-03-30  9:11           ` Borislav Petkov
2012-03-30 10:46             ` Mauro Carvalho Chehab
2012-03-30 15:32               ` Greg K H
2012-03-30 15:31           ` Greg K H
2012-03-30 17:34             ` Mauro Carvalho Chehab
2012-03-30 19:24               ` Greg K H
2012-03-29 17:06 ` [PATCH 02/14] mpc85xx_edac: convert sysfs logic " Mauro Carvalho Chehab
2012-03-29 17:06 ` [PATCH 03/14] amd64_edac: " Mauro Carvalho Chehab
2012-03-29 17:06 ` [PATCH 04/14] i7core_edac: convert it " Mauro Carvalho Chehab
2012-03-29 17:06 ` [PATCH 05/14] edac: Get rid of the old kobj's from the edac mc code Mauro Carvalho Chehab
2012-03-29 17:06 ` [PATCH 06/14] edac: add a new per-dimm API and make the old per-virtual-rank API obsolete Mauro Carvalho Chehab
2012-03-29 17:06 ` [PATCH 07/14] edac: add a sysfs node to report the maximum location for the system Mauro Carvalho Chehab
2012-03-29 17:06 ` [PATCH 08/14] edac: Add debufs nodes to allow doing fake error inject Mauro Carvalho Chehab
2012-03-29 17:06 ` [PATCH 09/14] edac: Create a per-Memory Controller bus Mauro Carvalho Chehab
2012-03-29 17:06 ` [PATCH 10/14] edac: Move grain/dtype/edac_type calculus to be out of channel loop Mauro Carvalho Chehab
2012-03-29 17:06 ` [PATCH 11/14] i82975x_edac: Test nr_pages earlier to save a few CPU cycles Mauro Carvalho Chehab
2012-03-29 17:06 ` [PATCH 12/14] i5100_edac: Fix a warning when compiled with 32 bits Mauro Carvalho Chehab
2012-03-29 17:07 ` [PATCH 13/14] i7300_edac: Get rid of some wrongly-solved rebase conflict Mauro Carvalho Chehab
2012-03-29 17:07 ` [PATCH 14/14] edac: Only expose csrows/channels on legacy API if they're populated Mauro Carvalho Chehab
2012-03-29 20:46 ` [PATCH 00/14] Fix the EDAC API Aristeu Rozanski Filho

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=4F74EDEC.5020804@redhat.com \
    --to=mchehab@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.