From patchwork Mon Feb 7 16:56:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 538421 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p17GvE9t011188 for ; Mon, 7 Feb 2011 16:57:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754207Ab1BGQ5K (ORCPT ); Mon, 7 Feb 2011 11:57:10 -0500 Received: from mail-ew0-f46.google.com ([209.85.215.46]:39558 "EHLO mail-ew0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754070Ab1BGQ5J (ORCPT ); Mon, 7 Feb 2011 11:57:09 -0500 Received: by ewy5 with SMTP id 5so2411036ewy.19 for ; Mon, 07 Feb 2011 08:57:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:cc:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=7+xHQXxH6itOiLgfRS6ceDGN9Ril2CtlqC1qTimGRII=; b=jlOV9KUa/5KX0Au1G3LsJ3u+GYemEyv2kKHUbhg9VjkgjlvzOiS2wYe4Ndzlo+M7We C+9OMC5/AV15n5nztXE1GrY8MIf2oNEOBl0XoAD3NJsW+KPbqMxT4nzVpBvUI4+N3F9n b/g15UAwhtbFItl1xTSD/GybzcmXOPbGFkYjo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=vLiXpGo9lhd1jgVjfi11rdTDrkdNWlsyxzBx1rkaHwbqUbvgngQlGkDlx8jULaI00Z aOSeWyRqFs1IKa6/zX5+pdut2SJj7V6XkUaFPxKVRLwHBCnUjyu9ShqTJ++Q2ysvdv0i 76a9goUL9wTxx1jxtY+9xljhcJAakdo1iZ21I= Received: by 10.223.96.73 with SMTP id g9mr4551519fan.24.1297097827766; Mon, 07 Feb 2011 08:57:07 -0800 (PST) Received: from bicker ([212.49.88.34]) by mx.google.com with ESMTPS id n7sm1289267fam.11.2011.02.07.08.57.01 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 07 Feb 2011 08:57:05 -0800 (PST) Date: Mon, 7 Feb 2011 19:56:50 +0300 From: Dan Carpenter To: Mauro Carvalho Chehab Cc: Manu Abraham , Andreas Regel , Oliver Endriss , linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch] [media] stv090x: handle allocation failures Message-ID: <20110207165650.GF4384@bicker> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 07 Feb 2011 16:57:14 +0000 (UTC) diff --git a/drivers/media/dvb/frontends/stv090x.c b/drivers/media/dvb/frontends/stv090x.c index d3362d0..85101e8 100644 --- a/drivers/media/dvb/frontends/stv090x.c +++ b/drivers/media/dvb/frontends/stv090x.c @@ -4783,7 +4783,13 @@ struct dvb_frontend *stv090x_attach(const struct stv090x_config *config, } else { state->internal = kmalloc(sizeof(struct stv090x_internal), GFP_KERNEL); + if (!state->internal) + goto error; temp_int = append_internal(state->internal); + if (!temp_int) { + kfree(state->internal); + goto error; + } state->internal->num_used = 1; state->internal->mclk = 0; state->internal->dev_ver = 0; @@ -4796,7 +4802,7 @@ struct dvb_frontend *stv090x_attach(const struct stv090x_config *config, if (stv090x_setup(&state->frontend) < 0) { dprintk(FE_ERROR, 1, "Error setting up device"); - goto error; + goto err_remove; } } @@ -4811,6 +4817,8 @@ struct dvb_frontend *stv090x_attach(const struct stv090x_config *config, return &state->frontend; +err_remove: + remove_dev(state->internal); error: kfree(state); return NULL;