* [bug report] bus: ti-sysc: Add handling for clkctrl opt clocks
@ 2018-05-17 12:45 Dan Carpenter
2018-05-17 14:03 ` Tony Lindgren
2018-05-17 22:03 ` Tony Lindgren
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2018-05-17 12:45 UTC (permalink / raw)
To: kernel-janitors
Hello Tony Lindgren,
The patch 09dfe5810762: "bus: ti-sysc: Add handling for clkctrl opt
clocks" from Apr 16, 2018, leads to the following static checker
warning:
drivers/bus/ti-sysc.c:131 sysc_get_one_clock()
error: buffer overflow 'clock_names' 2 <= 9
drivers/bus/ti-sysc.c
120 static int sysc_get_one_clock(struct sysc *ddata, const char *name)
121 {
122 int error, i, index = -ENODEV;
123
124 if (!strncmp(clock_names[SYSC_FCK], name, 3))
125 index = SYSC_FCK;
126 else if (!strncmp(clock_names[SYSC_ICK], name, 3))
127 index = SYSC_ICK;
128
129 if (index < 0) {
130 for (i = SYSC_OPTFCK0; i < SYSC_MAX_CLOCKS; i++) {
131 if (!clock_names[i]) {
^^^^^^^^^^^^^^
This isn't right. The clock_names[] array only has the two elements...
Probably it should be testing ddate->clocks[i]?
132 index = i;
133 break;
134 }
135 }
136 }
137
138 if (index < 0) {
139 dev_err(ddata->dev, "clock %s not added\n", name);
140 return index;
141 }
142
143 ddata->clocks[index] = devm_clk_get(ddata->dev, name);
144 if (IS_ERR(ddata->clocks[index])) {
145 if (PTR_ERR(ddata->clocks[index]) = -ENOENT)
146 return 0;
147
148 dev_err(ddata->dev, "clock get error for %s: %li\n",
149 name, PTR_ERR(ddata->clocks[index]));
150
Should we set ddata->clocks[index] = NULL on this path?
151 return PTR_ERR(ddata->clocks[index]);
152 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [bug report] bus: ti-sysc: Add handling for clkctrl opt clocks
2018-05-17 12:45 [bug report] bus: ti-sysc: Add handling for clkctrl opt clocks Dan Carpenter
@ 2018-05-17 14:03 ` Tony Lindgren
2018-05-17 22:03 ` Tony Lindgren
1 sibling, 0 replies; 3+ messages in thread
From: Tony Lindgren @ 2018-05-17 14:03 UTC (permalink / raw)
To: kernel-janitors
* Dan Carpenter <dan.carpenter@oracle.com> [180517 12:47]:
> Hello Tony Lindgren,
>
> The patch 09dfe5810762: "bus: ti-sysc: Add handling for clkctrl opt
> clocks" from Apr 16, 2018, leads to the following static checker
> warning:
>
> drivers/bus/ti-sysc.c:131 sysc_get_one_clock()
> error: buffer overflow 'clock_names' 2 <= 9
>
> drivers/bus/ti-sysc.c
> 120 static int sysc_get_one_clock(struct sysc *ddata, const char *name)
> 121 {
> 122 int error, i, index = -ENODEV;
> 123
> 124 if (!strncmp(clock_names[SYSC_FCK], name, 3))
> 125 index = SYSC_FCK;
> 126 else if (!strncmp(clock_names[SYSC_ICK], name, 3))
> 127 index = SYSC_ICK;
> 128
> 129 if (index < 0) {
> 130 for (i = SYSC_OPTFCK0; i < SYSC_MAX_CLOCKS; i++) {
> 131 if (!clock_names[i]) {
> ^^^^^^^^^^^^^^
> This isn't right. The clock_names[] array only has the two elements...
> Probably it should be testing ddate->clocks[i]?
Yup so it seems. Will take a look today.
> 143 ddata->clocks[index] = devm_clk_get(ddata->dev, name);
> 144 if (IS_ERR(ddata->clocks[index])) {
> 145 if (PTR_ERR(ddata->clocks[index]) = -ENOENT)
> 146 return 0;
> 147
> 148 dev_err(ddata->dev, "clock get error for %s: %li\n",
> 149 name, PTR_ERR(ddata->clocks[index]));
> 150
>
> Should we set ddata->clocks[index] = NULL on this path?
Maybe yeah. At least if clk_prepare later on fails we want to set it to
either to NULL or error to prevent clk_enable() being called on a failed
clock.
Regards,
Tony
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [bug report] bus: ti-sysc: Add handling for clkctrl opt clocks
2018-05-17 12:45 [bug report] bus: ti-sysc: Add handling for clkctrl opt clocks Dan Carpenter
2018-05-17 14:03 ` Tony Lindgren
@ 2018-05-17 22:03 ` Tony Lindgren
1 sibling, 0 replies; 3+ messages in thread
From: Tony Lindgren @ 2018-05-17 22:03 UTC (permalink / raw)
To: kernel-janitors
* Tony Lindgren <tony@atomide.com> [180517 07:03]:
> * Dan Carpenter <dan.carpenter@oracle.com> [180517 12:47]:
> > 143 ddata->clocks[index] = devm_clk_get(ddata->dev, name);
> > 144 if (IS_ERR(ddata->clocks[index])) {
> > 145 if (PTR_ERR(ddata->clocks[index]) = -ENOENT)
> > 146 return 0;
> > 147
> > 148 dev_err(ddata->dev, "clock get error for %s: %li\n",
> > 149 name, PTR_ERR(ddata->clocks[index]));
> > 150
> >
> > Should we set ddata->clocks[index] = NULL on this path?
>
> Maybe yeah. At least if clk_prepare later on fails we want to set it to
> either to NULL or error to prevent clk_enable() being called on a failed
> clock.
Looks like no need, we're bailing out of the probe anyways on errors.
And the clock_enable/disable calls do IS_ERR_OR_NULL(ddata->clocks[i]).
I'll send out the fix shortly.
Regards,
Tony
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-05-17 22:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-17 12:45 [bug report] bus: ti-sysc: Add handling for clkctrl opt clocks Dan Carpenter
2018-05-17 14:03 ` Tony Lindgren
2018-05-17 22:03 ` Tony Lindgren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).