From patchwork Fri Nov 3 16:27:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Limonciello, Mario" X-Patchwork-Id: 10040679 X-Patchwork-Delegate: dvhart@infradead.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CBB3160384 for ; Fri, 3 Nov 2017 16:28:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC94D27F92 for ; Fri, 3 Nov 2017 16:28:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B144329795; Fri, 3 Nov 2017 16:28:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7285E27F92 for ; Fri, 3 Nov 2017 16:28:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932997AbdKCQ1z (ORCPT ); Fri, 3 Nov 2017 12:27:55 -0400 Received: from esa3.dell-outbound.iphmx.com ([68.232.153.94]:50004 "EHLO esa3.dell-outbound.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756065AbdKCQ1a (ORCPT ); Fri, 3 Nov 2017 12:27:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dell.com; i=@dell.com; q=dns/txt; s=smtpout; t=1509726132; x=1541262132; h=from:to:cc:subject:date:message-id; bh=dU/qDQvhTIiSPeRLPD3WMSxD9F7kJC7eKQjV32g1oc8=; b=xWxwqO0sWPioSNhsKRYaAkJq1qeakwbFifBbR/CpmnWf23o1LmM4Q0FP s7gzlLDf6UUge+jcXVW/Bz7jDVkE/kQae14E9KaKBeBHEV9a+QbcnVHWI glpQ+Hj6Ar19n5VrHI14YvULXK7sIDaJ5r8zV6p5Kx5a69us0CQYbk2xc U=; Received: from esa2.dell-outbound2.iphmx.com ([68.232.153.202]) by esa3.dell-outbound.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Nov 2017 11:22:12 -0500 Received: from ausxippc106.us.dell.com ([143.166.85.156]) by esa2.dell-outbound2.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Nov 2017 22:22:22 +0600 X-LoopCount0: from 10.208.86.39 X-IronPort-AV: E=Sophos;i="5.44,339,1505797200"; d="scan'208";a="169424152" X-DLP: DLP_GlobalPCIDSS From: Mario Limonciello To: dvhart@infradead.org, Andy Shevchenko Cc: LKML , platform-driver-x86@vger.kernel.org, pali.rohar@gmail.com, Mario Limonciello Subject: [PATCH 1/2] platform/x86: dell-wmi-descriptor: check if memory was allocated Date: Fri, 3 Nov 2017 11:27:21 -0500 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP devm_kzalloc will return NULL pointer if no memory was allocated. This should be checked. This problem also existed when the driver was dell-wmi.c. Signed-off-by: Mario Limonciello Reviewed-by: Pali Rohár --- drivers/platform/x86/dell-wmi-descriptor.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/platform/x86/dell-wmi-descriptor.c b/drivers/platform/x86/dell-wmi-descriptor.c index 3204c408e261..28ef5f37cfbf 100644 --- a/drivers/platform/x86/dell-wmi-descriptor.c +++ b/drivers/platform/x86/dell-wmi-descriptor.c @@ -121,6 +121,11 @@ static int dell_wmi_descriptor_probe(struct wmi_device *wdev) priv = devm_kzalloc(&wdev->dev, sizeof(struct descriptor_priv), GFP_KERNEL); + if (!priv) { + ret = -ENOMEM; + goto out; + } + priv->interface_version = buffer[2]; priv->size = buffer[3]; ret = 0;