Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3514769imm; Wed, 5 Sep 2018 01:10:26 -0700 (PDT) X-Google-Smtp-Source: ANB0VdboAxE2YeOKZ+gBlVeUhBAucg4yrGzqFCP26fILkG3PRcM7OfGKDnuvyTwdb9N5/okGbcHw X-Received: by 2002:a63:1516:: with SMTP id v22-v6mr34792538pgl.150.1536135026384; Wed, 05 Sep 2018 01:10:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536135026; cv=none; d=google.com; s=arc-20160816; b=ecyFLlBrf4OtQ8Rk/z5mM0+BJUTHnJM5ka9lK1Vj4f9yiBZKJ1l/GQKaeIFFjsk1CG CcTOwMSRyRa477yDBjYRbgOxY78pa5BpCTrNQdoWOLPixvOXoz+SLSRWyMTrroh6bSkI 9LsLwmGsBQzLeAoXAJSPem1K8bZ6rfBEN0ODbTbY68Zicz02GsHJSoEcYjagguSKSir9 /nAFvZ7f+F+GPENwTiN1QhJsJtkn+v8z8bWq55GsTRfAb0+76dj2yc3d+F2VRtWP4HOq Wl3V64fhZ7SFFn1NOygA3rIzqvsyhAZMGrgo213E3QiiEP1SarPEjqkGH5zNeuYJyWvZ 1Ccw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=wucLOe9FGaO4zjqtYykAipzc0sp+iISCPDZTv0/at7U=; b=LloBe0uCVmmRH8/ReAbfVu7O9tZ+6Cmgj8CHMcyQBgps3epILift/+GJ6JGvRnqXiM 5mUfmTZCKz/H5aMmsuZPWInNoD4I8PUy3CFUgYgN5Z745So/jek5cRX/eUWLgXtTtmPM qAFur7S8v2Wpb7y7rXQEt8ZTfZeLuJPES1os0QtIJxl4205etTAuVrm18iQ9Hz71POOq Yv7mAe/5I/vzDrIqW3LRdlPac+H0hY4gYQYGRAivU0QlJXp9uYdyby4BcOakbeXIyyUA Q3FruAnRzsNjfQto21HNcpxGRkjfRFQyrrwoOo6zDEuDl7+Bfafw4tVXdqINyhUbFDNO U+bQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h2-v6si1323412pgk.330.2018.09.05.01.10.11; Wed, 05 Sep 2018 01:10:26 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727742AbeIEMhy (ORCPT + 99 others); Wed, 5 Sep 2018 08:37:54 -0400 Received: from mx2.suse.de ([195.135.220.15]:50796 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725865AbeIEMhy (ORCPT ); Wed, 5 Sep 2018 08:37:54 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 14669AE9E; Wed, 5 Sep 2018 08:08:52 +0000 (UTC) Date: Wed, 5 Sep 2018 10:08:51 +0200 (CEST) From: Jiri Kosina To: "Gustavo A. R. Silva" cc: Stefan Agner , Benjamin Tissoires , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] HID: core: fix NULL pointer dereference In-Reply-To: <20180829152209.GA29831@embeddedor.com> Message-ID: References: <20180829152209.GA29831@embeddedor.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 29 Aug 2018, Gustavo A. R. Silva wrote: > There is a NULL pointer dereference in case memory resources > for *parse* are not successfully allocated. > > Fix this by adding a new goto label and make the execution > path jump to it in case vzalloc() fails. > > Addresses-Coverity-ID: 1473081 ("Dereference after null check") > Fixes: b2dd9f2e5a8a ("HID: core: fix memory leak on probe") > Signed-off-by: Gustavo A. R. Silva > --- > drivers/hid/hid-core.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c > index 4548dae..5bec924 100644 > --- a/drivers/hid/hid-core.c > +++ b/drivers/hid/hid-core.c > @@ -1000,7 +1000,7 @@ int hid_open_report(struct hid_device *device) > parser = vzalloc(sizeof(struct hid_parser)); > if (!parser) { > ret = -ENOMEM; > - goto err; > + goto alloc_err; > } > > parser->device = device; > @@ -1049,6 +1049,7 @@ int hid_open_report(struct hid_device *device) > hid_err(device, "item fetching failed at offset %d\n", (int)(end - start)); > err: > kfree(parser->collection_stack); > +alloc_err: > vfree(parser); > hid_close_report(device); > return ret; Queued in for-4.19/fixes. Thanks, -- Jiri Kosina SUSE Labs