From patchwork Thu Nov 17 12:30:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Korotkov X-Patchwork-Id: 21641 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp375207wrr; Thu, 17 Nov 2022 04:39:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf46r7rU3lhOrFvT74VrmWkSnN/hS/K7kuAkdql2v/ydf7aKyGiGaOgp7YyjZvIMfMPu3jrF X-Received: by 2002:a17:902:b40b:b0:186:c589:9ed3 with SMTP id x11-20020a170902b40b00b00186c5899ed3mr2685969plr.52.1668688776494; Thu, 17 Nov 2022 04:39:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668688776; cv=none; d=google.com; s=arc-20160816; b=ZSV14R04bIWA4lJWX7kCXct7ReXdmW9WFXdD0gcgvcf54PIILiRx6Y8lxxUuVsrX4m YYo8QHayrYBo+I0BrVWV2hffRu7xIfJKI2zFqekDN38hdjODlvBzTFVb8YlTpuEyQRhb QiGLqB7l1y4FRaccpt5/W4oiyevLe2zSw8fy6hbtcOEBsOcZDgBwjPLOWW5LJ++OXrvP rxb9iI93PyronYM35LTDwpKDTUO2MgjbrkGYD7TW7d5ndTusxnGUZOr+76MHeR5kFQz3 Vm+OtCcBpsCsfnWN0XboJjI5h6+PksMiz0yuwTEGrfYPL1e38EfudDeaLEzqfA99kUsF bQtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=25zzCeIdQLt2oZnq3HAIA1FC7vZFFoxeYg3WH60K9nE=; b=W9pPuZBbkxnDuN0mFjFyR93ofP22sWjJVghIPzD1ROy3laxVmZYGEcKVYoxiSHZZrd dSxy2HxwDmBnpRedrI0/sTldtRa3zb+TyMp36pgo2jHVxCUakG70J6ER91A1uzl/oOya FtbObxM08gwYY1HW9oIZ44a1R3rYOT0fItCCE988I0qAEMgZlaAte9AlfNWH5z5MwwHF UuEUkpZQTmzt9SPb6Cfiabg+CdXVkTnJSlpt7R6vLKeU+MqpayrznIFayjyp9xJexSFH KW3PIVFguk4UuYm9/Wiis72nTRpgxIVYXnHPL3JMcWFmS70ucmYMueEE3p/6qsCUUCe0 h1Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qPGMkYwe; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g6-20020a056a000b8600b0053abea59ab7si883360pfj.336.2022.11.17.04.39.23; Thu, 17 Nov 2022 04:39:36 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=qPGMkYwe; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231634AbiKQMda (ORCPT + 99 others); Thu, 17 Nov 2022 07:33:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239823AbiKQMdI (ORCPT ); Thu, 17 Nov 2022 07:33:08 -0500 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC4A876146; Thu, 17 Nov 2022 04:32:18 -0800 (PST) Received: by mail-lj1-x234.google.com with SMTP id k19so2529940lji.2; Thu, 17 Nov 2022 04:32:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=25zzCeIdQLt2oZnq3HAIA1FC7vZFFoxeYg3WH60K9nE=; b=qPGMkYweiJF1ezIePnlKNNr50vIJs3qoth6up0ubbki0AWF6i0eXAYm4WpLeQrR6sV RI/LDYMNVXusVREwcxiVtzn7fXDWZxc6vm2I2uUgWz6FS1D8PTc3E+NjhbNGqrhdyxSB urKQy6MCHB6xfhCuQIWsIR8ezalcpIoP9jLu2A6Rj9pbZ2TWKWlUTT/CLpcd09/Lz8Bp FhpAutf3kXqJqaLqKNuFdzmKCmVhVEnQMDTjKQ9wK6taAILCYbuDCjFIIQ+3RIpbgPiX n8RaLcWHx9Q3Tgi88H2LjUyGC/dvCgrPi6EVONCZRFGX51Q06JkviHBloW+6gbQwcfMD L+BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=25zzCeIdQLt2oZnq3HAIA1FC7vZFFoxeYg3WH60K9nE=; b=O/fKsGU3j2DVZxeE6U1ReervR3VNCV0Dn8E/QLyR0PQrRSQUpYta7NjpcKpb2Tts5s 3dqYIh4JgytuSFMPgwuFCIdUE0XtrUiAXvXkl9WKqF7LCAaXZoZ1fBR7YIiLDJvLCh9Q EaRR+BUpXqXJYJikyOYQ4K/ePaiX5PqJ6LPUlznmjLq26KpwEe5DdCy0ZogLGWbrYMPD W+VwV/yu9XgTbC4OrI/ucu8axa3f7QKiTLeFBVmNDi0eKL1LJl8NDLKXGEJZAGqpmFUR wXiH2iK3BF7h68rZuJBCcg/o8Xp3aX186tZkq4o9S3k1V5I1GHeTEH26GhgGz2hEa8Ay r32w== X-Gm-Message-State: ANoB5pmdUNUEyTZR6tMNoQNsqyj0M1Usy80qF3yIdsrsohbiQn3d/JIB LFc8Tck5/rOv5gGeyVUQuwY= X-Received: by 2002:a2e:88d3:0:b0:277:72a:41a5 with SMTP id a19-20020a2e88d3000000b00277072a41a5mr1020205ljk.352.1668688336925; Thu, 17 Nov 2022 04:32:16 -0800 (PST) Received: from mkor.rasu.local ([212.22.67.162]) by smtp.gmail.com with ESMTPSA id k20-20020ac24f14000000b0049ad315cfc3sm127362lfr.162.2022.11.17.04.32.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 04:32:16 -0800 (PST) From: Maxim Korotkov To: Tony Lindgren Cc: Maxim Korotkov , Haojian Zhuang , Linus Walleij , "Manjunathappa, Prakash" , linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] pinctrl: single: Fix potential division by zero Date: Thu, 17 Nov 2022 15:30:34 +0300 Message-Id: <20221117123034.27383-1-korotkov.maxim.s@gmail.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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?1749747002214592076?= X-GMAIL-MSGID: =?utf-8?q?1749747002214592076?= There is a possibility of dividing by zero due to the pcs->bits_per_pin if pcs->fmask() also has a value of zero and called fls from asm-generic/bitops/builtin-fls.h or arch/x86/include/asm/bitops.h. The function pcs_probe() has the branch that assigned to fmask 0 before pcs_allocate_pin_table() was called Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 4e7e8017a80e ("pinctrl: pinctrl-single: enhance to configure multiple pins of different modules") Signed-off-by: Maxim Korotkov Reviewed-by: Tony Lindgren --- drivers/pinctrl/pinctrl-single.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c index 67bec7ea0f8b..414ee6bb8ac9 100644 --- a/drivers/pinctrl/pinctrl-single.c +++ b/drivers/pinctrl/pinctrl-single.c @@ -727,7 +727,7 @@ static int pcs_allocate_pin_table(struct pcs_device *pcs) mux_bytes = pcs->width / BITS_PER_BYTE; - if (pcs->bits_per_mux) { + if (pcs->bits_per_mux && pcs->fmask) { pcs->bits_per_pin = fls(pcs->fmask); nr_pins = (pcs->size * BITS_PER_BYTE) / pcs->bits_per_pin; } else {