Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756921AbdGLHkm (ORCPT ); Wed, 12 Jul 2017 03:40:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58468 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756657AbdGLHkk (ORCPT ); Wed, 12 Jul 2017 03:40:40 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2F708C04D301 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=benjamin.tissoires@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2F708C04D301 Date: Wed, 12 Jul 2017 09:40:35 +0200 From: Benjamin Tissoires To: "Gustavo A. R. Silva" Cc: Jiri Kosina , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] HID: hid-logitech-hidpp: add NULL check on devm_kmemdup() return value Message-ID: <20170712074035.GF22282@mail.corp.redhat.com> References: <20170707051213.GA6074@embeddedgus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20170707051213.GA6074@embeddedgus> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 12 Jul 2017 07:40:40 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 956 Lines: 29 On Jul 07 2017 or thereabouts, Gustavo A. R. Silva wrote: > Check return value from call to devm_kmemdup() > in order to prevent a NULL pointer dereference. > > Signed-off-by: Gustavo A. R. Silva > --- Reviewed-by: Benjamin Tissoires > drivers/hid/hid-logitech-hidpp.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c > index 41b3946..501e16a 100644 > --- a/drivers/hid/hid-logitech-hidpp.c > +++ b/drivers/hid/hid-logitech-hidpp.c > @@ -2732,6 +2732,9 @@ static int hidpp_initialize_battery(struct hidpp_device *hidpp) > hidpp_battery_props, > sizeof(hidpp_battery_props), > GFP_KERNEL); > + if (!battery_props) > + return -ENOMEM; > + > num_battery_props = ARRAY_SIZE(hidpp_battery_props) - 2; > > if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE) > -- > 2.5.0 >