From patchwork Sat Feb 18 00:53:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li zeming X-Patchwork-Id: 57919 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp181590wrn; Thu, 16 Feb 2023 00:36:17 -0800 (PST) X-Google-Smtp-Source: AK7set+QreoxeNYl6R/Ze/CxKysysb/xxJ4YNCirsj8holjQVfZ3DglZdQ5AjpT+Uk4YQiPfPFGl X-Received: by 2002:a05:6402:2485:b0:4a2:5652:d8ba with SMTP id q5-20020a056402248500b004a25652d8bamr1234370eda.18.1676536577426; Thu, 16 Feb 2023 00:36:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676536577; cv=none; d=google.com; s=arc-20160816; b=Z6VfnnsWrFL7pPflQKNWQmCDlKqdBGeaD7aEOlkemcuwcgeka7IePuODu80Cy1u6zg 6DBomZCo6qfOG8BUHjT62/EMxns3BnjWh8AubpfpceCaIkccpAVmAEEXMBcC2Jc726Eu MC64ax52FNZ8OIbwR5a/xw9Phg2Pb3cVEQCOT4es3JtFrTnSksR1RHHoooM2BHUKbIaP Z9O6wzrfIxX5I4gCZyPGlFYqiK9ao2E3Ifbkc2Fe9XWNIl7UvuWydlEnU52pU9UU96qb UvOtecN2/3RoYiV+w7vqlkusZueGZEeeihXgkA5i4XYwCvaHBgHt4wEnEyBYX//naJUB oHPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=JDs1eteIJRU5dXFZrmWYZByqihTtTrjEKchQZSR2BVI=; b=APGFrwGDcd40mQi0Tx+34D86a5uuaKWxWx/iEy1K3kAFQZtFUKPvGtIyDsZR03JL0/ 6baaGCRXpu58SJKuvYKtp15DZ3Ojb/JTYK8nRijnmnF4FWInNEFIrFuHs7DMNk8FnLF4 sSXFCx4oS1dFMZKw6aWjWnR3yddCnSjqsX/frOHHeu0J6WXw97c8NsjRYNWaQqGR1mj4 LbIdoa7nPkNEyxJew+zCj5lryKm6ArDt+IRPYbqBlxuWZluoto1NGS1sVF7a5facCZH+ 6ZFoKcIS41XTtUarKQ9pnGdVpPke2ZM1yNXjGvxRzAaHj7j2Uaf0xuJdokjOQSq5MzrI 023A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l1-20020a056402028100b004ab08cae52bsi1574728edv.54.2023.02.16.00.35.53; Thu, 16 Feb 2023 00:36:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229909AbjBPIWm (ORCPT + 99 others); Thu, 16 Feb 2023 03:22:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229615AbjBPIWk (ORCPT ); Thu, 16 Feb 2023 03:22:40 -0500 Received: from mail.nfschina.com (unknown [42.101.60.237]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5759D36447; Thu, 16 Feb 2023 00:22:39 -0800 (PST) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id 657381A00A89; Thu, 16 Feb 2023 16:23:14 +0800 (CST) X-Virus-Scanned: amavisd-new at nfschina.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (localhost.localdomain [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id J7ndbD2t2LUH; Thu, 16 Feb 2023 16:23:13 +0800 (CST) Received: from localhost.localdomain (unknown [219.141.250.2]) (Authenticated sender: zeming@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 7ACD41A00856; Thu, 16 Feb 2023 16:23:13 +0800 (CST) From: Li zeming To: mst@redhat.com, jasowang@redhat.com, pbonzini@redhat.com, stefanha@redhat.com, jejb@linux.ibm.com, martin.petersen@oracle.com Cc: virtualization@lists.linux-foundation.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Li zeming Subject: [PATCH] scsi: virtio_scsi: Modify the kmalloc allocation flag Date: Sat, 18 Feb 2023 08:53:56 +0800 Message-Id: <20230218005356.3932-1-zeming@nfschina.com> X-Mailer: git-send-email 2.18.2 X-Spam-Status: No, score=0.9 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_24_48, RDNS_NONE,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757976017893815037?= X-GMAIL-MSGID: =?utf-8?q?1757976017893815037?= The inq_result pointer must be allocated successfully; otherwise, subsequent function execution may crash. Signed-off-by: Li zeming --- drivers/scsi/virtio_scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index d07d24c06b54..3252f4b42261 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -336,7 +336,7 @@ static void virtscsi_rescan_hotunplug(struct virtio_scsi *vscsi) struct Scsi_Host *shost = virtio_scsi_host(vscsi->vdev); unsigned char scsi_cmd[MAX_COMMAND_SIZE]; int result, inquiry_len, inq_result_len = 256; - char *inq_result = kmalloc(inq_result_len, GFP_KERNEL); + char *inq_result = kmalloc(inq_result_len, __GFP_NOFAIL); shost_for_each_device(sdev, shost) { inquiry_len = sdev->inquiry_len ? sdev->inquiry_len : 36;