Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3924652imm; Mon, 8 Oct 2018 11:46:40 -0700 (PDT) X-Google-Smtp-Source: ACcGV63FlKwz9T99zb0wQE8qdB+LJ5k4qjh5qOuVg+rDeQ8UNI1+IJurIrE5G+HC1moLxpJksVUU X-Received: by 2002:a63:c112:: with SMTP id w18-v6mr22601443pgf.429.1539024400603; Mon, 08 Oct 2018 11:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539024400; cv=none; d=google.com; s=arc-20160816; b=kVZzADpW29Q2ZJIhVh4tBKxYrAqz5xlVXZMbP9AEqfafvADNPAzJRjpSPljn00WcRx oXjwroXj14Rx0iQIbFUryGZIVZjywNfcjp4LOUMwY1eP3pCpoT170icMSd1NhSQwcPBU BGGK6BgkiPF97i2nvFeKhZzgtoCxB7ifiRQ3FHs/ItYbp/Z/fBhS5nXEpvsBfN+K0/BJ 33+iXfD9Qb3eBEO+kHY3ilUJzLucm2JqDfbfEY5LYj2i8yDUpODeGHm9mZ1kPrg1lh1V qiouruckoknyfX4y7GOoFrYkRlFCRQQKTJkFiNQp8URSTM3xU+ix8rLka32giPj1aseP VSJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KB2IV0yAM1wuO8gBFB3Fro2PQK7YtR1kMyEIbj06DSU=; b=qvl5Z6hh+EJE10cMjAxQfTSB2RlUhNyGAjB+H3V8r9LvPekZMB06pPVIAYRDtNiQy8 9myLhJb3kQIxsL5Mmy3ZZ9iU11BfnKtScWHUvJV+Z6i4cn4uhrjy5lMXFYyNB0KJOtDI QK0E+U+bU1BMdHGkVkPJbD2pAOvq4+wL6Fb0iRvZZZig0Z5Ak1S+WOg+o4oMjEorRCer k6Rlep4gQQ879hDY4OYOmM5X0fLXnqPCLSYc5GqvxiPmw6/7lxyionYGqvSzuR4QqPyK l18+jH96DhmE3opp7iA6fY3y6rBc6LwvK6NPXenZeci+1j0m7+c+C8UAfFtUYChWE4cT oRpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IiS8HtJg; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a15-v6si18763534pfn.248.2018.10.08.11.46.25; Mon, 08 Oct 2018 11:46:40 -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=@kernel.org header.s=default header.b=IiS8HtJg; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731130AbeJIB7J (ORCPT + 99 others); Mon, 8 Oct 2018 21:59:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:47318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728570AbeJIB7H (ORCPT ); Mon, 8 Oct 2018 21:59:07 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D2BDC21479; Mon, 8 Oct 2018 18:46:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539024361; bh=jA3sLgoXXBUU44gVuWVWTDRDRlTSpxZwVjIxadzjbRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IiS8HtJgL/2jCC9mmq63V99jF83GcYjMfzjObjehSYG3PSRtDwPJVKdDaKceAwDJn +tDHnYJqiz7tyzwbzpQTA/6phMyV6TssYhJL7Cq1ygdoMNnQKLAZjgHhgYd2oYxp3A Y5/wOAkNlEvQvDYZ+lQ7A0WVKcuXdJwyOmIr4txc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Varun Prakash , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.18 008/168] scsi: csiostor: add a check for NULL pointer after kmalloc() Date: Mon, 8 Oct 2018 20:29:48 +0200 Message-Id: <20181008175620.355042947@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181008175620.043587728@linuxfoundation.org> References: <20181008175620.043587728@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Varun Prakash [ Upstream commit 89809b028b6f54187b7d81a0c69b35d394c52e62 ] Reported-by: Colin Ian King Signed-off-by: Varun Prakash Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/csiostor/csio_hw.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) --- a/drivers/scsi/csiostor/csio_hw.c +++ b/drivers/scsi/csiostor/csio_hw.c @@ -2275,8 +2275,8 @@ bye: } /* - * Returns -EINVAL if attempts to flash the firmware failed - * else returns 0, + * Returns -EINVAL if attempts to flash the firmware failed, + * -ENOMEM if memory allocation failed else returns 0, * if flashing was not attempted because the card had the * latest firmware ECANCELED is returned */ @@ -2304,6 +2304,13 @@ csio_hw_flash_fw(struct csio_hw *hw, int return -EINVAL; } + /* allocate memory to read the header of the firmware on the + * card + */ + card_fw = kmalloc(sizeof(*card_fw), GFP_KERNEL); + if (!card_fw) + return -ENOMEM; + if (csio_is_t5(pci_dev->device & CSIO_HW_CHIP_MASK)) fw_bin_file = FW_FNAME_T5; else @@ -2317,11 +2324,6 @@ csio_hw_flash_fw(struct csio_hw *hw, int fw_size = fw->size; } - /* allocate memory to read the header of the firmware on the - * card - */ - card_fw = kmalloc(sizeof(*card_fw), GFP_KERNEL); - /* upgrade FW logic */ ret = csio_hw_prep_fw(hw, fw_info, fw_data, fw_size, card_fw, hw->fw_state, reset);