From patchwork Fri Apr 5 23:55:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13619591 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (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 7563C374D3 for ; Fri, 5 Apr 2024 23:55:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712361333; cv=none; b=QQarlS6XsQ3SNgylLjMTSt6ngoFsCvEsfl/kLucz/yWn1G8FNt1Vw8Sc92P6Xg944JC+epYsp3vwHUuI3zpfGqjiuCkALZGj2CE/t3gieysLvmUdaoz/oRTluPzG6lYY0uqG01vWWA5bs4wqgWn7EDEo80RW04c5IUlcyOvoZ94= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712361333; c=relaxed/simple; bh=7xPlnYSjrmpNj6g5vLJQTqeTr8k5/AjwUO3thQOm7QE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=pIxWf4kBhScmy/vqQSVkSBXNZD99cFJBfJAw+0cJuvwyfcXnhgF2WFtzm2WsmAQZUaCPIwHHeoff3dBJfm/+4PcJluCpOjM+L1Vf+Gopx1PeRfW/R8ZF/dGa7ziyyxKLBv8j2RyfdQR2lMF7G8wElvvjblT0UvJIg0InnfV/ZUE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=FsG1zIns; arc=none smtp.client-ip=209.85.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="FsG1zIns" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6ecfeefe94cso878897b3a.0 for ; Fri, 05 Apr 2024 16:55:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1712361330; x=1712966130; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=2WCC3IJqhv4SmaSMsO3I3VSMes2xHhZ2xVHKQJWcwgE=; b=FsG1zInsuU1bG7wvuGDClSrtAEgoZPSXkISvFxv2Jpt6a9DUd+GHdIoO6jWoJAYReL zWrpMF++8valsrmenM7l0ic3mQvu/y4jbZGeh3a0G5xnfh8a1yJqvEWfCxQhfB4VWq4u XAgUzcyOekYb/mpm2pbckMnsiljkxEsoxImCQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712361330; x=1712966130; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2WCC3IJqhv4SmaSMsO3I3VSMes2xHhZ2xVHKQJWcwgE=; b=MTyL7xhEOlCybxrqUqxkLb0xjNtwSNrLG50LaU3qMzc2KKI6CkpudhWTfaTPBd1yyA kLnS7pf+2/PfecwLckiwvN47p/VE53k5Y0fpQ5wF43RDrdgRTo+cUr2OuP6bPvB0cZn5 rnVlMzBz8FmGFYWnCVNqXFQdoADdUsliQLb+Uclro9QWOuqPFHSHcI7Z6AD44kTlHWs/ oTzvhC9O+6xTE7d5glhygLQG/TD8qKGs3XYbLvBzx7/bOcL84s/Cibm6oVj4lHx+RnHB lI8xpZbYFRDapCYSDqLs2lpTAAwDKnawSA3TEySM048f1StaRa590sjOhpJV5xE9Avv1 fW4w== X-Gm-Message-State: AOJu0YwdvIElSWaPir+d/jbxLgnD9J4SDYxn4CWB05EHBxhhqix6mTS2 eat3BujKU5yP9Hp1gaM6eitL8TkVZtXbbeUizbMU9NrOe27sL9r5DZdXd4o9Pw== X-Google-Smtp-Source: AGHT+IHmcheZ6GpqlQcuBe4tjBorOKcpy9N46GkWMRznIDYD/lSgTuO9wjGsorS4Y19P39ubAeqV9Q== X-Received: by 2002:a05:6a00:1490:b0:6ec:fc97:81a with SMTP id v16-20020a056a00149000b006ecfc97081amr4021368pfu.3.1712361329788; Fri, 05 Apr 2024 16:55:29 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id it24-20020a056a00459800b006ea81423c65sm2162078pfb.148.2024.04.05.16.55.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Apr 2024 16:55:28 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, Vikas Gupta Subject: [PATCH net 1/3] bnxt_en: Fix possible memory leak in bnxt_rdma_aux_device_init() Date: Fri, 5 Apr 2024 16:55:11 -0700 Message-Id: <20240405235513.64668-2-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240405235513.64668-1-michael.chan@broadcom.com> References: <20240405235513.64668-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Vikas Gupta If ulp = kzalloc() fails, the allocated edev will leak because it is not properly assigned and the cleanup path will not be able to free it. Fix it by assigning it properly immediately after allocation. Fixes: 303432211324 ("bnxt_en: Remove runtime interrupt vector allocation") Reviewed-by: Andy Gospodarek Signed-off-by: Vikas Gupta Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c index 93f9bd55020f..a5f9c9090a6b 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c @@ -392,12 +392,13 @@ void bnxt_rdma_aux_device_init(struct bnxt *bp) if (!edev) goto aux_dev_uninit; + aux_priv->edev = edev; + ulp = kzalloc(sizeof(*ulp), GFP_KERNEL); if (!ulp) goto aux_dev_uninit; edev->ulp_tbl = ulp; - aux_priv->edev = edev; bp->edev = edev; bnxt_set_edev_info(edev, bp);