public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gigaset: gigaset_isowbuf_getbytes() may return signed unnoticed
@ 2008-04-23 21:27 Roel Kluin
  2008-04-25  9:29 ` Tilman Schmidt
  0 siblings, 1 reply; 3+ messages in thread
From: Roel Kluin @ 2008-04-23 21:27 UTC (permalink / raw)
  To: hjlipp, tilman; +Cc: gigaset307x-common, lkml

ifd->offset is unsigned. gigaset_isowbuf_getbytes() may return signed unnoticed

Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
---
diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c
index 5255b5e..c97479b 100644
--- a/drivers/isdn/gigaset/bas-gigaset.c
+++ b/drivers/isdn/gigaset/bas-gigaset.c
@@ -1050,9 +1050,9 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
 		}
 
 		/* retrieve block of data to send */
-		ifd->offset = gigaset_isowbuf_getbytes(ubc->isooutbuf,
-						       ifd->length);
-		if (ifd->offset < 0) {
+		rc = gigaset_isowbuf_getbytes(ubc->isooutbuf, ifd->length);
+		ifd->offset = rc;
+		if (rc < 0) {
 			if (ifd->offset == -EBUSY) {
 				gig_dbg(DEBUG_ISO,
 					"%s: buffer busy at frame %d",

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] gigaset: gigaset_isowbuf_getbytes() may return signed unnoticed
  2008-04-23 21:27 [PATCH] gigaset: gigaset_isowbuf_getbytes() may return signed unnoticed Roel Kluin
@ 2008-04-25  9:29 ` Tilman Schmidt
  0 siblings, 0 replies; 3+ messages in thread
From: Tilman Schmidt @ 2008-04-25  9:29 UTC (permalink / raw)
  To: Roel Kluin; +Cc: hjlipp, gigaset307x-common, lkml

[-- Attachment #1: Type: text/plain, Size: 1195 bytes --]

Am 23.04.2008 23:27 schrieb Roel Kluin:
> ifd->offset is unsigned. gigaset_isowbuf_getbytes() may return signed unnoticed

Thanks, good catch. I wonder why neither sparse nor gcc emitted
a warning for that.

> --- a/drivers/isdn/gigaset/bas-gigaset.c
> +++ b/drivers/isdn/gigaset/bas-gigaset.c
> @@ -1050,9 +1050,9 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
>  		}
>  
>  		/* retrieve block of data to send */
> -		ifd->offset = gigaset_isowbuf_getbytes(ubc->isooutbuf,
> -						       ifd->length);
> -		if (ifd->offset < 0) {
> +		rc = gigaset_isowbuf_getbytes(ubc->isooutbuf, ifd->length);
> +		ifd->offset = rc;
> +		if (rc < 0) {
>  			if (ifd->offset == -EBUSY) {
>  				gig_dbg(DEBUG_ISO,
>  					"%s: buffer busy at frame %d",

Please, also replace ifd->offset by rc in the body of the "if (rc < 0)"
and put the assignment to ifd->offset behind it so that it is only done
if rc >= 0. (Frame *ifd is not used in the < 0 case.)

Thanks,
Tilman

-- 
Tilman Schmidt                    E-Mail: tilman@imap.cc
Bonn, Germany
Diese Nachricht besteht zu 100% aus wiederverwerteten Bits.
Ungeöffnet mindestens haltbar bis: (siehe Rückseite)


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] gigaset: gigaset_isowbuf_getbytes() may return signed unnoticed
@ 2008-05-10 17:52 Tilman Schmidt
  0 siblings, 0 replies; 3+ messages in thread
From: Tilman Schmidt @ 2008-05-10 17:52 UTC (permalink / raw)
  To: Andrew Morton, Linux Kernel Mailing List,
	ISDN4Linux Developer Mailing List
  Cc: Hansjoerg Lipp, Roel Kluin

ifd->offset is unsigned. gigaset_isowbuf_getbytes() may return signed unnoticed.
Revised version of patch originally submitted by Roel Kluin <12o3l@tiscali.nl>.

Signed-off-by: Tilman Schmidt <tilman@imap.cc>
---
 drivers/isdn/gigaset/bas-gigaset.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c
index 5255b5e..3f11910 100644
--- a/drivers/isdn/gigaset/bas-gigaset.c
+++ b/drivers/isdn/gigaset/bas-gigaset.c
@@ -1050,10 +1050,9 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
 		}
 
 		/* retrieve block of data to send */
-		ifd->offset = gigaset_isowbuf_getbytes(ubc->isooutbuf,
-						       ifd->length);
-		if (ifd->offset < 0) {
-			if (ifd->offset == -EBUSY) {
+		rc = gigaset_isowbuf_getbytes(ubc->isooutbuf, ifd->length);
+		if (rc < 0) {
+			if (rc == -EBUSY) {
 				gig_dbg(DEBUG_ISO,
 					"%s: buffer busy at frame %d",
 					__func__, nframe);
@@ -1062,11 +1061,12 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
 			} else {
 				dev_err(ucx->bcs->cs->dev,
 					"%s: buffer error %d at frame %d\n",
-					__func__, ifd->offset, nframe);
-				return ifd->offset;
+					__func__, rc, nframe);
+				return rc;
 			}
 			break;
 		}
+		ifd->offset = rc;
 		ucx->limit = ubc->isooutbuf->nextread;
 		ifd->status = 0;
 		ifd->actual_length = 0;
-- 
1.5.4.7.gd8534-dirty


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-05-10 17:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-23 21:27 [PATCH] gigaset: gigaset_isowbuf_getbytes() may return signed unnoticed Roel Kluin
2008-04-25  9:29 ` Tilman Schmidt
  -- strict thread matches above, loose matches on Subject: below --
2008-05-10 17:52 Tilman Schmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox