Re: [PATCH v1 1/1] pwm: core: use device_match_name() instead of strcmp(dev_name(...
From: Andy Shevchenko
Date: Fri Oct 25 2024 - 09:04:44 EST
On Thu, Oct 24, 2024 at 10:55:36PM +0200, Uwe Kleine-König wrote:
> On Thu, Oct 24, 2024 at 06:19:05PM +0300, Andy Shevchenko wrote:
...
> > idr_for_each_entry_ul(&pwm_chips, chip, tmp, id) {
> > - const char *chip_name = dev_name(pwmchip_parent(chip));
> > -
> > - if (chip_name && strcmp(chip_name, name) == 0)
> > + if (device_match_name(pwmchip_parent(chip), name))
>
> This theoretically changes behaviour in a few cases. For example if
> dev_name(pwmchip_parent(chip)) is NULL the new code would crash. Can
> this happen?
Please, tell me how
(looking at the of device_add() and kobject_set_name_vargs() implementations)?
Btw, have you ever seen this check somewhere else? (I don't, but I haven't
covered full kernel sources, of course.)
--
With Best Regards,
Andy Shevchenko