Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: twl6040-vibra - use cleanup facility for device_node

Use the '__free(device_node)' macro to simplify the code and error
handling. This makes the error handling more robust by ensuring that the
device node is always freed.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20241010-input_automate_of_node_put-v1-4-ebc62138fbf8@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Javier Carrasco and committed by
Dmitry Torokhov
0ba9d3a5 0ec6f58b

+2 -6
+2 -6
drivers/input/misc/twl6040-vibra.c
··· 229 229 static int twl6040_vibra_probe(struct platform_device *pdev) 230 230 { 231 231 struct device *twl6040_core_dev = pdev->dev.parent; 232 - struct device_node *twl6040_core_node; 233 232 struct vibra_info *info; 234 233 int vddvibl_uV = 0; 235 234 int vddvibr_uV = 0; 236 235 int error; 237 236 238 - twl6040_core_node = of_get_child_by_name(twl6040_core_dev->of_node, 239 - "vibra"); 237 + struct device_node *twl6040_core_node __free(device_node) = 238 + of_get_child_by_name(twl6040_core_dev->of_node, "vibra"); 240 239 if (!twl6040_core_node) { 241 240 dev_err(&pdev->dev, "parent of node is missing?\n"); 242 241 return -EINVAL; ··· 243 244 244 245 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); 245 246 if (!info) { 246 - of_node_put(twl6040_core_node); 247 247 dev_err(&pdev->dev, "couldn't allocate memory\n"); 248 248 return -ENOMEM; 249 249 } ··· 261 263 &info->vibrmotor_res); 262 264 of_property_read_u32(twl6040_core_node, "ti,vddvibl-uV", &vddvibl_uV); 263 265 of_property_read_u32(twl6040_core_node, "ti,vddvibr-uV", &vddvibr_uV); 264 - 265 - of_node_put(twl6040_core_node); 266 266 267 267 if ((!info->vibldrv_res && !info->viblmotor_res) || 268 268 (!info->vibrdrv_res && !info->vibrmotor_res)) {