Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1023413rwi; Wed, 19 Oct 2022 05:59:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5AXMfI/ImeXs0iWPocgsHtdiMq/bXwhiy27qlcaixOAVJvVGKXiATQtfMV1/a4r9aIh453 X-Received: by 2002:a17:907:5c2:b0:77e:def7:65d8 with SMTP id wg2-20020a17090705c200b0077edef765d8mr6787486ejb.487.1666184345392; Wed, 19 Oct 2022 05:59:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666184345; cv=none; d=google.com; s=arc-20160816; b=LUfp7Lfzpbyc+8cUE2y5OM3UmjWLw8H0ApTevApBAvTdtp1gSI//PWxXbbMt8Bi1xv cmw7dNrSJlrr6YIjE7DG7ahgR04CokUsHr/vAJr/qS14gDn/ca1yotESD34fS+b9QJIx K/iDgkSykE48fYqhYfJHjlDoOSWaUWkpD5Zm7AsaphZra/ZF+QFh5uf5gcldnfzFp/da OOtlJRQmD6hr8Xl5TZfbbsO1A+TIzU/dc2HsBJHEi6t055Pqbsk+qvOoryUwnNv3x5Lo sHONmTSNjp0Cc/LUlQqIEhzkjtEXvVimlhJyyJ3lqYzUJZdsJASEPT93/Z7GgqE/Mtmp ng2A== 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=2gns+FEdS4MRDGVMHTHPbHNp/HxSEF7fIZwKgvc6t3o=; b=SC2yjDkSsvviQfgdN/tYrNjHd4DmAotQLTxrX3/qpeDhfvozTKwUalR7p9WryDs9AF 8NZPXMXB0TqT/MqgcKZVYG9ljdd1o7ZLIVl4cnjMMx0rongJ6+tY5cDaXsfyEl7xcemD rwlUmPvCHTjlJbguuAdzjLW6UHh/k91vDVsDWusc7IC+5D6FrQDZ9Y6kWbGbofcRlwyJ bwNyjuHazK40Nl9wJ6Gkxs+j8HwHE5lwW8Wu2wz8Q/sQTUn6NbklMzonK5mgKARDsR8b VYKnzNF82IOIi/P3fO/Dvs5pwDSRvBAqtFwxQSDw7H+b5jdsMZ9SKdfcrM5+FG2INhAL JlEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sNT3XQMg; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sc11-20020a1709078a0b00b007303db545e6si13441302ejc.786.2022.10.19.05.58.38; Wed, 19 Oct 2022 05:59:05 -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=sNT3XQMg; 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 S231837AbiJSL4E (ORCPT + 99 others); Wed, 19 Oct 2022 07:56:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232624AbiJSLyy (ORCPT ); Wed, 19 Oct 2022 07:54:54 -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 4DAE8BE51C; Wed, 19 Oct 2022 04:34:13 -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 D30A6CE2157; Wed, 19 Oct 2022 09:03:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B50C4C433C1; Wed, 19 Oct 2022 09:03:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170220; bh=1OAwvSabGh6LnKItuicwtRw9I08Q/Qc3Yz5P8kejiIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sNT3XQMgoTyxVBCMHZf/jf5RHQ+SvhM/NLbITtdDL/txxfriWRt0HkIQsL3h4mFOp EEqwgmIxHHydCYJnLYnFT4Bbvh8wQcigyVvIXdgsG7Ph0/mtXcF2++fVinaSEnkmGt ussTs7x1W8ncngz2BURXn6bAN1X8GQVRvfOI3nZw= 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 6.0 573/862] fsi: core: Check error number after calling ida_simple_get Date: Wed, 19 Oct 2022 10:31:00 +0200 Message-Id: <20221019083315.296999903@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 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 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 3a7b78e36701..5858e6339a10 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -1314,6 +1314,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); master->dev.class = &fsi_master_class; -- 2.35.1