Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2907026ybi; Sun, 28 Jul 2019 20:44:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjyWmKJZS8JXsUAdKE+DV188C1SFLBacnQSzQG2p9wzEcp86CJzCU5IfBCAeiGAXlChOSh X-Received: by 2002:aa7:96ad:: with SMTP id g13mr35858863pfk.182.1564371858076; Sun, 28 Jul 2019 20:44:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564371858; cv=none; d=google.com; s=arc-20160816; b=o4xrq/1uLttEISup6E37yGH+1NQ05QO9Yl7mUwgv1vypuFUDKMX5jsELUbYeu5iZhz GjvGzfz9aq7itwGsXRkJo3pjGzd9aMwTkkjBg0pAgHEgjcsspKpyMXJUwNlBbzo0BbaX RjCLJjaLTqwETATzyDbk6souTUL585UeSIALJcAPoPerETsFlmwXJBgiXp8m5bfyjif3 qBBwyHfrwbAd+8JmtbSy15cs98gEpP8va4ro8nr8XEpItuHXG9LNxBhAE7rjBv5c4/6Z b2+ca1YqJ+Qw/jUQg3hlsMJeBd+SjXrVDFqfjuQVTB516tb4kRs1hKd/tdDm3mUQJPaL 7H6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=pLFtk/7F5eVVtua+aE9FkwIBwxxf0EwZRWJyAn6pvVI=; b=DPq78P7sXb2DpSZ6fmEkzDSKwSDzM9rtgcZE86yOU76emLA8UhW0tKO60EIN5o7MjJ t6YJRR2a0+u2I6MHhUA9jBBUFHIPK9CgCVoVJxpUWbYX8rM+eeiDkGBUaYd42WW38z4R YNpoIdMBelM3xp7syJggBi0sUaIjblMPVBDjdVyFdoFeMhxXXWp9uMN1ReRriss9vZ+g AT7slDFnJCo09WGy4kxizpwdYE9KL4Kr6aKUu1JKxAobBzFwc7HYMDbQ2vdXIwbmTqB+ UUmuEW7AClnrFiue2rsFl5TV6LclcFS219cmWhsUEmB50TZDcWrpoYz6RcR4yHcNxbtp Y5zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=a+ytlk7Z; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p4si9611432pgk.496.2019.07.28.20.43.51; Sun, 28 Jul 2019 20:44:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=a+ytlk7Z; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726558AbfG2DI7 (ORCPT + 99 others); Sun, 28 Jul 2019 23:08:59 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:39566 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725681AbfG2DI7 (ORCPT ); Sun, 28 Jul 2019 23:08:59 -0400 Received: by mail-pf1-f193.google.com with SMTP id f17so23230857pfn.6; Sun, 28 Jul 2019 20:08:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=pLFtk/7F5eVVtua+aE9FkwIBwxxf0EwZRWJyAn6pvVI=; b=a+ytlk7ZHUWsS6Nb5eTXltj46JbqaavLLOpVr/emP+ST4FTqxcMXUyc2fUMtA7NZIi O1unhUmP0Ul72y/reBqbxEa8g7KKUOjxDyr1pz3vY4lLBTpBEu3ExwIndr0osARri6Dk fVubLbS96lpk47DRJKj68yDzc7Fw+BrSywy5pM49HIxxizynfZiZY7YZXgDxcSqC03ul Hdrn+EP4gacUEQPIizZi65k8xiD1UFUe/OG9brph2q30DMFNk4K6Rl5EoSWWU4nleT2u AemndnpMYnHpTl2qEBYPfGTDuwBg56yRp3muDuMw4/K7QCRg4L2iAnriSJ6DP4Lpi8t5 ZU3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=pLFtk/7F5eVVtua+aE9FkwIBwxxf0EwZRWJyAn6pvVI=; b=cNeegUtchAtOHGz68bih9+y7c8FWKtnv6nC3c0cbt9jVn/FTSb6R5UPMtOr4oP6Xrq Ww2NQ8C8DMg7o+C+PkE06zX2QX66aAp3ku4vuFDI9zJcvnE3AhkADyhwPqA9jngC0itM jmCrl8LGr7Dl4lYfPXbNpBJVAGd0lx9zHgnK1E8T5cWD1fcWSBU8zv4yJVIpvrgmsK07 cZOs8to6Yzo9kNsWKdFBD6aaHeumVgR2GZeB0zqFTU6LYXA20Z/9KniJMkR8jGgGdwJm XXw/2SDtCxSujoSC+14+DchOQJxGlVTM6sUt6YA4YqCU8OCTgSP2EWotd3QNwWdz6S7R vW4A== X-Gm-Message-State: APjAAAXJXBgKxungXxoEfDZqkgafJ5I5krIN2EI00ntSzD6E4l9iFaOw eDsYNnjBisfuAC/cOK4eo/WUof+R X-Received: by 2002:a65:4786:: with SMTP id e6mr99800479pgs.448.1564369738236; Sun, 28 Jul 2019 20:08:58 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:4:72:808::3ca]) by smtp.gmail.com with ESMTPSA id z20sm94807865pfk.72.2019.07.28.20.08.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Jul 2019 20:08:57 -0700 (PDT) From: Jia-Ju Bai To: sathya.prakash@broadcom.com, chaitra.basappa@broadcom.com, suganath-prabu.subramani@broadcom.com, jejb@linux.ibm.com, martin.petersen@oracle.com Cc: MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] scsi: mpt3sas: Fix a possible null-pointer dereference in mpt3sas_transport_update_links() Date: Mon, 29 Jul 2019 11:08:51 +0800 Message-Id: <20190729030851.22059-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In mpt3sas_transport_update_links(), there is an if statement on line 994 to check whether mpt3sas_phy->phy is NULL: if (mpt3sas_phy->phy) When mpt3sas_phy->phy is NULL, it is used on line 999: dev_printk(KERN_INFO, &mpt3sas_phy->phy->dev, ...) Thus, a possible null-pointer dereference may occur. To fix this bug, mpt3sas_phy->phy is checked before being used. This bug is found by a static analysis tool STCheck written by us. Signed-off-by: Jia-Ju Bai --- drivers/scsi/mpt3sas/mpt3sas_transport.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_transport.c b/drivers/scsi/mpt3sas/mpt3sas_transport.c index 5324662751bf..df790a9877a0 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_transport.c +++ b/drivers/scsi/mpt3sas/mpt3sas_transport.c @@ -995,7 +995,8 @@ mpt3sas_transport_update_links(struct MPT3SAS_ADAPTER *ioc, mpt3sas_phy->phy->negotiated_linkrate = _transport_convert_phy_link_rate(link_rate); - if ((ioc->logging_level & MPT_DEBUG_TRANSPORT)) + if ((ioc->logging_level & MPT_DEBUG_TRANSPORT) && + mpt3sas_phy->phy) dev_printk(KERN_INFO, &mpt3sas_phy->phy->dev, "refresh: parent sas_addr(0x%016llx),\n" "\tlink_rate(0x%02x), phy(%d)\n" -- 2.17.0