From patchwork Fri May 18 21:27:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Khoroshilov X-Patchwork-Id: 10412235 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 03D5F602CB for ; Fri, 18 May 2018 21:28:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E90512434C for ; Fri, 18 May 2018 21:28:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DDC4A26E49; Fri, 18 May 2018 21:28:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A305C2434C for ; Fri, 18 May 2018 21:28:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752075AbeERV2C (ORCPT ); Fri, 18 May 2018 17:28:02 -0400 Received: from mail.ispras.ru ([83.149.199.45]:38938 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751985AbeERV2A (ORCPT ); Fri, 18 May 2018 17:28:00 -0400 Received: from localhost.localdomain (ppp85-140-177-31.pppoe.mtu-net.ru [85.140.177.31]) by mail.ispras.ru (Postfix) with ESMTPSA id 2CBE2540374; Sat, 19 May 2018 00:27:58 +0300 (MSK) From: Alexey Khoroshilov To: "James E.J. Bottomley" , "Martin K. Petersen" Cc: Alexey Khoroshilov , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org, Peter Melnichenko Subject: [PATCH] aic94xx: don't return zero on failure paths in aic94xx_init() Date: Sat, 19 May 2018 00:27:18 +0300 Message-Id: <1526678838-31469-1-git-send-email-khoroshilov@ispras.ru> X-Mailer: git-send-email 2.7.4 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If sas_domain_attach_transport() fails in aic94xx_init(), it breaks off initialization, deallocates all resources, but returns zero. The patch adds -ENOMEM as return value in this case. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Peter Melnichenko Signed-off-by: Alexey Khoroshilov --- drivers/scsi/aic94xx/aic94xx_init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c index 6c838865ac5a..4a4746cc6745 100644 --- a/drivers/scsi/aic94xx/aic94xx_init.c +++ b/drivers/scsi/aic94xx/aic94xx_init.c @@ -1030,8 +1030,10 @@ static int __init aic94xx_init(void) aic94xx_transport_template = sas_domain_attach_transport(&aic94xx_transport_functions); - if (!aic94xx_transport_template) + if (!aic94xx_transport_template) { + err = -ENOMEM; goto out_destroy_caches; + } err = pci_register_driver(&aic94xx_pci_driver); if (err)