ChangeSet 1.1006.11.14, 2003/03/19 14:35:42-08:00, wolfgang@iksw-muees.de [PATCH] USB: Memory leak in auerswald driver Oleg Drokin has reported a memory leak in auerbuf.c, which is only exposed under low memory conditions. The appended patch fixes this leak. It is for 2.4.21. drivers/usb/auerbuf.c | 4 +++- drivers/usb/auermain.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff -Nru a/drivers/usb/auerbuf.c b/drivers/usb/auerbuf.c --- a/drivers/usb/auerbuf.c Thu Mar 27 16:01:58 2003 +++ b/drivers/usb/auerbuf.c Thu Mar 27 16:01:58 2003 @@ -28,6 +28,7 @@ /* free a single auerbuf */ void auerbuf_free(struct auerbuf *bp) { + if (!bp) return; kfree(bp->bufp); kfree(bp->dr); if (bp->urbp) { @@ -81,7 +82,7 @@ int auerbuf_setup(struct auerbufctl *bcp, unsigned int numElements, unsigned int bufsize) { - struct auerbuf *bep; + struct auerbuf *bep = NULL; dbg("auerbuf_setup called with %d elements of %d bytes", numElements, bufsize); @@ -113,6 +114,7 @@ bl_fail: /* not enought memory. Free allocated elements */ dbg("auerbuf_setup: no more memory"); + auerbuf_free (bep); auerbuf_free_buffers(bcp); return -ENOMEM; } diff -Nru a/drivers/usb/auermain.c b/drivers/usb/auermain.c --- a/drivers/usb/auermain.c Thu Mar 27 16:01:58 2003 +++ b/drivers/usb/auermain.c Thu Mar 27 16:01:58 2003 @@ -55,7 +55,7 @@ /*-------------------------------------------------------------------*/ /* Version Information */ -#define DRIVER_VERSION "1.2.0" +#define DRIVER_VERSION "1.2.3" #define DRIVER_AUTHOR "Wolfgang Mües " #define DRIVER_DESC "Auerswald PBX/System Telephone usb driver"