RE: function "class_device_add" in inux26/drivers/base/class.c

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

 





> -----Original Message-----
> From: Greg KH [mailto:greg@xxxxxxxxx]
> Sent: Wednesday, April 26, 2006 10:41 PM
> To: Vishal Sharda
> Cc: tyler@xxxxxxxx; kernelnewbies@xxxxxxxxxxxx
> Subject: Re: function "class_device_add" in
inux26/drivers/base/class.c
>
>
> A: Because it messes up the order in which people normally read text.
> Q: Why is top-posting such a bad thing?
> A: Top-posting.
> Q: What is the most annoying thing on usenet and in e-mail?
>
> A: No.
> Q: Should I include quotations after my reply?
>
>
> On Wed, Apr 26, 2006 at 05:42:44PM +0530, Vishal Sharda wrote:
> >
> > Yes, I'd seen that but the question is that whether can it be NULL?
> >
> > I had gone through the function chains from where it is called but
> > couldn't find where can it be NULL?
>
> Are you having a problem with some driver that is causing this to
> happen?  Or just wanting to figure out why I put a "let's better be
safe
> than sorry" check in the code?
>
> thanks,
>
> greg k-h


No, as of now I am not having a problem with any driver. But if you see
the code of 2.6.14:

if (MAJOR(class_dev->devt)) {
  struct class_device_attribute *attr;
  attr = kzalloc(sizeof(*attr), GFP_KERNEL);

  if (!attr) {
  error = -ENOMEM;
  kobject_del(&class_dev->kobj);
  goto register_done;
  }
  attr->attr.name = "dev";
  attr->attr.mode = S_IRUGO;

******  attr->attr.owner = parent->owner;			
  attr->show = show_dev;
  attr->store = NULL;
  class_device_create_file(class_dev, attr);
  class_dev->devt_attr = attr;
  }

The code above marked with asterisks could crash the system. So, either
there should be a check as it is there at one place in the code in the
same function as sown below:
if (parent)
  class_dev->kobj.parent = &parent->subsys.kset.kobj;

Or what I think is that probably it is not necessary to check this based
on all of the caller function tree I've gone through.

Regards,
Vishal.

**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux