From: Greg KH <greg@kroah.com>
To: Narendra K <Narendra_K@dell.com>
Cc: netdev@vger.kernel.org, linux-hotplug@vger.kernel.org,
linux-pci@vger.kernel.org, matt_domsch@dell.com,
charles_rose@dell.com, jordan_hargrave@dell.com,
vijay_nijhawan@dell.com
Subject: Re: [PATCH] Export SMBIOS provided firmware instance and label to
Date: Sat, 10 Jul 2010 17:52:01 +0000 [thread overview]
Message-ID: <20100710175201.GB22779@kroah.com> (raw)
In-Reply-To: <20100710171445.GA24568@auslistsprd01.us.dell.com>
On Sat, Jul 10, 2010 at 12:14:45PM -0500, Narendra K wrote:
> +static char smbios_attr[4096];
> +
> +enum smbios_attr_enum {
> + SMBIOS_ATTR_LABEL_SHOW = 1,
> + SMBIOS_ATTR_INSTANCE_SHOW,
> +};
> +
> +static mode_t
> +smbios_instance_string_exist(struct kobject *kobj, struct attribute *attr,
> + int attribute)
> +{
> + struct device *dev;
> + struct pci_dev *pdev;
> + const struct dmi_device *dmi;
> + struct dmi_dev_onboard *donboard;
> + int bus;
> + int devfn;
> +
> + dev = container_of(kobj, struct device, kobj);
> + pdev = to_pci_dev(dev);
> +
> + bus = pdev->bus->number;
> + devfn = pdev->devfn;
> +
> + dmi = NULL;
> + while ((dmi = dmi_find_device(DMI_DEV_TYPE_DEV_ONBOARD,
> + NULL, dmi)) != NULL) {
> + donboard = dmi->device_data;
> + if (donboard && donboard->bus = bus &&
> + donboard->devfn = devfn) {
> + if (attribute = SMBIOS_ATTR_INSTANCE_SHOW)
> + return scnprintf(smbios_attr, PAGE_SIZE,
> + "%d\n", donboard->instance);
> + else if (attribute = SMBIOS_ATTR_LABEL_SHOW)
> + return scnprintf(smbios_attr, PAGE_SIZE,
> + "%s\n", dmi->name);
Wait, depending on the attribute you are looking at, you are placing the
data in a single buffer? What happens if userspace opens and reads both
files at once?
Please don't use this function for your show attributes, just properly
copy the correct string into the userspace buffer. This logic just
complicates things a lot more, right?
thanks,
greg k-h
next prev parent reply other threads:[~2010-07-10 17:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-10 17:14 [PATCH] Export SMBIOS provided firmware instance and label to sysfs Narendra K
2010-07-10 17:49 ` [PATCH] Export SMBIOS provided firmware instance and label to Greg KH
2010-07-10 17:52 ` Greg KH [this message]
[not found] <EDA0A4495861324DA2618B4C45DCB3EE612B93@blrx3m08.blr.amer.dell.com>
2010-07-14 12:13 ` [PATCH] Export SMBIOS provided firmware instance and label to sysfs Narendra K
2010-07-19 16:57 ` Narendra_K
2010-07-21 3:54 ` [PATCH] Export SMBIOS provided firmware instance and label to Greg KH
2010-07-21 3:59 ` Greg KH
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=20100710175201.GB22779@kroah.com \
--to=greg@kroah.com \
--cc=Narendra_K@dell.com \
--cc=charles_rose@dell.com \
--cc=jordan_hargrave@dell.com \
--cc=linux-hotplug@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=matt_domsch@dell.com \
--cc=netdev@vger.kernel.org \
--cc=vijay_nijhawan@dell.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).