All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] hwmon: Add "label" attribute
@ 2022-01-27  8:52 Dan Carpenter
  2022-01-27  9:47 ` Paul Cercueil
  2022-01-31 16:27 ` [PATCH] hwmon: Fix possible NULL pointer Paul Cercueil
  0 siblings, 2 replies; 6+ messages in thread
From: Dan Carpenter @ 2022-01-27  8:52 UTC (permalink / raw)
  To: paul; +Cc: linux-hwmon

Hello Paul Cercueil,

This is a semi-automatic email about new static checker warnings.

The patch 073c3ea6c530: "hwmon: Add "label" attribute" from Jan 10,
2022, leads to the following Smatch complaint:

    drivers/hwmon/hwmon.c:825 __hwmon_device_register()
    warn: variable dereferenced before check 'dev' (see line 810)

drivers/hwmon/hwmon.c
   809
   810		if (device_property_present(dev, "label")) {
                                            ^^^
The patch adds a new unchecked dereference

   811			err = device_property_read_string(dev, "label", &label);
   812			if (err < 0)
   813				goto free_hwmon;
   814	
   815			hwdev->label = kstrdup(label, GFP_KERNEL);
   816			if (hwdev->label == NULL) {
   817				err = -ENOMEM;
   818				goto free_hwmon;
   819			}
   820		}
   821	
   822		hwdev->name = name;
   823		hdev->class = &hwmon_class;
   824		hdev->parent = dev;
   825		hdev->of_node = dev ? dev->of_node : NULL;
                                ^^^
Existing code checked for NULL

   826		hwdev->chip = chip;
   827		dev_set_drvdata(hdev, drvdata);

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-01-31 16:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-27  8:52 [bug report] hwmon: Add "label" attribute Dan Carpenter
2022-01-27  9:47 ` Paul Cercueil
2022-01-27 14:28   ` Guenter Roeck
2022-01-27 16:43     ` Paul Cercueil
2022-01-27 17:17       ` Guenter Roeck
2022-01-31 16:27 ` [PATCH] hwmon: Fix possible NULL pointer Paul Cercueil

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.