From patchwork Mon Oct 17 17:11:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khazhismel Kumykov X-Patchwork-Id: 3611 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1556218wrs; Mon, 17 Oct 2022 10:12:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM68vXxGCSwt5ejvvM0W8uS8HN3umvMmhc5mdRlukeG1TBtEHoip1TvpgFOsg+DVhBYATg3T X-Received: by 2002:a17:902:c7ca:b0:181:927a:9449 with SMTP id r10-20020a170902c7ca00b00181927a9449mr13141338pla.11.1666026770903; Mon, 17 Oct 2022 10:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666026770; cv=none; d=google.com; s=arc-20160816; b=PDlNhDTbL3wSjUvlIfdgI4yK+9ZDSCSaWU34GRC7kcGwBcfZFEICLdSxoJ6DIxFB3k kxrrOhCucUPj2o5k5ZFCGFzLL1pkQ+EYB/4P3mR29c534vAnryOej2TKbfOKU0E3X9WC rsQkvo7JUnwsTZwBHlwpDliHMuu2T1V5OfmnwDfqUq6vUGUL9hEVeEWvZnykdqydfRrM LE3dBMaINq8yKK24X8Azy3gqXjtBNrUkNgfQMWo7gOkKofcZgE5xex4pX/7SQpHVMzP2 FcPwd0PB+6mq4Utp2fmACov58uEBl8gs8El4wL2xKUjpdzOHsZf+ZA5wC6buOn9P+xBC Sbfg== 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; bh=0tBsZ76gwc8/70eg063yamfq95Tc780KUhRC9NyQyUU=; b=WcDhBqdi3amZ9Fm9zdadq/H7sIGyxQOUwOPzsl6W5fsY+uuFz0tZ1rh14QYatn0pQH QZ0j5I4aiTP1OoRGmz2iO0oB8/NK6yebUJm+xBWn/MjSjbaLFDjDia8Lya80iImsQ+Ip vlAqmb0dFUddWqskm/koJeGylkQ0KsUDCvkWsj7H7DVb7kWDOXTwOwBydCOeh6JoRHme WdfQi1o3Ms8fUZ+xDkydy7nllA8Dv+7Ni3gPwE6go4N8Jmry0Ok2G/7HjQGtGSSv+Xy1 3HHfyKs6jl4ja24AXBtP1XvsIn/jPpBfW21ZSelMIZ3Udl9T4pZPRTSqBg8YdjLzJYCS HvJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="JfqX/tWX"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w9-20020a631609000000b00458ce4748f6si12134015pgl.409.2022.10.17.10.12.36; Mon, 17 Oct 2022 10:12:50 -0700 (PDT) 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; dkim=pass header.i=@chromium.org header.s=google header.b="JfqX/tWX"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229742AbiJQRL4 (ORCPT + 99 others); Mon, 17 Oct 2022 13:11:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230003AbiJQRLy (ORCPT ); Mon, 17 Oct 2022 13:11:54 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ECF86FA0F for ; Mon, 17 Oct 2022 10:11:53 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id q9so10996256pgq.8 for ; Mon, 17 Oct 2022 10:11:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=0tBsZ76gwc8/70eg063yamfq95Tc780KUhRC9NyQyUU=; b=JfqX/tWXuWfol9Fbo7MMWPEIFekj8VCvbIam0iehMAxcW9tuJ0AW88tOYP1WRwJvVR 8MKwYYrzg1NOd9uiLXL/mItJH+Ryi/C3tcDrgRmOwmQTCqtVXWncmqhdarpXTD6ljyKW N9Z8PbF/v6gBfq2SYCKJVrmfFcJVeDP9Vm4f0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0tBsZ76gwc8/70eg063yamfq95Tc780KUhRC9NyQyUU=; b=jssn4aMpDUFTlcnfMsvpV3mCYOekFktMpYAk9fUaO7aOQLTkZsilTN1OwMZ/y/4FuD tJQ8kOmPif4l2dLYJ+klIgbdskixa5Ox84GEys4w30n4qD53Pq9ZV/ivN21FI6t0Etdt Q+pfVs27C5Uj29NApwruraw1hbAHWJrO77r9gM3KRA1HH02F9FRXtEuNRjFwhY+K+4r1 ipJKgJ2iud6KDvXEy2CofOESarS9B4j5+o9x/Pa0XlStG+HZx7pHc/iTyVziKFUbi0Gb ytlKxZ1do4pCgL7WZryhqI4P1cVr7Oj2hgPiz+VMM9VjfI2rqZm5x9KxgW29NW3p0gWw 4Q9w== X-Gm-Message-State: ACrzQf2LDkfbnDUfRVpql1Brt/wtCTB1vcbhOQMoM8P5OjQBc8leJBdK 50sQ0YOvuvE7316NFpUw/xiipg== X-Received: by 2002:a63:4a53:0:b0:439:3c80:e053 with SMTP id j19-20020a634a53000000b004393c80e053mr11584993pgl.3.1666026712543; Mon, 17 Oct 2022 10:11:52 -0700 (PDT) Received: from khazhy-linux.svl.corp.google.com ([2620:15c:2d4:203:a9cb:592c:5760:8872]) by smtp.gmail.com with ESMTPSA id b8-20020a17090a7ac800b00205d70ccfeesm9706025pjl.33.2022.10.17.10.11.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 10:11:52 -0700 (PDT) From: Khazhismel Kumykov X-Google-Original-From: Khazhismel Kumykov To: "James E.J. Bottomley" , "Martin K. Petersen" Cc: Gabriel Krisman Bertazi , Greg Kroah-Hartman , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Khazhismel Kumykov Subject: [PATCH] scsi: fix crash in scsi_remove_host after alloc failure Date: Mon, 17 Oct 2022 10:11:47 -0700 Message-Id: <20221017171147.3300575-1-khazhy@google.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog MIME-Version: 1.0 X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham 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?1746955687206594063?= X-GMAIL-MSGID: =?utf-8?q?1746955687206594063?= If transport_register_device returns error, shost_gendev has already been cleaned up - however since we ignore the error device setup continues happily. We will eventually call transport_unregister_device, attempting to delete shost_gendev again, resulting in a crash. It looks like when this cleanup behavior was added, iscsi was updated, but scsi was missed. Fixes: cd7ea70bb00a ("scsi: drivers: base: Propagate errors through the transport component") Signed-off-by: Khazhismel Kumykov --- drivers/scsi/scsi_sysfs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index c95177ca6ed2..722ab042fbd7 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -1599,7 +1599,11 @@ EXPORT_SYMBOL(scsi_register_interface); **/ int scsi_sysfs_add_host(struct Scsi_Host *shost) { - transport_register_device(&shost->shost_gendev); + int err; + + err = transport_register_device(&shost->shost_gendev); + if (err) + return err; transport_configure_device(&shost->shost_gendev); return 0; }