Message ID | b7e69e04-e15c-41ec-b62b-37253debc654@web.de (mailing list archive) |
---|---|
State | Rejected |
Headers | show |
Series | powermac: Call of_node_put(bk_node) only once in pmac_has_backlight_type() | expand |
Context | Check | Description |
---|---|---|
snowpatch_ozlabs/github-powerpc_ppctests | success | Successfully ran 8 jobs. |
snowpatch_ozlabs/github-powerpc_selftests | success | Successfully ran 8 jobs. |
snowpatch_ozlabs/github-powerpc_clang | success | Successfully ran 5 jobs. |
snowpatch_ozlabs/github-powerpc_kernel_qemu | success | Successfully ran 21 jobs. |
snowpatch_ozlabs/github-powerpc_sparse | success | Successfully ran 4 jobs. |
First of all, the change is wrong. We can't dereference "prop" after calling of_node_put(). You have to be a bit extra careful reviewing Markus's patches because a lot of the rest of us have blocked these messages so you're on your own in that way. On Wed, Oct 02, 2024 at 10:43:46PM +0200, Christophe Leroy wrote: > > > Le 02/10/2024 à 22:02, Markus Elfring a écrit : > > From: Markus Elfring <elfring@users.sourceforge.net> > > Date: Wed, 2 Oct 2024 21:50:27 +0200 > > > > An of_node_put(bk_node) call was immediately used after a pointer check > > for an of_get_property() call in this function implementation. > > Thus call such a function only once instead directly before the check. > > It seems pointless to perform a put immediately after a get. Shouldn't > of_find_property() be used instead ? And then of_property_read_string() > would probably be better. > > Maybe you can even use of_property_match_string(). The of_get_property() function doesn't do a get as in get/put, it just finds the property and returns it. It doesn't bump the reference count. It's a confusing name in that way. The The of_node_put() pairs with of_find_node_by_name(). regards, dan carpenter
On 03/10/2024 07:56, Dan Carpenter wrote: > First of all, the change is wrong. We can't dereference "prop" after calling > of_node_put(). You have to be a bit extra careful reviewing Markus's patches > because a lot of the rest of us have blocked these messages so you're on your > own in that way. Yep, I plonked him some time ago and everything is in spam. The code looks just incorrect and I think Markus did not understand it before transforming. Best regards, Krzysztof
diff --git a/arch/powerpc/platforms/powermac/backlight.c b/arch/powerpc/platforms/powermac/backlight.c index 12bc01353bd3..d3666595a62e 100644 --- a/arch/powerpc/platforms/powermac/backlight.c +++ b/arch/powerpc/platforms/powermac/backlight.c @@ -61,11 +61,9 @@ int pmac_has_backlight_type(const char *type) if (bk_node) { const char *prop = of_get_property(bk_node, "backlight-control", NULL); - if (prop && strncmp(prop, type, strlen(type)) == 0) { - of_node_put(bk_node); - return 1; - } of_node_put(bk_node); + if (prop && strncmp(prop, type, strlen(type)) == 0) + return 1; } return 0;