Message ID | 20231209111857.19393-1-pchelkin@ispras.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5997187vqy; Sat, 9 Dec 2023 03:25:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IE5BSOyoBU/YIc+yribZyqNTIpP6bQkopZIcKFexiK97aS/NsE2emPgDfbY0KBEOldBzjgK X-Received: by 2002:a17:902:dacc:b0:1d0:700b:3f71 with SMTP id q12-20020a170902dacc00b001d0700b3f71mr2848810plx.43.1702121138895; Sat, 09 Dec 2023 03:25:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702121138; cv=none; d=google.com; s=arc-20160816; b=ZyCxO3yqCejOyONh7lF8AXxYfYedU/kmpqmVU3UwXdK+WWlwJ3VlRlzs941MNhka8j 1QdiSekf56yD6dZrofJLfb4oMMB3dy5qMf6yIL1NSUWHW39izeLsK38RiXjsE5tx5gF3 /Egvajh5S/iUklza55YYXaDveyRajWQqJBVw1EFNh2Z9/wT2PyVypg06QXN62Y2biL6Q qmpx2wTdWt2ylOLSvPmmeHFY8/MZdFXE7/a3qPZmtZZxvlp5yDV8RZAKURTvnIEjgUVG 1pdOssWAd6aJd3UGfEFCaRlE/LcLYQlWz8ciWKGMxc76he5ocCAL+Di8MDpxB2hNroIx kg2A== 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 :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=odq4MrakWESK/R0F/Uy9J0JMTX/2+rbQ0CI8lN5aBHQ=; fh=uiC2sXnlryOCiGme8NX+oc38VtVZ77CslTuw2orKTV0=; b=0sxQeVv2EIyY3wpWnfVn5MMbvrc5R6lfYtAf7XqcUcZhAb6M/A8pqApkdFgAAhJqSV JntnOmIMQD4Knzx5XUpxM33+eeQPBiRoK0VOLcOeewNUVkkWSw6c9EVi4XOBt2jdk/ZT 92jTXUx0S4kiR1chen3A1FXPPyLxDEDS4PzxggRCnZYPzSgz9puihPGupULMeOB5tG8L fL2BQnQvECS/L8VMJUEFI7P5+tVz7+PyvcYxFsm/Ddzuwok8nveFJmC9IdGotNkUWCgi TIsHFwg/xkY7raatafIo/ePEYCYEPFZdMHTVd+pLFLqBF4LCTIRgaLYc1wFB0vil2rWw 5lbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=I+zLitdM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id k7-20020a63d847000000b005bd70a177a3si2845263pgj.876.2023.12.09.03.25.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 03:25:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=I+zLitdM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 3E83D805E432; Sat, 9 Dec 2023 03:25:36 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229567AbjLILTT (ORCPT <rfc822;makky5685@gmail.com> + 99 others); Sat, 9 Dec 2023 06:19:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229446AbjLILTS (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 9 Dec 2023 06:19:18 -0500 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B92910D8; Sat, 9 Dec 2023 03:19:23 -0800 (PST) Received: from localhost.localdomain (unknown [46.242.8.170]) by mail.ispras.ru (Postfix) with ESMTPSA id 61BDE400CBDC; Sat, 9 Dec 2023 11:19:19 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 61BDE400CBDC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1702120760; bh=odq4MrakWESK/R0F/Uy9J0JMTX/2+rbQ0CI8lN5aBHQ=; h=From:To:Cc:Subject:Date:From; b=I+zLitdMGwY0lck2CkXo2mrldGQO4nakM7w/WDRRft6Py2+4wvuucp5bPls9vgdDf 2Oha2DFT77/GNJoLVxFC7w1uTEPKoE1sk3AiPcJx0+ckXqcOudEwAznuz1/rmNcnbz SeQ4W7SfQ1C7n41e/c1slG0BMdLTI+snqwGXSAgk= From: Fedor Pchelkin <pchelkin@ispras.ru> To: Don Brace <don.brace@microchip.com> Cc: Fedor Pchelkin <pchelkin@ispras.ru>, "James E.J. Bottomley" <jejb@linux.ibm.com>, "Martin K. Petersen" <martin.petersen@oracle.com>, Alex Chiang <achiang@hp.com>, Mike Miller <mikem@beardog.cce.hp.com>, "Stephen M. Cameron" <scameron@beardog.cce.hp.com>, storagedev@microchip.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Alexey Khoroshilov <khoroshilov@ispras.ru>, lvc-project@linuxtesting.org Subject: [PATCH] scsi: hpsa: prevent memory leak in hpsa_big_passthru_ioctl Date: Sat, 9 Dec 2023 14:18:56 +0300 Message-ID: <20231209111857.19393-1-pchelkin@ispras.ru> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sat, 09 Dec 2023 03:25:36 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784803375323764555 X-GMAIL-MSGID: 1784803375323764555 |
Series |
scsi: hpsa: prevent memory leak in hpsa_big_passthru_ioctl
|
|
Commit Message
Fedor Pchelkin
Dec. 9, 2023, 11:18 a.m. UTC
In case copy_from_user() fails during the buffers allocating loop inside
hpsa_big_passthru_ioctl(), the last allocated buffer (accessed by sg_used
index) is not freed on cleanup1 error path as sg_used index has not been
incremented yet.
Free the last allocated buffer directly if copy_from_user() fails.
Found by Linux Verification Center (linuxtesting.org).
Fixes: edd163687ea5 ("[SCSI] hpsa: add driver for HP Smart Array controllers.")
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
---
drivers/scsi/hpsa.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index af18d20f3079..897f9ee3c004 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c @@ -6536,6 +6536,7 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, if (ioc->Request.Type.Direction & XFER_WRITE) { if (copy_from_user(buff[sg_used], data_ptr, sz)) { status = -EFAULT; + kfree(buff[sg_used]); goto cleanup1; } } else