Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp4034640pxp; Tue, 15 Mar 2022 11:03:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywXEYAaHFHoAcH+QZYXRGyhesds6QYfOr3wmxGTVlxkpoIOA5mfKYRFISg6Jefhn5wV8a7 X-Received: by 2002:a17:907:7d8a:b0:6db:3261:d8de with SMTP id oz10-20020a1709077d8a00b006db3261d8demr25258970ejc.239.1647367385720; Tue, 15 Mar 2022 11:03:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647367385; cv=none; d=google.com; s=arc-20160816; b=bvwsryQ6Q+bkWaE1T8X2SdYt+RV4UizwMjnAXuw4rcFXnDd1yH7buQSqcaQb5scGJW lo2jQu3zhVPtupGfJjNJ/gS4zJgsgQR/cV0ldeUvkO0kkvxJJ4OPuZ7K4PIbTIh1ylD9 FiWrkZZHl3bC3Ok3vo1WZnD4x3Y3+aB7rZ+SeQOU8VEbqiGe6Xb6F+qIDx8wMdI6PD8C b1qOLgpeecd//ihNwoJitpGr5RW2LDlBqCYNx4z/a9BCDz1L1wNDwDDD1LavuqFmhNsq 27Us+Torly0iI0d1aVdbuW/vCh+XCHR7mcQZy6FMqj6fLfwNcOV3q5VzbK4eLCek0xJH XtGg== 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=5O7x28za7qcVERkjzTUxGwghb4NQQLnKtep5wa/4JaI=; b=DLTLe0Dbw80rsCECv1++6DoZ3/r5c8sTwxFNTItbLts4T/9wC12AqMhKz1x+0QpGFt otch7kvEcaFGQb6uoREa6TsZyZS0aJUrEcHokJ8+rPKwfxmBUQEiy94ltWnRxOws5ZIf Kd/KXIV2hWKoOCjR6H7888HOumu8B52fsDRItlbnegjG+QAKEdMJfaz4E93zo2Pe5VrG 9frSQMRzKrYElIEy1vT5t9PHsijg3jWrfSMosaTRdcI4wovSmtkSUb8+Dq9QIkESNSQ7 wEqto9G+Yv1oMkFydTGyJXXo7KDPeb/g1ekyTGPBGlh4tTVz7TTC/jNPdSg5b+7SGLw2 p8Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uBdeGiSe; 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 a15-20020a170906190f00b006db7222899csi10497833eje.453.2022.03.15.11.02.37; Tue, 15 Mar 2022 11:03:05 -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=uBdeGiSe; 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 S243239AbiCNMao (ORCPT + 99 others); Mon, 14 Mar 2022 08:30:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242729AbiCNMTb (ORCPT ); Mon, 14 Mar 2022 08:19:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F22950049; Mon, 14 Mar 2022 05:14:37 -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 dfw.source.kernel.org (Postfix) with ESMTPS id D52CA60B19; Mon, 14 Mar 2022 12:14:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB4DEC340EC; Mon, 14 Mar 2022 12:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647260076; bh=NpB9lD05+lxXqHn0huSyZfBLfH7o5TypdNrGMja0yvw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uBdeGiSePD7jqgeGUeZve9UZtf2DdwdjM6L6dQmJ8dc0z064dfpu6s81lIiy/DH6x 3JwpfyGJ0l5isA4xmKlG1tsmzpKGT1/AEVs4xsOy6AwEMS2nsUmB7iEUzMmhlbms4W wf7lsBjVG377pQHsoVQCsaRbh1+9nRvANf0QMVVY= 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 5.16 022/121] net: qlogic: check the return value of dma_alloc_coherent() in qed_vf_hw_prepare() Date: Mon, 14 Mar 2022 12:53:25 +0100 Message-Id: <20220314112744.748629071@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220314112744.120491875@linuxfoundation.org> References: <20220314112744.120491875@linuxfoundation.org> User-Agent: quilt/0.66 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 597cd9cd57b5..7b0e390c0b07 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_vf.c +++ b/drivers/net/ethernet/qlogic/qed/qed_vf.c @@ -513,6 +513,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, @@ -552,6 +555,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