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.

macintosh: Use common error handling code in via_pmu_led_init()

Add a jump target so that a bit of exception handling can be better reused
at the end of this function implementation.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://patch.msgid.link/189b93e2-4e81-438d-9c77-cbe4d9d7a0d9@web.de

authored by

Markus Elfring and committed by
Michael Ellerman
352268dc 2e716f5c

+10 -9
+10 -9
drivers/macintosh/via-pmu-led.c
··· 92 92 if (dt == NULL) 93 93 return -ENODEV; 94 94 model = of_get_property(dt, "model", NULL); 95 - if (model == NULL) { 96 - of_node_put(dt); 97 - return -ENODEV; 98 - } 95 + if (!model) 96 + goto put_node; 97 + 99 98 if (strncmp(model, "PowerBook", strlen("PowerBook")) != 0 && 100 99 strncmp(model, "iBook", strlen("iBook")) != 0 && 101 100 strcmp(model, "PowerMac7,2") != 0 && 102 - strcmp(model, "PowerMac7,3") != 0) { 103 - of_node_put(dt); 104 - /* ignore */ 105 - return -ENODEV; 106 - } 101 + strcmp(model, "PowerMac7,3") != 0) 102 + goto put_node; 103 + 107 104 of_node_put(dt); 108 105 109 106 spin_lock_init(&pmu_blink_lock); ··· 109 112 pmu_blink_req.done = pmu_req_done; 110 113 111 114 return led_classdev_register(NULL, &pmu_led); 115 + 116 + put_node: 117 + of_node_put(dt); 118 + return -ENODEV; 112 119 } 113 120 114 121 late_initcall(via_pmu_led_init);