Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752745AbcLDGKQ (ORCPT ); Sun, 4 Dec 2016 01:10:16 -0500 Received: from m50-138.163.com ([123.125.50.138]:53613 "EHLO m50-138.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752546AbcLDGKO (ORCPT ); Sun, 4 Dec 2016 01:10:14 -0500 From: Pan Bian To: Yuval Mintz , Ariel Elior , everest-linux-l2@cavium.com, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH 1/1] net: ethernet: qlogic: set error code on failure Date: Sun, 4 Dec 2016 13:53:53 +0800 Message-Id: <1480830833-5084-1-git-send-email-bianpan201603@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: C9GowABn9gdxr0NY_X+5IQ--.41930S3 X-Coremail-Antispam: 1Uf129KBjvdXoW7Wr1UXrWUCFy5Xr1xAF1fZwb_yoWDWFX_WF W8Z3Wfuw1rJrZ0kw43JrZrX3sYgFyDur1rZry7t34aq347Cw1DZrn2vrykJFW8u3yxAFyD Grn3Ja4UCw1jyjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUYdcTDUUUUU== X-Originating-IP: [114.243.30.33] X-CM-SenderInfo: held01tdqsiiqwqtqiywtou0bp/xtbBohM291aDq2dV3gAAsi Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1004 Lines: 30 From: Pan Bian When calling dma_mapping_error(), the value of return variable rc is 0. And when the call returns an unexpected value, rc is not set to a negative errno. Thus, it will return 0 on the error path, and its callers cannot detect the bug. This patch fixes the bug, assigning "-ENOMEM" to err. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=189041 Signed-off-by: Pan Bian --- drivers/net/ethernet/qlogic/qed/qed_ll2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/qlogic/qed/qed_ll2.c b/drivers/net/ethernet/qlogic/qed/qed_ll2.c index f95385c..62ae55b 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_ll2.c +++ b/drivers/net/ethernet/qlogic/qed/qed_ll2.c @@ -1730,6 +1730,7 @@ static int qed_ll2_start_xmit(struct qed_dev *cdev, struct sk_buff *skb) mapping))) { DP_NOTICE(cdev, "Unable to map frag - dropping packet\n"); + rc = -ENOMEM; goto err; } } else { -- 1.9.1