On Fri, Oct 02, 2015 at 02:37:18PM +0200, Benjamin Baier wrote:
> Fix memory leak in error path.
> Found by llvm/scan-build.
Thanks, I've just committed this.
>
> Also port (sc->sc_ports[port]) was not assigned, so "goto freeport;"
> seems wrong.
>
> Index: ahci.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/ic/ahci.c,v
> retrieving revision 1.22
> diff -u -p -r1.22 ahci.c
> --- ahci.c 27 Aug 2015 18:47:29 -0000 1.22
> +++ ahci.c 26 Sep 2015 09:29:57 -0000
> @@ -460,7 +460,8 @@ ahci_port_alloc(struct ahci_softc *sc, u
> if (ap->ap_err_scratch == NULL) {
> printf("%s: unable to allocate DMA scratch buf for port %d\n",
> DEVNAME(sc), port);
> - goto freeport;
> + free(ap, M_DEVBUF, sizeof(*ap));
> + goto reterr;
> }
>
> #ifdef AHCI_DEBUG
>