Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp836076imm; Fri, 27 Jul 2018 07:01:52 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc2CQjaZnsvS5WV8MuVY9IPSHyewNjDkgDmcsZ0lznk/4wxQiD0C4biSgpldOQbLXigpuUL X-Received: by 2002:a63:90c8:: with SMTP id a191-v6mr6275520pge.173.1532700112733; Fri, 27 Jul 2018 07:01:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532700112; cv=none; d=google.com; s=arc-20160816; b=JJps/JlCUlavKn2ecw1HwJ/poWY1o1wPwyTWBHGluMInQBQDwdzEbPp2QWmRn6voU8 X3cptPVO0pf9mlH8XQucYYuXND0CA5YBoOyezevljqyBg4XGomYk5UcJ58iUf8T6ROEx l7z3Hvueowvx+fk8wDeWyH78st434bRUpUb2eJXUeRGpHD3CdTHERTmmEybZ26KFGKEO 5W5GsnSK6iXwK/jBrWCvp53ZwIGJTq6QqxI08dNH6pkHEyTUnfMT94esLK+3OvT6bclV 8QpDFQZEYS5avY6jVp0vxdLl0CljNG8jvJPgLEz2mbP41iEuV5KjWyJUGNu1UZetWqOG EjLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=PvMyag2gFWIOtOJYBUi1yNXoTY64Gpo7hiIU6M+J6DY=; b=BRsBTdCyMkG896FCDy1csXQCYNmxflcXocqgeskU+IwiGqz49BBmSS3Hu94Zs69b21 xFLi4HzUVXR/cx7ZflYBjWC3h8tZ0G8y3c6ztffUHlM0m3gjynZczvnsfW44VuSnjhl4 jB5TNs4LUU/1ZXk+FvsRZddRl0153SxpLjTf/WPOqbBnD6tEeTvHd4J7wHayoZ4Ymubr ZYtRsQGzoDpjOZ6uRp7hMsukP5QKBcx3yPpqVfPj5cF3kpkmetAlhBgnPk27ZZBehAn0 Gqwog3iyQIx6BpfhAPdZm4+5tUqrMNf+vVlHvg2y+BOUXpPfT94o542BTOJdAdfOydTy 2bvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g27-v6si3651124pgm.208.2018.07.27.07.01.37; Fri, 27 Jul 2018 07:01:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732846AbeG0PWA (ORCPT + 99 others); Fri, 27 Jul 2018 11:22:00 -0400 Received: from bran.ispras.ru ([83.149.199.196]:20113 "EHLO smtp.ispras.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730714AbeG0PWA (ORCPT ); Fri, 27 Jul 2018 11:22:00 -0400 Received: from myklebust.intra.ispras.ru (unknown [10.10.2.207]) by smtp.ispras.ru (Postfix) with ESMTP id 8E441203B2; Fri, 27 Jul 2018 16:59:54 +0300 (MSK) From: Anton Vasilyev To: Tony Lindgren Cc: Anton Vasilyev , Liam Girdwood , Mark Brown , linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH] regulator: tps65217: Fix NULL pointer dereference on probe Date: Fri, 27 Jul 2018 16:59:29 +0300 Message-Id: <20180727135929.13406-1-vasilyev@ispras.ru> X-Mailer: git-send-email 2.18.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is no check that tps->strobes is allocated successfully in tps65217_regulator_probe(). The patch adds corresponding check. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Anton Vasilyev --- drivers/regulator/tps65217-regulator.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c index fc12badf3805..d84fab616abf 100644 --- a/drivers/regulator/tps65217-regulator.c +++ b/drivers/regulator/tps65217-regulator.c @@ -232,6 +232,8 @@ static int tps65217_regulator_probe(struct platform_device *pdev) tps->strobes = devm_kcalloc(&pdev->dev, TPS65217_NUM_REGULATOR, sizeof(u8), GFP_KERNEL); + if (!tps->strobes) + return -ENOMEM; platform_set_drvdata(pdev, tps); -- 2.18.0