Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp700059lqo; Wed, 8 May 2024 11:59:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUaFvq+oH2WBMlZVRj4jKbQGmQpZiQxhyuLfJztcAhwz5iCvIHGallAFLCUxreo8KbNe8EKDbJKwYW7riHnAPnqGraJGEAHW/DWYYKcoQ== X-Google-Smtp-Source: AGHT+IGK6+Cs1NwVtgQw9Mh0kWzlK9O60aeZiYhP0A3GiuyCt6XOGSa3NPQRLf0Mdmqg7QXiuypr X-Received: by 2002:a05:622a:494:b0:43a:a82d:4fa with SMTP id d75a77b69052e-43dbed1b5f5mr36757731cf.15.1715194769301; Wed, 08 May 2024 11:59:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715194769; cv=pass; d=google.com; s=arc-20160816; b=TiIt9hhMCVQ+xtAwr2yh+4BB4yYT+NCY7HQYcD1DdAByrZ4bpOLfNpXAGGOFWI0Nfv 5Q+//1S0WS8LHfFmNs7+fAlbc8firXKJOesXXjpz+HGge0j6yFbN7OPSA5nWQ7a8I0zs ZcfNB2rg95ddqxan8jVjHd5Gj5/ZIcaTttIhzhIuJgP83pfxKszgaP7GEmm4/5LsA9CQ iYMRSmV8e9U+6dtldPH2iW3w1pGVcmBK4D/yTrAD8FBjCrfuytvTSZv97Siksz6UpXul 3xSEqSZpTu35MqkRvrlK3WumHD88ZP2duvOGsSkwg4nHrAKKdFIi/DmP0TSq1ZeznaYv nUrw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=eFrOIrDzTcMn622VateT75IhKFBfpAyCB1nXrmsjnHc=; fh=LN98oZukT0t42XWtdxZuSL7YwWx38q1kixjLChlt/3c=; b=w18kTu+GQzBqVHlwsIv6tmdr9KgbXz7yI3QCilwHjZUS/C3pJzvC4O4GaCH6+Oiu7G tRodwpfHgwvRrUJUPn1QsT3TxRmfsGTM1E/SXx2pyq+lAmCZDoD7B4uGXO1N3dKQt9EX zDOEEhXID5/6ux8nkmRnoVYFGp2tlStzk+vb2aBDxErvBeDTyAZXnbwPtli0qaMF35iK WoWMsxR9EsGvnKvthEhcFSfs0SU5XXkcRpMh5d9vL16/9UNhs97d02l4EZFIRUIUTzaN io651v4A17xxSvdO2zr/6dgJYOwL9ZMLIMd0YWMkJ4styHYP4GtualghCiqmWYc6s4+w d7fQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-173735-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173735-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id o11-20020ac85a4b000000b0043b0461d941si14736711qta.225.2024.05.08.11.59.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 11:59:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-173735-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-173735-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173735-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0B1731C218C8 for ; Wed, 8 May 2024 18:59:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 19E7612EBFA; Wed, 8 May 2024 18:59:17 +0000 (UTC) Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DDDDF12C464; Wed, 8 May 2024 18:59:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715194756; cv=none; b=W+qP7fjU5bs8uWvg/aDv0q7fnXbn+fHt2sdHXAn7jj7f4v9afzqG+05lI1krDCWhCucBfCVNPUfl9P+T0oQXs4LC2GZybT30cYqrAr86fM5Qw9YVLps7GsH7WnTCwGIjGBzJ57UKQQQn7A30el2ZLnsuSGwQaDIJKkWyJFxm79A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715194756; c=relaxed/simple; bh=bSLgq4FvpeTB8kkbHpmgDPjDvcsz7KxXYPf2zdLXhbE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=NCce4Ldz5dgmyybSyhFm1iuZExaIjAGQZq87DAX2l+qbbbM1/YGHGm88swsA3FE5b7ncmk8da4tYbkfMFKEPUAyg237jdcravRudX33YAs8twKoRtNBHxQAtp69qj2ZYihqZVRo/3x2lP8WWmkesaMzc09Q2/W97xfz3i6+zgbQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-573137ba8d7so2246542a12.0; Wed, 08 May 2024 11:59:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715194753; x=1715799553; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=eFrOIrDzTcMn622VateT75IhKFBfpAyCB1nXrmsjnHc=; b=A+Aj4wEFOeuc/nFRSoBL5uvJPwdxNMvzAXrXL8DVPKKmyVK5st23UEOE0wmV0Evl6A AeihrgEPjAfKzWwYEq4hwIyw7HYPl9u43Dl21PhrWo/bHE/tFBTt+QbMiOrxwY/XgmZ6 FWCYtEzS/dZDLYdKqPS0CUjbGBTa1h2Ny4GA4toLyMUHBVUAlOmjx7z0hMvHwxff60Wl ICPz+GunUI7YJBpxmLyWTN8hTnda4BJ8VRNhYzzWzH0oDobbstQndZlxt1f8TRfPm6sq QfhT5beqTB8Blqov2r3QUH8gzU8D3eaECCtl+SiyP3RDv3thjfyY7HbjLgv0xGW2FDPn jA8A== X-Forwarded-Encrypted: i=1; AJvYcCVIeXjhzS2ua7kAs7E7cOFQKd9gprvmSzs8qBaTcfZeGA5X4D9QJye1F9g1gknkUdz4PvimVG4kDBXr4V+CtmVMc0+nIMGrR7kZUmqxTRcFd4fXA68y+LFkkQQGpyxtY13IgNMoDW5h07RwfvA= X-Gm-Message-State: AOJu0YxboxBGMXDuA2iX21nBrV0TW5eixOCdtSGPQcCiQXMMJ85d1Byv ElW1O0/OtBxcvH8gn2gFsWCZ1UpjOe+QmfriMScrQjo9giOB2PfmtO3fEg== X-Received: by 2002:a50:d50c:0:b0:572:3eaa:a637 with SMTP id 4fb4d7f45d1cf-573326dbfe0mr342070a12.2.1715194753099; Wed, 08 May 2024 11:59:13 -0700 (PDT) Received: from localhost (fwdproxy-lla-006.fbsv.net. [2a03:2880:30ff:6::face:b00c]) by smtp.gmail.com with ESMTPSA id ee53-20020a056402293500b0056fede24155sm7890077edb.89.2024.05.08.11.59.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 11:59:12 -0700 (PDT) From: Breno Leitao To: horms@kernel.org, Kalle Valo , Jeff Johnson , "David S. Miller" Cc: netdev@vger.kernel.org, linux-wireless@vger.kernel.org (open list:NETWORKING DRIVERS (WIRELESS)), ath11k@lists.infradead.org (open list:QUALCOMM ATHEROS ATH11K WIRELESS DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH wireless-next] ath11k: Fix error path in ath11k_pcic_ext_irq_config Date: Wed, 8 May 2024 11:59:01 -0700 Message-ID: <20240508185902.70975-1-leitao@debian.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit If one of the dummy allocation fails in ath11k_pcic_ext_irq_config(), the previous allocated devices might leak due to returning without deallocating the devices. Instead of returning on the error path, deallocate all the previously allocated net_devices and then return. Fixes: bca592ead825 ("wifi: ath11k: allocate dummy net_device dynamically") Signed-off-by: Breno Leitao --- drivers/net/wireless/ath/ath11k/pcic.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/pcic.c b/drivers/net/wireless/ath/ath11k/pcic.c index 79eb3f9c902f..debe7c5919ef 100644 --- a/drivers/net/wireless/ath/ath11k/pcic.c +++ b/drivers/net/wireless/ath/ath11k/pcic.c @@ -561,6 +561,7 @@ static int ath11k_pcic_ext_irq_config(struct ath11k_base *ab) { int i, j, n, ret, num_vectors = 0; u32 user_base_data = 0, base_vector = 0; + struct ath11k_ext_irq_grp *irq_grp; unsigned long irq_flags; ret = ath11k_pcic_get_user_msi_assignment(ab, "DP", &num_vectors, @@ -574,14 +575,16 @@ static int ath11k_pcic_ext_irq_config(struct ath11k_base *ab) irq_flags |= IRQF_NOBALANCING; for (i = 0; i < ATH11K_EXT_IRQ_GRP_NUM_MAX; i++) { - struct ath11k_ext_irq_grp *irq_grp = &ab->ext_irq_grp[i]; + irq_grp = &ab->ext_irq_grp[i]; u32 num_irq = 0; irq_grp->ab = ab; irq_grp->grp_id = i; irq_grp->napi_ndev = alloc_netdev_dummy(0); - if (!irq_grp->napi_ndev) - return -ENOMEM; + if (!irq_grp->napi_ndev) { + ret = -ENOMEM; + goto fail_allocate; + } netif_napi_add(irq_grp->napi_ndev, &irq_grp->napi, ath11k_pcic_ext_grp_napi_poll); @@ -606,11 +609,8 @@ static int ath11k_pcic_ext_irq_config(struct ath11k_base *ab) int irq = ath11k_pcic_get_msi_irq(ab, vector); if (irq < 0) { - for (n = 0; n <= i; n++) { - irq_grp = &ab->ext_irq_grp[n]; - free_netdev(irq_grp->napi_ndev); - } - return irq; + ret = irq; + goto fail_irq; } ab->irq_num[irq_idx] = irq; @@ -635,6 +635,15 @@ static int ath11k_pcic_ext_irq_config(struct ath11k_base *ab) } return 0; +fail_irq: + /* i ->napi_ndev was properly allocated. Free it also */ + i += 1; +fail_allocate: + for (n = 0; n < i; n++) { + irq_grp = &ab->ext_irq_grp[n]; + free_netdev(irq_grp->napi_ndev); + } + return ret; } int ath11k_pcic_config_irq(struct ath11k_base *ab) -- 2.43.0