Received: by 2002:ac0:a874:0:0:0:0:0 with SMTP id c49csp354317ima; Fri, 15 Mar 2019 04:27:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqyY/B/+yh+T2rMZ2N+lPOTul1Oui/4hl97qz7oZnHJZr1sWpDr2VIKRlrYFKgg/zkOJwz3Z X-Received: by 2002:a62:1346:: with SMTP id b67mr3592406pfj.195.1552649243842; Fri, 15 Mar 2019 04:27:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552649243; cv=none; d=google.com; s=arc-20160816; b=AJd6PHU0j6sT4VE8LrG4jDwGVUpDrx6TmtrigPq72SF3GeKXrUXOyWkVA4r61vcz5m OEBRzd2qmlCclSmnI/vpWKJs3vlWDzUbOXKXRD9IiigaGiwqwI8tf4TE/rg9nNOEqWwY NQ7Q9lPZ8OGAizpZxW/Tk0wN6FxxqYaGePUqj/GIHPAHM/bojqDXWL7egmVJt3+j9vkE DjwGF+IgQNykKES87GJ+2unfQ36Af8qUZnjB6pnrcCqsXbv2KZsH0bKcVNbv0jsNwqac o6BbJpJktQTORPyuLKbI89dUfMNC5ClgVDXs83K6TJExMUiCgH8LdNeeqKpQ1NDF9+rB VnEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to:date :references:subject:cc:to:from; bh=kovW0d3boIkdCUEF/dYUzvrobWOMSRIBVXNm+LJVOMg=; b=ofzL9VGPOHB/3uxuwFdRZndC61rE+q+cunqLIJJqBIo7j1L4e4B0wWBeV03tTvKaXS NFZrKjls8pjEoKKfGwjhfMygK/mUHz4PSSkUAhIhQro72dka4ogHbxQutPPi076uf0qp VwTAZioS72SnyH/AcwWPd01s5ilmmVpR3M4+hJAwr12eT/4jhjABcEuO3T0txvLui0yj qDgyB5DUqoOedxMzCYsJf7WeDyy0O6oQJCY1Z6CIg2evTLGwsWRfOjwBd/kiqAZiW+N7 9MKq2tq1u/GhR48cIx69gAApGEcrS8ydVJfVbuk+e5d2qrAF/CpP5orZzTbNFOYLitY7 hIMA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6si1565617pgk.478.2019.03.15.04.27.09; Fri, 15 Mar 2019 04:27:23 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728994AbfCOLY3 (ORCPT + 99 others); Fri, 15 Mar 2019 07:24:29 -0400 Received: from mx2.suse.de ([195.135.220.15]:47232 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726785AbfCOLY2 (ORCPT ); Fri, 15 Mar 2019 07:24:28 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 774EEAF26; Fri, 15 Mar 2019 11:24:27 +0000 (UTC) From: Luis Henriques To: Aditya Pakki Cc: kjlu@umn.edu, Ilya Dryomov , "Yan\, Zheng" , Sage Weil , "David S. Miller" , ceph-devel@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] libceph: Avoid a NULL pointer dereference References: <20190314211724.21306-1-pakki001@umn.edu> Date: Fri, 15 Mar 2019 11:24:26 +0000 In-Reply-To: <20190314211724.21306-1-pakki001@umn.edu> (Aditya Pakki's message of "Thu, 14 Mar 2019 16:17:24 -0500") Message-ID: <87ef78bct1.fsf@suse.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Aditya Pakki writes: > kmalloc allocates memory for dest->name and attempts to call > memcpy without a check for failure. This patch avoids such a scenario. Since kmalloc is being invoked with the __GFP_NOFAIL flag, it will never fail. Thus, there's no point in checking for NULL in this case. Cheers, -- Luis > > Signed-off-by: Aditya Pakki > --- > net/ceph/osdmap.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c > index 48a31dc9161c..c76a7c7e6a77 100644 > --- a/net/ceph/osdmap.c > +++ b/net/ceph/osdmap.c > @@ -1901,6 +1901,8 @@ void ceph_oid_copy(struct ceph_object_id *dest, > } else { > dest->name = dest->inline_name; > } > + if (!dest->name) > + return; > memcpy(dest->name, src->name, src->name_len + 1); > dest->name_len = src->name_len; > }