From patchwork Mon Oct 24 11:31:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10190 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp641655wru; Mon, 24 Oct 2022 13:36:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7HAyLmmMjcBwB6tW2oTy+t7LarFAM2d1PdQ3uIr5jL83zzkQviPR4+1ks4Y8oswqhgnFss X-Received: by 2002:a63:5a1b:0:b0:461:9934:6f62 with SMTP id o27-20020a635a1b000000b0046199346f62mr29727951pgb.266.1666643762570; Mon, 24 Oct 2022 13:36:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666643762; cv=none; d=google.com; s=arc-20160816; b=YQW26tThe9eyNztCw8l1NFI1AHQoOFvYBQpMf8iHiwxQQOhCyqp7pQ+1Bx4AxDndj0 XFDnQLfBZUVCQGD50YYQ22Dk/m4YI6oF4/Rj6zaQkYe2e/T+d7Y930zzlj2w6jP5dyiM CCDRy51eqfS+yTpj0tns6KGqVIzDQiHsZ6OKpJnTttZBeQj1H4D4sPVPtIpAYUB6ut+c q8nirPiAzgQZ/6wX1cGOpDv1JPwuDH4awcryfOHZxO43teWabZv04leGm3OcAgotbe00 EZSfjdsimYSgDnsNgW5ZXXlcAJYxjr4WkyR1w4UiWEh+ZueEOOOmwTCvZ70ek/wNrxwZ NoVw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mhrnEAmN77+RJHaVT4tPm8zG5lYwoWjh+dwR9ZXYH3U=; b=pWy4Y8p69s4WwEHeGpBVfQWN23bmSBr6v2xHJCkmjlaTAyQr7FxqtqiBfvCn3RqvRX PazBgQKb9O8NMxc/j57oVggbYDPEPS+G7fehXheAkypDOLOAWD0lmbFg6sB3tXvOG//3 NtGCtxKRuXSYzeoaACgj0OoQYRZZWjqPBapcWx7x+/j/fRFS3R61RIYTYHWgJRz3LuJM kn5he9ZAlMS6lP2acsPM15GeDRRzTXOVinNxYe5dAAQyB7ZOQcdhNYRxy6Z08VZNLbmm oiLXCG/Pli5cklWa2nul51y72xrtyOc/OCPUsNNchns/w7AH7MztUBwEenCDuAIoLENH YKsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=F739Hle2; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e9-20020a637449000000b0043c700feb0dsi601121pgn.160.2022.10.24.13.35.31; Mon, 24 Oct 2022 13:36:02 -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=@linuxfoundation.org header.s=korg header.b=F739Hle2; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231928AbiJXUZm (ORCPT + 99 others); Mon, 24 Oct 2022 16:25:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233548AbiJXUXi (ORCPT ); Mon, 24 Oct 2022 16:23:38 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F04BDFA9; Mon, 24 Oct 2022 11:39:06 -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 ams.source.kernel.org (Postfix) with ESMTPS id D4BE3B815F2; Mon, 24 Oct 2022 12:12:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C98DC433D6; Mon, 24 Oct 2022 12:12:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613560; bh=KqJLZ6cRDvhGDBZ0Cn5kRIj2K7+4uDN50DC5R9l8bLk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F739Hle2KcghIukFwsHB048C9d7xiQDi9sBMal7CgdYgERu8uzHS9HXGjJ7n79gYE tjXa2XjekJXG60RJVWEmlZjLfNfJRxoI40SilGEiHbwQrgTc0uG8m9nic8yBdASmBL 9uEiGWUfcIAV8LJTS8Lcl67LhY4MzWp809nVe/1I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiasheng Jiang , Eddie James , Joel Stanley , Sasha Levin Subject: [PATCH 5.4 156/255] fsi: core: Check error number after calling ida_simple_get Date: Mon, 24 Oct 2022 13:31:06 +0200 Message-Id: <20221024113007.831407481@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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 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?1747602649821932313?= X-GMAIL-MSGID: =?utf-8?q?1747602649821932313?= From: Jiasheng Jiang [ Upstream commit 35af9fb49bc5c6d61ef70b501c3a56fe161cce3e ] If allocation fails, the ida_simple_get() will return error number. So master->idx could be error number and be used in dev_set_name(). Therefore, it should be better to check it and return error if fails, like the ida_simple_get() in __fsi_get_new_minor(). Fixes: 09aecfab93b8 ("drivers/fsi: Add fsi master definition") Signed-off-by: Jiasheng Jiang Reviewed-by: Eddie James Link: https://lore.kernel.org/r/20220111073411.614138-1-jiasheng@iscas.ac.cn Signed-off-by: Joel Stanley Signed-off-by: Sasha Levin --- drivers/fsi/fsi-core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index cb980a60af0e..09e571578232 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -1271,6 +1271,9 @@ int fsi_master_register(struct fsi_master *master) mutex_init(&master->scan_lock); master->idx = ida_simple_get(&master_ida, 0, INT_MAX, GFP_KERNEL); + if (master->idx < 0) + return master->idx; + dev_set_name(&master->dev, "fsi%d", master->idx); rc = device_register(&master->dev);