From patchwork Sat Aug 21 11:08:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave X-Patchwork-Id: 121601 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o7LAoqW1012937 for ; Sat, 21 Aug 2010 10:50:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751783Ab0HUKum (ORCPT ); Sat, 21 Aug 2010 06:50:42 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:57356 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751731Ab0HUKul (ORCPT ); Sat, 21 Aug 2010 06:50:41 -0400 Received: by wyb32 with SMTP id 32so4722301wyb.19 for ; Sat, 21 Aug 2010 03:50:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=hA6mlU1E65wOmhK7kfdZK92W+kuuznVFbnvL8n2wV98=; b=QaaMS39A4kcwfxM3GxFImsStg7dzrGloj4QcHu/JiJaJibEDQDmZqudWwxR/k/vKM/ P9uBnZjyoPNQQxwj1oH9wF699tMezDyfjFwJ+mcqAJDlxhv4XBjrX/pHd9DnhS1HOrYt Q/C+xLaFjbDiDxVNUXJrGeAtj+m0JxoDoqRQE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=mgkzUhoTZAnaxelaXgTFNMZzptovFfxSnu5MIT0F/qRZuXyRnm8s5WQVOX7R61+FPK Kd3KDUYoGbAqz83BmRbR6IfqwG9noTKFIguzEoUrUHFBipQugfSpHQn4PisZXsQA5Hec S97YE/6cSIBflFuBhdOKJWOE1nOoGtTHb/CTc= Received: by 10.216.48.146 with SMTP id v18mr2392748web.56.1282387840231; Sat, 21 Aug 2010 03:50:40 -0700 (PDT) Received: from minime (5e00e3a1.bb.sky.com [94.0.227.161]) by mx.google.com with ESMTPS id u32sm2389585weq.11.2010.08.21.03.50.38 (version=SSLv3 cipher=RC4-MD5); Sat, 21 Aug 2010 03:50:39 -0700 (PDT) From: David Kilroy To: linux-wireless@vger.kernel.org Cc: dkirjanov@kernel.org, David Kilroy Subject: [PATCH] orinoco: Fix walking past the end of the buffer Date: Sat, 21 Aug 2010 12:08:15 +0100 Message-Id: <1282388895-30045-1-git-send-email-kilroyd@googlemail.com> X-Mailer: git-send-email 1.7.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sat, 21 Aug 2010 10:50:53 +0000 (UTC) diff --git a/drivers/net/wireless/orinoco/hw.c b/drivers/net/wireless/orinoco/hw.c index 077baa8..b4772c1 100644 --- a/drivers/net/wireless/orinoco/hw.c +++ b/drivers/net/wireless/orinoco/hw.c @@ -762,14 +762,17 @@ int orinoco_hw_get_act_bitrate(struct orinoco_private *priv, int *bitrate) case FIRMWARE_TYPE_INTERSIL: /* Intersil style rate */ case FIRMWARE_TYPE_SYMBOL: /* Symbol style rate */ for (i = 0; i < BITRATE_TABLE_SIZE; i++) - if (bitrate_table[i].intersil_txratectrl == val) + if (bitrate_table[i].intersil_txratectrl == val) { + *bitrate = bitrate_table[i].bitrate * 100000; break; + } - if (i >= BITRATE_TABLE_SIZE) + if (i >= BITRATE_TABLE_SIZE) { printk(KERN_INFO "%s: Unable to determine current bitrate (0x%04hx)\n", priv->ndev->name, val); + err = -EIO; + } - *bitrate = bitrate_table[i].bitrate * 100000; break; default: BUG(); diff --git a/drivers/net/wireless/orinoco/wext.c b/drivers/net/wireless/orinoco/wext.c index cf7be1e..93505f9 100644 --- a/drivers/net/wireless/orinoco/wext.c +++ b/drivers/net/wireless/orinoco/wext.c @@ -589,8 +589,15 @@ static int orinoco_ioctl_getrate(struct net_device *dev, /* If the interface is running we try to find more about the current mode */ - if (netif_running(dev)) - err = orinoco_hw_get_act_bitrate(priv, &bitrate); + if (netif_running(dev)) { + int act_bitrate; + int lerr; + + /* Ignore errors if we can't get the actual bitrate */ + lerr = orinoco_hw_get_act_bitrate(priv, &act_bitrate); + if (!lerr) + bitrate = act_bitrate; + } orinoco_unlock(priv, &flags);