* [PATCH -next] usb: typec: mux: Fix unsigned comparison with less than zero
@ 2019-02-19 6:57 ` YueHaibing
0 siblings, 0 replies; 4+ messages in thread
From: YueHaibing @ 2019-02-19 6:57 UTC (permalink / raw)
To: heikki.krogerus, gregkh; +Cc: linux-kernel, linux-usb, YueHaibing
The return from the call to fwnode_property_read_u16_array is int,
it can be a negative error code however this is being assigned to
an size_t variable 'nval', hence the check is always false.
Fix this by making 'nval' an int.
Detected by Coccinelle ("Unsigned expression compared with
zero: nval < 0")
Fixes: 96a6d031ca99 ("usb: typec: mux: Find the muxes by also matching against the device node")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
drivers/usb/typec/mux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c
index a5947d9..54d7497 100644
--- a/drivers/usb/typec/mux.c
+++ b/drivers/usb/typec/mux.c
@@ -126,7 +126,7 @@ static void *typec_mux_match(struct device_connection *con, int ep, void *data)
{
const struct typec_altmode_desc *desc = data;
struct typec_mux *mux;
- size_t nval;
+ int nval;
bool match;
u16 *val;
int i;
--
2.7.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [-next] usb: typec: mux: Fix unsigned comparison with less than zero
@ 2019-02-19 6:57 ` YueHaibing
0 siblings, 0 replies; 4+ messages in thread
From: YueHaibing @ 2019-02-19 6:57 UTC (permalink / raw)
To: heikki.krogerus, gregkh; +Cc: linux-kernel, linux-usb, YueHaibing
The return from the call to fwnode_property_read_u16_array is int,
it can be a negative error code however this is being assigned to
an size_t variable 'nval', hence the check is always false.
Fix this by making 'nval' an int.
Detected by Coccinelle ("Unsigned expression compared with
zero: nval < 0")
Fixes: 96a6d031ca99 ("usb: typec: mux: Find the muxes by also matching against the device node")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
drivers/usb/typec/mux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c
index a5947d9..54d7497 100644
--- a/drivers/usb/typec/mux.c
+++ b/drivers/usb/typec/mux.c
@@ -126,7 +126,7 @@ static void *typec_mux_match(struct device_connection *con, int ep, void *data)
{
const struct typec_altmode_desc *desc = data;
struct typec_mux *mux;
- size_t nval;
+ int nval;
bool match;
u16 *val;
int i;
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH -next] usb: typec: mux: Fix unsigned comparison with less than zero
@ 2019-02-19 7:48 ` Heikki Krogerus
0 siblings, 0 replies; 4+ messages in thread
From: Heikki Krogerus @ 2019-02-19 7:48 UTC (permalink / raw)
To: YueHaibing; +Cc: gregkh, linux-kernel, linux-usb
On Tue, Feb 19, 2019 at 02:57:50PM +0800, YueHaibing wrote:
> The return from the call to fwnode_property_read_u16_array is int,
> it can be a negative error code however this is being assigned to
> an size_t variable 'nval', hence the check is always false.
> Fix this by making 'nval' an int.
>
> Detected by Coccinelle ("Unsigned expression compared with
> zero: nval < 0")
>
> Fixes: 96a6d031ca99 ("usb: typec: mux: Find the muxes by also matching against the device node")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/typec/mux.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c
> index a5947d9..54d7497 100644
> --- a/drivers/usb/typec/mux.c
> +++ b/drivers/usb/typec/mux.c
> @@ -126,7 +126,7 @@ static void *typec_mux_match(struct device_connection *con, int ep, void *data)
> {
> const struct typec_altmode_desc *desc = data;
> struct typec_mux *mux;
> - size_t nval;
> + int nval;
> bool match;
> u16 *val;
> int i;
thanks,
--
heikki
^ permalink raw reply [flat|nested] 4+ messages in thread
* [-next] usb: typec: mux: Fix unsigned comparison with less than zero
@ 2019-02-19 7:48 ` Heikki Krogerus
0 siblings, 0 replies; 4+ messages in thread
From: Heikki Krogerus @ 2019-02-19 7:48 UTC (permalink / raw)
To: YueHaibing; +Cc: gregkh, linux-kernel, linux-usb
On Tue, Feb 19, 2019 at 02:57:50PM +0800, YueHaibing wrote:
> The return from the call to fwnode_property_read_u16_array is int,
> it can be a negative error code however this is being assigned to
> an size_t variable 'nval', hence the check is always false.
> Fix this by making 'nval' an int.
>
> Detected by Coccinelle ("Unsigned expression compared with
> zero: nval < 0")
>
> Fixes: 96a6d031ca99 ("usb: typec: mux: Find the muxes by also matching against the device node")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/typec/mux.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c
> index a5947d9..54d7497 100644
> --- a/drivers/usb/typec/mux.c
> +++ b/drivers/usb/typec/mux.c
> @@ -126,7 +126,7 @@ static void *typec_mux_match(struct device_connection *con, int ep, void *data)
> {
> const struct typec_altmode_desc *desc = data;
> struct typec_mux *mux;
> - size_t nval;
> + int nval;
> bool match;
> u16 *val;
> int i;
thanks,
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-02-19 7:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-19 6:57 [PATCH -next] usb: typec: mux: Fix unsigned comparison with less than zero YueHaibing
2019-02-19 6:57 ` [-next] " YueHaibing
2019-02-19 7:48 ` [PATCH -next] " Heikki Krogerus
2019-02-19 7:48 ` [-next] " Heikki Krogerus
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.