Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp854410pxk; Thu, 17 Sep 2020 19:10:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmO8MaeYT32tKd/v+4E/AeeXY+GR0e5mNPZajNdDO5zKmr2sDQoGNNUCXqc8vzYavwVLe9 X-Received: by 2002:a17:906:d0c9:: with SMTP id bq9mr33431354ejb.352.1600395045378; Thu, 17 Sep 2020 19:10:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600395045; cv=none; d=google.com; s=arc-20160816; b=DoXlRjCI+mlz+mobO4HlsJmhBLun92tkYb1S81Bqnff1EBeCNXqMXyisu4NAQUDbZQ LnajHdPJdUWfCxPxfY7q3V6K98PHxmieHXlaun7/DI1xiKlvVCOyJu/hddlG4wmHAZEm ko/PXeKTaePuMJey04wtbb6rC3eZnhXsg1z+87X3esT4Zi5Vrx2WfaxdBMnRABWm7QI2 IHr/shNfIvXjTD+lKs6aJvUbAa+eLTa3l0taKWb3Q0om4oOMJBI5DT42KflxyUj71tSA 80earQ9GbS+KnA0mXxRru12DBr70PkqhM44AI5/AZFDHtaGprdV2T2qyzaPaLz9mekcb +S8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YRi5ms2iOI2lK7LxwJ+sIyZwCWAshO8rYXelZs14jmI=; b=hYMAbFa1LFm/XzusmOJzZStfcfHL+DMAQjXvTxZNpwHqA4Vd8fx6vYj5TiDES8Onug mpJ3YkHSaDHJ6DIb15lCNbtwfYMdR6NL04t5aoP+XfEC3XfGfg335D0F+GjLfzHWJ55Z fBtmrQ+mODzvsApgMsAM7+XKHb80xmbs+xyoMkW/PoYAYF8ug5uR/71KxWOcyQG6AhgI ia5pm/Vyd7hhwPoCs/ud9fQS7yV3qHMulyKjqLnqhne4tGC1OxeGVQMVP3LbX/sUhR8O WfDjKk0Qe7nvSW1wpY7iERtTqncv1KEUKFiPGJxfKUdVmq32GWdv+OhMFaguuxStyGbt w4dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wbVVJfYM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j3si1240016ejb.156.2020.09.17.19.10.22; Thu, 17 Sep 2020 19:10:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wbVVJfYM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727740AbgIRCGS (ORCPT + 99 others); Thu, 17 Sep 2020 22:06:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:55302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727720AbgIRCGL (ORCPT ); Thu, 17 Sep 2020 22:06:11 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0364A238E2; Fri, 18 Sep 2020 02:06:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394770; bh=UTORA0vFhKrSQVJFeXxzWe2A2a4craZybvPVO4CRqC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wbVVJfYMUsyjwVw4qyiI4nxUAlNqTXqNDlyWvWM4sKTxh/2GjvSxiTsKQYAs/yhio ia9rPyeGrUAkpBFoS+HbYA1ty6RqAdR8pqgqzcCSKpJQ/DF0nuPnCXZKeMNjpg7WCc WSAs5SD+BiUqckms/9oR+t3HJ3DYbQgyY42z5kG4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Christophe JAILLET , "Martin K . Petersen" , Sasha Levin , linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 245/330] scsi: aacraid: Fix error handling paths in aac_probe_one() Date: Thu, 17 Sep 2020 21:59:45 -0400 Message-Id: <20200918020110.2063155-245-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe JAILLET [ Upstream commit f7854c382240c1686900b2f098b36430c6f5047e ] If 'scsi_host_alloc()' or 'kcalloc()' fail, 'error' is known to be 0. Set it explicitly to -ENOMEM before branching to the error handling path. While at it, remove 2 useless assignments to 'error'. These values are overwridden a few lines later. Link: https://lore.kernel.org/r/20200412094039.8822-1-christophe.jaillet@wanadoo.fr Signed-off-by: Christophe JAILLET Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/aacraid/linit.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 514aed38b5afe..1035f947f1bcf 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -1607,7 +1607,7 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) struct Scsi_Host *shost; struct aac_dev *aac; struct list_head *insert = &aac_devices; - int error = -ENODEV; + int error; int unique_id = 0; u64 dmamask; int mask_bits = 0; @@ -1632,7 +1632,6 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) error = pci_enable_device(pdev); if (error) goto out; - error = -ENODEV; if (!(aac_drivers[index].quirks & AAC_QUIRK_SRC)) { error = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); @@ -1664,8 +1663,10 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) pci_set_master(pdev); shost = scsi_host_alloc(&aac_driver_template, sizeof(struct aac_dev)); - if (!shost) + if (!shost) { + error = -ENOMEM; goto out_disable_pdev; + } shost->irq = pdev->irq; shost->unique_id = unique_id; @@ -1690,8 +1691,11 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) aac->fibs = kcalloc(shost->can_queue + AAC_NUM_MGT_FIB, sizeof(struct fib), GFP_KERNEL); - if (!aac->fibs) + if (!aac->fibs) { + error = -ENOMEM; goto out_free_host; + } + spin_lock_init(&aac->fib_lock); mutex_init(&aac->ioctl_mutex); -- 2.25.1