Tue Sep 18 21:28:22 2018 UTC ()
fix ata_xfer leak on drive probe


(jdolecek)
diff -r1.62 -r1.63 src/sys/dev/ic/ahcisata_core.c

cvs diff -r1.62 -r1.63 src/sys/dev/ic/ahcisata_core.c (expand / switch to unified diff)

--- src/sys/dev/ic/ahcisata_core.c 2018/07/09 10:44:44 1.62
+++ src/sys/dev/ic/ahcisata_core.c 2018/09/18 21:28:22 1.63
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ahcisata_core.c,v 1.62 2018/07/09 10:44:44 kamil Exp $ */ 1/* $NetBSD: ahcisata_core.c,v 1.63 2018/09/18 21:28:22 jdolecek Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006 Manuel Bouyer. 4 * Copyright (c) 2006 Manuel Bouyer.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -16,27 +16,27 @@ @@ -16,27 +16,27 @@
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 * 25 *
26 */ 26 */
27 27
28#include <sys/cdefs.h> 28#include <sys/cdefs.h>
29__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.62 2018/07/09 10:44:44 kamil Exp $"); 29__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.63 2018/09/18 21:28:22 jdolecek Exp $");
30 30
31#include <sys/types.h> 31#include <sys/types.h>
32#include <sys/malloc.h> 32#include <sys/malloc.h>
33#include <sys/param.h> 33#include <sys/param.h>
34#include <sys/kernel.h> 34#include <sys/kernel.h>
35#include <sys/systm.h> 35#include <sys/systm.h>
36#include <sys/disklabel.h> 36#include <sys/disklabel.h>
37#include <sys/proc.h> 37#include <sys/proc.h>
38#include <sys/buf.h> 38#include <sys/buf.h>
39 39
40#include <dev/ata/atareg.h> 40#include <dev/ata/atareg.h>
41#include <dev/ata/satavar.h> 41#include <dev/ata/satavar.h>
42#include <dev/ata/satareg.h> 42#include <dev/ata/satareg.h>
@@ -985,26 +985,28 @@ ahci_probe_drive(struct ata_channel *chp @@ -985,26 +985,28 @@ ahci_probe_drive(struct ata_channel *chp
985 AHCI_WRITE(sc, AHCI_P_IE(chp->ch_channel), 985 AHCI_WRITE(sc, AHCI_P_IE(chp->ch_channel),
986 AHCI_P_IX_TFES | AHCI_P_IX_HBFS | AHCI_P_IX_HBDS | 986 AHCI_P_IX_TFES | AHCI_P_IX_HBFS | AHCI_P_IX_HBDS |
987 AHCI_P_IX_IFS | 987 AHCI_P_IX_IFS |
988 AHCI_P_IX_OFS | AHCI_P_IX_DPS | AHCI_P_IX_UFS | 988 AHCI_P_IX_OFS | AHCI_P_IX_DPS | AHCI_P_IX_UFS |
989 AHCI_P_IX_PSS | AHCI_P_IX_DHRS | AHCI_P_IX_SDBS); 989 AHCI_P_IX_PSS | AHCI_P_IX_DHRS | AHCI_P_IX_SDBS);
990 /* wait 500ms before actually starting operations */ 990 /* wait 500ms before actually starting operations */
991 ata_delay(chp, 500, "ahciprb", AT_WAIT); 991 ata_delay(chp, 500, "ahciprb", AT_WAIT);
992 break; 992 break;
993 993
994 default: 994 default:
995 break; 995 break;
996 } 996 }
997 ata_channel_unlock(chp); 997 ata_channel_unlock(chp);
 998
 999 ata_free_xfer(chp, xfer);
998} 1000}
999 1001
1000static void 1002static void
1001ahci_setup_channel(struct ata_channel *chp) 1003ahci_setup_channel(struct ata_channel *chp)
1002{ 1004{
1003 return; 1005 return;
1004} 1006}
1005 1007
1006static int 1008static int
1007ahci_exec_command(struct ata_drive_datas *drvp, struct ata_xfer *xfer) 1009ahci_exec_command(struct ata_drive_datas *drvp, struct ata_xfer *xfer)
1008{ 1010{
1009 struct ata_channel *chp = drvp->chnl_softc; 1011 struct ata_channel *chp = drvp->chnl_softc;
1010 struct ata_command *ata_c = &xfer->c_ata_c; 1012 struct ata_command *ata_c = &xfer->c_ata_c;