From patchwork Wed Dec 30 14:14:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Barak X-Patchwork-Id: 7933711 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DE082BEEED for ; Wed, 30 Dec 2015 14:17:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 15B4C20274 for ; Wed, 30 Dec 2015 14:17:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 328AD202E6 for ; Wed, 30 Dec 2015 14:17:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751407AbbL3ORO (ORCPT ); Wed, 30 Dec 2015 09:17:14 -0500 Received: from [193.47.165.129] ([193.47.165.129]:40657 "EHLO mellanox.co.il" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751779AbbL3ORN (ORCPT ); Wed, 30 Dec 2015 09:17:13 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from matanb@mellanox.com) with ESMTPS (AES256-SHA encrypted); 30 Dec 2015 16:16:50 +0200 Received: from rsws33.mtr.labs.mlnx (dev-r-vrt-064.mtr.labs.mlnx [10.212.64.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id tBUEGna1005588; Wed, 30 Dec 2015 16:16:50 +0200 From: Matan Barak To: Doug Ledford Cc: linux-rdma@vger.kernel.org, Or Gerlitz , Majd Dibbiny , Moni Shoua , Matan Barak Subject: [PATCH] IB/core: Fix dereference before check Date: Wed, 30 Dec 2015 16:14:18 +0200 Message-Id: <1451484858-1530-3-git-send-email-matanb@mellanox.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1451484858-1530-1-git-send-email-matanb@mellanox.com> References: <1451484858-1530-1-git-send-email-matanb@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sparse complains about dereference before check. Fixing this by moving the check before the dereference. Fixes: 200298326b27 ('IB/core: Validate route when we init ah') Signed-off-by: Matan Barak --- Hi Doug, This patch eliminates a deference before check sparse false warning. This was introduced in the RoCE v2 series. Regards, Matan drivers/infiniband/core/addr.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c index 0b5f245..791cc98 100644 --- a/drivers/infiniband/core/addr.c +++ b/drivers/infiniband/core/addr.c @@ -497,13 +497,14 @@ int rdma_resolve_ip_route(struct sockaddr *src_addr, struct sockaddr_storage ssrc_addr = {}; struct sockaddr *src_in = (struct sockaddr *)&ssrc_addr; - if (src_addr->sa_family != dst_addr->sa_family) - return -EINVAL; + if (src_addr) { + if (src_addr->sa_family != dst_addr->sa_family) + return -EINVAL; - if (src_addr) memcpy(src_in, src_addr, rdma_addr_size(src_addr)); - else + } else { src_in->sa_family = dst_addr->sa_family; + } return addr_resolve(src_in, dst_addr, addr, false); }