Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5174224ioo; Tue, 31 May 2022 22:59:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyry7n8wiDv3yMNDpv4w448e40uIkMovLpqveXrWXC4aS79MTHhv9eDgA22lho00Ug3zXjp X-Received: by 2002:aa7:d285:0:b0:42d:ca4f:a046 with SMTP id w5-20020aa7d285000000b0042dca4fa046mr18194200edq.354.1654063164648; Tue, 31 May 2022 22:59:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654063164; cv=none; d=google.com; s=arc-20160816; b=c+KY718dq+QChktGgkqm99uQQMWFD+55s5n8jgQHuSa7HiX5gjxYPKB4y3yULWHvNO 2QVtz5qy6I5tzgG6Pa0rwxqBeVSpNdZ/Q/8l0Gj8mT93V09QO00UrCNJ/N5tkMnvghGj 0VikfjoSaW8fcr70ud8s/mk6ogMxp2b456vgc+c4MfaivPglSoHxw+dTDoMrj/ajHqvc 6JymG78kRfpCalYidAtXkZ7kzXrrQnx4R9GpIjtutV26eCoDYY+UExoY3yV/x19uVaY2 1hRYoaj4/yPwCb8PJZQP3hgBlTtExtzuh0iZL/Zti+j7Srj51ONSR3XV78cavFRwLq19 kmZA== 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=E7U5wehPLoTItVRc+qtZ62uxlrqoFlbHfUPgXlamojM=; b=JJUds0/JBv5RkEFmP3mQ72PtjfcJQWU5YwHvxVRd+UDDu+jCDAOtGY3cQEQbtfJazd 79oDX0xf0BPZjBrFLWeoIDG+EIPIZHZ0A3S22o7LNG3O0Bx+fmNuHRCiJZBCoCWDD2Bh y7JlvTNYPoZ1g1Phz32HRklwRKYSGf6UaloA/s+1DS6imBXdWAVQbZzEi/P3E4NNurfr lha0R51eFy78LjTb/MggHugKY2q3d7Jz40UXFkCwrDESCMDrdkjoryPWr27RahKLA/xz BhzF1tJRhSw3KG+n1M488vpneEPtCi1s+BnWxIYE/oY7p784fqwHdIDbIoYDkrMwUdk+ 7Z9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lyLCGQBg; 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 l10-20020a056402254a00b0042dbc78dfe0si798948edb.612.2022.05.31.22.58.53; Tue, 31 May 2022 22:59:24 -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=lyLCGQBg; 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 S241961AbiE3Oge (ORCPT + 99 others); Mon, 30 May 2022 10:36:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241678AbiE3OR5 (ORCPT ); Mon, 30 May 2022 10:17:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 904CF7354D; Mon, 30 May 2022 06:47:55 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 6103E60FD7; Mon, 30 May 2022 13:47:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84DFCC3411E; Mon, 30 May 2022 13:47:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653918473; bh=JSualys+wE7HH/++xefNdthks7nl0trL8q7V5fzWJDA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lyLCGQBgnxNMEyBDvQzvNXGzUFZiXblAbg/hf+FLuXWDATxD1Ukz7xwkfmd98cKs6 lgYJu9/ai11403mKQrY4s+kbIHmso9fQjxKZ+DtB79zqHxPc3C5grB4VuAIyCZrXLM FMnpIIJx+BizoI4GKSVKoRSCvZuwj+I/uOKYAjJuL1XrwMlxwhteCBGjpnvd0C37jK n+tmsxwSkNMpqIwrfceQL4v3gQRX5DlhSc3h+k+R7M9edQia6o/ziXQ5URaQ8KSKan p8y06/RUzsts25mVycJY4lLwmTcacWmuGAv/X4yVGN4bCeCF/nNKIhHzQXzzJ+HmX0 NAF97f0tabVuA== 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 5.4 21/55] scsi: megaraid: Fix error check return value of register_chrdev() Date: Mon, 30 May 2022 09:46:27 -0400 Message-Id: <20220530134701.1935933-21-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220530134701.1935933-1-sashal@kernel.org> References: <20220530134701.1935933-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 ff6d4aa92421..8b1ba690039b 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -4635,7 +4635,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