Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp135835imu; Thu, 24 Jan 2019 22:58:40 -0800 (PST) X-Google-Smtp-Source: ALg8bN53tjf8OoW2mIQfGr7oMCV8vtQqq1cG2vm3ESgEYf/5G0ULU0vjczP3zsETlemxua88vans X-Received: by 2002:a62:1d8f:: with SMTP id d137mr9690518pfd.11.1548399520819; Thu, 24 Jan 2019 22:58:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548399520; cv=none; d=google.com; s=arc-20160816; b=VNM1j5JY7QTcakUiUwetP8nQRODL6WgpkvYXr9VIpnig9BJVqkhip5kJ1ljsxk3uNY IvoeikiVQwaVlpjqb4aeBLrGWpNbjsSgHt/R4HT/3trAj8QzRXepmhRHvpKSLbbr6At4 aGNhowCRBpglZ10a+c/QXWDc7f7NsGutA6NJMWxrDRn47wxdW8HaFWd8ziqxT6FNofa5 QNmLCKWsVprONJVPzUgvx/FVBERB4b6f8uoE+WZQjBrdpHUCXDpVE5558NpI5tlR4EK0 ahDP853UCoePCrXpltEDzy+en0+mhDi6XH0X5oonsxrESGSjV/8NGVCAHQT4w6uVWh6a wznw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=zv8x412M3xy9NTN/1GaiIYd9L8YDnqNfiS5wtnkMdJk=; b=AUV9fY56e3RyyLKEayMEKvQaUoL9Q1mT6dydqBC8oHGZRMRQ7CWjgWLkZFl+ptM5Bp J/xiXJmp87MxZRPCcVeyRYD649AZFwTf1Z+8u/cu2+mUFaXID4AOn6qo/D8y0ZBsxOXr cEKfAE3b+o5mqhN9sudNlsqE23cXjW7MKOAQms8Rth8PALBRbmFWnorn11IeIY7+vh8x m6ULmy6FUvb7uvDMUyPqXghgNzMdF4Xm9685JeSCd5euFmQj6ss7YtXeORMQ+ZpwCAF/ kjlYZ+WhlgfTI8Dsp5B8Jmva/qMkablBFL9jOuID26sJbd8/rEmlf4XzM9EEWFLmDgHU ZzKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=K0CLtXuU; 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 l186si2655344pge.205.2019.01.24.22.58.25; Thu, 24 Jan 2019 22:58:40 -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=@gmail.com header.s=20161025 header.b=K0CLtXuU; 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 S1728059AbfAYGzl (ORCPT + 99 others); Fri, 25 Jan 2019 01:55:41 -0500 Received: from mail-oi1-f196.google.com ([209.85.167.196]:42848 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726323AbfAYGzk (ORCPT ); Fri, 25 Jan 2019 01:55:40 -0500 Received: by mail-oi1-f196.google.com with SMTP id w13so6942844oiw.9; Thu, 24 Jan 2019 22:55:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zv8x412M3xy9NTN/1GaiIYd9L8YDnqNfiS5wtnkMdJk=; b=K0CLtXuUr2acDIGOdrHOwdHaL9+tPvNv6Ck0qg2XMOD15tzgtjpWmUzG/0QXnrU1OU vGlfdfVpZpKrq4gtSbBz5UXuW6dygo4uyl0WJgv/4p6FNKBjbJbi+C6Xl232or5O6pIU 28UbKCHnOeY7fhzEf9/FlqSx+p5FCfjcp/pp1i1VVymWEWCthl7cnmRV98QLzeVeaHya 7IsM9JUWsz+HJomfJUmp6TIN9TUABg256cPb/dAl8NvmXXBDJCbbl87rDOteMVh3yrcH hyq/68xJgCNlV+RUBvN35D4lBaRjd66Z7tcYQyGwbewsjsMPMkq9Tti5k7oTcu/AXy3/ NJCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zv8x412M3xy9NTN/1GaiIYd9L8YDnqNfiS5wtnkMdJk=; b=e5z90sbXVg4U5PChCO5OZjJ31UoMKiUINjAspQDwbTAA8mVOhaDPeberLBU1dfqd5Q 8E9bIBXivOnz40OHq5D1ixwx6dP9gYzPqlok9X+y0/7aKV6wgxEgiQ9nXdWPjQL+FHMF /lNUzpUuM3/L+FFotuQd+7qpgJIner4GSMc98RTMPTTYETVRox4lSZu17On0BLl2/R4f pDIFHg/r0rbdR8wTj+0nkwOLcUM0oFDyxEPS76HYLVLriYKL+DCYgouiahRUmtd1nh5g d+xUucUnPtVsX4wrip0nAP23eid3IjIZkOkc5aHkGwtzcTND9Xsai89Va66YM65wWwYP e03w== X-Gm-Message-State: AJcUukdtRagYlaYML4sV3SictUL++M+w7qecMyZXhpD31yfCU0rs0MHH cCouih84uTLKy124YX+qPeoSpnvLNsGH89Ad10o= X-Received: by 2002:aca:6c4:: with SMTP id 187mr611054oig.290.1548399339886; Thu, 24 Jan 2019 22:55:39 -0800 (PST) MIME-Version: 1.0 References: <20190124142755.GA31059@bhar.linux> In-Reply-To: <20190124142755.GA31059@bhar.linux> From: Alexandru Ardelean Date: Fri, 25 Jan 2019 08:55:27 +0200 Message-ID: Subject: Re: [PATCH] drivers: iio: industrialio-core: add check when kzalloc fails To: Bharath Vedartham Cc: jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 24, 2019 at 4:28 PM Bharath Vedartham wrote: > > add code to handle the case when kzalloc fails to allocate memory to dev > > Signed-off-by: Bharath Vedartham > --- > drivers/iio/industrialio-core.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c > index 4f5cd9f..93caa6b 100644 > --- a/drivers/iio/industrialio-core.c > +++ b/drivers/iio/industrialio-core.c > @@ -1475,6 +1475,8 @@ struct iio_dev *iio_device_alloc(int sizeof_priv) > } > dev_set_name(&dev->dev, "iio:device%d", dev->id); > INIT_LIST_HEAD(&dev->buffer_list); > + } else { > + return NULL; I'd argue that this is a bit redundant, because `dev` is NULL, the return below (return dev) will also return NULL. Alex > } > > return dev; > -- > 2.7.4 >