Bug 229721 - src/sys/arm64/rockchip/rk_pinctrl.c:354: poor error checking ?
Summary: src/sys/arm64/rockchip/rk_pinctrl.c:354: poor error checking ?
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: arm (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Mitchell Horne
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-12 10:56 UTC by David Binderman
Modified: 2024-06-27 17:58 UTC (History)
5 users (show)

See Also:


Attachments
Make bias variable signed (726 bytes, patch)
2024-03-01 21:51 UTC, John F. Carr
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2018-07-12 10:56:56 UTC
src/sys/arm64/rockchip/rk_pinctrl.c:354]: (style) Unsigned variable 'bias' can't be negative so it is unnecessary to test it.

Source code is

        bias = rk_pinctrl_parse_bias(pin_conf);
        if (bias >= 0) {

but bias is unsigned and the return type of the function is int.

Suggest sanity check return value from function *before* writing
it into an unsigned variable.
Comment 1 John F. Carr 2024-03-01 21:51:24 UTC
Created attachment 248859 [details]
Make bias variable signed
Comment 2 commit-hook freebsd_committer freebsd_triage 2024-06-14 16:43:07 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=97ab935d566c85458bc7cab99c402f026d704eff

commit 97ab935d566c85458bc7cab99c402f026d704eff
Author:     John F. Carr <jfc@mit.edu>
AuthorDate: 2024-06-14 16:37:06 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2024-06-14 16:42:27 +0000

    rk_pinctrl: fix error check

    The parse_bias method returns a signed int, with a value of -1 when
    the device tree reports nothing of the bias configuration. Convert the
    local 'bias' from unsigned to signed to properly check this condition.

    PR:             229721
    Reviewed by:    mhorne
    MFC after:      3 days

 sys/arm64/rockchip/rk_pinctrl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2024-06-27 17:57:38 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=53a64a0938241869b7dc657c5bf30e3bde1879c2

commit 53a64a0938241869b7dc657c5bf30e3bde1879c2
Author:     John F. Carr <jfc@mit.edu>
AuthorDate: 2024-06-14 16:37:06 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2024-06-27 17:56:23 +0000

    rk_pinctrl: fix error check

    The parse_bias method returns a signed int, with a value of -1 when
    the device tree reports nothing of the bias configuration. Convert the
    local 'bias' from unsigned to signed to properly check this condition.

    PR:             229721
    Reviewed by:    mhorne
    MFC after:      3 days

    (cherry picked from commit 97ab935d566c85458bc7cab99c402f026d704eff)

 sys/arm64/rockchip/rk_pinctrl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)