Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5284875imm; Tue, 31 Jul 2018 08:25:49 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfvLwCJSEFA7Ax6jnIEkPRL65kmWzUpFIR+Cama/fgcEOvcRLZ/wpUKDZFbC6+bh8k1Ja8C X-Received: by 2002:a17:902:8541:: with SMTP id d1-v6mr21179131plo.81.1533050749437; Tue, 31 Jul 2018 08:25:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533050749; cv=none; d=google.com; s=arc-20160816; b=XaJMOgr1XojHiysKn+/nXHAt6tNKWHO29EsyHgQL6AqOtA6mYR+f1lFeH4sBc6vG6W LRl28d41Bso++TWzolMK19A+t/nbTQ3LJmwol75x4Dwr4Zl3gFcqE06zumRMxuSiTPBy ihIws35O5+RRLR/QmoEji0gtsAnk3LMjKbkCG3B3LIr3dPCLTVzB0xWAX+M8AVDmqhIR 8RC1X+QkB5itp0v2p30tUTpht7t7o6+KexMI3crSk4Z8z5p1fxrPI6ZGIudg75Oo8+Ie EjJGH1/mjCqTKOY0egVbEnPCEbSqBW+zErDgAdP4+77Zr2priIbVAnYffWGTXsGjbb5j aV3Q== 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 :dkim-signature:arc-authentication-results; bh=GpP6k4JTfrqeihunp3ivhRw2aZFUwsJn6HIbR/dMplM=; b=ZKgOEBh8mMm0yJuRG+yXgjnUyBpB2LWtomBSx0xqmDQQmbxH6jieEoZE43zkdPQr4C UGHoV/D38yQpu17PHVXVM7ghrC3mGDy90d/j6kGDusOOwvMTRPLKyVnla7wPFoWVT/uw E+Vr7eLw5vl4AXXZJJGsKWtayQgDGJfWnatgLlM7EZeVVz7JUxsFZvctDZkBlMupCZcd Pl4VgSTCRJGXkW6LOG1IvtHIIQ4bFM9tq6PjM+iM41glxVhUPS33oT66X3rgedka10Ei ZsTZzH9dhiDD8qc58pSJs0ib7jRpffTzu/85ibe8QHX22z0NwrnBQRqIYm9VwTBtLicY aphA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nhCFErvj; 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 c3-v6si4218466pfg.181.2018.07.31.08.25.35; Tue, 31 Jul 2018 08:25:49 -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=nhCFErvj; 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 S1732344AbeGaRE7 (ORCPT + 99 others); Tue, 31 Jul 2018 13:04:59 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:34231 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726789AbeGaRE6 (ORCPT ); Tue, 31 Jul 2018 13:04:58 -0400 Received: by mail-lj1-f194.google.com with SMTP id f8-v6so14102109ljk.1 for ; Tue, 31 Jul 2018 08:24:08 -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; bh=GpP6k4JTfrqeihunp3ivhRw2aZFUwsJn6HIbR/dMplM=; b=nhCFErvja+2FXOK0GxY6DjLZasQ4AxKbMrGse3MmY2DPv1jm44J1zxxaSey5SOs4GR XaEFHykMebSUgivIOATKI3eOagb+AuxUqjRIu/xWb2ykDvhTc4/XJGNrQYSrw66lmEnV BmuPROU7PpPGdCk3vzRZpnjm9VGwKHBVkfiQAzVMFF2YkWqONDSUVj+j2G6yt85+X/7z 9QErhpdkG8jNcJVKmVjFk8Yro7RnssgpEHihhZEg6ZF2YqrnIaeltTVfGABn4zq1CZqv 2NLL6ydhwhnayaXJkluta2sqiXH442WHCjgVnmZh0CiFXYdMQrDzGpoYp3SCn1y+6v15 iEJw== 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; bh=GpP6k4JTfrqeihunp3ivhRw2aZFUwsJn6HIbR/dMplM=; b=Ignio/R5GhHNcedvvF3QQm7yplvZ9cES8+7V9ZZMEpIxgDLw5JsAirHUxbA3bBkMaB Mz8P/JBeNJ9QsMlCvexxspEFYY39VGECNPDzrNody6eHd9/Rx4hlX8ROMz7X7ViAlyHh qOLuIDDrU4F5uRl2Te6O2Y8YKFSGQRJFIo2LOlRzLJqXJ2e2je24VbqwQAemt7xIyCCG wV6H2lmKQYXMcxb7UOjTT9ajfgx9/ycWEKB4CD9bsPpaQWpqdtva30eiVIN9qfsJUdx3 40trg7Eh1WtKn8YAoDvIN6//ssPQXZzta3gi49U9u1Ya/sml8WrPT+OKI63lIEM1RsXF T3pQ== X-Gm-Message-State: AOUpUlHoV70/Tf44iG2dzKrYVvpkuO8hPwarzvljpfUnoSCQOhYuBnqR qI68kbZhalMI3rTZrTPoB44= X-Received: by 2002:a2e:1004:: with SMTP id j4-v6mr17433673lje.2.1533050647911; Tue, 31 Jul 2018 08:24:07 -0700 (PDT) Received: from localhost.localdomain ([188.162.65.47]) by smtp.gmail.com with ESMTPSA id g133-v6sm1998271lfg.81.2018.07.31.08.24.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Jul 2018 08:24:06 -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] staging: gasket: sysfs: fix potential null dereference Date: Tue, 31 Jul 2018 18:23:20 +0300 Message-Id: <20180731152320.11575-1-brnkv.i1@gmail.com> X-Mailer: git-send-email 2.16.4 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c index ef4eca02afa6..682e5c21f203 100644 --- a/drivers/staging/gasket/gasket_sysfs.c +++ b/drivers/staging/gasket/gasket_sysfs.c @@ -101,6 +101,12 @@ 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) { + pr_err("%s: can't allocate memory\n", __func__); + 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