Message ID | 20221118104332.943-1-korotkov.maxim.s@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp115901wrr; Fri, 18 Nov 2022 02:48:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf4lSfy2a5onE1jWyAX06Q/dWAp6MxzERy8wmCPxPoXX8h1/brICX1linyWHmLW9N3JGMTHF X-Received: by 2002:a17:90a:194b:b0:20c:c0f:7c69 with SMTP id 11-20020a17090a194b00b0020c0c0f7c69mr7029418pjh.196.1668768502991; Fri, 18 Nov 2022 02:48:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668768502; cv=none; d=google.com; s=arc-20160816; b=fXMrQRAjfZG09dkCGmuNTrrL0xFi0PEGlUKj/XaGc4314nmS7+GFOzI9h4UgfSUvce /rXI1MgRoJsPBE54v9FGpEDCrTc6RoSNcmiIzYQ6avOKbnEDmy83rBBOZa5U4MpqRy+3 S+2YcHfdefQ0cgkXXQ8MtIV3TUQP9suh0+nrN4dqYZb7ZVYrIqxJ4PWWgzWuhIiZ/qW/ Dbibz4VGs/2af/Aq4gFg2U+RIXIbNv2SYGddWmjxPVmnndSQC6QZRUyux/eUcm5tT/GE xxaodgJFGRwTGm8PeB7SyTwoa0CfEa36s6JBBXepqUSOoWmvzO0PgcWxooHLWj3Ha1Bw Nslg== 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=M54rSFxQLijO3j26nQU0jB0r1Bnt0dCKzsYSgimLrI4=; b=QgdIpCr3xdwvC/W7y1PN6SbDTIGZUniYVBGq/NTzBkGHufAWc7K0AStRaCRbWPZiJS fvDD24b2Y5Vt84X5hPZhe2CRkqZb2hgRRJVxKxK2x6Nkc/IpHD1BW0F16hGJ5HfNvmV8 AROCCqJ6fDjtofx3K5JsugIUCpKKeoWKo2pIjqF3BvkRzW4j6RD/RAW3JE9IxV2Fzv5Q 8l5WEmAn3CRXPTkcylxINOxLizUYPhWhD0cZjnDLqmOiSuxAsgknwuoNCjx8LCo0yknS TRkxPvtTu5P96ugLih+FtZPufcexneYiqqg5dHvjVP93cwvL8OkF+pUPLqIvhrKZ7QO1 Tg3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KMvnRwY0; 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 cw15-20020a056a00450f00b0056cb8f6f027si3126054pfb.357.2022.11.18.02.48.10; Fri, 18 Nov 2022 02:48:22 -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=KMvnRwY0; 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 S241541AbiKRKoF (ORCPT <rfc822;kkmonlee@gmail.com> + 99 others); Fri, 18 Nov 2022 05:44:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241493AbiKRKn6 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 18 Nov 2022 05:43:58 -0500 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9EF111A23; Fri, 18 Nov 2022 02:43:56 -0800 (PST) Received: by mail-lf1-x133.google.com with SMTP id g12so7587257lfh.3; Fri, 18 Nov 2022 02:43:56 -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=M54rSFxQLijO3j26nQU0jB0r1Bnt0dCKzsYSgimLrI4=; b=KMvnRwY0L3d/A/JoE/GXTUQz3sVPfvFmvGZpaOggwoHMG6wnO+7CkXqhK7Q7RJI7sK WfR74K9m6eZtlWz+JZxVHEICLP4OT//621qOZhBu2Tn5k35N3yYUwesIA9mDw4uLFE4W 4JK4Yr3psUhtsKmVuJNkgIhBQTZ5eg4xmgGVGsEgl4njX5METYg97AT+Byxfaou20Mg5 uzsCERH0AZpX+8LAzQ/2CC8ScUhF5Uwu30RlWuNpIY9X3gb5K6WyrSdQSoTfRsPmhoHb NL1sGo6t0gtxPXc65aEsxspqq5QAfl+gMQgASAuNG5fNJGtDvTbsOM68Z3uB/xOQk8T8 FD4g== 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=M54rSFxQLijO3j26nQU0jB0r1Bnt0dCKzsYSgimLrI4=; b=gMw2yel/DbddWShEycCRp1KUPRti2gF3BM5v8UdIs7Wd3h3+zkhW2D6ksutjf76mDU NeLjkSO+6eZt+G9Y1F1/nL0DEEnayZtrYQU/lN74/o9HxEPtWGdFPA6ecdO/J/6RuYu/ znAlyXRH4OC9dCy0RgO2pX2fpxOLuyJpNffEwcQDsKpIYZE0UTfldTlu15FYyxgbeLwA j7K8Hoe/fxMP/m7YWLfrrtVz9zk+wwjimLkF5RBkIXhYwsSBdzbA6CdmoI8CzACS3SNJ 0CX+8YEwLASRlv2EfCioWN9ooZKQMPRtsQBHzH3LwotvSrESIzA9WEkDeyyuMgIQcFA8 r+EQ== X-Gm-Message-State: ANoB5pndm94Ft0nQ83EBqKOw+WSA2T3kxtkiERVnRbjDNHuwk9wqXkve 0nndVMblJgBkWaR8WSHeupw= X-Received: by 2002:a05:6512:324c:b0:4a2:2e51:85c1 with SMTP id c12-20020a056512324c00b004a22e5185c1mr2134919lfr.658.1668768235135; Fri, 18 Nov 2022 02:43:55 -0800 (PST) Received: from mkor.rasu.local ([212.22.67.162]) by smtp.gmail.com with ESMTPSA id v26-20020a056512049a00b0048b365176d9sm606174lfq.286.2022.11.18.02.43.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 02:43:54 -0800 (PST) From: Maxim Korotkov <korotkov.maxim.s@gmail.com> To: Tony Lindgren <tony@atomide.com> Cc: Maxim Korotkov <korotkov.maxim.s@gmail.com>, Haojian Zhuang <haojian.zhuang@linaro.org>, Linus Walleij <linus.walleij@linaro.org>, 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 NULL dereference Date: Fri, 18 Nov 2022 13:43:32 +0300 Message-Id: <20221118104332.943-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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749830601661418182?= X-GMAIL-MSGID: =?utf-8?q?1749830601661418182?= |
Series |
pinctrl: single: fix potential NULL dereference
|
|
Commit Message
Maxim Korotkov
Nov. 18, 2022, 10:43 a.m. UTC
Added checking of pointer "function" in pcs_set_mux().
pinmux_generic_get_function() can return NULL and the pointer
"function" was dereferenced without checking against NULL.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 571aec4df5b7 ("pinctrl: single: Use generic pinmux helpers for managing functions")
Signed-off-by: Maxim Korotkov <korotkov.maxim.s@gmail.com>
---
drivers/pinctrl/pinctrl-single.c | 2 ++
1 file changed, 2 insertions(+)
Comments
* Maxim Korotkov <korotkov.maxim.s@gmail.com> [221118 10:33]: > Added checking of pointer "function" in pcs_set_mux(). > pinmux_generic_get_function() can return NULL and the pointer > "function" was dereferenced without checking against NULL. Reviewed-by: Tony Lindgren <tony@atomide.com>
Dear Linus, Will this patch be applied or rejected? best regards, Max On 18.11.2022 15:52, Tony Lindgren wrote: > * Maxim Korotkov <korotkov.maxim.s@gmail.com> [221118 10:33]: >> Added checking of pointer "function" in pcs_set_mux(). >> pinmux_generic_get_function() can return NULL and the pointer >> "function" was dereferenced without checking against NULL. > > Reviewed-by: Tony Lindgren <tony@atomide.com>
On Fri, Nov 18, 2022 at 11:43 AM Maxim Korotkov <korotkov.maxim.s@gmail.com> wrote: > Added checking of pointer "function" in pcs_set_mux(). > pinmux_generic_get_function() can return NULL and the pointer > "function" was dereferenced without checking against NULL. > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > Fixes: 571aec4df5b7 ("pinctrl: single: Use generic pinmux helpers for managing functions") > Signed-off-by: Maxim Korotkov <korotkov.maxim.s@gmail.com> Patch applied for fixes. Yours, Linus Walleij
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c index 67bec7ea0f8b..5655a2da5413 100644 --- a/drivers/pinctrl/pinctrl-single.c +++ b/drivers/pinctrl/pinctrl-single.c @@ -372,6 +372,8 @@ static int pcs_set_mux(struct pinctrl_dev *pctldev, unsigned fselector, if (!pcs->fmask) return 0; function = pinmux_generic_get_function(pctldev, fselector); + if (!function) + return -EINVAL; func = function->data; if (!func) return -EINVAL;