Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp4128260ioo; Mon, 30 May 2022 19:10:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7dQsq1VLjxVIYleP/M/NzivHzF8CQygnBENf88Gu34donrir5IpIDVLLJXgkH0h0Y5eu4 X-Received: by 2002:aa7:86cb:0:b0:518:3e92:f78b with SMTP id h11-20020aa786cb000000b005183e92f78bmr57676261pfo.61.1653963041795; Mon, 30 May 2022 19:10:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653963041; cv=none; d=google.com; s=arc-20160816; b=bq4+I9LJG1olUZnRT6FGP8NsmFQX9ek0dBpZmL0DC7SKhZwHF7ps3LEpAOEezcPhi9 TmzRHfOF2OjE3XXi0aDe9mKUnFVlYWifci4ltV1crdSaKqh+5Q4fs4+GidoFQcPuK3eF RXCP0+8PP7yddLIq/ns0q7qYyMN7x9v6zzWRbjkNbkuFz2teMLPhwEr2ou25/uBZCdRR lnLoDoMdChnm4XpImsBHEMIeeG3GieBgEIuM5TTgtjQIV8L2e64hN7G+CiZ4blw+3Wcu hAWb5UyShAZpAvQTLNGc4b+XjZGz6Fjl3hKT14cUEvDVB2nBO3X4UwwQ6bHJF0JndycA fH8Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BAP49eOJMqXB9MRpKU7OdKPujNuvpaeo7hUuIlcHfwE=; b=DSjcbBWuAqvnpWlg2VK6sYTtyUVcakJ20AB/ywOLh9sEUq+NTownaPlCqTMawlVPuB cjQ13ioV//oYKs+NMQuopspGeYghXAWaaL656W5b9zugAyWhV5295W8loKSKOHmJZz6J 06WHZFS3/7kzClQmvIW4oD2v+6wVYIElcxdWo6XoAPdSGicFlVFp6qdeoU8WQAXSk0Ot 4TdSzjCjYRTF2S5X8kI38K16IZqLCa0EI2rjcACfXm4JZrHRjJ6pjHZTDLMkC71dWjpX 6hTBvTerxYzAQyl3Qmq1mpnDk5kCxYK/d2revCml9vFmppuGhniIw3CvCdDYj7t5xfvb ywxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oEmL5Ka1; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i2-20020a17090aee8200b001df4ea7a026si1205587pjz.34.2022.05.30.19.10.29; Mon, 30 May 2022 19:10:41 -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=@kernel.org header.s=k20201202 header.b=oEmL5Ka1; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240997AbiE3Ovt (ORCPT + 99 others); Mon, 30 May 2022 10:51:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242490AbiE3ObO (ORCPT ); Mon, 30 May 2022 10:31:14 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5C29EBA9F; Mon, 30 May 2022 06:53:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 4549BCE1024; Mon, 30 May 2022 13:52:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7067CC3411C; Mon, 30 May 2022 13:52:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653918760; bh=493NnMb0m3jXFaC9Qo/ThcPB1+4sJ7bhd1oanoqWjbQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oEmL5Ka13BFL8PxJxMyMRJvDnZozmtYpkVjnM6zAPl3YN2Qfb5mYgLvCTLklpqGN+ py+vxmM6eTq9bsugxtqbV+WGahp03Wvx3WLxnPveT/qgBN+mP24GVwDvj0uwfnKUFN X9aTTx6HnbFpz67mfqD7nn+m21jrU/0fqv/iqy5yO8fbPuyhhQmfCM1hlgkAkNY44f UjzlQPWc0d5pLHGPtBgbJtghMi8tcCxERrjMMmPc3ZV4GUxGaVmIAWzIfE+sbobwvN 3OTaWuOmCbFr87miNEDuNmVOIgOkPbxURjtK/CEAL+US1pPXdD14KOJg0XYiTgfBj1 ZpZkhw+4FcA4w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Lv Ruyi , Zeal Robot , "Martin K . Petersen" , Sasha Levin , kashyap.desai@broadcom.com, sumit.saxena@broadcom.com, shivasharan.srikanteshwara@broadcom.com, jejb@linux.ibm.com, megaraidlinux.pdl@broadcom.com, linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 11/24] scsi: megaraid: Fix error check return value of register_chrdev() Date: Mon, 30 May 2022 09:51:58 -0400 Message-Id: <20220530135211.1937674-11-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220530135211.1937674-1-sashal@kernel.org> References: <20220530135211.1937674-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Lv Ruyi [ Upstream commit c5acd61dbb32b6bda0f3a354108f2b8dcb788985 ] If major equals 0, register_chrdev() returns an error code when it fails. This function dynamically allocates a major and returns its number on success, so we should use "< 0" to check it instead of "!". Link: https://lore.kernel.org/r/20220418105755.2558828-1-lv.ruyi@zte.com.cn Reported-by: Zeal Robot Signed-off-by: Lv Ruyi Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/megaraid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 2cbfec6a7466..2f7132edcd3f 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -4705,7 +4705,7 @@ static int __init megaraid_init(void) * major number allocation. */ major = register_chrdev(0, "megadev_legacy", &megadev_fops); - if (!major) { + if (major < 0) { printk(KERN_WARNING "megaraid: failed to register char device\n"); } -- 2.35.1