Re: [PATCH 1/2] firmware: google: Expose CBMEM over sysfs

From: Greg Kroah-Hartman
Date: Wed Nov 20 2019 - 09:02:16 EST


On Wed, Nov 20, 2019 at 02:39:46PM +0100, patrick.rudolph@xxxxxxxxxxxxx wrote:
> +static int cbmem_probe(struct coreboot_device *cdev)
> +{
> + struct device *dev = &cdev->dev;
> + struct cb_priv *priv;
> + int err;
> +
> + priv = kzalloc(sizeof(*priv), GFP_KERNEL);
> + if (!priv)
> + return -ENOMEM;
> +
> + memcpy(&priv->entry, &cdev->cbmem_entry, sizeof(priv->entry));
> +
> + priv->remap = memremap(priv->entry.address,
> + priv->entry.entry_size, MEMREMAP_WB);
> + if (!priv->remap) {
> + err = -ENOMEM;
> + goto failure;
> + }
> +
> + err = sysfs_create_group(&dev->kobj, &cb_mem_attr_group);

Ick, you just raced userspace and lost :(

Please set the default group for the driver (dev_groups), so that the
driver core will correctly create and remove this group without you
having to do anything.

thanks,

greg k-h