Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3766582imm; Mon, 11 Jun 2018 01:09:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIJmmYeWBJ8vFPOvvyjx7Q0NwlnHiwfEOpGn1UeSrLroi7hohvBSsUlRWdMofbrjOpbBwDJ X-Received: by 2002:a63:12:: with SMTP id 18-v6mr14184322pga.121.1528704590615; Mon, 11 Jun 2018 01:09:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528704590; cv=none; d=google.com; s=arc-20160816; b=z056UDAlLBGG+qNq3I2vAR1NA8RHcAv+ufjYnsmNUDyE9fDxqj5NgxYyuR4qZsGd6S jQCUXKJW3QJlxFSfkaQdrpeg+XWMpFDeWik2U1ZKT+/3e/LQBNp3DHoYoSUkEqp8qWN6 1PfLmJ3nPwUqO1cR777a/4l5tTkyvV6SU60NLl2a8SjqId80KV+dfyXnYapd5yx3S4u0 3swzU7d4UAin8CYS9tAxBqSmmHJfESvqntn/S0ULc4rI7kp3u94pbS3JTxsAZyBE6yfZ vs8WJMC0i+OtfV9TExhf97rrRDs27AwLpQ2PzmuGnpGTDqdDhstIPDbitoFiMPTY6JCh aG1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :dkim-signature:arc-authentication-results; bh=K3kACUPAfqbxZzulW9WPncbnq99w+I0nZ59lhPVqKyg=; b=E6UNEzS1+kYUv1JR4WMGYb3BzEuQEnYM2LspV5GKXF0TDhhK6RLpoQEwB95Irsctsc ag6xEkXLFy+jzLwxjg/YAu5a5iLPf6Az03Vz+IWZOmJbp/+5/wgSlsaVUjaLEv39Tf4D CDvWF0yA/NDQJypdNZR+AE6fSCIhZSlLZTUNGR+yzZALe3WvIXpODJQTxRH8wLqLV9eJ pjoQoNOhuwgrnd8LWMMkN4xf7VOwZqKdCEa03pr6nsjzS3pMiwE8Dp9j0pAEkPmFtq68 O06EX2OcdNeRVy6QX4I0siZMb6tdVH6QH00tCYij9vaiVY06usJ7A5Kxrx4/f0NrMWUG Ga0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=QVEF33G1; 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=fail (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 3-v6si65022707plf.84.2018.06.11.01.09.36; Mon, 11 Jun 2018 01:09:50 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=QVEF33G1; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932498AbeFKIIz (ORCPT + 99 others); Mon, 11 Jun 2018 04:08:55 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:36272 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932109AbeFKIIx (ORCPT ); Mon, 11 Jun 2018 04:08:53 -0400 Received: by mail-pf0-f195.google.com with SMTP id a12-v6so9817962pfi.3 for ; Mon, 11 Jun 2018 01:08:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=K3kACUPAfqbxZzulW9WPncbnq99w+I0nZ59lhPVqKyg=; b=QVEF33G1G6eAUeWOdxXm+hBVSzMu70QPUIiU02l5K+WSiI2Lv+CaddcKpZWMY4W3oH M27flgeEblO0eI1jQ4fBzQxSbvLXe0BpZovYsQP4bgUiiq/vg9hVd28abEKAqNXgYHys IMzIp5se+24J/yw+3jYALLuplugRmPspffJ74WOwbzljJrEs7cJ+9AnB8x+GGe3Z812v knl0J5GTFEjvjcqnli4PkprErYDC8mrMIU6Pqd2RJbWNEZ6tEBU/xcwnWzkKS63VUEWa X/C9BBt7NBn1FQIVtUA9rHCx8TvSwbPbe7wJW9/vs8/VhCBH0yxZsNEDWR+2cN+P1u5i fk+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=K3kACUPAfqbxZzulW9WPncbnq99w+I0nZ59lhPVqKyg=; b=PAFEzpjWh4MaGDsetG/VQl8v72E/TTkGr8OVnzQAyMFYt5bV4Ztr0b82OXhZ8KZXin NQ/ka4R6oR7p/tZiCxoFIq8HxG3HmA+Br8DJ/oSj1l1OY/XZhzthOKcKVkJVyZy3iZuH CpR4qJIwNZne5oK6tItznsJ9FA1TF+/qfew6JFcSJKuYjRA1cyLBBwFzAnDzkvLNusvo kT8EDDvHrz6BG9ltr0hut6oA2e46ynNjOVNBb8r7TTovtLek61Wg4Im1e9y+9eRLyZiT FjEH+/ol8bikIRdVRO2RASXYVEjbH8PESAqPSLkU9waMM2wfSLglDh80vS/kxLfnTeNS UGFw== X-Gm-Message-State: APt69E3ZSbSyiG7Y7O7wRQk9I4K1GA7SKmLnFlx/PCJspbbgskhhSawU lMPMBZYQPcqm5Lt41niH30ys0rSTeY8= X-Received: by 2002:a63:86c8:: with SMTP id x191-v6mr13563799pgd.2.1528704533184; Mon, 11 Jun 2018 01:08:53 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id m5-v6sm108887977pfa.93.2018.06.11.01.08.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 01:08:52 -0700 (PDT) From: Zhouyang Jia Cc: Zhouyang Jia , Jaroslav Kysela , Takashi Iwai , Bhumika Goyal , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH] ALSA: sonicvibes: add error handling for snd_ctl_add Date: Mon, 11 Jun 2018 16:08:40 +0800 Message-Id: <1528704521-34060-1-git-send-email-jiazhouyang09@gmail.com> X-Mailer: git-send-email 2.7.4 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When snd_ctl_add fails, the lack of error-handling code may cause unexpected results. This patch adds error-handling code after calling snd_ctl_add. Signed-off-by: Zhouyang Jia --- sound/pci/sonicvibes.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c index a8abb15..57cb77a 100644 --- a/sound/pci/sonicvibes.c +++ b/sound/pci/sonicvibes.c @@ -1188,6 +1188,7 @@ SONICVIBES_SINGLE("Joystick Speed", 0, SV_IREG_GAME_PORT, 1, 15, 0); static int snd_sonicvibes_create_gameport(struct sonicvibes *sonic) { struct gameport *gp; + int err; sonic->gameport = gp = gameport_allocate_port(); if (!gp) { @@ -1203,7 +1204,10 @@ static int snd_sonicvibes_create_gameport(struct sonicvibes *sonic) gameport_register_port(gp); - snd_ctl_add(sonic->card, snd_ctl_new1(&snd_sonicvibes_game_control, sonic)); + err = snd_ctl_add(sonic->card, + snd_ctl_new1(&snd_sonicvibes_game_control, sonic)); + if (err < 0) + return err; return 0; } -- 2.7.4