Message ID | 20230715094452.36119-1-ruc_gongyuanjun@163.com (mailing list archive) |
---|---|
State | Rejected |
Headers | show |
Series | [1/1] hwmon: check the return value of platform_get_resource() | expand |
On 7/15/23 02:44, Yuanjun Gong wrote: > platform_get_resource() may fail, therefore, the return value > of platform_get_resource should be checked to avoid null pointer > dereference in devm_request_region(). > No, it can not, because the device was instantiated from platform_create_bundle() which always creates the resource. Guenter > Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com> > --- > drivers/hwmon/w83627ehf.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c > index fe960c0a624f..7793a4273e00 100644 > --- a/drivers/hwmon/w83627ehf.c > +++ b/drivers/hwmon/w83627ehf.c > @@ -1703,6 +1703,8 @@ static int __init w83627ehf_probe(struct platform_device *pdev) > struct device *hwmon_dev; > > res = platform_get_resource(pdev, IORESOURCE_IO, 0); > + if (!res) > + return -EINVAL; > if (!devm_request_region(dev, res->start, IOREGION_LENGTH, DRVNAME)) > return -EBUSY; >
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index fe960c0a624f..7793a4273e00 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c @@ -1703,6 +1703,8 @@ static int __init w83627ehf_probe(struct platform_device *pdev) struct device *hwmon_dev; res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (!res) + return -EINVAL; if (!devm_request_region(dev, res->start, IOREGION_LENGTH, DRVNAME)) return -EBUSY;
platform_get_resource() may fail, therefore, the return value of platform_get_resource should be checked to avoid null pointer dereference in devm_request_region(). Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com> --- drivers/hwmon/w83627ehf.c | 2 ++ 1 file changed, 2 insertions(+)