From patchwork Thu Sep 24 19:27:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Vecera X-Patchwork-Id: 1370837 X-Patchwork-Delegate: mkubecek@suse.cz Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=D1rwaa7a; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4By4ny25Hhz9sTC for ; Fri, 25 Sep 2020 05:28:06 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728861AbgIXT2F (ORCPT ); Thu, 24 Sep 2020 15:28:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56398 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728758AbgIXT2E (ORCPT ); Thu, 24 Sep 2020 15:28:04 -0400 Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600975683; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=aIojZ/R8vH9rsjdmoutCPlVLGB4yUkhagiFAMXUflws=; b=D1rwaa7aS+RnKUze8c9atdPVGJtDPa+GCg4wX4HDEsO1rraxhPWJge8y9M+hMWd2rXTw1f olfPgh8J83GttsYURZBQkYQCLvHBLm33jkr0obJHILkB5M4U8XulBy1zc3Pgz8TlW219Af JV1ezlasDXxNwzAZDyPCk8P0GS3Dz2o= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-271-MBbwkCBAPjiCpOm19CTUAg-1; Thu, 24 Sep 2020 15:28:01 -0400 X-MC-Unique: MBbwkCBAPjiCpOm19CTUAg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AB0AA1005E76; Thu, 24 Sep 2020 19:28:00 +0000 (UTC) Received: from ceranb.redhat.com (unknown [10.40.195.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD5D160BF3; Thu, 24 Sep 2020 19:27:59 +0000 (UTC) From: Ivan Vecera To: netdev@vger.kernel.org Cc: Michal Kubecek Subject: [PATCH ethtool 1/2] netlink: return -ENOMEM when calloc fails Date: Thu, 24 Sep 2020 21:27:57 +0200 Message-Id: <20200924192758.577595-1-ivecera@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Fixes: f2c17e107900 ("netlink: add netlink handler for gfeatures (-k)") Cc: Michal Kubecek Signed-off-by: Ivan Vecera --- netlink/features.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/netlink/features.c b/netlink/features.c index 3f1240437350..b2cf57eea660 100644 --- a/netlink/features.c +++ b/netlink/features.c @@ -112,16 +112,17 @@ int dump_features(const struct nlattr *const *tb, unsigned int *feature_flags = NULL; struct feature_results results; unsigned int i, j; - int ret; + int ret = 0; ret = prepare_feature_results(tb, &results); if (ret < 0) return -EFAULT; - ret = -ENOMEM; feature_flags = calloc(results.count, sizeof(feature_flags[0])); - if (!feature_flags) + if (!feature_flags) { + ret = -ENOMEM; goto out_free; + } /* map netdev features to legacy flags */ for (i = 0; i < results.count; i++) { @@ -184,7 +185,7 @@ int dump_features(const struct nlattr *const *tb, out_free: free(feature_flags); - return 0; + return ret; } int features_reply_cb(const struct nlmsghdr *nlhdr, void *data)