From patchwork Wed Sep 16 06:31:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nicholas A. Bellinger" X-Patchwork-Id: 7191251 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 503A39F380 for ; Wed, 16 Sep 2015 06:37:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 69DEB20791 for ; Wed, 16 Sep 2015 06:37:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EB853205FC for ; Wed, 16 Sep 2015 06:37:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751742AbbIPGhu (ORCPT ); Wed, 16 Sep 2015 02:37:50 -0400 Received: from mail-oi0-f43.google.com ([209.85.218.43]:33181 "EHLO mail-oi0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751779AbbIPGht (ORCPT ); Wed, 16 Sep 2015 02:37:49 -0400 Received: by oixx17 with SMTP id x17so113797619oix.0 for ; Tue, 15 Sep 2015 23:37:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Dn27wNxlfinJCjjiCos8jCEJPx2G4z6kYJZHPLi2rBo=; b=P5Hr1cojuHJdG/gfnpXg+C8FvENzOlD04JeTr6jZ458dTO93OFSHL2/kpbqiu16srp p7+0GbMlurpUehnlR06dSY+8QAb2SE7fZQAjlR3gknyR9KUP8fCwUI+Tb4gs2QOncz5b uTAFUJfazSft6OBh6t++XMPMub6hlmfyEPSpbT0wkZ+meZxYXNA2nvnLDICSty6Gb7/w /TBORpxwbLFNshxTRPX+AvqzOZ1/mndabtmbqFqQsqHAoLBZm5h0Sg454ZBXP6+h3jxa UiQ7CqyszXuQcdNiPIuSjK9JOkNhqIAhOm3TEtTE7uKxgXngRKq8ziMzrMhLMh+ayhza nqMA== X-Gm-Message-State: ALoCoQnO9gibkxsjmdmzP/OD4hZFaSjQFCw98TFF4z55qSJijFjk+OowZmTIxJkBk360f7k74i5P X-Received: by 10.60.102.33 with SMTP id fl1mr7278012oeb.11.1442385468992; Tue, 15 Sep 2015 23:37:48 -0700 (PDT) Received: from localhost.localdomain (mail.linux-iscsi.org. [67.23.28.174]) by smtp.gmail.com with ESMTPSA id l205sm969354oig.4.2015.09.15.23.37.48 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 15 Sep 2015 23:37:48 -0700 (PDT) From: "Nicholas A. Bellinger" To: target-devel Cc: linux-scsi , Nicholas Bellinger , Sagi Grimberg , Christoph Hellwig , Hannes Reinecke Subject: [PATCH] target: Fix target_sense_desc_format NULL pointer dereference Date: Wed, 16 Sep 2015 06:31:19 +0000 Message-Id: <1442385079-749-1-git-send-email-nab@daterainc.com> X-Mailer: git-send-email 1.7.2.5 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 From: Nicholas Bellinger This patch allows target_sense_desc_format() to be called without a valid se_device pointer, which can occur during an early exception ahead of transport_lookup_cmd_lun() setting up se_cmd->se_device. This addresses a v4.3-rc1 specific NULL pointer dereference regression introduced by commit 4e4937e8. Cc: Sagi Grimberg Cc: Christoph Hellwig Cc: Hannes Reinecke Signed-off-by: Nicholas Bellinger --- drivers/target/target_core_hba.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/target/target_core_hba.c b/drivers/target/target_core_hba.c index 9522960..22390e0 100644 --- a/drivers/target/target_core_hba.c +++ b/drivers/target/target_core_hba.c @@ -187,5 +187,5 @@ core_delete_hba(struct se_hba *hba) bool target_sense_desc_format(struct se_device *dev) { - return dev->transport->get_blocks(dev) > U32_MAX; + return (dev) ? dev->transport->get_blocks(dev) > U32_MAX : false; }