Skip to contentSkip to conversation

calloc: Fix possible memory leak

PATCH Applied Alexander Shiyan 2 participants 4 messages Oct 21, 2013 – Oct 22, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 calloc: Fix possible memory leak

---
 common/dlmalloc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
common/dlmalloc.c +2 -2
index 7ad368e..b4341fe 100644
@@ -1750,11 +1750,11 @@ void *calloc(size_t n, size_t elem_size)
 	mchunkptr oldtop = top;
 	INTERNAL_SIZE_T oldtopsize = chunksize(top);
 
-	void *mem = malloc(sz);
-
 	if ((long)n < 0)
 		return NULL;
 
+	void *mem = malloc(sz);
+
 	if (!mem)
 		return NULL;
 	else {
Signature · 7 lines
1.8.1.5


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 2/3 gadget: at91: Fix uninitialized variable

Variable udc is used unitialized for DBG(xxx).

---
 drivers/usb/gadget/at91_udc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/gadget/at91_udc.c +2 -2
index a11379c..acd9e44 100644
@@ -414,6 +414,8 @@ static int at91_ep_queue(struct usb_ep *_ep,
 	req = container_of(_req, struct at91_request, req);
 	ep = container_of(_ep, struct at91_ep, ep);
 
+	udc = ep->udc;
+
 	if (!_req || !_req->complete
 			|| !_req->buf || !list_empty(&req->queue)) {
 		DBG(udc, "invalid request\n");
@@ -425,8 +427,6 @@ static int at91_ep_queue(struct usb_ep *_ep,
 		return -EINVAL;
 	}
 
-	udc = ep->udc;
-
 	if (!udc || !udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) {
 		DBG(udc, "invalid device\n");
 		return -EINVAL;
Signature · 7 lines
1.8.1.5


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 3/3 ubifs: Remove redundant assignment

In reply to Alexander Shiyan
---
 fs/ubifs/recovery.c | 1 -
 fs/ubifs/scan.c     | 1 -
 2 files changed, 2 deletions(-)
fs/ubifs/recovery.c +0 -1
index df7262f..634ecb3 100644
@@ -392,7 +392,6 @@ static void clean_buf(const struct ubifs_info *c, void **buf, int lnum,
 {
 	int empty_offs, pad_len;
 
-	lnum = lnum;
 	dbg_rcvry("cleaning corruption at %d:%d", lnum, *offs);
 
 	if (c->min_io_size == 1) {
fs/ubifs/scan.c +0 -1
index 0ed8247..633a56f 100644
@@ -175,7 +175,6 @@ struct ubifs_scan_leb *ubifs_start_scan(const struct ubifs_info *c, int lnum,
 void ubifs_end_scan(const struct ubifs_info *c, struct ubifs_scan_leb *sleb,
 		    int lnum, int offs)
 {
-	lnum = lnum;
 	dbg_scan("stop scanning LEB %d at offset %d", lnum, offs);
 	ubifs_assert(offs % c->min_io_size == 0);
 
Signature · 7 lines
1.8.1.5


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#3 lore raw
In reply to Alexander Shiyan
Quoted 2 lines · Alexander Shiyan

Applied all, thanks

Sascha

Quoted 31 lines
---
 common/dlmalloc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
common/dlmalloc.c +2 -2
index 7ad368e..b4341fe 100644
@@ -1750,11 +1750,11 @@ void *calloc(size_t n, size_t elem_size)
 	mchunkptr oldtop = top;
 	INTERNAL_SIZE_T oldtopsize = chunksize(top);
 
-	void *mem = malloc(sz);
-
 	if ((long)n < 0)
 		return NULL;
 
+	void *mem = malloc(sz);
+
 	if (!mem)
 		return NULL;
 	else {
Signature · 7 lines
1.8.1.5


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox