Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3427617pxf; Mon, 29 Mar 2021 01:48:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGA1+7PEgXSqLgYTGS315nNRU+daXTeij3fKEOgsfkGDF6s/c1hfIVBME29rfezHs43plx X-Received: by 2002:a17:906:1c41:: with SMTP id l1mr27179543ejg.299.1617007705754; Mon, 29 Mar 2021 01:48:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617007705; cv=none; d=google.com; s=arc-20160816; b=QsEJnUosm7spyjjomexRZQpPM8nFu562peRQFBmE2o9gnvO56MntXrfRquyz9EAY8b CaJ68cdb1/7xlxi4jUDPWvuhvJYK6LBno7jxQxUQXEeoicrPMlg9vPMNERKwUdBwL5TR DfOl3OUMv/5w518z2G0WJSAyOrx+XD1PD7u6y95k2zDWVLZeh+ddX8HiZhCDRcWkrvGt FXeMJhzZk9IZTzgEKq8jQLvRDRmHI7iXAImlLgKrhR7JQmM7cSTjCOzoM712+OPpeJlC yHWBnCemrp9aW5qMFP93iLEaQ0taQh1vR4FhZgVismlSAbbEvoNU2mfkBRUohyeJ6Mto Stqw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AT7s2aCZL+ljVAH0dhD5TGtUQOZ0P9EJkfDXv0oakUc=; b=eb6VV96kcD2x+KkWL+iGwOuEfHWuOnm9KbZhGXxNJQEm8HcXeKMfkvfP85L2j0NHWX hKUhULlrFjVQKBsGxYF2Z4WCymBzzFNC8zEqZAb9C4ckLWJ0pDy8rV10fd01be+wU8ag V9PorRDtAla3fYWHVxv2OdOOC0B14J6ZwoH2xyAgYxbfIH7UMrrwSaTMEvhb37hNIdpW J0LRi20UiR35lFOAFijDE1aPxEfZ05+8adVPeGwU1fEKJIKeOqNlNaiOENu0CEYnrzlQ YFaYUnZldFF7B13dabiqdCz5z2OI1W7vNkmpA/tSAeuMLlIypWJPjYfnEJMdtChtS5Wk HaSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n3l9Bpwi; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z15si13116727ejr.192.2021.03.29.01.48.03; Mon, 29 Mar 2021 01:48:25 -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=@linuxfoundation.org header.s=korg header.b=n3l9Bpwi; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235157AbhC2IoE (ORCPT + 99 others); Mon, 29 Mar 2021 04:44:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:43434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233706AbhC2I0V (ORCPT ); Mon, 29 Mar 2021 04:26:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2C9AF61990; Mon, 29 Mar 2021 08:25:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617006337; bh=EJHW6ObRthk4WkC5HcNlhh2sK4Bpkm9I2fnR6lpVyAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n3l9Bpwit/RJMCYyeLEmdfXgnCTrCYzzSikZnV5AXTwTmpS/kOo9LI76XopxE+859 ucAumEjLTPSDRwDLh3T81ngoDqKMY8PEzeUeVzRpaevzLtpeAaierlK0NEKC5ZoH4x arRvS6Iz3RCFCt1Ir9edKuibIi9UOrP0kptnADA8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, TOTE Robot , Jia-Ju Bai , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.10 204/221] scsi: mpt3sas: Fix error return code of mpt3sas_base_attach() Date: Mon, 29 Mar 2021 09:58:55 +0200 Message-Id: <20210329075635.924761491@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jia-Ju Bai [ Upstream commit 3401ecf7fc1b9458a19d42c0e26a228f18ac7dda ] When kzalloc() returns NULL, no error return code of mpt3sas_base_attach() is assigned. To fix this bug, r is assigned with -ENOMEM in this case. Link: https://lore.kernel.org/r/20210308035241.3288-1-baijiaju1990@gmail.com Fixes: c696f7b83ede ("scsi: mpt3sas: Implement device_remove_in_progress check in IOCTL path") Reported-by: TOTE Robot Signed-off-by: Jia-Ju Bai Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/mpt3sas/mpt3sas_base.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index bb940cbcbb5d..ac25ec5f9738 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -7358,14 +7358,18 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc) ioc->pend_os_device_add_sz++; ioc->pend_os_device_add = kzalloc(ioc->pend_os_device_add_sz, GFP_KERNEL); - if (!ioc->pend_os_device_add) + if (!ioc->pend_os_device_add) { + r = -ENOMEM; goto out_free_resources; + } ioc->device_remove_in_progress_sz = ioc->pend_os_device_add_sz; ioc->device_remove_in_progress = kzalloc(ioc->device_remove_in_progress_sz, GFP_KERNEL); - if (!ioc->device_remove_in_progress) + if (!ioc->device_remove_in_progress) { + r = -ENOMEM; goto out_free_resources; + } ioc->fwfault_debug = mpt3sas_fwfault_debug; -- 2.30.1