Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1188058imm; Wed, 1 Aug 2018 11:39:55 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd0daFzd7tKa9jbLg5ZW2OfuZkhbw6OlvcvjIwdAsgQ/6DLWhWic3ICizWA7grmwN0L3oNe X-Received: by 2002:a63:4a61:: with SMTP id j33-v6mr25626292pgl.436.1533148795434; Wed, 01 Aug 2018 11:39:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533148795; cv=none; d=google.com; s=arc-20160816; b=Y0scB8zWz8GHi1n9Vy/EBOPi7ke4NitqnhFDvqqjs7VFBW8lKRPq35XNmGFWOpGLxh DUnH/4aojvUi0iSHjCKuAQYqARU4+oWa7OSiJgBFPRpqOj2p8YzcTrO7pXLjGVMAX2Ic fR5PLIfKPBQQB+fQxyLK1PU2poVgAniv95IpFBzBn1O4fqEPZ7iCNnNNU4AoODkS5e72 0Cc//g4iUP2klspKuCwMjpI6K/eJNp9Q7KT+fgyyz2fzpGfLXuGfPH33uRk7pOFdDo29 T6CtOp6heD8PTNDWR/mtL1F8W5381SDodtOlJdDfowfDghW4MOAolCl/YBtoMEKZsnMD gSig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=AEuxU+RrmcJzzmMOQHyifCwZ+9iESsKRD5NlJK8j514=; b=gVeA4GImbI2+nu66AFGCI2vJNm+pKbQ7X9VeOIM63s9KwXdglwKEk0/T6TNHnV53K9 dZFYU9hX/DL9Xzl+e5p7EQ6Wxd+zf+/vTWF0udqxdW+H5p+yrsZa+OJb3Puf30mtzgdD grZO30o0jXyrATKKfKLByQ675WIxs0HH5QpWc+1a0ReojfZRW9EdCZgLBvHoWwPENAZa sXFtwHYDynDB8OcJTvueQQoE/0HKp/hp5K273+tVkeLgjuVvfqHKvew3ih/XQRKtfIWo 8rSvrkp7VjGM1K200yhj/oFxmoZBdhPcLORBTM3T8x+swLWUX0urDHRq1HxS3FYQdFjT t8DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SYEQxO4u; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n11-v6si14852631pgv.242.2018.08.01.11.39.40; Wed, 01 Aug 2018 11:39:55 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SYEQxO4u; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388712AbeHAUZY (ORCPT + 99 others); Wed, 1 Aug 2018 16:25:24 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:35905 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388660AbeHAUZY (ORCPT ); Wed, 1 Aug 2018 16:25:24 -0400 Received: by mail-lf1-f68.google.com with SMTP id b22-v6so14010175lfa.3 for ; Wed, 01 Aug 2018 11:38:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AEuxU+RrmcJzzmMOQHyifCwZ+9iESsKRD5NlJK8j514=; b=SYEQxO4uTofgyVJqTrLjNFpkz+XUA4wV57O4XxJtLrYWNj2lpYYGM+KdcEhY0pE3Oi HoY+cYUUnWth3DgJxS7OnL0AnAcVzgQsE79PEQyS2JA/z0UE7yxjoptso5KJAxUDbf0N h019E+t2irg7wO8haBMU0K7Hzu4IsY10y9m7959jO3pjRWuO7EJM1Ti/Xi9jWAsvvWKt v2Y+rUqXbm2c72y25AAPwlr24fAgpZQLWVuvoFiay1/nfy4/m6xLXpNns1Ww2AX2cdOB o1sYMw3shvttm53iI4zVXhRLXpA2ne74j9BHbWEtCXrkvPQFCT4CynqKCX94ldHTI6YP chJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AEuxU+RrmcJzzmMOQHyifCwZ+9iESsKRD5NlJK8j514=; b=rFZUaTsF2f3BnBBpheV0nDBW7MZJKAHnOy57mFSGuHryzlVYiuM2CAb9KMWVvEjy5i KvFlQy0SuPkWT2UNZSLMO18HP0igfR21JUEL5XQCJpoyW6fR7hdNEA1zyBKAm5atckb4 wYv5+P/vJkU1wZfW4HcSo/LuXg7zp1QMLupNZDUVwLItghH8yKDjN1PskW/aMmqN60+9 tTnrKkGRSplYjYKs4KIG5RalxMMO9a2FDFN1xPevSJF4omYCqhOgHvfcMUNiKakaGkSE hJmvZxALG5QoHhL9hghaFnVdb197SM6BZxOcODmgCNrqRPHgDJO9t8IagDeQQctgo+NH hLBA== X-Gm-Message-State: AOUpUlGgcvLQIedFEjx2tmzXxCbUVGcPkUj5/V+OChD80QbQlnfQAHCq 3OXdTSFOca75HpSQrwjAn4s= X-Received: by 2002:a19:5788:: with SMTP id l130-v6mr17435930lfb.93.1533148697918; Wed, 01 Aug 2018 11:38:17 -0700 (PDT) Received: from localhost.mts.local ([5.144.106.90]) by smtp.gmail.com with ESMTPSA id v136-v6sm2491473lfa.10.2018.08.01.11.38.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Aug 2018 11:38:17 -0700 (PDT) From: Ivan Bornyakov To: devel@driverdev.osuosl.org Cc: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, benchan@chromium.org, jnjoseph@google.com, rspringer@google.com, Ivan Bornyakov Subject: [PATCH v2] staging: gasket: sysfs: fix potential null dereference Date: Wed, 1 Aug 2018 21:37:44 +0300 Message-Id: <20180801183744.30293-1-brnkv.i1@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180801180807.GA31510@kroah.com> References: <20180801180807.GA31510@kroah.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add handling of possible allocation failure. Reported by smatch: drivers/staging/gasket/gasket_sysfs.c:105 put_mapping() error: potential null dereference 'files_to_remove'. (kcalloc returns null) Signed-off-by: Ivan Bornyakov --- drivers/staging/gasket/gasket_sysfs.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c index a4bfca43cd03..56d62aea5111 100644 --- a/drivers/staging/gasket/gasket_sysfs.c +++ b/drivers/staging/gasket/gasket_sysfs.c @@ -101,6 +101,11 @@ static void put_mapping(struct gasket_sysfs_mapping *mapping) files_to_remove = kcalloc(num_files_to_remove, sizeof(*files_to_remove), GFP_KERNEL); + if (!files_to_remove) { + mutex_unlock(&mapping->mutex); + return; + } + for (i = 0; i < num_files_to_remove; i++) files_to_remove[i] = mapping->attributes[i].attr; -- 2.16.4