From patchwork Mon Oct 31 13:02:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Changzhong X-Patchwork-Id: 13261 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2290229wru; Mon, 31 Oct 2022 05:43:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5GDmj9rdh7fWnzvuG3xpS/BXTAtkj5Vko5HJduKUKByeTB/24UTeO1HVYmwoBfhQJu1mxX X-Received: by 2002:a17:90b:3b8d:b0:20d:5c7a:abf1 with SMTP id pc13-20020a17090b3b8d00b0020d5c7aabf1mr15102555pjb.118.1667220192164; Mon, 31 Oct 2022 05:43:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667220192; cv=none; d=google.com; s=arc-20160816; b=I4OEY7WzZs9upXO/RqT/IfqgkDauVy3p7Jhxz3dRvCsbwMfoZp5Swqi6n5qtyo2I2w YslfJwq+Re9ZACfoKwbqDpoxrCrTS2HMHy/oPj28qnLvL3jVK0j0SdJTrKbz1j8qZWjc gnoWgkznZwWPK7ZZN13F+eyKRAOjv+aOMuLJBv5026KCWq3h5WrgeQ7dGANUquM3qYG5 VWCYe4ODpdKkrCa5CqoLeGs5DtkIbK5mV8pIsNnmwcTfLG+0BsDeqUo9ZxW1SOBlNuQD pDQ6BSu02pgyRteX68qBDXLkUq0eg3c6jQ4SOUX7ulmX7ERkvDnEPYosvQLJkO57Xb0+ tg4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=6htU0tTWIwHQv9j4sfW/CZN9rTFdCZEIugSygW2attI=; b=UaOQUjmJFfAPUQ5zCNnZdaBW4bHKX/mmT6Pb4OH9J7J6CXUDBPykRJqdn7vbUAOmgt urABxTHtoY/KsebGcnAVCifBDxXG/BIZ+XL5uZwcZnA93QQU8BYCf6pZ0g7HWKFTcj/b o/HOjpofFUzhrs9Mqs2pcNZwU1D3V4iGz12sTYaUTQGk5YAKTDFPP4is8f+yKtMPOJjB 6h9phzVLg0utx9S/FYZVb9M8gwrkpg+7CdyiYoWu/OO9dU+eDuFgNfEEludwu7mEll9r PIfWt/PTIatG5DJGiKjWTavlfSgXeXzPJsb4GqkIM8CJvhPNBSLoHxNp76lMNQUJXTnE yvpw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ls7-20020a17090b350700b001fde53d5d79si10310624pjb.5.2022.10.31.05.42.56; Mon, 31 Oct 2022 05:43:12 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231154AbiJaMmU (ORCPT + 99 others); Mon, 31 Oct 2022 08:42:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230249AbiJaMmS (ORCPT ); Mon, 31 Oct 2022 08:42:18 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C7157673; Mon, 31 Oct 2022 05:42:17 -0700 (PDT) Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4N1CPc2ljqzpW2h; Mon, 31 Oct 2022 20:38:44 +0800 (CST) Received: from dggpeml500006.china.huawei.com (7.185.36.76) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 31 Oct 2022 20:42:15 +0800 Received: from localhost.localdomain (10.175.112.70) by dggpeml500006.china.huawei.com (7.185.36.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 31 Oct 2022 20:42:14 +0800 From: Zhang Changzhong To: Thomas Bogendoerfer , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jeff Garzik , Finn Thain CC: Zhang Changzhong , , Subject: [PATCH net] net/sonic: use dma_mapping_error() for error check Date: Mon, 31 Oct 2022 21:02:02 +0800 Message-ID: <1667221322-8317-1-git-send-email-zhangchangzhong@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.175.112.70] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpeml500006.china.huawei.com (7.185.36.76) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748207080076350629?= X-GMAIL-MSGID: =?utf-8?q?1748207080076350629?= The DMA address returned by dma_map_single() should be checked with dma_mapping_error(). Fix it accordingly. Fixes: efcce839360f ("[PATCH] macsonic/jazzsonic network drivers update") Signed-off-by: Zhang Changzhong --- drivers/net/ethernet/natsemi/sonic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/natsemi/sonic.c b/drivers/net/ethernet/natsemi/sonic.c index d17d1b4..4050d5b 100644 --- a/drivers/net/ethernet/natsemi/sonic.c +++ b/drivers/net/ethernet/natsemi/sonic.c @@ -292,7 +292,7 @@ static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev) */ laddr = dma_map_single(lp->device, skb->data, length, DMA_TO_DEVICE); - if (!laddr) { + if (dma_mapping_error(lp->device, laddr)) pr_err_ratelimited("%s: failed to map tx DMA buffer.\n", dev->name); dev_kfree_skb_any(skb); return NETDEV_TX_OK; @@ -509,7 +509,7 @@ static bool sonic_alloc_rb(struct net_device *dev, struct sonic_local *lp, *new_addr = dma_map_single(lp->device, skb_put(*new_skb, SONIC_RBSIZE), SONIC_RBSIZE, DMA_FROM_DEVICE); - if (!*new_addr) { + if (dma_mapping_error(lp->device, *new_addr)) { dev_kfree_skb(*new_skb); *new_skb = NULL; return false;