Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3904265pxp; Tue, 15 Mar 2022 08:31:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzN+InYqFMCN5tJgocPNkCOWMMXzkHUEbkNOEaevnmmRTD4zNVcrH5UYmbOcLK/zdPNmwWU X-Received: by 2002:a17:906:358e:b0:6cf:61dd:5a1f with SMTP id o14-20020a170906358e00b006cf61dd5a1fmr23712844ejb.416.1647358262907; Tue, 15 Mar 2022 08:31:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647358262; cv=none; d=google.com; s=arc-20160816; b=rJ/rtxwLlIWrT0w1uT0QlRcyCrhy7qqXu4WAhP6f8x2CjyayVX6C7pBT4kPBR5Vbx3 OllZb5SLFyJ1k8pw8ECfZXckMezTdO8mknRofYH7A2p0xSk1LMbe1W42CYm6X6iozLZ6 NEQ2RbpJvoih8TZqrbuxk2rbWDG/AOL65bkePfNYfsxdRRCuP1ILZhWjHsfo4uDVdpUE e2SEvn3AsBK6tR0XTAkBC4JHDo1ktlip+7am1b04qhZGnRqRaoSWhfMyoBtLX3M2UsDC 6eSxLiS6uF1H+rEUr50P/CM4wa0fVyc4lyVeU129UK1N7zNYLSQRubgjgDe2gDX1f9SJ i1pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nOKaR+VLV2TLFPdyeJzC5YvE8rv8DbSpy8RsR0g8r4Y=; b=O74BhmesBM7TEXRbhXbTshtYoh+Gh1fFtSWH2Co8emaKPje2iufUeVesFvDwbOOtmu waLKwDnT8I0FXU3b3PATom8yAiwUo01xRxeQWetkk8S4oIbeBGmmM7e9b/W2wiBh6lJG e1vZIg4wK1XUhDThwJzrPGEx9E49Ue/TlMRBgZfQd6oGTmz7CYcvPc9f72LozI36q3WJ DmVMJfhjbHECKKZWcKvzJHWAKfG1yLCRsYsA/7OUmzRH7sqY3zuqDQoYJppoXo5qMXtK CGNtAkWexrGh62OcFSSLvmQljrMXmgXrC0IllYtjyA1YJUXNn5F+MzeL109sJSYX69vT k0vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xB+pUNgG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb24-20020a1709071c9800b006db56212c50si12450826ejc.461.2022.03.15.08.30.35; Tue, 15 Mar 2022 08:31:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xB+pUNgG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239431AbiCNLkV (ORCPT + 99 others); Mon, 14 Mar 2022 07:40:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239521AbiCNLjU (ORCPT ); Mon, 14 Mar 2022 07:39:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6678428E1B; Mon, 14 Mar 2022 04:37:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5ABF3B80DBA; Mon, 14 Mar 2022 11:37:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27759C340E9; Mon, 14 Mar 2022 11:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647257871; bh=DsABKZppagdsIxtu2uNyGEkaxNybt0ogdt4Q4cKUIe4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xB+pUNgG/LrSWHmud8vjDLu+c8Chv+ztOauC0cWuenQGI1fn5TT47lU+MRyDClNcy n1CD1ntlX/ORM60NiMDqkcCggI3+yrHoA4pIZTYHd8lgrc8MKIpUStIDLKGYnb8Bof 4bucA0etfwK8PF4aTsV/L4UwY/xe24jc0mVJ6etI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, TOTE Robot , Jia-Ju Bai , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 01/30] net: qlogic: check the return value of dma_alloc_coherent() in qed_vf_hw_prepare() Date: Mon, 14 Mar 2022 12:34:19 +0100 Message-Id: <20220314112731.828619993@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220314112731.785042288@linuxfoundation.org> References: <20220314112731.785042288@linuxfoundation.org> User-Agent: quilt/0.66 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jia-Ju Bai [ Upstream commit e0058f0fa80f6e09c4d363779c241c45a3c56b94 ] The function dma_alloc_coherent() in qed_vf_hw_prepare() can fail, so its return value should be checked. Fixes: 1408cc1fa48c ("qed: Introduce VFs") Reported-by: TOTE Robot Signed-off-by: Jia-Ju Bai Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/qlogic/qed/qed_vf.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/ethernet/qlogic/qed/qed_vf.c b/drivers/net/ethernet/qlogic/qed/qed_vf.c index 93a0fbf6a132..e12338abaf0a 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_vf.c +++ b/drivers/net/ethernet/qlogic/qed/qed_vf.c @@ -539,6 +539,9 @@ int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn) p_iov->bulletin.size, &p_iov->bulletin.phys, GFP_KERNEL); + if (!p_iov->bulletin.p_virt) + goto free_pf2vf_reply; + DP_VERBOSE(p_hwfn, QED_MSG_IOV, "VF's bulletin Board [%p virt 0x%llx phys 0x%08x bytes]\n", p_iov->bulletin.p_virt, @@ -578,6 +581,10 @@ int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn) return rc; +free_pf2vf_reply: + dma_free_coherent(&p_hwfn->cdev->pdev->dev, + sizeof(union pfvf_tlvs), + p_iov->pf2vf_reply, p_iov->pf2vf_reply_phys); free_vf2pf_request: dma_free_coherent(&p_hwfn->cdev->pdev->dev, sizeof(union vfpf_tlvs), -- 2.34.1