Re: [PATCH] drivers/base/core: refcount kobject and bus on device attribute read / store
From: Greg KH
Date: Tue Jun 22 2021 - 17:34:57 EST
On Tue, Jun 22, 2021 at 02:06:59PM -0700, Luis Chamberlain wrote:
> static ssize_t dev_attr_show(struct kobject *kobj, struct attribute *attr,
> char *buf)
> {
> - struct device_attribute *dev_attr = to_dev_attr(attr);
> - struct device *dev = kobj_to_dev(kobj);
> + struct device_attribute *dev_attr;
> + struct device *dev;
> + struct bus_type *bus = NULL;
> ssize_t ret = -EIO;
>
> + dev = get_device(kobj_to_dev(kobj));
> + if (!dev)
> + return ret;
That check is impossible to ever hit, please recognize what things like
kobj_to_dev() really are doing when calling it.
thanks,
greg k-h