2018-05-25 17:48:28

by Ivan Bornyakov

[permalink] [raw]
Subject: [PATCH] atm: zatm: fix memcmp casting

memcmp() returns int, but eprom_try_esi() cast it to unsigned char. One
can lose significant bits and get 0 from non-0 value returned by the
memcmp().

Signed-off-by: Ivan Bornyakov <[email protected]>
---
drivers/atm/zatm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
index 9c9a22958717..a8d2eb0ceb8d 100644
--- a/drivers/atm/zatm.c
+++ b/drivers/atm/zatm.c
@@ -1151,8 +1151,8 @@ static void eprom_get_byte(struct zatm_dev *zatm_dev, unsigned char *byte,
}


-static unsigned char eprom_try_esi(struct atm_dev *dev, unsigned short cmd,
- int offset, int swap)
+static int eprom_try_esi(struct atm_dev *dev, unsigned short cmd, int offset,
+ int swap)
{
unsigned char buf[ZEPROM_SIZE];
struct zatm_dev *zatm_dev;
--
2.16.1



2018-05-29 14:01:41

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] atm: zatm: fix memcmp casting

From: Ivan Bornyakov <[email protected]>
Date: Fri, 25 May 2018 20:49:52 +0300

> memcmp() returns int, but eprom_try_esi() cast it to unsigned char. One
> can lose significant bits and get 0 from non-0 value returned by the
> memcmp().
>
> Signed-off-by: Ivan Bornyakov <[email protected]>

Applied, thanks.