Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751633AbcLDK7i (ORCPT ); Sun, 4 Dec 2016 05:59:38 -0500 Received: from m50-135.163.com ([123.125.50.135]:46394 "EHLO m50-135.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750881AbcLDK7h (ORCPT ); Sun, 4 Dec 2016 05:59:37 -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: qed: set error code on failure Date: Sun, 4 Dec 2016 18:59:00 +0800 Message-Id: <1480849140-16166-1-git-send-email-bianpan201603@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: D9GowACXvfLz9kNYYhgrIQ--.11068S3 X-Coremail-Antispam: 1Uf129KBjvdXoW7Wr1UXrWUCFy5Xr1xAF1fZwb_yoWDWFX_WF W8Z3Wfuw1rJrZ0kw43JrZrX3sYgFyDur1rZry7t34aq347Cw1DZrn2vrykJFW8u3yxAFyD Grn3Ja4UCw1jyjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUYA73DUUUUU== X-Originating-IP: [114.243.30.33] X-CM-SenderInfo: held01tdqsiiqwqtqiywtou0bp/xtbBohc291aDq2kS3gAAsv 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