Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1904185lqe; Tue, 9 Apr 2024 04:14:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW+iCa6l+oijZjsPjNCPjFmm+ABh+FiSeOoebfF7eViyz6nsmyCBE7HmFG3QfVAiJyPb732IH0KieLyQ/kBriOV+kvPysYQVvvQo2FNvg== X-Google-Smtp-Source: AGHT+IGtfVOe9EI0sN0zB/xRYaRnifMiBFm6z5syTLi1/AMxVVLNSz6XrisgvlvfnYQWM7sylVpc X-Received: by 2002:a05:6a00:1250:b0:6ec:fdfe:9bea with SMTP id u16-20020a056a00125000b006ecfdfe9beamr10352453pfi.26.1712661291296; Tue, 09 Apr 2024 04:14:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712661291; cv=pass; d=google.com; s=arc-20160816; b=OpDG+XNc9XyDclp3uELmkq9XXacYGgtHmzZSvHsPFNHV8AUPWQzvZHaYk1AeEpZS/C /WPoag/IHv2RZ99Xb/l2R96OPxzlAG1whR0KPFak6R/p+0ZyWD9R1I2AxbOg88m0VPJV SXehUZN1Jm0hVR61fZSOwA2GTPcCXN8DCn16In43P8mYBONBzIuBHfLu1u57j1Y7ad+W W7C1Bf877It7pHU9b9VhW8R5LLOmkbs2XQoyTb1GpQ9Ll7UqAF8cDe8S4FHB8Q0PYRzl EH3ip6v74HC0FmuJLEtDYcRq+Qg5WuZL3O6zrmpq4SkUQpeRMNb5mJirsV3E5xd40qxt NIKQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=TSsEOmMeFjpa4wdVSYXOGdmsaMpEPa60zsgqosWqJow=; fh=DhqdYrtMGvuf50UuiO0Drys+uvLgYcvSUMgojiExdrk=; b=BcWGZX81JoNrPFqUx37159Dd4sBXPjRey43Khlj9tAyXAom7Y4Jjqa2MfRn8i/oPAL 9oaySaP4ORfTs04ZvX34RxTK8Mqi4M174Gz0XTO//DM96h3KFb2DT05bejb0CpMcs7w+ s8wOiRsFSs+++NM6Y00mS4EzU7AHnQ2pGqzd+JbCQMa1O69wz/V066vmTBKJYwvXpgE4 Zk1wcEF8N3aZSve3+t+BYHdjT0EFalMCMB//x3jGmYTTdWw9XJvCjNkRvWd4X0w6gatv rZj3fzm0xKlKO0eLV0RVAwLqZNlWugqvELi3A221F2nemJBy59V7FcqhorSBQmJoCTDj ldQg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=ZK93D7+G; arc=pass (i=1 spf=pass spfdomain=163.com dkim=pass dkdomain=163.com dmarc=pass fromdomain=163.com); spf=pass (google.com: domain of linux-kernel+bounces-136723-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136723-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id k128-20020a636f86000000b005f07f350e33si8116333pgc.139.2024.04.09.04.14.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 04:14:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136723-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=ZK93D7+G; arc=pass (i=1 spf=pass spfdomain=163.com dkim=pass dkdomain=163.com dmarc=pass fromdomain=163.com); spf=pass (google.com: domain of linux-kernel+bounces-136723-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136723-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E418B288CDB for ; Tue, 9 Apr 2024 11:04:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 04F3685934; Tue, 9 Apr 2024 11:04:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="ZK93D7+G" Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.5]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 23114811E9; Tue, 9 Apr 2024 11:04:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712660654; cv=none; b=VZE5YGr5vdGKTfTqW+en3o0pn7OUWziZN33RLd+9YMgbHzAIzFGw/l0Pkcd0j3vdTw1l+IVIgLSi2iKC6gRRnH4slM8THyWRTosfvBAI04sGk6XY+34ctFG8z38E/Npi/RNPtxv6WqTyiO5OlVvVC0Xtxrdl9/W2tCDaEaGySUQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712660654; c=relaxed/simple; bh=rfBIQ16lw3YLziXerzIzYPI5vDnBIoD+c9BYXTQHuR0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Lh7VzTwdeUXONgS8yRsd/NXRz8e8LGoIGsnuserVCSM0BpTTp6UTGrVIhGTWk8tA6sfqUrjIWkDXDfhryHELcO09GkBGUCQzE+lfMsLUnSaHzf3DLiMDP82S+i53Aor4N7es+QaIj2CbpkzC0U/Q6G++0wKRDeZjRPXXmwTYXWE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=ZK93D7+G; arc=none smtp.client-ip=220.197.31.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=TSsEO mMeFjpa4wdVSYXOGdmsaMpEPa60zsgqosWqJow=; b=ZK93D7+GzJuOQcApaNkcC xAKy96ciTg4nKffwK8Qe7dIzr10itFNlG0vcuTnCCTEm/+B8urwBoOZgg1rF0X7H aNz08JIbB10S+Vh8LARJ0eXtui1SyPoVwMy9qPuCPh5ipEs1NEDV+N9egBuHPsWg m/yLaxeNP9YjTIqgYNizpk= Received: from icess-ProLiant-DL380-Gen10.. (unknown [183.174.60.14]) by gzga-smtp-mta-g1-3 (Coremail) with SMTP id _____wDnl5dgIBVmhGZSAg--.8304S4; Tue, 09 Apr 2024 19:03:13 +0800 (CST) From: Ma Ke To: marcan@marcan.st, sven@svenpeter.dev, alyssa@rosenzweig.io, linus.walleij@linaro.org Cc: asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Ma Ke Subject: [PATCH] pinctrl: apple-gpio: Fix null pointer dereference in apple_gpio_pinctrl_probe() Date: Tue, 9 Apr 2024 19:02:54 +0800 Message-Id: <20240409110254.2201457-1-make_ruc2021@163.com> X-Mailer: git-send-email 2.37.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:_____wDnl5dgIBVmhGZSAg--.8304S4 X-Coremail-Antispam: 1Uf129KBjvdXoWruw1kCFWxCw4UWF48Gr47XFb_yoWfXrc_Ca ykCr97J348C3WrW3srtw13Zry0ka15XF9YqrnagasxCry3Xw1UJrWkuFs8G3yxW34kGFyq k3y8X34rXr1UujkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7sRNv31JUUUUU== X-CM-SenderInfo: 5pdnvshuxfjiisr6il2tof0z/1tbiPQG7C2VOCYQteQAAs+ devm_kasprintf() returns a pointer to dynamically allocated memory which can be NULL upon failure. We add a check to ensure that failure does not occur. Signed-off-by: Ma Ke --- drivers/pinctrl/pinctrl-apple-gpio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pinctrl/pinctrl-apple-gpio.c b/drivers/pinctrl/pinctrl-apple-gpio.c index 3751c7de37aa..af2f90d1950f 100644 --- a/drivers/pinctrl/pinctrl-apple-gpio.c +++ b/drivers/pinctrl/pinctrl-apple-gpio.c @@ -474,6 +474,8 @@ static int apple_gpio_pinctrl_probe(struct platform_device *pdev) for (i = 0; i < npins; i++) { pins[i].number = i; pins[i].name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "PIN%u", i); + if (!pins[i].name) + return -ENOMEM; pins[i].drv_data = pctl; pin_names[i] = pins[i].name; pin_nums[i] = i; -- 2.37.2