Received: by 10.223.176.5 with SMTP id f5csp3037874wra; Mon, 29 Jan 2018 07:56:39 -0800 (PST) X-Google-Smtp-Source: AH8x227WLtjJedSYRurtfy2qqTJqzcIRBOd2RcSHlwO9+UHYu1hvfsF175yJg05r1K3s1gXJIkXM X-Received: by 2002:a17:902:4e25:: with SMTP id f34-v6mr12865085ple.68.1517241399708; Mon, 29 Jan 2018 07:56:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517241399; cv=none; d=google.com; s=arc-20160816; b=dgGh1BehntckyM59XFKLcWFdOUevOHm/nuNSefo2akmgfiKlrA4M+Lr7yIi3ichKIo qxE6EPaFiOJen0Uv9R5Fc/ONrfLzrsT8/cFZwhteNUZzHZI7rezueID5uFsDGAmK7vDg YArweoFKvbD2tFUqbmcWsy4/cKXpIrwxedUf3NKHvBdG26zwOkGeGhbQduTl5xYiTASU sfr8fOCxZ1Mhnydg/5La7B6+MywVYndu0OkZ4Lez95CJglE4bxAgmsrkAVeIbv1VOvkh vL/ZduCnKogwGz/R6KmCwHOWj3svSJCMgR9g9bIW/wBvYdrJvuup0mfecqa51NE798Dc cKfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=WNXYLzK9r4vNiJJbrX7r3NAhUhPMTiY1JuVIR4NczmE=; b=X1oUsIC9h30ZGablQlQSkQ3+eUBojMKFg41QqyJvSfkRFfIq42nNUIIkIGjdK7tD26 l+04j7BaD/mNOp5zYSx2an5LClrhdCa7+FSbY2ABx/26Wdo81RQmEIIBeIiGUsLvMiLL cVCMw7d4mv6dfaeIEOjwX/japVZ8ax+SS2RF1jw4mcJoqkmvmg88JaHgsX+ASpz1NJqQ M8qgohesWKlvbdq9huT6PHVKzwxky0J7e8wgRuxT0EoZEBMoXHSS27dNRB3BwLuCOvQH 9qrNKZDGNCrfZpylU2LxzixYSq3g/aczmVocbWfWrinpwK62KPZa+BW3EEV9CZXkbvZ7 XTJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@eso.teric.us header.s=mail header.b=RjY5Brn7; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3-v6si3190709pls.325.2018.01.29.07.56.25; Mon, 29 Jan 2018 07:56:39 -0800 (PST) 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=@eso.teric.us header.s=mail header.b=RjY5Brn7; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752015AbeA2P4E (ORCPT + 99 others); Mon, 29 Jan 2018 10:56:04 -0500 Received: from eso.teric.us ([69.164.192.171]:52796 "EHLO eso.teric.us" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751378AbeA2P4B (ORCPT ); Mon, 29 Jan 2018 10:56:01 -0500 Received: from neo.teric.us (neo.teric.us [198.58.100.135]) by eso.teric.us (Postfix) with ESMTPS id 2A8CB1036F; Mon, 29 Jan 2018 09:56:01 -0600 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eso.teric.us; s=mail; t=1517241361; bh=WNXYLzK9r4vNiJJbrX7r3NAhUhPMTiY1JuVIR4NczmE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RjY5Brn70iZsiIpImOMbctPfn4GkGbsZUAeyOpd5MgjYsXa5XIgYDPMeNEa3sssH6 hbZPWwOJQAzGyKNNWf2kzch4JQ5ISNe7u9zjb6TYvcSgDa6Wk6O/mOmlVrS8wTQ6OL yH8h7rJ8birTnG3BOSwdgBpUabKPAEbMeHcBDQ0w3OUk06TbO7d4sCv8pfjeSABcly LLOUxocDIVg1/XdZyXIIGTMbKraS8DWBtOCN6KF5gOhQT9+aoVYQnoavLa99ZwolEq D32sS1lfXgvs3bNW9xmUoNMgBBU+29EBZmZi0W2F7S1K45ds3ZFvTNjU1o+MC4rI+s eSoGFUzrs3FIA== Received: by neo.teric.us (Postfix, from userid 1002) id EFB18185FDB; Mon, 29 Jan 2018 09:56:00 -0600 (CST) Date: Mon, 29 Jan 2018 09:56:00 -0600 From: Julia Cartwright To: Oleksandr Shamray Cc: gregkh@linuxfoundation.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, openbmc@lists.ozlabs.org, joel@jms.id.au, jiri@resnulli.us, tklauser@distanz.ch, linux-serial@vger.kernel.org, vadimp@mellanox.com, system-sw-low-level@mellanox.com, robh+dt@kernel.org, openocd-devel-owner@lists.sourceforge.net, linux-api@vger.kernel.org, davem@davemloft.net, mchehab@kernel.org, Jiri Pirko Subject: Re: [patch v18 1/4] drivers: jtag: Add JTAG core driver Message-ID: <20180129155600.GA1924@kryptos.localdomain> References: <1517236305-4880-1-git-send-email-oleksandrs@mellanox.com> <1517236305-4880-2-git-send-email-oleksandrs@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1517236305-4880-2-git-send-email-oleksandrs@mellanox.com> User-Agent: Mutt/1.8.3 (2017-05-23) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 29, 2018 at 04:31:42PM +0200, Oleksandr Shamray wrote: > Initial patch for JTAG driver > JTAG class driver provide infrastructure to support hardware/software > JTAG platform drivers. It provide user layer API interface for flashing > and debugging external devices which equipped with JTAG interface > using standard transactions. > > Driver exposes set of IOCTL to user space for: > - XFER: > - SIR (Scan Instruction Register, IEEE 1149.1 Data Register scan); > - SDR (Scan Data Register, IEEE 1149.1 Instruction Register scan); > - RUNTEST (Forces the IEEE 1149.1 bus to a run state for a specified > number of clocks). > - SIOCFREQ/GIOCFREQ for setting and reading JTAG frequency. > > Driver core provides set of internal APIs for allocation and > registration: > - jtag_register; > - jtag_unregister; > - jtag_alloc; > - jtag_free; > > Platform driver on registration with jtag-core creates the next > entry in dev folder: > /dev/jtagX > > Signed-off-by: Oleksandr Shamray > Signed-off-by: Jiri Pirko > Acked-by: Philippe Ombredanne [..] > diff --git a/drivers/jtag/jtag.c b/drivers/jtag/jtag.c [..] > +struct jtag *jtag_alloc(size_t priv_size, const struct jtag_ops *ops) > +{ > + struct jtag *jtag; > + > + jtag = kzalloc(sizeof(*jtag) + priv_size, GFP_KERNEL); > + if (!jtag) > + return NULL; > + > + if (!ops) > + return NULL; > + > + if (!ops->idle || !ops->mode_set || !ops->status_get || !ops->xfer) > + return NULL; Did you think through this? You leak 'jtag' here and above. Perform all the ops checks prior to the allocation. Julia