Skip to contentSkip to conversation

gigaset: gigaset_isowbuf_getbytes() may return signed unnoticed

PATCH In review Roel Kluin 2 participants 2 messages Apr 23, 2008 – Apr 25, 2008

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 gigaset: gigaset_isowbuf_getbytes() may return signed unnoticed

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

---

drivers/isdn/gigaset/bas-gigaset.c +3 -3
index 5255b5e..c97479b 100644
@@ -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",
#1 lore raw

Am 23.04.2008 23:27 schrieb Roel Kluin:

Quoted 1 line

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.

Quoted 5 lines
drivers/isdn/gigaset/bas-gigaset.c +0 -0
@@ -1050,9 +1050,9 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
 		}
 

drivers/isdn/gigaset/bas-gigaset.c static int submit_iso_write_urb(struct isow_urbctx_t *ucx) · line 1058

Quoted 10 lines
drivers/isdn/gigaset/bas-gigaset.c +3 -3
 		/* 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

Signature · 4 lines
Tilman Schmidt                    E-Mail: [email protected]
Bonn, Germany
Diese Nachricht besteht zu 100% aus wiederverwerteten Bits.
Ungeöffnet mindestens haltbar bis: (siehe Rückseite)